[antlr-interest] Gated semantic predicates behaving like validating predicates

Steve Bennett stevagewp at gmail.com
Sun Feb 3 04:21:52 PST 2008


Hi all (and sorry for spamming the list),

I've got a weird situation where some code that has been working for a
long time is now generating failed predicate messages:

line 1:17 rule RFC_LINK failed predicate: {!in_noparse}?
line 1:19 rule RFC_LINK failed predicate: {!in_noparse}?

Where the code looks like this:

----
RFC_LINK: {!in_noparse}?=>
  ((RFC_LINK_ACTUAL) => RFC_LINK_ACTUAL
  | LETTER { $type=LETTERS; }
  );

fragment
RFC_LINK_ACTUAL:
    'RFC'
    ' '+
    ('0'..'9')+;
----

I actually have a sequence of rules that start with that predicate,
and if I comment one out, the next one just fails.

I don't understand what I could have changed to suddenly make this
occur. I was experimenting with the latest build, but this should be
ANTLRworks 1.1.7.

Similarly, this code is now generating warnings (and refusing to
compile under 3.1b1 which seems to be stricter about unreachable
tokens):

ESCAPED_PUNC     : {in_noparse}? => '#' | '*' | ':' | ';' | '|' | '['
| ']' | '=' | '/';


HASH            : {!in_noparse}? => '#';
ASTERISK        : {!in_noparse}? => '*';
...

[23:18:57] warning(208): C:\antlr\mediawiki4.g:932:1: The following
token definitions are unreachable:
ASTERISK,COLON,SEMICOLON,PIPE,LEFT_BRACKET,RIGHT_BRACKET,EQUALS,SLASH


Obviously I have inadvertently changed something to cause this, but
what? Any ideas welcome.

Steve, who apologises for his constant newbie questions.


More information about the antlr-interest mailing list