Hello,
I'm not positive I see what's going on here or why it would not be parsing. It can properly identify Positive or Negative Infinity, even NaN, but it is having difficulty with actual numeric values. Instead it is finding "option" to fail parsing and instead seeing this as an Empty Statement.
Based on the Google Protocol Buffer grammar v2:
Here are a few snippets:
fragment DIG: [0-9];
fragment E: [Ee];
fragment SIGNAGE: [+-];
INFINITY: 'inf';
NOT_A_NUMBER: 'nan';
// It is worth establishing lexical comprehension for EXPONENT.
EXPONENT: E SIGNAGE? DIG+;
ONE_OR_MORE_DIG: DIG+;
ZERO_OR_MORE_DIG: DIG*;
/*
floatLit = (
decimals "." [ decimals ] [ exponent ]
| decimals exponent
| "." decimals [ exponent ]
)
| "inf"
| "nan"
decimals = decimalDigit { decimalDigit }
exponent = ( "e" | "E" ) [ "+" | "-" ] decimals
// Also, technically the spec does not differentiate + from - Infinity, but we can here.
*/
infinity: INFINITY;
nan: NOT_A_NUMBER;
//floatDigitsDotDigitsExponent: ONE_OR_MORE_DIG DOT ZERO_OR_MORE_DIG EXPONENT?;
floatDigitsDotDigitsExponent: ONE_OR_MORE_DIG DOT ONE_OR_MORE_DIG? EXPONENT?;
floatDigitsExponent: ONE_OR_MORE_DIG EXPONENT;
floatDotDigitsExponent: DOT ONE_OR_MORE_DIG EXPONENT?;
floatLit : sign? (
infinity
| nan
| floatDigitsDotDigitsExponent
| floatDigitsExponent
| floatDotDigitsExponent
)
;
/*
constant = fullIdent | ( [ "-" | "+" ] intLit ) | ( [ "-" | "+" ] floatLit ) |
strLit | boolLit
*/
constant
: booleanLit
| quotedStrLit
| floatLit
| intLit
| fullIdentLit
;
/*
option = "option" optionName "=" constant ";"
optionName = ( ident | "(" fullIdent ")" ) { "." ident }
*/
optionDecl: OPTION optionName EQU constant EOS;
Note that FullIdent, Integer, String, Boolean, those are all working. Floating Point is failing and instead reporting that as "Integer", skipping the rest of the statement, and then discovering an "empty statement".
Any suggestions how to make Floating Point grammar work?
Thanks!
Best regards,
Michael Powell