[antlr-interest] Syntactic predicate ignored?
Ken Williams
ken.williams at thomsonreuters.com
Fri Jun 11 10:01:28 PDT 2010
I am surprised that the following grammar matches "xli" as a STATE rather
than as a ROMAN. It's like it's completely ignoring the syntactic predicate
on STATE. Anyone have any insight into what's going on?
I'm using:
ANTLRWorks 1.4
ANTLR 3.2 Sep 23, 2009 12:02:23
StringTemplate 3.2.1
Java 1.6.0_20 (Apple Inc.)
------------------------
grammar testg;
options { output=AST; }
cite : token+ EOF ;
token : ROMAN | STATE ;
fragment LETTER : 'a'..'z' ;
STATE: (('mi'|'dc') (EOF | ~LETTER)) => LETTER+
{System.err.println("Found state");};
// From Perl 6 Exegesis on pattern matching
//http://search.cpan.org/~lichtkind/Perl6-Doc-0.36/lib/Perl6/Doc/Design/E05.
pod
fragment ROMANPAT
: 'm'* ('d'?('c'('c'('c')?)?)?|'c'('d'|'m'))
('l'?('x'('x'('x')?)?)?|'x'('l'|'c'))
('v'?('i'('i'('i')?)?)?|'i'('v'|'x'))
;
ROMAN : (ROMANPAT (EOF | ~LETTER)) => ROMANPAT
{System.err.println("Found roman");};
------------------------
--
Ken Williams
Sr. Research Scientist
Thomson Reuters
Phone: 651-848-7712
ken.williams at thomsonreuters.com
More information about the antlr-interest
mailing list