Skip to content

Commit 184d474

Browse files
authored
Merge pull request #3841 from dolik-rce/update-kotlin-1.9
Update kotlin parser
2 parents 5f3415b + a41827e commit 184d474

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

peg/kotlin.peg

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ classParameters <- LPAREN __* (classParameter (__* COMMA __* classParameter)* (_
6262
classParameter <- (modifiers? _* VAL {PUSH_KIND(auxil, K_CONSTANT);} / modifiers? _* VAR {PUSH_KIND(auxil, K_VARIABLE);} / modifiers? {PUSH_KIND(auxil, K_IGNORE);} _*)? __* <simpleIdentifier> {makeKotlinTag(auxil, $1, $1s, true);} _* COLON __* type (__* ASSIGNMENT __* expression)? {POP_SCOPE(auxil);}
6363
delegationSpecifiers <- annotatedDelegationSpecifier (__* COMMA __* annotatedDelegationSpecifier)*
6464
delegationSpecifier <- constructorInvocation / explicitDelegation / userType / functionType
65-
constructorInvocation <- userType _* valueArguments
65+
constructorInvocation <- userType __* valueArguments
6666
annotatedDelegationSpecifier <- annotation* __* delegationSpecifier
6767
explicitDelegation <- (userType / functionType) __* BY __* expression
6868
typeParameters <- LANGLE __* typeParameter (__* COMMA __* typeParameter)* (__* COMMA)? __* RANGLE
@@ -74,7 +74,7 @@ typeConstraint <- annotation* simpleIdentifier __* COLON __* type
7474
classMemberDeclarations <- (classMemberDeclaration semis?)*
7575
classMemberDeclaration <- secondaryConstructor / anonymousInitializer / companionObject / declaration
7676
anonymousInitializer <- INIT __* block
77-
companionObject <- modifiers? COMPANION __* OBJECT {PUSH_KIND(auxil, K_OBJECT);} <(__* simpleIdentifier)?> {makeKotlinTag(auxil, $1e-$1s != 0 ? $1 : "Companion", $1s, true);} (__* COLON __* delegationSpecifiers)? (__* classBody)? {POP_SCOPE(auxil);}
77+
companionObject <- modifiers? COMPANION __* (DATA __*)? OBJECT {PUSH_KIND(auxil, K_OBJECT);} <(__* simpleIdentifier)?> {makeKotlinTag(auxil, $1e-$1s != 0 ? $1 : "Companion", $1s, true);} (__* COLON __* delegationSpecifiers)? (__* classBody)? {POP_SCOPE(auxil);}
7878
functionValueParameters <- LPAREN __* (functionValueParameter (__* COMMA __* functionValueParameter)* (__* COMMA)?)? __* RPAREN
7979
functionValueParameter <- parameterModifiers? _* parameter (__* ASSIGNMENT __* expression)?
8080
functionDeclaration <- modifiers? _* FUN {PUSH_KIND(auxil, K_METHOD);} _* (__* typeParameters)? _* (__* receiverTypeAndDot)? __* <simpleIdentifier> {makeKotlinTag(auxil, $1, $1s, true);} __* functionValueParameters _* (__* COLON __* type)? _* (__* typeConstraints)? _* (__* functionBody)? {POP_SCOPE(auxil);}
@@ -141,7 +141,7 @@ infixOperation <- elvisExpression (_* inOperator __* elvisExpression / _* isOper
141141
elvisExpression <- infixFunctionCall (__* elvis __* infixFunctionCall)*
142142
elvis <- QUEST_NO_WS COLON
143143
infixFunctionCall <- rangeExpression (_* simpleIdentifier __* rangeExpression)*
144-
rangeExpression <- additiveExpression (_* RANGE __* additiveExpression)*
144+
rangeExpression <- additiveExpression (_* (RANGE_UNTIL / RANGE) __* additiveExpression)*
145145
additiveExpression <- multiplicativeExpression (_* additiveOperator __* multiplicativeExpression)*
146146
multiplicativeExpression <- asExpression (_* multiplicativeOperator __* asExpression)*
147147
asExpression <- prefixUnaryExpression (__* asOperator __* type)*
@@ -203,9 +203,9 @@ inside_valueArgument <- annotation? __* (simpleIdentifier __* ASSIGNMENT __*)? M
203203
lambdaLiteral <- LCURL {PUSH_KIND(auxil, K_METHOD); makeKotlinTag(auxil, "<lambda>", $0s, true);} __* statements __* RCURL {POP_SCOPE(auxil);} / LCURL {PUSH_KIND(auxil, K_METHOD); makeKotlinTag(auxil, "<lambda>", 8, true);} __* lambdaParameters? __* ARROW __* statements __* RCURL {POP_SCOPE(auxil);}
204204
lambdaParameters <- lambdaParameter (__* COMMA __* lambdaParameter)* (__* COMMA)?
205205
lambdaParameter <- variableDeclaration / multiVariableDeclaration (__* COLON __* type)?
206-
anonymousFunction <- FUN {PUSH_KIND(auxil, K_METHOD); makeKotlinTag(auxil, "<anonymous>", $0s, true);} (__* type __* DOT)? __* parametersWithOptionalType (__* COLON __* type)? (__* typeConstraints)? (__* functionBody)? {POP_SCOPE(auxil);}
206+
anonymousFunction <- (SUSPEND __*)? FUN {PUSH_KIND(auxil, K_METHOD); makeKotlinTag(auxil, "<anonymous>", $0s, true);} (__* type __* DOT)? __* parametersWithOptionalType (__* COLON __* type)? (__* typeConstraints)? (__* functionBody)? {POP_SCOPE(auxil);}
207207
functionLiteral <- lambdaLiteral / anonymousFunction
208-
objectLiteral <- OBJECT __* COLON __* delegationSpecifiers __* classBody / OBJECT __* classBody
208+
objectLiteral <- (DATA __*)? OBJECT __* COLON __* delegationSpecifiers __* classBody / OBJECT __* classBody
209209
thisExpression <- THIS_AT / THIS !(Letter / UnicodeDigit)
210210
superExpression <- SUPER_AT / SUPER (LANGLE __* type __* RANGLE)? (AT_NO_WS simpleIdentifier)?
211211
ifExpression <- IF __* LPAREN __* expression __* RPAREN __* controlStructureBody? __* SEMICOLON? __* ELSE __* (controlStructureBody / SEMICOLON) / IF __* LPAREN __* expression __* RPAREN __* (controlStructureBody / SEMICOLON)
@@ -314,6 +314,7 @@ MOD_ASSIGNMENT <- '%='
314314
ARROW <- '->'
315315
#DOUBLE_ARROW <- '=>'
316316
RANGE <- '..'
317+
RANGE_UNTIL <- '..<'
317318
COLONCOLON <- '::'
318319
#DOUBLE_SEMICOLON <- ';;'
319320
#HASH <- '#'

0 commit comments

Comments
 (0)