[antlr-interest] Same rule -> different tokens

Sergiy Dubovik sergiy.dubovik at gmail.com
Wed May 25 22:17:02 PDT 2011


Hi!

I'm trying to implement ruby like grammar:
def func
    if x < 1<NL>
        print ""
    end
end

In if statement there has to be new line <NL>, otherwise I get
problems with expression rules, also ruby requires new line there.
However I want to ignore new lines in all other cases. I did something
like this with flex and bison, and solution was to make a global flag
and it would be set in bison grammar file after expression to true and
lexer would return token otherwise it would skip it. Shall I use
similar approach with antlr or is there better solution? I'm trying to
avoid any code in the grammar because I develop it with antlrworks
which works only with java code but I need to generate C code.

Thanks.
br,
Sergiy


More information about the antlr-interest mailing list