Parsing property declarations by looking ahead

This commit is contained in:
Andrey Breslav
2010-12-20 20:30:52 +03:00
parent 6361d0eb0a
commit 6f241b7f9f
7 changed files with 195 additions and 204 deletions
+3 -2
View File
@@ -1,7 +1,5 @@
fun foo)
fun [a] f foo()
fun [a] T.foo.()
fun [a] T<T>.{(A<B>) : ()}()
fun [a] T.foo(a : ) : bar
fun [a()] T.foo<T : {(a) : b>(a : foo) : bar
fun [a()] T.foo<>(a : foo) : bar
@@ -10,3 +8,6 @@ fun [a()] T.foo<, T, , T>(a : foo) : bar
fun [a()] T.foo<T, T>(, a : foo, , a: b) : bar
fun foo() : = a;
fun [a] T<T>.{(A<B>) : ()}.-()
+53 -79
View File
@@ -33,84 +33,6 @@ JetFile: Functions_ERR.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiErrorElement:Expecting function name
<empty list>
TYPE_PARAMETER_LIST
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
PsiElement(IDENTIFIER)('T')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiElement(DOT)('.')
PsiErrorElement:Expecting function name
PsiElement(LBRACE)('{')
TYPE_PARAMETER_LIST
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiErrorElement:Expecting a parameter declaration
PsiElement(IDENTIFIER)('A')
PsiErrorElement:Expecting ')'
PsiElement(LT)('<')
PsiErrorElement:Expecting function body
PsiElement(IDENTIFIER)('B')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(GT)('>')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
@@ -431,4 +353,56 @@ JetFile: Functions_ERR.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('a')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n\n\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
PsiElement(IDENTIFIER)('T')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('A')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiErrorElement:Expecting function name
PsiElement(MINUS)('-')
TYPE_PARAMETER_LIST
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
+29 -43
View File
@@ -3,24 +3,20 @@ JetFile: Properties.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
@@ -28,9 +24,8 @@ JetFile: Properties.jet
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
@@ -55,15 +50,12 @@ JetFile: Properties.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
<empty list>
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
@@ -75,14 +67,13 @@ JetFile: Properties.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
@@ -96,9 +87,8 @@ JetFile: Properties.jet
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
@@ -146,9 +136,8 @@ JetFile: Properties.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
@@ -199,9 +188,8 @@ JetFile: Properties.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
@@ -280,9 +268,8 @@ JetFile: Properties.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
@@ -341,9 +328,8 @@ JetFile: Properties.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
+3 -3
View File
@@ -1,6 +1,6 @@
var - f = s
var - f {}
var - f :
var - {}
var f {}
var f :
val foo :
val [a foo = foo
val foo.bar.
+31 -47
View File
@@ -3,22 +3,8 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting receiver type or property name
PsiErrorElement:Expecting property name or receiver type
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('s')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting receiver type or property name
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter
@@ -28,10 +14,17 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting receiver type or property name
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace('\n')
@@ -41,8 +34,6 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
<empty list>
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
@@ -53,15 +44,14 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiErrorElement:Expecting ']' to close an attribute annotation
<empty list>
PsiElement(IDENTIFIER)('a')
PsiErrorElement:Expecting ']' to close an attribute annotation
<empty list>
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
@@ -85,14 +75,13 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
ATTRIBUTE
USER_TYPE
USER_TYPE
USER_TYPE
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
@@ -111,9 +100,8 @@ JetFile: Properties_ERR.jet
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
@@ -166,9 +154,8 @@ JetFile: Properties_ERR.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
@@ -221,9 +208,8 @@ JetFile: Properties_ERR.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
@@ -282,8 +268,6 @@ JetFile: Properties_ERR.jet
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
RECEIVER_TYPE_ATTRIBUTES
<empty list>
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')