[antlr-interest] Matching the * character
Steve O'Hara
sohara at pivotal-solutions.co.uk
Thu Mar 27 16:27:33 PDT 2008
I'm new to Antlr so forgive me if this is a stupid question...
I'm trying to match a database search criteria that looks like the
following;
'some text'*, *'more criteria' & 'more criteria'*
My grammar is;
expression
: subExpression (WS? (COMMA | AMPERSAND) WS? subExpression)*
;
subExpression
: WS? (Identifier | subExpressionText) WS?
;
subExpressionText
: (STAR | QUESTION*)? QuotedString (STAR | QUESTION*)? WS?
;
Letter : 'a'..'z' | 'A'..'Z' | '_' | '\u0080'..'\ufffe' ;
Digit : '0'..'9' ;
Identifier : Letter (Letter | Digit)* ;
QuotedString :'\'' (~'\'')* '\'' ;
WS : (' ' | '\t' | '\n' | '\r')+ ;
COMMA : ',' ;
AMPERSAND : '&' ;
QUESTION : '?' ;
STAR : '*' ;
The parser finds the first quoted string (some text) but fails after
that with a NoViableAltException. If I change the * to ? it works fine.
I'm waiting for delivery of the reference manual so maybe I'm breaking
some sort of golden rule here, but any help would be greatly
appreciated.
Steve
Steve O'Hara
Pivotal Solutions
( +44 (0)7802 484227
+44 (0)208 660 7288 (Fax)
* sohara at pivotal-solutions.co.uk <mailto:>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080327/b1fd0f4d/attachment-0001.html
More information about the antlr-interest
mailing list