[antlr-interest] Help with this grammar?
Charlie Hubbard
charlie.hubbard at gmail.com
Sat Jul 2 16:20:07 PDT 2005
I'm having trouble with the following piece of a grammar:
ruleOptions
: LPAREN
( keyword:IDENT (COLON keywordParam)? SEMICOLON )* RPAREN
;
keywordParam returns [ String param = "" ] { StringBuffer buf = new
StringBuffer(); }
: (letter:~SEMICOLON { buf.append( letter ); } )* { param =
buf.toString(); }
;
This portion recognizes one or more keyword parameter combinations.
Each keyword is optionally followed by a section of parameters.
Really it is only a single parameter, but that parameter could contain
more than one option. The keyword-parameter sequence is ended by a
semi-colon. So here is an example:
( message: "Hi, there this is a paramter of message keyword";
classtype: blah; rev: 6;)
The following parser works, but it is failing on some characters I
didn't expect. I'm currently getting the following error:
exception: filename:17:93: unexpected char: '>'
Here is the line it's having trouble with:
msg:"EXPLOIT delegate proxy overflow"; dsize:>1000;
the '>' character is not recogized by that grammar. Why? I thought
the use of ~SEMICOLON would recognized everything, but ';'.
I'm new to ANTLR, but I'm beginning to get the hang of it. But I'm
still getting hung up on little things like this.
Thanks
Charlie
More information about the antlr-interest
mailing list