iterating the token stream backwards by scope

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
iterating backwards by scope

i have a contenxt is which to do "intellisense" i need to look backwards.. here is an example

get-command "blablabla" -sth


when i type the - before something, i will lookback in the stream for an CmdLetToken (which get-commands is matching based on the XML definition).. and then use that to find out the parameters i should show..
in a simple situation this is easy (i just readreverse until i hit a cmdlet token or a lineterminatingtoken. However something liek this is a bit harder

get-command $(other-cmdlet "balbla ) -sth

or

get-command { other-cmdlet
"something else" } -sth

IS THERE a way i can read back in the same "scope" level that i am?

Karl

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
While we have implemented some helper methods in our v4.0 code to aid in finding matching scope level tokens, we don't have anything in v3.1 built-in for that. Your best bet is to write a method that iterates backwards through a token stream and keep a scope level counter. When you encounter an inner scope, increment the scope counter. Then decrement it when you leave the inner scope. If the counter is at 0 when you find the matching token, then you know you found the token at the same scope level.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.