Precedence of basic operations tested
This commit is contained in:
@@ -27,6 +27,7 @@ arrowTupleExpression
|
|||||||
: match ("->" match)*
|
: match ("->" match)*
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// ATTENTION
|
||||||
match
|
match
|
||||||
: conjunction ("match" "{" matchEntry+ "}")*
|
: conjunction ("match" "{" matchEntry+ "}")*
|
||||||
;
|
;
|
||||||
@@ -55,8 +56,9 @@ elvisOperation
|
|||||||
: infixFunctionCall ("?:" infixFunctionCall)*
|
: infixFunctionCall ("?:" infixFunctionCall)*
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// ATTENTION
|
||||||
infixFunctionCall
|
infixFunctionCall
|
||||||
: rangeExpression (SimpleName rangeExpression)*
|
: rangeExpression (SimpleName (typeParameters | rangeExpression))*
|
||||||
;
|
;
|
||||||
|
|
||||||
rangeExpression
|
rangeExpression
|
||||||
@@ -165,7 +167,8 @@ prefixUnaryOperation
|
|||||||
|
|
||||||
postfixUnaryOperation
|
postfixUnaryOperation
|
||||||
: "++" : "--"
|
: "++" : "--"
|
||||||
: valueArguments
|
: typeArguments? valueArguments
|
||||||
|
: typeArguments
|
||||||
: arrayAccess
|
: arrayAccess
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -187,7 +190,7 @@ valueArguments
|
|||||||
;
|
;
|
||||||
|
|
||||||
infixFunctionCall
|
infixFunctionCall
|
||||||
: expression SimpleName typeArguments expression?
|
: expression SimpleName typeArguments
|
||||||
: expression SimpleName expression
|
: expression SimpleName expression
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
DISJUNCTION(OROR),
|
DISJUNCTION(OROR),
|
||||||
MATCH(MATCH_KEYWORD),
|
MATCH(MATCH_KEYWORD),
|
||||||
// TODO: don't build a binary tree, build a tuple
|
// TODO: don't build a binary tree, build a tuple
|
||||||
ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ),
|
|
||||||
ARROW(JetTokens.ARROW),
|
ARROW(JetTokens.ARROW),
|
||||||
|
ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ),
|
||||||
;
|
;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
fun foo() {
|
||||||
|
a + b
|
||||||
|
a + b * c
|
||||||
|
a + (b * c)
|
||||||
|
a + b > c * c
|
||||||
|
a + b in c * d
|
||||||
|
a.b
|
||||||
|
a + b.c
|
||||||
|
a.b + c
|
||||||
|
a.b++
|
||||||
|
--a.b++
|
||||||
|
--a * b
|
||||||
|
a+b..b-1
|
||||||
|
1..2 foo 2..3
|
||||||
|
1 foo 2 ?: 1 bar 3
|
||||||
|
a ?: b in b?: c
|
||||||
|
a : b < b : c
|
||||||
|
a < b == b > c
|
||||||
|
a != b && c
|
||||||
|
a || b && c
|
||||||
|
a = b -> c
|
||||||
|
a = b || c
|
||||||
|
}
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
JetFile: Precedence.jet
|
||||||
|
NAMESPACE
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
TYPE_PARAMETER_LIST
|
||||||
|
<empty list>
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MUL)('*')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TUPLE
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MUL)('*')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(GT)('>')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MUL)('*')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(in)('in')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MUL)('*')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('d')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
POSTFIX_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(PLUSPLUS)('++')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
PREFIX_EXPRESSION
|
||||||
|
PsiElement(MINUSMINUS)('--')
|
||||||
|
POSTFIX_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(PLUSPLUS)('++')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PREFIX_EXPRESSION
|
||||||
|
PsiElement(MINUSMINUS)('--')
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(MUL)('*')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(PLUS)('+')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(RANGE)('..')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(MINUS)('-')
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('1')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('1')
|
||||||
|
PsiElement(RANGE)('..')
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('2')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('2')
|
||||||
|
PsiElement(RANGE)('..')
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('3')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('1')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('2')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ELVIS)('?:')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('1')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
INTEGER_CONSTANT
|
||||||
|
PsiElement(INTEGER_LITERAL)('3')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ELVIS)('?:')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(in)('in')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiElement(ELVIS)('?:')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LT)('<')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LT)('<')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(EQEQ)('==')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(GT)('>')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(EXCLEQ)('!=')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ANDAND)('&&')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(OROR)('||')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ANDAND)('&&')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(EQ)('=')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ARROW)('->')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(EQ)('=')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(OROR)('||')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -55,6 +55,7 @@ public class JetParsingTest extends ParsingTestCase {
|
|||||||
public void testNamespaceBlock_ERR() throws Exception {doTest(true);}
|
public void testNamespaceBlock_ERR() throws Exception {doTest(true);}
|
||||||
public void testNamespaceBlock() throws Exception {doTest(true);}
|
public void testNamespaceBlock() throws Exception {doTest(true);}
|
||||||
public void testNewlinesInParentheses() throws Exception {doTest(true);}
|
public void testNewlinesInParentheses() throws Exception {doTest(true);}
|
||||||
|
public void testPrecedence() throws Exception {doTest(true);}
|
||||||
public void testProperties() throws Exception {doTest(true);}
|
public void testProperties() throws Exception {doTest(true);}
|
||||||
public void testProperties_ERR() throws Exception {doTest(true);}
|
public void testProperties_ERR() throws Exception {doTest(true);}
|
||||||
public void testSimpleClassMembers() throws Exception {doTest(true);}
|
public void testSimpleClassMembers() throws Exception {doTest(true);}
|
||||||
|
|||||||
Reference in New Issue
Block a user