From e7e25857a42d3fae5d8c88d71a5f61c50175fe13 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 3 Apr 2020 19:44:48 +0100 Subject: [PATCH] unary minus is at end not in front --- src/soc/decoder/pseudo/parser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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] -- 2.30.2