Allow to separate top-level script declarations and statements with semicolon

This fix allows to write one-liner scripts like "val x = 3; println(x)", which
were previously rejected by the parser.
This commit is contained in:
Ilya Chernikov
2019-11-19 19:14:27 +01:00
parent b8034567ef
commit 7bb9f97b11
4 changed files with 42 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
val x = 6; println(x * 7)
+35
View File
@@ -0,0 +1,35 @@
KtFile: OneLiner.kts
PACKAGE_DIRECTIVE
<empty list>
IMPORT_LIST
<empty list>
SCRIPT
BLOCK
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('6')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace(' ')
SCRIPT_INITIALIZER
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('println')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MUL)('*')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('7')
PsiElement(RPAR)(')')