[antlr-interest] A look-ahead/rewind problem
Andreas Meyer
andreas.meyer at smartshift.de
Mon Mar 23 06:03:09 PDT 2009
Lukasz Guminski schrieb:
>
>
>
> I would suggest you try without the syntactic predicate, turn your
> semantic predicate into a gated semantic predicate {...}? => such that
> it is forced to be evaluated:
>
> block_open: {is_block_open()}?=> BLOCK_BOUNDARY
>
>
> I cannot use a function without a parameter, because the decision
> bases on the name of a block. So the function needs to be of a form:
> /is_block_open(String blockName)/ function, and retrieving the
> parameter requires the parser to make a look-ahead. That's what I need
> the syntactic predicate for.
Yes, that was meant as an example. If you need lookahead, you may also
consider using something like
input.LT(2).getText().equals(mystackofnames.top()). Anyway, have you
tried turning the sem. predicate into a gated sem. predicate (just add a
=> after the ?)
Andreas
More information about the antlr-interest
mailing list