From 433ab59cf9b7ab1ae10754798fc1c110e705db76 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 29 Mar 2020 14:43:41 +0100 Subject: [PATCH] add listmaker --- src/soc/decoder/power_pseudo.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/soc/decoder/power_pseudo.py b/src/soc/decoder/power_pseudo.py index 695a47f9..97ae73c6 100644 --- a/src/soc/decoder/power_pseudo.py +++ b/src/soc/decoder/power_pseudo.py @@ -55,7 +55,7 @@ tokens = ( # taken from decmial.py but without the leading sign def t_NUMBER(t): r"""(\d+(\.\d*)?|\.\d+)([eE][-+]? \d+)?""" - t.value = decimal.Decimal(t.value) + t.value = int(t.value) return t def t_STRING(t): @@ -602,6 +602,21 @@ def p_atom_number(p): | STRING""" p[0] = ast.Const(p[1]) +#'[' [listmaker] ']' | + +def p_atom_listmaker(p): + """atom : LBRACK listmaker RBRACK""" + p[0] = p[2] + +def p_listmaker(p): + """listmaker : test COMMA listmaker + | test + """ + if len(p) == 2: + p[0] = ast.List([p[1]]) + else: + p[0] = ast.List([p[1]] + p[3].nodes) + def p_atom_tuple(p): """atom : LPAR testlist RPAR""" p[0] = p[2] @@ -736,8 +751,9 @@ RA <- [0]*56|| perm[0:7] """ bpermd = r""" -index <- (RS)[8*i:8*i+7] -#RA <- [0]*56 # || perm[0:7] +#index <- (RS)[8*i:8*i+7] +RA <- [0]*56 # || perm[0:7] +print (RA) """ code = bpermd -- 2.30.2