コード例 #1
0
def p_param_spec(p):
    '''
    param_spec : type_spec ID
               | LBRACKET type_spec ID EQUALS value_option RBRACKET
    '''
    if DEBUG:
        print("\nparam spec: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    if len(p) == 7:
        p[0] = ast.ParamSpec(p[2], ast.ID(p[3]), p[5])
    else:
        p[0] = ast.ParamSpec(p[1], ast.ID(p[2]), None)
コード例 #2
0
def p_value_option(p):
    '''
    value_option : ID
    '''
    if DEBUG:
        print("\nvalue option: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    p[0] = ast.ID(p[1])
コード例 #3
0
def p_function_decl(p):
    '''
    function_decl : FUNCTION return_type_spec ID param_list compound_statement
    '''
    if DEBUG:
        print("\nfun decl: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    p[0] = ast.FunctionDecl(p[2], ast.ID(p[3]), p[4], p[5])
コード例 #4
0
def p_primary_expr_ID(p):
    '''
    primary_expr : ID
    '''
    if DEBUG:
        print("\nprimary expr: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    p[0] = ast.ID(p[1])
コード例 #5
0
def p_object_call(p):
    '''
    object_call : PERIOD ID
    '''
    if DEBUG:
        print("\nobject call: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    p[0] = ast.ObjectCall(ast.ID(p[2]))
コード例 #6
0
def p_for_statement(p):
    '''
    for_statement : FOR LPAREN ID IN expr RPAREN statement
    '''
    if DEBUG:
        print("\nfor stmt: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    p[0] = ast.For(ast.ID(p[3]), p[5], p[7])
コード例 #7
0
def p_object_class_spec(p):
    '''
    object_class_spec : GT ID LT
    '''
    if DEBUG:
        print("\nobject class spec: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    #p[0] = p[2]
    p[0] = ast.ObjectClassSpec(ast.ID(p[2]))
コード例 #8
0
def p_argument_expr(p):
    '''
    argument_expr : conditional_expr
                  | ID EQUALS conditional_expr
    '''
    if DEBUG:
        print("\nargument expr: ", end="")
        for i in range(len(p)):
            print(i, " ", p[i], " ", end="")
    if len(p) == 4:
        p[0] = (ast.ID(p[1]), p[3])
    else:
        p[0] = p[1]
コード例 #9
0
ファイル: ucparser.py プロジェクト: AgustinaDiamint/mc921
 def p_identifier(self, p):
     """ identifier : ID """
     p[0] = ast.ID(p[1], coord=self._token_coord(p, 1))
コード例 #10
0
ファイル: parser.py プロジェクト: lordcrekit/cse440fs16proj02
def p_id(p):
    "id : ID"
    p[0] = ast.ID(p[1])