[antlr-interest] Q re use of Semantic Predicates

Gerald B. Rosenberg gbr at newtechlaw.com
Mon Jun 6 00:21:41 PDT 2005


I need to have two different but overlapping definitions of a WORD, one 
valid only within an xml tag and one valid everywhere else.  Am I correct 
in thinking the solution lies with semantic predicates?  If so, what is the 
right way to define the WORD rule?  My effort below results in the 
predicate equivalently qualifying both alternatives.

XMLTAG:
     '<'  { this.inXmlTag = true; }
     WORD  WS  ATTR  ('/')?
     '>'  { this.inXmlTag = false; }
;

WORD:
       ( {this.inXmlTag}? ( LETTERS | PUNCT1 ) )
     | ( LETTERS | NUMBERS | PUNCT2 )
;


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/20050606/ae0543a1/attachment.html


More information about the antlr-interest mailing list