s.expect(')')
return node
+def p_yield_expression(s):
+ # s.sy == "yield"
+ pos = s.position()
+ s.next()
+ if s.sy not in ('EOF', 'NEWLINE', ')'):
+ expr = p_expr(s)
+ s.error("generators ('yield') are not currently supported")
+ return Nodes.PassStatNode(pos)
+
#power: atom trailer* ('**' factor)*
def p_power(s):
s.next()
if s.sy == ')':
result = ExprNodes.TupleNode(pos, args = [])
+ elif s.sy == 'yield':
+ result = p_yield_expression(s)
else:
result = p_expr(s)
s.expect(')')
node = p_import_statement(s)
elif s.sy == 'from':
node = p_from_import_statement(s, first_statement = first_statement)
+ elif s.sy == 'yield':
+ node = p_yield_expression(s)
elif s.sy == 'assert':
node = p_assert_statement(s)
elif s.sy == 'pass':
"print", "del", "pass", "break", "continue", "return",
"raise", "import", "exec", "try", "except", "finally",
"while", "if", "elif", "else", "for", "in", "assert",
- "and", "or", "not", "is", "in", "lambda", "from",
+ "and", "or", "not", "is", "in", "lambda", "from", "yield",
"cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE"
]