From: Kevin Brown Date: Fri, 15 May 2020 19:52:16 +0000 (-0400) Subject: Add support for negative numbers X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8ad01caeee807c873f209581ef609fce879ce2b;p=thirdparty%2Fjinja.git Add support for negative numbers This also fixes a bug where the exponent was not being properly captured as well, just the sign of the number --- diff --git a/grammar.ebnf b/grammar.ebnf index 0f8a6ada..6d266108 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -535,12 +535,17 @@ INTEGER_LITERAL /[\d_]*\d+/ ; +SIGNED_INTEGER_LITERAL + = + /[+-]?[\d_]*\d+/ + ; + NUMBER_LITERAL = literal_type:`number` - whole:INTEGER_LITERAL - ["." fractional:INTEGER_LITERAL] - [ ( "e" | "E" ) exponent:[ ( "+" | "-" ) ] INTEGER_LITERAL ] + whole:SIGNED_INTEGER_LITERAL + [ "." fractional:INTEGER_LITERAL ] + [ ( "e" | "E" ) exponent:SIGNED_INTEGER_LITERAL ] ; STRING_LITERAL