Dynamic Language question - how to ignore token conditionaly

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Michael Dempsey - Sr. Developer, Teradata Corp
Version: 12.1.0302

I have converted a language definition used by another tool to the format used by Syntax Editor and everything works except for one case.

In the other language I was able to define 'scopes' defined by start/end token pairs that could be referenced by other token sets (Pattern groups in SyntaxEditor)

When defining a Pattern Group I would specify which 'scopes' that group was valid within.
(Kind of the reverse of your States/ChildStates)

In most cases all patern groups are valid within any scope, however the statement terminator (";") is not to be treated as a statement terminator if it occurs anywhere within a pair of parens, or anywhere between the words 'Begin' and 'End'.

I handled the additional cases of 'within comments' and 'within string delimiters' by defining those as child states.

I can't really define parens and Begin/End as child states however because every other pattern group would also be valid within those child states. (SQL allows vitrually anything to be nested within anything else)

Is there any way to recognise this situation such that the ";" is not treated as a statement terminator in these 2 situations.
(Note that this is a Dynamic language. I do have code behind it to handle outlining if that helps - but I think it has already classified the token by the time that code fires.)


Comments (1)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Mike,

Sorry but the only way to accomplish what you want is to make the Begin/End and parens as child states.  I suppose then you'd need to duplicate all the other pattterns within the main one. 

You could possibly do the duplication programmatically after the lexer has loaded.  There is a section on making updates to the lexer in the documentation.  So to sum up, make the lexer with the main patterns defined in the default state.  Have empty states for Begin/End and parens.  Load up the lexer and programmatically copy the lexer data into those stub states.

Or alternatively, open your .langproj file in the VS code editor after you're done setting up the default state with patterns, and stub child states.  And then just duplicate all the XML tags into the child states.

Actipro Software Support

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.