[antlr-interest] Token position 0, -1

Mike Lischke mike at lischke-online.de
Wed Jul 11 01:06:07 PDT 2012


thanks for taking time to respond.

> The 1 == 2 is necessary because that is the only way I could make the
> conditional code work with the code generation techniques we have. In
> different circumstances, you will see 1 == 1 and the code is incorporated.
> The size of the C file only makes a difference with old debuggers that
> used a 16 but line number field. The performance boost is significant.

We all have our restrictions, haven't we?

> Don't do all the rewriting stuff anyway, as it adds code and execution
> time that you don't need. Just:
> ->^(NODE x t )
> Then you want the start and end tokens from NODE in your tree grammar and
> asking those tokens for their info will give you everything you want. In
> general, do only the tree re-writing you need to make the tree unambiguous
> - there is no need to move the text from one token in to another and so
> on.

Since the "tree" generated by default is rather a straight list, it is difficult to have context info at hand when parsing it (e.g. nesting levels of recursive structures). It would be easier if we could (partially) switch off the tree-flattening which happens at each rule's exit. This would even safe another couple of CPU cycles.

Btw: is there a way to toggle AST generation entirely at runtime?


More information about the antlr-interest mailing list