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

Differentiate between unary + number and number of unary '-' char #55

Closed xsawyerx closed 4 years ago

xsawyerx commented 4 years ago

When we see a -4, it's parsed ambiguously as:

# (Program
#   (StatementSeq
#     (Statement
#       (NonBraceExprValueR
#         (NonBraceValue (NonBraceLiteral (LitNumber '-' '4')))))))
# (Program
#   (StatementSeq
#     (Statement
#       (NonBraceExprUnaryR
#         '-'
#         (ExprValueR
#           (Value
#             (Literal (NonBraceLiteral (LitNumber '4')))))))))