mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
parsing Python 2.5 conditional expressions
This commit is contained in:
@@ -0,0 +1 @@
|
||||
x = true_value if condition else false_value
|
||||
@@ -0,0 +1,20 @@
|
||||
PyFile:ConditionalExpression.py
|
||||
PyAssignmentStatement
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyConditionalExpression
|
||||
PyReferenceExpression: true_value
|
||||
PsiElement(Py:IDENTIFIER)('true_value')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: condition
|
||||
PsiElement(Py:IDENTIFIER)('condition')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ELSE_KEYWORD)('else')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: false_value
|
||||
PsiElement(Py:IDENTIFIER)('false_value')
|
||||
@@ -0,0 +1 @@
|
||||
[f for f in 1, (lambda x: x if x >= 0 else -1)]
|
||||
@@ -0,0 +1,52 @@
|
||||
PyFile:ConditionalParenLambda.py
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTupleExpression
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('1')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParenthesizedExpression
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParameterList
|
||||
PyParameter
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyConditionalExpression
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyBinaryExpression
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:GE)('>=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ELSE_KEYWORD)('else')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:MINUS)('-')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('1')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
@@ -0,0 +1 @@
|
||||
[x for x in lambda: True, lambda: False if x()]
|
||||
@@ -0,0 +1,41 @@
|
||||
PyFile:LambdaComprehension.py
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTupleExpression
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PyParameterList
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: True
|
||||
PsiElement(Py:IDENTIFIER)('True')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PyParameterList
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: False
|
||||
PsiElement(Py:IDENTIFIER)('False')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: x
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
@@ -0,0 +1 @@
|
||||
lambda x: 5 if x else 2
|
||||
@@ -0,0 +1,23 @@
|
||||
PyFile:LambdaConditional.py
|
||||
PyExpressionStatement
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParameterList
|
||||
PyParameter
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyConditionalExpression
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('5')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ELSE_KEYWORD)('else')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('2')
|
||||
Reference in New Issue
Block a user