Context sensitive keywords

SyntaxEditor for WPF Forum

Posted 9 years ago by T.H. in den Bosch
Version: 10.2.0531
Avatar
Hello everyone,

I have a language with context sensitive keywords. For this language I have a hand-coded lexer and parser. The parser determines whether an identifier token is a keyword and then modifies its type to aid syntax highlighting.

I am trying to wrap the lexer and parser to create a syntax editor for this language.

Is it possible to update the syntax highlighting after parse requests have been performed in the background, so the syntax editor reflects the changes made to the tokens by the parser? I have not found a way to do so, but I could easily have missed something.

If this is not possible, is there maybe a way around it, a way to effectively achieve the same effect?

I can always run the parser in the lexer phase of the syntax editor, but I fear that that will be too slow.

Any help is appreciated.

Taco.

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

The ideal way to change the highlighting is via a custom classification tagger.

You would probably want to come up with a mechanism to quickly retrieve the custom keywords ranges and then provide them to your custom classification tagger.

One way you could do this is to have the parser compile a list of the custom keywords ranges and store it in your custom parse data object. The parse data is available to the various language services registered with your language, so the classification tagger could retrieve it. It would then tag each range appropriately, causing the syntax highlighting to change accordingly. The tagger would only be called for ranges that are displayed.

There are QuickStarts that demonstrate the use of classification taggers, which you may find helpful in setting this up.

Please let us know if you have further questions.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) 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.