Esempio n. 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
Esempio n. 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
Esempio n. 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])
Esempio n. 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])
Esempio n. 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
Esempio n. 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
Esempio n. 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:])
Esempio n. 8
0
 def action_ident(s, l, t):
     return ast.Ident(ast.make_span(s, l, t), t[0])
Esempio n. 9
0
 def action_num_lit(s, l, t):
     return ast.Number(ast.make_span(s, l, t), t[0])
Esempio n. 10
0
 def action_str_lit(s, l, t):
     return ast.StringLit(ast.make_span(s, l, t), t[0])
Esempio n. 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])
Esempio n. 12
0
 def action_json_obj(s, l, t):
     return ast.JsonObj(ast.make_span(s, l, t), t)
Esempio n. 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:])
Esempio n. 14
0
 def action_ident(s, l, t):
     return ast.Ident(ast.make_span(s, l, t), t[0])
Esempio n. 15
0
 def action_num_lit(s, l, t):
     return ast.Number(ast.make_span(s, l, t), t[0])
Esempio n. 16
0
 def action_json_obj(s, l, t):
     return ast.JsonObj(ast.make_span(s, l, t), t)
Esempio n. 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])
Esempio n. 18
0
 def action_assignment(s, l, t):
     return ast.Assignment(ast.make_span(s, l, t), t[0], t[1])
Esempio n. 19
0
 def action_assignment(s, l, t):
     return ast.Assignment(ast.make_span(s, l, t), t[0], t[1])
Esempio n. 20
0
 def action_str_lit(s, l, t):
     return ast.StringLit(ast.make_span(s, l, t), t[0])
Esempio n. 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
Esempio n. 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