Lukasz Guminski wrote:
2009/3/23 Andreas Meyer <[email protected]>
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 ?)
input.LT(2).getText() does not work because it returns only the next
character. So when I have
BLOCK
with_a_very_long_name
then LT(2) does not return the full name.
Are you doing this in the lexer or the parser? LT in the parser will
return the token at that position and the text will be the entire text,
not the first character. Of course you need to know that LT(2) is the
correct reference and not a WS token or something else not HIDDEN. If
you just consumed BLOCK_BOUNDARY, then you want LT(1) not LT(2).
JIm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
|
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address