[antlr-interest] Multiple optional fields question
mynetadm
alecsandru.chirosca at comtec.ro
Mon Dec 13 23:52:43 PST 2004
Hi list
I'm doing an parser to test de ANTLR capabilities and I have one
problem,,,,
we have something like :
test+1200+234EM123+1+TEST;
where fields : test, 1200 , 234EM123 are mandatory and 1 and TEST are
optional. I have to support options like :
test+1200+234EM123++TEST; or test+1200+234EM123+1 or test+1200+234EM123;
so I made :
class myParser extends Parser;
options { k=4; }
test: ( field1:TEXT DELIM field2:NUMBER DELIM copositeField
(DELIM (field3:DIGIT)?)?
(DELIM (field4:TEXT)?)?
ENDLINE
);
compositeField: (
na:NUMBER t:TEXT nb:NUMBER
)
class myLexer extends Lexer;
DIGIT: ('0'..'9');
NUMBER: (DIGIT)(DIGIT)+;
CHAR: ('a'..'z' | 'A'..'Z');
TEXT: (CHAR)(CHAR)+;
ENDLINE: ";";
the problem is that :
test+1200+234EM123+1+TEST; interprets corectly
test+1200+234EM123+1; interprets corectly
test+1200+234EM123++TEST; interprets corectly
test+1200+234EM123; gives me an unexpected end of line
Can anyone help me please?
BR,
alecs
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list