Beispiel #1
0
 def p_argument(self, p):
     """argument : test
                 | test comp_for
                 | test EQUALS test
     """
     # Really [keyword '='] test
     # The reason that keywords are test nodes instead of NAME is that using
     # NAME results in an ambiguity.
     p1 = p[1]
     lenp = len(p)
     if lenp == 2:
         p0 = p1
     elif lenp == 3:
         if p1 == '**':
             p0 = ast.keyword(arg=None, value=p[2])
         elif p1 == '*':
             p0 = ast.Starred(value=p[2])
         else:
             p0 = ast.GeneratorExp(elt=p1, generators=p[2]['comps'],
                                   lineno=p1.lineno,
                                   col_offset=p1.col_offset)
     elif lenp == 4:
         p0 = ast.keyword(arg=p1.id, value=p[3])
     else:
         assert False
     p[0] = p0
Beispiel #2
0
 def p_argument(self, p):
     """argument : test
                 | test comp_for
                 | test EQUALS test
     """
     # Really [keyword '='] test
     # The reason that keywords are test nodes instead of NAME is that using
     # NAME results in an ambiguity.
     p1 = p[1]
     lenp = len(p)
     if lenp == 2:
         p0 = p1
     elif lenp == 3:
         if p1 == '**':
             p0 = ast.keyword(arg=None, value=p[2])
         elif p1 == '*':
             p0 = ast.Starred(value=p[2])
         else:
             p0 = ast.GeneratorExp(elt=p1,
                                   generators=p[2]['comps'],
                                   lineno=p1.lineno,
                                   col_offset=p1.col_offset)
     elif lenp == 4:
         p0 = ast.keyword(arg=p1.id, value=p[3])
     else:
         assert False
     p[0] = p0
Beispiel #3
0
Datei: v35.py Projekt: zzp0/xonsh
 def _set_arg(self, args, arg, ensure_kw=False):
     if isinstance(arg, ast.keyword):
         args['keywords'].append(arg)
     elif ensure_kw:
         args['keywords'].append(ast.keyword(arg=None, value=arg))
     else:
         args['args'].append(arg)
Beispiel #4
0
 def p_argument_eq(self, p):
     """argument : test EQUALS test"""
     p3 = p[3]
     p[0] = ast.keyword(arg=p[1].id,
                        value=p3,
                        lineno=p3.lineno,
                        col_offset=p3.col_offset)
Beispiel #5
0
 def p_argument_kwargs(self, p):
     """argument : POW test"""
     p2 = p[2]
     p[0] = ast.keyword(arg=None,
                        value=p2,
                        lineno=p2.lineno,
                        col_offset=p2.col_offset)
Beispiel #6
0
Datei: v35.py Projekt: zzp0/xonsh
 def p_argument_eq(self, p):
     """argument : test EQUALS test"""
     p[0] = ast.keyword(arg=p[1].id, value=p[3])
Beispiel #7
0
Datei: v35.py Projekt: zzp0/xonsh
 def p_argument_kwargs(self, p):
     """argument : POW test"""
     p[0] = ast.keyword(arg=None, value=p[2])