Fix parsing error

This commit is contained in:
Jan-Niclas Loosen
2025-11-20 22:09:31 +01:00
parent 7ac8889a1d
commit cb0c7ac2e0
6 changed files with 593 additions and 580 deletions

View File

@@ -54,12 +54,13 @@ def p_E_seq(p):
p[0] = ast.SEQ(p[1], p[3])
def p_E_if(p):
'E : IF LPAREN B RPAREN THEN E ELSE E'
p[0] = ast.IF(p[3], p[6], p[8])
'E : IF B THEN E ELSE E'
p[0] = ast.IF(p[2], p[4], p[6])
def p_E_while(p):
'E : WHILE LPAREN B RPAREN DO LBRACE E RBRACE'
p[0] = ast.WHILE(p[3], p[7])
'E : WHILE B DO LBRACE E RBRACE'
p[0] = ast.WHILE(p[2], p[5])
# ------------------------------------------------------------
# Rules for A