xsawyerx / guacamole

Guacamole is a parser toolkit for Standard Perl. It provides fully static BNF-based parsing capability to a reasonable subset of Perl.
https://metacpan.org/pod/Guacamole
20 stars 8 forks source link

Hex numbers are valid constants too #101

Closed Tux closed 4 years ago

Tux commented 4 years ago
diff --git a/lib/Guacamole.pm b/lib/Guacamole.pm
index caff3ff..0ef4bcb 100644
--- a/lib/Guacamole.pm
+++ b/lib/Guacamole.pm
@@ -1376,11 +1376,16 @@ VersionNumberSegment ~ [0-9] [0-9] [0-9]
                      | [0-9] [0-9]
                      | [0-9]

+HexPrefix ~ '0x'
+HexDigits ~ [0-9a-fA-F]+
+HexNumber ~ HexPrefix HexDigits
+
 LitNumber ::= LitNumberDec
 LitNumberDec ~ Digits Period Digits
              | Digits Period
              | Period Digits
              | Digits
+             | HexNumber

 Period      ~ '.'
 Digits      ~ [0-9]+

It is too silly not too allow hex numeric constants.

xsawyerx commented 4 years ago

It's a bug to not support hex numbers, not a feature. :) PR #103 created.