[antlr-interest] Error in predicate logic

Terence Parr parrt at cs.usfca.edu
Tue Mar 13 13:46:03 PDT 2007


On Feb 15, 2007, at 9:42 AM, Gerald B. Rosenberg wrote:

> Did I just run into the same bug, or is this a different problem  
> (and how to fix)?
>
> Trying to parse HTML to recognize the ampersand encoded special  
> characters.
>
> SPCHAR
> : ( AMP GRIDLET INT SEMI ) => AMP GRIDLET INT SEMI
> | ( AMP LETTERS SEMI ) => AMP LETTERS SEMI
> | ( AMP ) => AMP { $type=PCCHAR; }
> ;
>
> fragment PCCHAR : LETTER | DIGIT | PUNCTUATION | '>' | '/' ;
> fragment LETTERS : (LETTER)+ ;
> fragment LETTER  : 'a'..'z'| 'A'..'Z';
> fragment AMP: '&' ;
> fragment GRIDLET: '#' ;
> fragment SEMI: ';' ;
>
> The SPCHAR rule works as expected for input that:
> - fully matches either of the first two subrules
> - matches "&X" -- where "X" is anything *other* than a GRIDLET or a  
> LETTER
>
> For input "&hello there" , I get line 1:6 mismatched character ' '  
> expecting ';'

There is no space allowed in LETTERS; it therefore fails to match alt 2.
Ter




More information about the antlr-interest mailing list