コード例 #1
0
def add():
    if 'ADDITIVE(' in current_tok:
        a = AST.Add()
        a.op = current_tok.split('(')[1].split(')')[0]
        token('ADDITIVE(')
        a.right = simple_expression()
        return a
    elif (current_tok in ('SC', 'THEN', 'DO', 'RP')) or ('COMPARE('
                                                         in current_tok):
        return None
    else:
        raise ParserError
コード例 #2
0
 def p_Add(self, p):
     '''Add : Expr plus Expr'''
     p[0] = AST.Add( E1 = p[1], E2 = p[3],
                     lineno = p.lineno(1) )