[antlr-interest] Tweaking a source file.
Terence Parr
parrt at cs.usfca.edu
Wed Oct 18 14:56:14 PDT 2006
On Oct 17, 2006, at 8:32 PM, David Piepgrass wrote:
> The first decision I need to make is, should I use ANTLR 2 or ANTLR
> 3? The readme for ANTLR 3 says "For example, to read in some input,
> tweak it, and write it back out preserving whitespace, is easy in
> v3." That sounds great because it is exactly what I need to
> accomplish. But how can it be done?
Use TokenRewriteStream instead of COmmonTokenStream. Look at the v2
to v3 translator I just did for an example. :)
ter
> Does an example exist? For my application, I think an observer
> inserted between the lexer and parser can do the job--I just don't
> know the details.
>
> The second big question is, what is the easiest way to make an AST,
> and is this task also easier in v3?
>
> The third question is, how can one parse a language where
> indentation is syntactically significant?
>
Keep whitespace tokens as real tokens (don't skip them). :)
Ter
More information about the antlr-interest
mailing list