[antlr-interest] Decision can match input such as ... using multiple alternatives
Andrey Pavlenko
andrey.a.pavlenko at googlemail.com
Sat Oct 23 02:43:36 PDT 2010
Hi All,
Could someone help me with the below grammar? I'm getting the
following warning on the 'attr_value : ~(EOL | '#' | '[' | ']')+;'
rule:
warning(200): config.g:33:4: Decision can match input such as
"{CONFIG..COMMENT, SPACE, '/', '='}" using multiple alternatives: 1,
2.
What's wrong with this grammar?
________________________________________________
grammar config;
options {
language = Java;
output = AST;
}
tokens {
CONFIG;
SECTION;
SECTION_NAME;
NODE;
ATTRIBUTE;
ATTR_NAME;
ATTR_VALUE;
}
config : (COMMENT | section | EOL | SPACE)* -> ^(CONFIG COMMENT* section*);
section : section_header (EOL+ attribute)* -> ^(SECTION section_header
attribute*);
section_header
: '[' node+ ']' -> ^(SECTION_NAME ^(NODE node)+);
node : ('/' ~(EOL | '#' | '[' | ']' | '/')*);
attribute : attr_name '=' attr_value -> ^(ATTRIBUTE ^(ATTR_NAME
attr_name) ^(ATTR_VALUE attr_value));
attr_name
: ~(EOL | '#' | '[' | ']' | '=')+;
attr_value
: ~(EOL | '#' | '[' | ']')+;
COMMENT : ('#' (~('\n' | '\r'))* ('\n' | '\r' | '\r' '\n')?);
SPACE : (' ' | '\t' | '\f')+;
EOL : ('\n' | '\r' | '\r' '\n');
________________________________________________
Thanks.
More information about the antlr-interest
mailing list