[antlr-interest] Grammar issue
maulattu
maulattu at yahoo.it
Mon Mar 21 01:53:05 PDT 2011
Hi all,
for a matter of convenience I didn't write here all the rules for white spaces
and so on, but I've them in order to skip white spaces, tab, \r, \n and so on.
It seems the lexer recognize as "textLiteral" the parameter names (i.e.:
"VARIABLE" and "MESSAGE_").
Any suggestions?
Thank you all :)
/*----------------------------------------*/
parametersList
: parametersDeclaration+ EOF
;
parametersDeclaration
: parameter_with_index /* like PARAM_1 above*/
| paramemter_without_index /* like VARIABILE above */
;
parameter_with_index
: parameterName = 'PARAM_' parameterIndex '=' numericLiteral
| parameterName = 'MESSAGE_' parameterIndex '=' textLiteral
;
paramemter_without_index
: parameterName = 'VARIABLE' '=' textLiteral
;
/*----------------------------------------*/
parameterIndex
: DECIMAL_LITERAL
;
numericLiteral
: HEX_LITERAL
| DECIMAL_LITERAL
;
textLiteral
: TEXT_LITERAL
;
HEX_LITERAL
: '0' ('x' | 'X') HEX_DIGIT+
;
DECIMAL_LITERAL
: '0' | '1'..'9' '0'..'9'*
;
/*----------------------------------------*/
fragment
TEXT_LITERAL
: LETTER (LETTER | '0'..'9')*
;
fragment
HEX_DIGIT
: ('0'..'9' | 'a'..'f' | 'A'..'F')
;
fragment
LETTER
: 'A'..'Z'
| 'a'..'z'
| '_'
| '+'
;
________________________________
Da: Stephen Tuttlebee <themightystephen at googlemail.com>
A: antlr-interest at antlr.org
Inviato: Gio 17 marzo 2011, 13:00:59
Oggetto: Re: [antlr-interest] Grammar issue
Hi
Is not the failure to parse:
MESSAGE_1 = this is a message
due to the whitespace between the words in the string following the
equals sign?
Do you have a whitespace lexer rule (often called WS)? I suspect the
parser is failing due to the fact that it parses up to 'MESSAGE_1 =
this' just fine but then after that point it is expecting another
'parametersDeclaration' to follow, for which the remaining input 'is a
message' would not have any rules that matches it (the parser would be
expecting one of three things next, either 'PARAM_', 'MESSAGE_' or
'VARIABLE').
I'm not an expert on ANTLR, but I think that might be your problem.
Thanks
Stephen
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list