Custom highlighting (beginner!)

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by tristan hunting
Version: 4.0.0276
Avatar
I would like to make var3 in the code sample below be given a custom highlighting style (green squiggly underline) that indicates it has not been declared.

[globalvariabledefinitions]
var1="adslkfjalkd"

[context]
set(var2="asfdsakj")
print(${systemdefinedvariable}+${var1}+${var2}+${var3})


As you can see there are a few different ways variables can be defined and also in built system variables.

I have the lexical analysis pretty much complete using a dynamic syntax language.

I am new to this control and finding it difficult to understand how everything fits together. A basic outline of how I should set about achieving the above would be greatly appreciated!

Comments (4)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tristan,

I'm assuming that you have a compiler available for this language that will give you an error message that var3 is not yet defined?

If so, you can add a span indicator over the offset range for that text. Check out our Indicators QuickStart for a sample of how to add a wave line in any color.


Actipro Software Support

Posted 11 years ago by tristan hunting
Avatar
No compiler - it's an interpreted language with a very loosely defined syntax. I was hoping to avoid writing a full semantic parser - indeed with the syntax I am unsure if this would even be possible.

There is only one file that contains all the code so my plan was to loop through the token stream to build a list of defined variables and then loop again to custom highlight any VariableNameToken that are undefined. I am unsure where would be the correct place to put this code?
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you don't have a compiler then as you said the two options are make a semantic grammar that builds an AST (the right way but potentially more work) or do token scanning. You can scan tokens in a PerformSemanticParse method override of your SyntaxLanguage class.


Actipro Software Support

Posted 11 years ago by tristan hunting
Avatar
Many thanks I'll consider writing a semantic parser - it's reasuring to know I am on the right track.
The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.