def p_assignment(p): '''statement : ID ASSIGN expr SEMICOL | index ASSIGN expr SEMICOL''' ref = p[1] if isinstance(ref, str): ref = ast.VarUse(ref).at(loc(p, 1)) p[0] = ast.Assignment(ref, p[3]).at(loc(p))
def p_modification(p): '''statement : ID MODIFY expr SEMICOL | index MODIFY expr SEMICOL''' ref = p[1] if isinstance(ref, str): ref = ast.VarUse(ref).at(loc(p, 1)) op = ast.Operator.get(p[2][:-1]) p[0] = ast.Modification(ref, op, p[3]).at(loc(p))
def p_varuse(p): '''expr : ID''' p[0] = ast.VarUse(p[1]).at(loc(p))