Problems matching *
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, March 27, 2008 06:22 PM

I'm new to Antlr so forgive me if this is a stupid question... I'm trying to match a 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 |    More>>

I'm new to Antlr so forgive me if this is a stupid question...


I'm trying to match a 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 : (' ' | ' ' | '
' | '
')+ ;

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    <<Less
About | Sitemap | Contact