support for Python 2.5 yield expressions

This commit is contained in:
Dmitry Jemerov
2008-02-03 16:28:37 +03:00
parent 326e677837
commit 942eff8eb0
12 changed files with 113 additions and 0 deletions
@@ -0,0 +1,3 @@
def f():
yield 42
<error descr="'return' with argument inside generator">return 28</error>
@@ -0,0 +1 @@
<error descr="'yield' outside of function">yield 42</error>
+2
View File
@@ -0,0 +1,2 @@
def f():
foo(yield 42)
+2
View File
@@ -0,0 +1,2 @@
def f():
x = yield 42
+22
View File
@@ -0,0 +1,22 @@
PyFile:YieldInAssignment.py
PyFunction
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('f')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyAssignmentStatement
PyReferenceExpression: x
PsiElement(Py:IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyYieldExpression
PsiElement(Py:YIELD_KEYWORD)('yield')
PsiWhiteSpace(' ')
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('42')
@@ -0,0 +1,3 @@
def g():
x = 0
x += yield 42
@@ -0,0 +1,31 @@
PyFile:YieldInAugAssignment.py
PyFunction
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('g')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyAssignmentStatement
PyReferenceExpression: x
PsiElement(Py:IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('0')
PsiWhiteSpace('\n ')
PyAugAssignmentStatement
PyReferenceExpression: x
PsiElement(Py:IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(Py:PLUSEQ)('+=')
PsiWhiteSpace(' ')
PyYieldExpression
PsiElement(Py:YIELD_KEYWORD)('yield')
PsiWhiteSpace(' ')
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('42')
@@ -0,0 +1,2 @@
def f():
x = 12 + (yield)
@@ -0,0 +1,28 @@
PyFile:YieldInParentheses.py
PyFunction
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('f')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyAssignmentStatement
PyReferenceExpression: x
PsiElement(Py:IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyBinaryExpression
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('12')
PsiWhiteSpace(' ')
PsiElement(Py:PLUS)('+')
PsiWhiteSpace(' ')
PyParenthesizedExpression
PsiElement(Py:LPAR)('(')
PyYieldExpression
PsiElement(Py:YIELD_KEYWORD)('yield')
PsiElement(Py:RPAR)(')')
+2
View File
@@ -0,0 +1,2 @@
def f():
yield 42
+17
View File
@@ -0,0 +1,17 @@
PyFile:YieldStatement.py
PyFunction
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('f')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyExpressionStatement
PyYieldExpression
PsiElement(Py:YIELD_KEYWORD)('yield')
PsiWhiteSpace(' ')
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('42')