[antlr-interest] Grammar generation results in exception

Johannes Luber jaluber at gmx.de
Mon Jun 25 06:00:28 PDT 2007


Thomas Brandon wrote:
> This error is because you have mixed rewrites and AST building
> operators (! and ^) in a single rule. In this case the error is
> because you have used '^' (as an operator on a token, not in the
> rewrite itself) as well as rewrites in your element element rule. Your
> atom and ebnf rules also mix rewrites and AST operators.
> Due to the lack of location information these errors can be tricky to
> track down. Slowly removing (or adding to a new grammar) rules until
> you find the error can help. Though due to dependencies between rules
> this can be tricky.
> Another trick is to introduce the other sort of error, either a !
> (tokenRefBangTrack.st error) or a ^ (tokenRefRuleRootTrack.st error)
> in a rule with rewrites. For instance, as you have a ^ error adding a
> ! to a rule before the (first) rule giving the error will change the
> error given to a tokenRefBangTrack.st error, by moving the location
> where you insert the error through your grammar until the message does
> not change you can locate the error.
> I assume these errors will be better dealt with when Ter migrates to
> an ANTLR 3 grammar in the tool.
> 
> Tom.
> 

Thanks! That was it. Now only ambiguities have to be dealt with. Is it
guaranteed that with backtracking and memoization the correct parse tree
will be generated, or do exist situations where things have be manually
solved?

Best regards,
Johannes Luber


More information about the antlr-interest mailing list