Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANTLR's AST tree updating

Tags:

c#

antlr

I use Lexer and Parser classes generated by ANTLR tool (targeting C#). Assume I have parsed some code and got an AST tree for it. What if part of my initial code has changed and I want to update just the corresponding parts of the tree? Is there a common way to do that? For example a line of code was inserted inside some functions body. And I want to rebuild just the part of the tree representing this function and update positions of subsequent functions tokens

like image 248
Natalia Avatar asked Nov 13 '22 12:11

Natalia


1 Answers

There are a few projects out there which do what you might want to accomplish. But I don't know if ANTLR supports this. You might take a look at: http://en.wikipedia.org/wiki/Incremental_compiler

For syntax highlighting propose only, I suggest using regular expression for the different token in your syntax. (If you update just the line you're working on you should not get any performance problems.)

like image 88
raisyn Avatar answered Nov 16 '22 02:11

raisyn