From f8752c59945205b717c4b21ceeb4044ae9a0e9df Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 10 Aug 2023 10:47:22 +0200 Subject: Bug 1450: Fix 'Number' rule, i.e. only consume positive numbers as `additiveExpr` and `unaryExpr` consume the '-' operator n GlueGen commit 10032c0115f2794a254cffc2a1cd5e48ca8ff0b8 in branch JOGL_2_SANDBOX Ken hacked in consuming a '-' prefix to have negative numbers covered by 'Number'. This is wrong, as it breaks deduction of `additiveExpr` and 'unaryExpr' rules, which want to consume '-' and '+'. The latter is used to completely resolve constant expressions starting from the 'constExpr' rule. See ISO 9899:202x Programming Language - C https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf --- src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g index 88dbc1e..a7670ad 100644 --- a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g +++ b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g @@ -801,7 +801,7 @@ protected NumberSuffix ; Number - : ( ('-')? ( Digit )+ ( '.' | 'e' | 'E' ) )=> ('-')? ( Digit )+ + : ( ( Digit )+ ( '.' | 'e' | 'E' ) )=> ( Digit )+ ( '.' ( Digit )* ( Exponent )? | Exponent ) @@ -821,7 +821,7 @@ Number ( NumberSuffix )* - | ('-')? '1'..'9' ( Digit )* + | '1'..'9' ( Digit )* ( NumberSuffix )* -- cgit v1.2.3