[antlr-interest] gathering any character until specified char
Ben Corne
ben.corne at gmail.com
Mon Aug 15 02:26:05 PDT 2011
Here's another try:
authors
: auth+=until_separator (',' auth+=until_separator)*
-> ^(AGAUTHORS $auth)
;
until_separator
: (~SEPARATOR)*
;
SEPARATOR : ',' ;
This results again in empty values.
Is there an option I need to toggle to make sure the characters get
accounted for?
2011/8/14 Ben Corne <ben.corne at gmail.com>
> HI all
>
> I'm trying to create a list of any characters but trailing whitespaces
> separated by comma's.
> Here are the rules for a specific case where I need this kind of list:
>
> authors
> : (auth+=(.*)) WS* (',' WS* auth+=(.*) WS*)
> -> ^(AGAUTHORS $auth)
> ;
> WS : ( ' '
> | '\t'
> | '\r'
> | '\n'
> )
> ;
>
> Input: Ben Corne , An antlr FAN
> Parse tree should look like this:
> authors
> |------------ 'Ben Corne'
> |------------ WS
> |------------ ','
> |------------ WS
> |------------ 'An antlr FAN'
>
> Instead I get one that doesn't seem to gather any character but the ','
> (tested in debugger)
> Anyone know what I'm doing wrong here?
>
> Kind regards
> Ben Corne
>
More information about the antlr-interest
mailing list