[antlr-interest] Help with this grammar?

Nigel Sheridan-Smith nbsherid at secsme.org.au
Sat Jul 2 16:52:00 PDT 2005


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Charlie Hubbard
> Sent: Sunday, 3 July 2005 9:20 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Help with this grammar?
> 
> 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: '>'
> 


What is your "charVocabulary" setting? If you do not define a character to
watch in the lexer, it is treated as an invalid character, and will not even
be recognised by ~SEMICOLON.

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435




More information about the antlr-interest mailing list