[antlr-interest] Error in predicate logic
Gerald B. Rosenberg
gbr at newtechlaw.com
Fri Feb 16 07:17:39 PST 2007
At 12:57 AM 2/16/2007, Gavin Lambert wrote:
>At 06:42 16/02/2007, Gerald B. Rosenberg wrote:
>>SPCHAR
>>: ( AMP GRIDLET INT SEMI ) => AMP GRIDLET INT SEMI
>>| ( AMP LETTERS SEMI ) => AMP LETTERS SEMI
>>| ( AMP ) => AMP { $type=PCCHAR; }
>>;
>
>Ok, I could be wrong, but I don't think you need any of those
>syntactic predicates, since your lookahead matches what you're
>trying to parse anyway.
Right, but seems I still have to take care of the intervening states
somehow to prevent getting the error message -- after a bit of trial
and error, I found this to work:
SPCHAR :
( AMP GRIDLET INT SEMI { printState("SpDigit "); }
| AMP LETTERS SEMI { printState("SpLettr "); }
| AMP LETTERS ~';' { $type=PCDATA; printState("P1Data "); }
| AMP GRIDLET INT ~';' { $type=PCDATA; printState("P2Data "); }
| AMP GRIDLET ~INT { $type=PCDATA; printState("P3Data "); }
| AMP { $type=PCDATA; printState("PcData "); }
) ;
A bit literal. Still, is there a better way?
Also, using ~SEMI produced a lexer with an undefined set
variable. Using an explicit ~';' works, but seems counter-intuitive
given that both the plain SEMI and ~INT work.
>Oh, and what you call a GRIDLET is normally called a "hash
>mark". Except for some Americans, who inexplicably call it a "pound sign".
I have always taken "Gridlet" to be far more descriptive ;)
Thanks,
Gerald
----
Gerald B. Rosenberg, Esq.
NewTechLaw
285 Hamilton Avenue, Suite 520
Palo Alto, CA 94301-2576
650.325.2100 (office) / 650.703.1724 (cell)
650.325.2107 (fax)
www.newtechlaw.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070216/65f1db64/attachment.html
More information about the antlr-interest
mailing list