From: Luke Kenneth Casson Leighton Date: Fri, 3 Apr 2020 18:44:48 +0000 (+0100) Subject: unary minus is at end not in front X-Git-Tag: div_pipeline~1549 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e7e25857a42d3fae5d8c88d71a5f61c50175fe13;p=soc.git unary minus is at end not in front --- diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index ff66e01a..68551b5c 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -346,7 +346,7 @@ class PowerParser: | comparison BITOR comparison | comparison BITAND comparison | PLUS comparison - | MINUS comparison + | comparison MINUS | INVERT comparison | comparison APPEND comparison | power""" @@ -364,7 +364,10 @@ class PowerParser: else: p[0] = ast.BinOp(p[1], binary_ops[p[2]], p[3]) elif len(p) == 3: - p[0] = ast.UnaryOp(unary_ops[p[1]], p[2]) + if isinstance(p[2], str) and p[2] == '-': + p[0] = ast.UnaryOp(unary_ops[p[2]], p[1]) + else: + p[0] = ast.UnaryOp(unary_ops[p[1]], p[2]) else: p[0] = p[1]