[antlr-interest] Quoted Name Value Pairs

Jesse Anderson jesse.anderson at 4bright.com
Tue Apr 22 12:29:42 PDT 2008


I am trying to write a program that takes in commands with name value 
pairs.  Multiple commands can be entered by separating them with a ";".  
Here is an example input:
"add target="directory/name 123/" workspace="blah321";remove id="blah";"

When I try to run this with ANTLRWorks 1.1.7, the program doesn't parse 
the input correctly and no hits are generated.

Here is my file:

expr        : ( add | remove | set | list )* ;

add        : ADD addterms SEMICOLON ;

addterms     : ( WHITESPACE ( WORKSPACE | TARGET | PATTERN | USER | 
START | FILESIZE | THROTTLE | STATUS ) equalsvalue )* ;

remove        : REMOVE removeterms SEMICOLON ;

removeterms    : WHITESPACE ID equalsvalue ;

set        : SET setterms SEMICOLON ;

setterms    : ( WHITESPACE ( ID | WORKSPACE | TARGET | PATTERN | USER | 
START | FILESIZE | THROTTLE | STATUS ) equalsvalue )* ;

list        : LIST listterms SEMICOLON ;

listterms    : ( WHITESPACE WORKSPACE equalsvalue )? ;

equalsvalue     : EQUALS QUOTEDVALUE ;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/

QUOTEDVALUE : '"' (~'"')* '"';

WHITESPACE : WHITESPACECHAR+ ;

WHITESPACECHAR : ( '\t' | ' ' | '\r' | '\n'| '\u000C' ) ;

EQUALS : ( '=' ) ;

SEMICOLON : ( ';' )* ;

Thanks.


More information about the antlr-interest mailing list