iterating the token stream backwards by scope

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by karl - Senior Software Architect, Shelltools, LLC
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


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

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


Comments (1)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
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 (v21.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.