[antlr-interest] useing antlr to get key information from comment line
李家智
javamonkey at 163.com
Thu Dec 9 18:06:56 PST 2010
i am new to antlr. i put key infomation in the comment and try to use antlr to retrive comment in text file.
here is the grammar:
grammar T;
options {backtrack=true;}
all : (txt)*;
txt :comment {System.out.println("found comment");}
|content {System.out.println("found content");}
;
comment
: COMMENT_TAG content
;
content
: STRING NEWLINE
;
COMMENT_TAG
: '#'
;
NEWLINE: ('\r'? '\n')+;
STRING
: ('\u0010'..'\uffff')*
;
the input text like this :
#command parameter parameter
hello,this is text;
it dose not work,the output is
found content
found content
my expectation is follow :
found comment
found content
.
how to modify the grammar?
Regards
Joel li
More information about the antlr-interest
mailing list