예제 #1
0
 def action_create_connections(s, l, t):
     ast_conn = ast.into_connection(t[0])
     ast_conn.span = ast.make_span(s, l, t)
     for i in range(1, len(t)):
         next_conn = ast.into_connection(t[i])
         ast_conn.connect_to(next_conn, emitter)
     return ast_conn
예제 #2
0
 def action_create_connections(s, l, t):
     ast_conn = ast.into_connection(t[0])
     ast_conn.span = ast.make_span(s, l, t)
     for i in range(1, len(t)):
         next_conn = ast.into_connection(t[i])
         ast_conn.connect_to(next_conn, emitter)
     return ast_conn
예제 #3
0
 def action_expr(s, l, t):
     if len(t) != 1:
         raise exception.BananaGrammarBug(
             'Bug found in the grammar for expression,'
             ' Please report this bug.')
     if isinstance(t[0], ast.Expr):
         return t[0]
     return ast.Expr(ast.make_span(s, l, t), t[0])
예제 #4
0
 def action_expr(s, l, t):
     if len(t) != 1:
         raise exception.BananaGrammarBug(
             'Bug found in the grammar for expression,'
             ' Please report this bug.'
         )
     if isinstance(t[0], ast.Expr):
         return t[0]
     return ast.Expr(ast.make_span(s, l, t), t[0])
예제 #5
0
 def action_parse_comp_ctor(s, l, tokens):
     comp = ast.Component(ast.make_span(s, l, tokens))
     for tok in tokens:
         if isinstance(tok, ast.Ident):
             comp.set_ctor(tok)
         elif isinstance(tok, ast.ComponentCtorArg):
             comp.add_arg(tok)
         else:
             raise exception.BananaGrammarBug(
                 'Bug found in the grammar, Please report this bug')
     return comp
예제 #6
0
 def action_parse_comp_ctor(s, l, tokens):
     comp = ast.Component(ast.make_span(s, l, tokens))
     for tok in tokens:
         if isinstance(tok, ast.Ident):
             comp.set_ctor(tok)
         elif isinstance(tok, ast.ComponentCtorArg):
             comp.add_arg(tok)
         else:
             raise exception.BananaGrammarBug(
                 'Bug found in the grammar, Please report this bug'
             )
     return comp
예제 #7
0
 def action_dot_path(s, l, t):
     # First token is the name of the variable
     # The rest is the property path
     if isinstance(t[0], ast.StringLit) and len(t[1:]) == 0:
         return t[0]
     return ast.DotPath(ast.make_span(s, l, t), t[0], t[1:])
예제 #8
0
 def action_ident(s, l, t):
     return ast.Ident(ast.make_span(s, l, t), t[0])
예제 #9
0
 def action_num_lit(s, l, t):
     return ast.Number(ast.make_span(s, l, t), t[0])
예제 #10
0
 def action_str_lit(s, l, t):
     return ast.StringLit(ast.make_span(s, l, t), t[0])
예제 #11
0
 def action_parse_ctor_arg(s, l, t):
     if len(t) > 1:
         return ast.ComponentCtorArg(ast.make_span(s, l, t), t[1], t[0])
     else:
         return ast.ComponentCtorArg(ast.make_span(s, l, t), t[0])
예제 #12
0
 def action_json_obj(s, l, t):
     return ast.JsonObj(ast.make_span(s, l, t), t)
예제 #13
0
 def action_dot_path(s, l, t):
     # First token is the name of the variable
     # The rest is the property path
     if isinstance(t[0], ast.StringLit) and len(t[1:]) == 0:
         return t[0]
     return ast.DotPath(ast.make_span(s, l, t), t[0], t[1:])
예제 #14
0
 def action_ident(s, l, t):
     return ast.Ident(ast.make_span(s, l, t), t[0])
예제 #15
0
 def action_num_lit(s, l, t):
     return ast.Number(ast.make_span(s, l, t), t[0])
예제 #16
0
 def action_json_obj(s, l, t):
     return ast.JsonObj(ast.make_span(s, l, t), t)
예제 #17
0
 def action_parse_ctor_arg(s, l, t):
     if len(t) > 1:
         return ast.ComponentCtorArg(ast.make_span(s, l, t), t[1], t[0])
     else:
         return ast.ComponentCtorArg(ast.make_span(s, l, t), t[0])
예제 #18
0
 def action_assignment(s, l, t):
     return ast.Assignment(ast.make_span(s, l, t), t[0], t[1])
예제 #19
0
 def action_assignment(s, l, t):
     return ast.Assignment(ast.make_span(s, l, t), t[0], t[1])
예제 #20
0
 def action_str_lit(s, l, t):
     return ast.StringLit(ast.make_span(s, l, t), t[0])
예제 #21
0
 def action_merge_connections(s, l, t):
     ast_conn = ast.Connection(ast.make_span(s, l, t))
     ast_conn.merge_all(t, emitter)
     return ast_conn
예제 #22
0
 def action_merge_connections(s, l, t):
     ast_conn = ast.Connection(ast.make_span(s, l, t))
     ast_conn.merge_all(t, emitter)
     return ast_conn