From: Luke Kenneth Casson Leighton Date: Mon, 30 Mar 2020 12:05:36 +0000 (+0100) Subject: sigh add in do while syntax X-Git-Tag: div_pipeline~1605 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fdb7a9a3eba8e0b9d14f6bbf5903aa6585f529d4;p=soc.git sigh add in do while syntax --- diff --git a/src/soc/decoder/power_pseudo.py b/src/soc/decoder/power_pseudo.py index 31e16c66..3ed3c083 100644 --- a/src/soc/decoder/power_pseudo.py +++ b/src/soc/decoder/power_pseudo.py @@ -91,7 +91,7 @@ RESERVED = { "for": "FOR", "to": "TO", "while": "WHILE", - "do": "do", + "do": "DO", "return": "RETURN", } @@ -180,9 +180,7 @@ def python_colonify(lexer, tokens): for token in tokens: print ("track colon token", token, token.type) - if token.type == 'DO': - continue # skip. do while is redundant - elif token.type == 'THEN': + if token.type == 'THEN': # turn then into colon token.type = "COLON" yield token @@ -532,13 +530,13 @@ def p_for_stmt(p): p[0] = ast.For(p[2], it, p[8], []) def p_while_stmt(p): - """while_stmt : WHILE test COLON suite ELSE COLON suite - | WHILE test COLON suite + """while_stmt : DO WHILE test COLON suite ELSE COLON suite + | DO WHILE test COLON suite """ - if len(p) == 5: - p[0] = ast.While(p[2], p[4], []) + if len(p) == 6: + p[0] = ast.While(p[3], p[5], []) else: - p[0] = ast.While(p[2], p[4], p[7]) + p[0] = ast.While(p[3], p[5], p[8]) def p_if_stmt(p): """if_stmt : IF test COLON suite ELSE COLON suite @@ -826,13 +824,13 @@ print (RA) bpermd = r""" if index < 64 then index <- 0 else index <- 5 -while index +do while index < 5 index <- 0 for i = 0 to 7 index <- 0 """ -bpermd = r""" +_bpermd = r""" for i = 0 to 7 index <- (RS)[8*i:8*i+7] if index < 64 then