From afb2d37447b5f4477898105a9d320b7e7bdc9d67 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Sat, 2 Feb 2008 22:43:27 +0300 Subject: [PATCH] parsing Python 2.5 conditional expressions --- python/testData/psi/ConditionalExpression.py | 1 + python/testData/psi/ConditionalExpression.txt | 20 +++++++ python/testData/psi/ConditionalParenLambda.py | 1 + .../testData/psi/ConditionalParenLambda.txt | 52 +++++++++++++++++++ python/testData/psi/LambdaComprehension.py | 1 + python/testData/psi/LambdaComprehension.txt | 41 +++++++++++++++ python/testData/psi/LambdaConditional.py | 1 + python/testData/psi/LambdaConditional.txt | 23 ++++++++ 8 files changed, 140 insertions(+) create mode 100644 python/testData/psi/ConditionalExpression.py create mode 100644 python/testData/psi/ConditionalExpression.txt create mode 100644 python/testData/psi/ConditionalParenLambda.py create mode 100644 python/testData/psi/ConditionalParenLambda.txt create mode 100644 python/testData/psi/LambdaComprehension.py create mode 100644 python/testData/psi/LambdaComprehension.txt create mode 100644 python/testData/psi/LambdaConditional.py create mode 100644 python/testData/psi/LambdaConditional.txt diff --git a/python/testData/psi/ConditionalExpression.py b/python/testData/psi/ConditionalExpression.py new file mode 100644 index 000000000000..81004a334813 --- /dev/null +++ b/python/testData/psi/ConditionalExpression.py @@ -0,0 +1 @@ +x = true_value if condition else false_value diff --git a/python/testData/psi/ConditionalExpression.txt b/python/testData/psi/ConditionalExpression.txt new file mode 100644 index 000000000000..aff4e9280413 --- /dev/null +++ b/python/testData/psi/ConditionalExpression.txt @@ -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') \ No newline at end of file diff --git a/python/testData/psi/ConditionalParenLambda.py b/python/testData/psi/ConditionalParenLambda.py new file mode 100644 index 000000000000..e596c7d2b238 --- /dev/null +++ b/python/testData/psi/ConditionalParenLambda.py @@ -0,0 +1 @@ +[f for f in 1, (lambda x: x if x >= 0 else -1)] \ No newline at end of file diff --git a/python/testData/psi/ConditionalParenLambda.txt b/python/testData/psi/ConditionalParenLambda.txt new file mode 100644 index 000000000000..6d7670353210 --- /dev/null +++ b/python/testData/psi/ConditionalParenLambda.txt @@ -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)(']') \ No newline at end of file diff --git a/python/testData/psi/LambdaComprehension.py b/python/testData/psi/LambdaComprehension.py new file mode 100644 index 000000000000..2cb5f5e70b04 --- /dev/null +++ b/python/testData/psi/LambdaComprehension.py @@ -0,0 +1 @@ +[x for x in lambda: True, lambda: False if x()] \ No newline at end of file diff --git a/python/testData/psi/LambdaComprehension.txt b/python/testData/psi/LambdaComprehension.txt new file mode 100644 index 000000000000..640c8c9d8421 --- /dev/null +++ b/python/testData/psi/LambdaComprehension.txt @@ -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)(']') \ No newline at end of file diff --git a/python/testData/psi/LambdaConditional.py b/python/testData/psi/LambdaConditional.py new file mode 100644 index 000000000000..2eac4d311ce1 --- /dev/null +++ b/python/testData/psi/LambdaConditional.py @@ -0,0 +1 @@ +lambda x: 5 if x else 2 \ No newline at end of file diff --git a/python/testData/psi/LambdaConditional.txt b/python/testData/psi/LambdaConditional.txt new file mode 100644 index 000000000000..ae279c1a19c5 --- /dev/null +++ b/python/testData/psi/LambdaConditional.txt @@ -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') \ No newline at end of file