[antlr-interest] options for mTokens
Emond Papegaaij
e.papegaaij at student.utwente.nl
Thu Sep 21 03:19:14 PDT 2006
Hello,
I'm faced with a problem with a combined grammar. My lexer contains mutual
recursive rules, hence I cannot use LL(*) for the mTokens rule. However it
does not seem to be possible to change the options for the generated
lexer. Specifying 'k = 2' in the top level options of the grammar only
results in 'k = 2' for the parser, not for the lexer. I would suspect
something like 'lexer::options' to work, but it is not valid according to
the syntax of ANTLR. Is there any way to set global options for the lexer
in a combined grammar (without splitting the grammar in a separate lexer
and parser)?
Another thing that bothers me is that it only seems to be possible to
specify options for the mTokens rule by specifying global options. If I
want to use LL(*) for all tokens, except mTokens I have to
repeat 'options{k=*;}' in every rule. Also is it not possible for ANTLR to
try to use LL(*) for mTokens and fall back to LL(k)[1] with backtracking
if LL(*) is not possible?
Best regards,
Emond Papegaaij
[1] Of course the value to use for k might be difficult to deduce. Perhaps
it can be the lowest value for which the following holds: 'diff(k) ==
diff(k+1)' where 'diff(k)' is the number of token rules that can be
differentiated with LL(k). The remainder of the rules (if any) would need
backtracking.
More information about the antlr-interest
mailing list