diff --git a/GroovyParser.g4 b/GroovyParser.g4 new file mode 100644 index 0000000..bffe4aa --- /dev/null +++ b/GroovyParser.g4 @@ -0,0 +1,1305 @@ +/* + * This file is adapted from the Antlr4 Java grammar which has the following license + * + * Copyright (c) 2013 Terence Parr, Sam Harwell + * All rights reserved. + * [The "BSD licence"] + * + * http://www.opensource.org/licenses/bsd-license.php + * + * Subsequent modifications by the Groovy community have been done under the Apache License v2: + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * The Groovy grammar is based on the official grammar for Java: + * https://github.com/antlr/grammars-v4/blob/master/java/Java.g4 + */ +parser grammar GroovyParser; + +options { + tokenVocab = GroovyLexer; + contextSuperClass = GroovyParserRuleContext; + superClass = AbstractParser; +} + +@header { + import java.util.Map; + import org.codehaus.groovy.ast.NodeMetaDataHandler; +} + +@members { + private int inSwitchExpressionLevel = 0; + + public static class GroovyParserRuleContext extends ParserRuleContext implements NodeMetaDataHandler { + private Map metaDataMap = null; + + public GroovyParserRuleContext() {} + + public GroovyParserRuleContext(ParserRuleContext parent, int invokingStateNumber) { + super(parent, invokingStateNumber); + } + + @Override + public Map getMetaDataMap() { + return this.metaDataMap; + } + + @Override + public void setMetaDataMap(Map metaDataMap) { + this.metaDataMap = metaDataMap; + } + } + + @Override + public int getSyntaxErrorSource() { + return GroovySyntaxError.PARSER; + } + + @Override + public int getErrorLine() { + Token token = _input.LT(-1); + + if (null == token) { + return -1; + } + + return token.getLine(); + } + + @Override + public int getErrorColumn() { + Token token = _input.LT(-1); + + if (null == token) { + return -1; + } + + return token.getCharPositionInLine() + 1 + token.getText().length(); + } +} + +// starting point for parsing a groovy file +compilationUnit + : nls (packageDeclaration sep?)? scriptStatements? EOF + ; + +scriptStatements + : scriptStatement (sep scriptStatement)* sep? + ; + +scriptStatement + : importDeclaration // Import statement. Can be used in any scope. Has "import x as y" also. + | typeDeclaration + // validate the method in the AstBuilder#visitMethodDeclaration, e.g. method without method body is not allowed + | { !SemanticPredicates.isInvalidMethodDeclaration(_input) }? + methodDeclaration[3, 9] + | statement + ; + +packageDeclaration + : annotationsOpt PACKAGE qualifiedName + ; + +importDeclaration + : annotationsOpt IMPORT STATIC? qualifiedName (DOT MUL | AS alias=identifier)? + ; + + +typeDeclaration + : classOrInterfaceModifiersOpt classDeclaration + ; + +modifier + : classOrInterfaceModifier + | m=( NATIVE + | SYNCHRONIZED + | TRANSIENT + | VOLATILE + | DEF + | VAR + ) + ; + +modifiersOpt + : (modifiers nls)? + ; + +modifiers + : modifier (nls modifier)* + ; + +classOrInterfaceModifiersOpt + : (classOrInterfaceModifiers + NL* /* Use `NL*` here for better performance, so DON'T replace it with `nls` */ + )? + ; + +classOrInterfaceModifiers + : classOrInterfaceModifier (nls classOrInterfaceModifier)* + ; + +classOrInterfaceModifier + : annotation // class or interface + | m=( PUBLIC // class or interface + | PROTECTED // class or interface + | PRIVATE // class or interface + | STATIC // class or interface + | ABSTRACT // class or interface + | SEALED // class or interface + | NON_SEALED // class or interface + | FINAL // class only -- does not apply to interfaces + | STRICTFP // class or interface + | DEFAULT // interface only -- does not apply to classes + ) + ; + +variableModifier + : annotation + | m=( FINAL + | DEF + | VAR + // Groovy supports declaring local variables as instance/class fields, + // e.g. import groovy.transform.*; @Field static List awe = [1, 2, 3] + // e.g. import groovy.transform.*; def a = { @Field public List awe = [1, 2, 3] } + // Notice: Groovy 2.4.7 just allows to declare local variables with the following modifiers when using annotations(e.g. @Field) + // TODO check whether the following modifiers accompany annotations or not. Because the legacy codes(e.g. benchmark/bench/heapsort.groovy) allow to declare the special instance/class fields without annotations, we leave it as it is for the time being + | PUBLIC + | PROTECTED + | PRIVATE + | STATIC + | ABSTRACT + | STRICTFP + ) + ; + +variableModifiersOpt + : (variableModifiers nls)? + ; + +variableModifiers + : variableModifier (nls variableModifier)* + ; + +typeParameters + : LT nls typeParameter (COMMA nls typeParameter)* nls GT + ; + +typeParameter + : annotationsOpt className (EXTENDS nls typeBound)? + ; + +typeBound + : type (BITAND nls type)* + ; + +typeList + : type (COMMA nls type)* + ; + + +/** + * t 0: class; 1: interface; 2: enum; 3: annotation; 4: trait; 5: record + */ +classDeclaration +locals[ int t ] + : ( CLASS { $t = 0; } + | INTERFACE { $t = 1; } + | ENUM { $t = 2; } + | AT INTERFACE { $t = 3; } + | TRAIT { $t = 4; } + | RECORD { $t = 5; } + ) + identifier + (nls typeParameters)? + (nls formalParameters)? + (nls EXTENDS nls scs=typeList)? + (nls IMPLEMENTS nls is=typeList)? + (nls PERMITS nls ps=typeList)? + nls classBody[$t] + ; + +// t see the comment of classDeclaration +classBody[int t] + : LBRACE nls + ( + /* Only enum can have enum constants */ + { 2 == $t }? + enumConstants (nls COMMA)? sep? + | + ) + (classBodyDeclaration[$t] (sep classBodyDeclaration[$t])*)? sep? RBRACE + ; + +enumConstants + : enumConstant (nls COMMA nls enumConstant)* + ; + +enumConstant + : annotationsOpt identifier arguments? anonymousInnerClassDeclaration[1]? + ; + +classBodyDeclaration[int t] + : (STATIC nls)? block + | memberDeclaration[$t] + ; + +memberDeclaration[int t] + : methodDeclaration[0, $t] + | fieldDeclaration + | modifiersOpt ( classDeclaration + | compactConstructorDeclaration + ) + ; + +/** + * t 0: *class member* all kinds of method declaration AND constructor declaration, + * 1: normal method declaration, 2: abstract method declaration + * 3: normal method declaration OR abstract method declaration + * ct 9: script, other see the comment of classDeclaration + */ +methodDeclaration[int t, int ct] + : modifiersOpt typeParameters? (returnType[$ct] nls)? + methodName formalParameters + ( + DEFAULT nls elementValue + | + (nls THROWS nls qualifiedClassNameList)? + (nls methodBody)? + )? + ; + +compactConstructorDeclaration + : methodName nls methodBody + ; + +methodName + : identifier + | stringLiteral + ; + +returnType[int ct] + : + standardType + | VOID + ; + +fieldDeclaration + : variableDeclaration[1] + ; + +variableDeclarators + : variableDeclarator (COMMA nls variableDeclarator)* + ; + +variableDeclarator + : variableDeclaratorId (nls ASSIGN nls variableInitializer)? + ; + +variableDeclaratorId + : identifier + ; + +variableInitializer + : enhancedStatementExpression + ; + +variableInitializers + : variableInitializer (nls COMMA nls variableInitializer)* nls COMMA? + ; + +emptyDims + : (annotationsOpt LBRACK RBRACK)+ + ; + +emptyDimsOpt + : emptyDims? + ; + +standardType +options { baseContext = type; } + : annotationsOpt + ( + primitiveType + | + standardClassOrInterfaceType + ) + emptyDimsOpt + ; + +type + : annotationsOpt + ( + ( + primitiveType + | + // !!! Error Alternative !!! + VOID + ) + | + generalClassOrInterfaceType + ) + emptyDimsOpt + ; + +classOrInterfaceType + : ( qualifiedClassName + | qualifiedStandardClassName + ) typeArguments? + ; + +generalClassOrInterfaceType +options { baseContext = classOrInterfaceType; } + : qualifiedClassName typeArguments? + ; + +standardClassOrInterfaceType +options { baseContext = classOrInterfaceType; } + : qualifiedStandardClassName typeArguments? + ; + +primitiveType + : BuiltInPrimitiveType + ; + +typeArguments + : LT nls typeArgument (COMMA nls typeArgument)* nls GT + ; + +typeArgument + : type + | annotationsOpt QUESTION ((EXTENDS | SUPER) nls type)? + ; + +annotatedQualifiedClassName + : annotationsOpt qualifiedClassName + ; + +qualifiedClassNameList + : annotatedQualifiedClassName (COMMA nls annotatedQualifiedClassName)* + ; + +formalParameters + : LPAREN formalParameterList? rparen + ; + +formalParameterList + : (formalParameter | thisFormalParameter) (COMMA nls formalParameter)* + ; + +thisFormalParameter + : type THIS + ; + +formalParameter + : variableModifiersOpt type? ELLIPSIS? variableDeclaratorId (nls ASSIGN nls expression)? + ; + +methodBody + : block + ; + +qualifiedName + : qualifiedNameElement (DOT qualifiedNameElement)* + ; + +/** + * Java doesn't have the keywords 'as', 'in', 'def', 'trait' so we make some allowances + * for them in package names for better integration with existing Java packages + */ +qualifiedNameElement + : identifier + | DEF + | IN + | AS + | TRAIT + ; + +qualifiedNameElements + : (qualifiedNameElement DOT)* + ; + +qualifiedClassName + : qualifiedNameElements identifier + ; + +qualifiedStandardClassName + : qualifiedNameElements className (DOT className)* + ; + +literal + : IntegerLiteral #integerLiteralAlt + | FloatingPointLiteral #floatingPointLiteralAlt + | stringLiteral #stringLiteralAlt + | BooleanLiteral #booleanLiteralAlt + | NullLiteral #nullLiteralAlt + ; + +// GSTRING + +gstring + : GStringBegin gstringValue (GStringPart gstringValue)* GStringEnd + ; + +gstringValue + : gstringPath + | closure + ; + +gstringPath + : identifier GStringPathPart* + ; + + +// LAMBDA EXPRESSION +lambdaExpression +options { baseContext = standardLambdaExpression; } + : lambdaParameters nls ARROW nls lambdaBody + ; + +// JAVA STANDARD LAMBDA EXPRESSION +standardLambdaExpression + : standardLambdaParameters nls ARROW nls lambdaBody + ; + +lambdaParameters +options { baseContext = standardLambdaParameters; } + : formalParameters + + // { a -> a * 2 } can be parsed as a lambda expression in a block, but we expect a closure. + // So it is better to put parameters in the parentheses and the following single parameter without parentheses is limited +// | variableDeclaratorId + ; + +standardLambdaParameters + : formalParameters + | variableDeclaratorId + ; + +lambdaBody + : block + | statementExpression + ; + +// CLOSURE +closure + : LBRACE (nls (formalParameterList nls)? ARROW)? sep? blockStatementsOpt RBRACE + ; + +// GROOVY-8991: Difference in behaviour with closure and lambda +closureOrLambdaExpression + : closure + | lambdaExpression + ; + +blockStatementsOpt + : blockStatements? + ; + +blockStatements + : blockStatement (sep blockStatement)* sep? + ; + +// ANNOTATIONS + +annotationsOpt + : (annotation (nls annotation)* nls)? + ; + +annotation + : AT annotationName (nls LPAREN elementValues? rparen)? + ; + +elementValues + : elementValuePairs + | elementValue + ; + +annotationName : qualifiedClassName ; + +elementValuePairs + : elementValuePair (COMMA elementValuePair)* + ; + +elementValuePair + : elementValuePairName nls ASSIGN nls elementValue + ; + +elementValuePairName + : identifier + | keywords + ; + +// TODO verify the potential performance issue because rule expression contains sub-rule assignments(https://github.com/antlr/grammars-v4/issues/215) +elementValue + : elementValueArrayInitializer + | annotation + | expression + ; + +elementValueArrayInitializer + : LBRACK (elementValue (COMMA elementValue)* COMMA?)? RBRACK + ; + +// STATEMENTS / BLOCKS + +block + : LBRACE sep? blockStatementsOpt RBRACE + ; + +blockStatement + : localVariableDeclaration + | statement + ; + +localVariableDeclaration + : { !SemanticPredicates.isInvalidLocalVariableDeclaration(_input) }? + variableDeclaration[0] + ; + +/** + * t 0: local variable declaration; 1: field declaration + */ +variableDeclaration[int t] + : modifiers nls + ( type? variableDeclarators + | typeNamePairs nls ASSIGN nls variableInitializer + ) + | + type variableDeclarators + ; + +typeNamePairs + : LPAREN typeNamePair (COMMA typeNamePair)* rparen + ; + +typeNamePair + : type? variableDeclaratorId + ; + +variableNames + : LPAREN variableDeclaratorId (COMMA variableDeclaratorId)+ rparen + ; + +conditionalStatement + : ifElseStatement + | switchStatement + ; + +ifElseStatement + : IF expressionInPar nls tb=statement ((nls | sep) ELSE nls fb=statement)? + ; + +switchStatement + : SWITCH expressionInPar nls LBRACE nls (switchBlockStatementGroup+ nls)? RBRACE + ; + +loopStatement + : FOR LPAREN forControl rparen nls statement #forStmtAlt + | WHILE expressionInPar nls statement #whileStmtAlt + | DO nls statement nls WHILE expressionInPar #doWhileStmtAlt + ; + +continueStatement + : CONTINUE + identifier? + ; + +breakStatement + : BREAK + identifier? + ; + +yieldStatement + : YIELD + expression + ; + +tryCatchStatement + : TRY resources? nls block + (nls catchClause)* + (nls finallyBlock)? + ; + +assertStatement + : ASSERT ce=expression (nls (COLON | COMMA) nls me=expression)? + ; + +statement + : block #blockStmtAlt + | conditionalStatement #conditionalStmtAlt + | loopStatement #loopStmtAlt + | tryCatchStatement #tryCatchStmtAlt + | SYNCHRONIZED expressionInPar nls block #synchronizedStmtAlt + | RETURN expression? #returnStmtAlt + | THROW expression #throwStmtAlt + | breakStatement #breakStmtAlt + | continueStatement #continueStmtAlt + | { inSwitchExpressionLevel > 0 }? + yieldStatement #yieldStmtAlt + | identifier COLON nls statement #labeledStmtAlt + | assertStatement #assertStmtAlt + | localVariableDeclaration #localVariableDeclarationStmtAlt + | statementExpression #expressionStmtAlt + | SEMI #emptyStmtAlt + ; + +catchClause + : CATCH LPAREN variableModifiersOpt catchType? identifier rparen nls block + ; + +catchType + : qualifiedClassName (BITOR qualifiedClassName)* + ; + +finallyBlock + : FINALLY nls block + ; + +resources + : LPAREN nls resourceList sep? rparen + ; + +resourceList + : resource (sep resource)* + ; + +resource + : localVariableDeclaration + | expression + ; + + +/** Matches cases then statements, both of which are mandatory. + * To handle empty cases at the end, we add switchLabel* to statement. + */ +switchBlockStatementGroup + : switchLabel (nls switchLabel)* nls blockStatements + ; + +switchLabel + : CASE expression COLON + | DEFAULT COLON + ; + +forControl + : enhancedForControl + | classicalForControl + ; + +enhancedForControl + : variableModifiersOpt type? variableDeclaratorId (COLON | IN) expression + ; + +classicalForControl + : forInit? SEMI expression? SEMI forUpdate? + ; + +forInit + : localVariableDeclaration + | expressionList[false] + ; + +forUpdate + : expressionList[false] + ; + + +// EXPRESSIONS + +castParExpression + : LPAREN type rparen + ; + +parExpression + : expressionInPar + ; + +expressionInPar + : LPAREN enhancedStatementExpression rparen + ; + +expressionList[boolean canSpread] + : expressionListElement[$canSpread] (COMMA nls expressionListElement[$canSpread])* + ; + +expressionListElement[boolean canSpread] + : MUL? expression + ; + +enhancedStatementExpression + : statementExpression + | standardLambdaExpression + ; + +statementExpression + : commandExpression #commandExprAlt + ; + +postfixExpression + : pathExpression op=(INC | DEC)? + ; + +switchExpression +@init { + inSwitchExpressionLevel++; +} +@after { + inSwitchExpressionLevel--; +} + : SWITCH expressionInPar nls LBRACE nls switchBlockStatementExpressionGroup* nls RBRACE + ; + +switchBlockStatementExpressionGroup + : (switchExpressionLabel nls)+ blockStatements + ; + +switchExpressionLabel + : ( CASE expressionList[true] + | DEFAULT + ) ac=(ARROW | COLON) + ; + +expression + // must come before postfixExpression to resovle the ambiguities between casting and call on parentheses expression, e.g. (int)(1 / 2) + : castParExpression castOperandExpression #castExprAlt + + // qualified names, array expressions, method invocation, post inc/dec + | postfixExpression #postfixExprAlt + + | switchExpression #switchExprAlt + + // ~(BNOT)/!(LNOT) (level 1) + | (BITNOT | NOT) nls expression #unaryNotExprAlt + + // math power operator (**) (level 2) + | left=expression op=POWER nls right=expression #powerExprAlt + + // ++(prefix)/--(prefix)/+(unary)/-(unary) (level 3) + | op=(INC | DEC | ADD | SUB) expression #unaryAddExprAlt + + // multiplication/division/modulo (level 4) + | left=expression nls op=(MUL | DIV | MOD) nls right=expression #multiplicativeExprAlt + + // binary addition/subtraction (level 5) + | left=expression op=(ADD | SUB) nls right=expression #additiveExprAlt + + // bit shift expressions (level 6) + | left=expression nls + ( ( dlOp=LT LT + | tgOp=GT GT GT + | dgOp=GT GT + ) + | rangeOp=( RANGE_INCLUSIVE + | RANGE_EXCLUSIVE_LEFT + | RANGE_EXCLUSIVE_RIGHT + | RANGE_EXCLUSIVE_FULL + ) + ) nls + right=expression #shiftExprAlt + + // boolean relational expressions (level 7) + | left=expression nls op=(AS | INSTANCEOF | NOT_INSTANCEOF) nls type #relationalExprAlt + | left=expression nls op=(LE | GE | GT | LT | IN | NOT_IN) nls right=expression #relationalExprAlt + + // equality/inequality (==/!=) (level 8) + | left=expression nls + op=( IDENTICAL + | NOT_IDENTICAL + | EQUAL + | NOTEQUAL + | SPACESHIP + ) nls + right=expression #equalityExprAlt + + // regex find and match (=~ and ==~) (level 8.5) + // jez: moved =~ closer to precedence of == etc, as... + // 'if (foo =~ "a.c")' is very close in intent to 'if (foo == "abc")' + | left=expression nls op=(REGEX_FIND | REGEX_MATCH) nls right=expression #regexExprAlt + + // bitwise or non-short-circuiting and (&) (level 9) + | left=expression nls op=BITAND nls right=expression #andExprAlt + + // exclusive or (^) (level 10) + | left=expression nls op=XOR nls right=expression #exclusiveOrExprAlt + + // bitwise or non-short-circuiting or (|) (level 11) + | left=expression nls op=BITOR nls right=expression #inclusiveOrExprAlt + + // logical and (&&) (level 12) + | left=expression nls op=AND nls right=expression #logicalAndExprAlt + + // logical or (||) (level 13) + | left=expression nls op=OR nls right=expression #logicalOrExprAlt + + // conditional test (level 14) + | con=expression nls + ( QUESTION nls tb=expression nls COLON nls + | ELVIS nls + ) + fb=expression #conditionalExprAlt + + // assignment expression (level 15) + // "(a) = [1]" is a special case of multipleAssignmentExprAlt, it will be handle by assignmentExprAlt + | left=variableNames nls op=ASSIGN nls right=statementExpression #multipleAssignmentExprAlt + | left=expression nls + op=( ASSIGN + | ADD_ASSIGN + | SUB_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | AND_ASSIGN + | OR_ASSIGN + | XOR_ASSIGN + | RSHIFT_ASSIGN + | URSHIFT_ASSIGN + | LSHIFT_ASSIGN + | MOD_ASSIGN + | POWER_ASSIGN + | ELVIS_ASSIGN + ) nls + right=enhancedStatementExpression #assignmentExprAlt + ; + +castOperandExpression +options { baseContext = expression; } + : castParExpression castOperandExpression #castExprAlt + + | postfixExpression #postfixExprAlt + + // ~(BNOT)/!(LNOT) + | (BITNOT | NOT) nls castOperandExpression #unaryNotExprAlt + + // ++(prefix)/--(prefix)/+(unary)/-(unary) + | op=(INC | DEC | ADD | SUB) castOperandExpression #unaryAddExprAlt + ; + +commandExpression + : expression + ( + { !SemanticPredicates.isFollowingArgumentsOrClosure($expression.ctx) }? + argumentList + | + /* if pathExpression is a method call, no need to have any more arguments */ + ) + + commandArgument* + ; + +commandArgument + : commandPrimary + // what follows is either a normal argument, parens, + // an appended block, an index operation, or nothing + // parens (a b already processed): + // a b c() d e -> a(b).c().d(e) + // a b c()() d e -> a(b).c().call().d(e) + // index (a b already processed): + // a b c[x] d e -> a(b).c[x].d(e) + // a b c[x][y] d e -> a(b).c[x][y].d(e) + // block (a b already processed): + // a b c {x} d e -> a(b).c({x}).d(e) + // + // parens/block completes method call + // index makes method call to property get with index + // + ( pathElement+ + | argumentList + )? + ; + +/** + * A "path expression" is a name or other primary, possibly qualified by various + * forms of dot, and/or followed by various kinds of brackets. + * It can be used for value or assigned to, or else further qualified, indexed, or called. + * It is called a "path" because it looks like a linear path through a data structure. + * Examples: x.y, x?.y, x*.y, x.@y; x[], x[y], x[y,z]; x(), x(y), x(y,z); x{s}; a.b[n].c(x).d{s} + * (Compare to a C lvalue, or LeftHandSide in the JLS section 15.26.) + * General expressions are built up from path expressions, using operators like '+' and '='. + * + * t 0: primary, 1: namePart, 2: arguments, 3: closureOrLambdaExpression, 4: indexPropertyArgs, 5: namedPropertyArgs, + * 6: non-static inner class creator + */ +pathExpression returns [int t] + : ( + primary + | + // if 'static' followed by DOT, we can treat them as identifiers, e.g. static.unused = { -> } + { _input.LT(2).getType() == DOT }? + STATIC + ) (pathElement { $t = $pathElement.t; })* + ; + +pathElement returns [int t] + : nls + ( + DOT nls NEW creator[1] + { $t = 6; } + | + // AT: foo.@bar selects the field (or attribute), not property + ( + ( DOT // The all-powerful dot. + | SPREAD_DOT // Spread operator: x*.y === x?.collect{it.y} + | SAFE_DOT // Optional-null operator: x?.y === (x==null)?null:x.y + | SAFE_CHAIN_DOT // Optional-null chain operator: x??.y.z === x?.y?.z + ) nls (AT | nonWildcardTypeArguments)? + | + METHOD_POINTER nls // Method pointer operator: foo.&y == foo.metaClass.getMethodPointer(foo, "y") + | + METHOD_REFERENCE nls // Method reference: System.out::println + ) + namePart + { $t = 1; } + + // Can always append a block, as foo{bar} + | closureOrLambdaExpression + { $t = 3; } + ) + + | arguments + { $t = 2; } + + // Element selection is always an option, too. + // In Groovy, the stuff between brackets is a general argument list, + // since the bracket operator is transformed into a method call. + | indexPropertyArgs + { $t = 4; } + + | namedPropertyArgs + { $t = 5; } + ; + +/** + * This is the grammar for what can follow a dot: x.a, x.@a, x.&a, x.'a', etc. + */ +namePart + : + ( identifier + + // foo.'bar' is in all ways same as foo.bar, except that bar can have an arbitrary spelling + | stringLiteral + + | dynamicMemberName + + /* just a PROPOSAL, which has not been implemented yet! + // PROPOSAL, DECIDE: Is this inline form of the 'with' statement useful? + // Definition: a.{foo} === {with(a) {foo}} + // May cover some path expression use-cases previously handled by dynamic scoping (closure delegates). + | block + */ + + // let's allow common keywords as property names + | keywords + ) + ; + +/** + * If a dot is followed by a parenthesized or quoted expression, the member is computed dynamically, + * and the member selection is done only at runtime. This forces a statically unchecked member access. + */ +dynamicMemberName + : parExpression + | gstring + ; + +/** An expression may be followed by [...]. + * Unlike Java, these brackets may contain a general argument list, + * which is passed to the array element operator, which can make of it what it wants. + * The brackets may also be empty, as in T[]. This is how Groovy names array types. + */ +indexPropertyArgs + : (SAFE_INDEX | LBRACK) expressionList[true]? RBRACK + ; + +namedPropertyArgs + : (SAFE_INDEX | LBRACK) (namedPropertyArgList | COLON) RBRACK + ; + +primary + : + // Append `typeArguments?` to `identifier` to support constructor reference with generics, e.g. HashMap::new + // Though this is not a graceful solution, it is much faster than replacing `builtInType` with `type` + identifier typeArguments? #identifierPrmrAlt + | literal #literalPrmrAlt + | gstring #gstringPrmrAlt + | NEW nls creator[0] #newPrmrAlt + | THIS #thisPrmrAlt + | SUPER #superPrmrAlt + | parExpression #parenPrmrAlt + | closureOrLambdaExpression #closureOrLambdaExpressionPrmrAlt + | list #listPrmrAlt + | map #mapPrmrAlt + | builtInType #builtInTypePrmrAlt + ; + +namedPropertyArgPrimary +options { baseContext = primary; } + : identifier #identifierPrmrAlt + | literal #literalPrmrAlt + | gstring #gstringPrmrAlt + | parExpression #parenPrmrAlt + | list #listPrmrAlt + | map #mapPrmrAlt + ; + +namedArgPrimary +options { baseContext = primary; } + : identifier #identifierPrmrAlt + | literal #literalPrmrAlt + | gstring #gstringPrmrAlt + ; + +commandPrimary +options { baseContext = primary; } + : identifier #identifierPrmrAlt + | literal #literalPrmrAlt + | gstring #gstringPrmrAlt + ; + +list + : LBRACK expressionList[true]? COMMA? RBRACK + ; + +map + : LBRACK + ( mapEntryList COMMA? + | COLON + ) + RBRACK + ; + +mapEntryList + : mapEntry (COMMA mapEntry)* + ; + +namedPropertyArgList +options { baseContext = mapEntryList; } + : namedPropertyArg (COMMA namedPropertyArg)* + ; + +mapEntry + : mapEntryLabel COLON nls expression + | MUL COLON nls expression + ; + +namedPropertyArg +options { baseContext = mapEntry; } + : namedPropertyArgLabel COLON nls expression + | MUL COLON nls expression + ; + +namedArg +options { baseContext = mapEntry; } + : namedArgLabel COLON nls expression + | MUL COLON nls expression + ; + +mapEntryLabel + : keywords + | primary + ; + +namedPropertyArgLabel +options { baseContext = mapEntryLabel; } + : keywords + | namedPropertyArgPrimary + ; + +namedArgLabel +options { baseContext = mapEntryLabel; } + : keywords + | namedArgPrimary + ; + +/** + * t 0: general creation; 1: non-static inner class creation + */ +creator[int t] + : createdName + ( nls arguments anonymousInnerClassDeclaration[0]? + | dim+ (nls arrayInitializer)? + ) + ; + +dim + : annotationsOpt LBRACK expression? RBRACK + ; + +arrayInitializer + : LBRACE nls (variableInitializers nls)? RBRACE + ; + +/** + * t 0: anonymous inner class; 1: anonymous enum + */ +anonymousInnerClassDeclaration[int t] + : classBody[0] + ; + +createdName + : annotationsOpt + ( primitiveType + | qualifiedClassName typeArgumentsOrDiamond? + ) + ; + +nonWildcardTypeArguments + : LT nls typeList nls GT + ; + +typeArgumentsOrDiamond + : LT GT + | typeArguments + ; + +arguments + : LPAREN enhancedArgumentListInPar? COMMA? rparen + ; + +argumentList +options { baseContext = enhancedArgumentListInPar; } + : firstArgumentListElement + ( COMMA nls + argumentListElement + )* + ; + +enhancedArgumentListInPar + : enhancedArgumentListElement + ( COMMA nls + enhancedArgumentListElement + )* + ; + +firstArgumentListElement +options { baseContext = enhancedArgumentListElement; } + : expressionListElement[true] + | namedArg + ; + +argumentListElement +options { baseContext = enhancedArgumentListElement; } + : expressionListElement[true] + | namedPropertyArg + ; + +enhancedArgumentListElement + : expressionListElement[true] + | standardLambdaExpression + | namedPropertyArg + ; + +stringLiteral + : StringLiteral + ; + +className + : CapitalizedIdentifier + ; + +identifier + : Identifier + | CapitalizedIdentifier + | VAR + | IN +// | DEF + | TRAIT + | AS + | YIELD + | PERMITS + | SEALED + | RECORD + ; + +builtInType + : BuiltInPrimitiveType + | VOID + ; + +keywords + : ABSTRACT + | AS + | ASSERT + | BREAK + | CASE + | CATCH + | CLASS + | CONST + | CONTINUE + | DEF + | DEFAULT + | DO + | ELSE + | ENUM + | EXTENDS + | FINAL + | FINALLY + | FOR + | GOTO + | IF + | IMPLEMENTS + | IMPORT + | IN + | INSTANCEOF + | INTERFACE + | NATIVE + | NEW + | NON_SEALED + | PACKAGE + | PERMITS + | RECORD + | RETURN + | SEALED + | STATIC + | STRICTFP + | SUPER + | SWITCH + | SYNCHRONIZED + | THIS + | THROW + | THROWS + | TRANSIENT + | TRAIT + | THREADSAFE + | TRY + | VAR + | VOLATILE + | WHILE + | YIELD + + | NullLiteral + | BooleanLiteral + + | BuiltInPrimitiveType + | VOID + + | PUBLIC + | PROTECTED + | PRIVATE + ; + +rparen + : RPAREN + ; + +nls + : NL* + ; + +sep : (NL | SEMI)+ + ; diff --git a/grammar.js b/grammar.js index e5a793e..7e245a2 100644 --- a/grammar.js +++ b/grammar.js @@ -1,64 +1,68 @@ module.exports = grammar({ name: 'Groovy', - + conflicts: $ => [ + [$.qualified_name] + ], rules: { // TODO: add the actual grammar rules source_file: $ => seq( optional($._shebang_comment), - optional(seq($.package_definition, repeat($._nl_semicolon))), - repeat( - choice( - seq( - $.import_statement, - repeat1($._nl_semicolon) - ), - seq( - $.script_part, - repeat1($._nl_semicolon) - ) - ) - ), - optional($.script_part) + optional(seq($.package_declaration, repeat($._sep))), + optional($._script_statements) ), static_modifier: $ => 'static', - import_statement: $ => seq( + _shebang_comment: $ => token.immediate(/#!.*\n/), + _script_statements: $ => seq( + $._script_statement, + repeat( + seq( + $._sep, + $._script_statement + ) + ), + repeat($._sep) + ), + import_declaration: $ => seq( 'import', optional($.static_modifier), field('name', - seq( - $.identifier, - repeat(seq('.', $.identifier)), - optional(seq('.', '*') - ) + seq($.qualified_name, + optional($.wildcard_import) ) ) ), - _shebang_comment: $ => token.immediate(/#!.*\n/), - package_definition: $ => seq( + wildcard_import: $ => seq('.','*'), + package_declaration: $ => seq( + optional($._annotations), 'package', - field('name', seq( - $.identifier, - repeat(seq('.', $.identifier)))) + field('name', $.qualified_name) ), - script_part: $ => choice( + _annotations: $ => seq( + $.annotation, + repeat($.annotation) + ), + annotation: $ => seq( + '@', + $.qualified_name + ), + _script_statement: $ => choice( + $.import_declaration, $.statement, $.method_declaration ), expression: $ => choice( - $.path_expression + $.qualified_name ), - path_expression: $ => seq( - repeat( - seq($.identifier, '.') - ), - $.identifier + qualified_name: $ => seq( + $.identifier, + repeat(seq('.', $.identifier)) ), identifier: $ => /[A-Za-z_][A-Za-z_0-9]*/, statement: $ => choice( $.expression ), method_declaration: $ => seq('def', field('name', $.identifier)), - _nl_semicolon: $ => choice('\n', ';'), + _sep: $ => choice('\n', ';'), word: $ => $.identifier } }); diff --git a/src/grammar.json b/src/grammar.json index 0a38c1b..d1d9531 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -24,13 +24,13 @@ "members": [ { "type": "SYMBOL", - "name": "package_definition" + "name": "package_declaration" }, { "type": "REPEAT", "content": { "type": "SYMBOL", - "name": "_nl_semicolon" + "name": "_sep" } } ] @@ -40,52 +40,12 @@ } ] }, - { - "type": "REPEAT", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "import_statement" - }, - { - "type": "REPEAT1", - "content": { - "type": "SYMBOL", - "name": "_nl_semicolon" - } - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "script_part" - }, - { - "type": "REPEAT1", - "content": { - "type": "SYMBOL", - "name": "_nl_semicolon" - } - } - ] - } - ] - } - }, { "type": "CHOICE", "members": [ { "type": "SYMBOL", - "name": "script_part" + "name": "_script_statements" }, { "type": "BLANK" @@ -98,7 +58,46 @@ "type": "STRING", "value": "static" }, - "import_statement": { + "_shebang_comment": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PATTERN", + "value": "#!.*\\n" + } + }, + "_script_statements": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_script_statement" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_sep" + }, + { + "type": "SYMBOL", + "name": "_script_statement" + } + ] + } + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_sep" + } + } + ] + }, + "import_declaration": { "type": "SEQ", "members": [ { @@ -125,39 +124,14 @@ "members": [ { "type": "SYMBOL", - "name": "identifier" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "." - }, - { - "type": "SYMBOL", - "name": "identifier" - } - ] - } + "name": "qualified_name" }, { "type": "CHOICE", "members": [ { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "." - }, - { - "type": "STRING", - "value": "*" - } - ] + "type": "SYMBOL", + "name": "wildcard_import" }, { "type": "BLANK" @@ -169,16 +143,34 @@ } ] }, - "_shebang_comment": { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "PATTERN", - "value": "#!.*\\n" - } - }, - "package_definition": { + "wildcard_import": { "type": "SEQ", "members": [ + { + "type": "STRING", + "value": "." + }, + { + "type": "STRING", + "value": "*" + } + ] + }, + "package_declaration": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_annotations" + }, + { + "type": "BLANK" + } + ] + }, { "type": "STRING", "value": "package" @@ -187,36 +179,48 @@ "type": "FIELD", "name": "name", "content": { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "identifier" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "." - }, - { - "type": "SYMBOL", - "name": "identifier" - } - ] - } - } - ] + "type": "SYMBOL", + "name": "qualified_name" } } ] }, - "script_part": { + "_annotations": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "annotation" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "annotation" + } + } + ] + }, + "annotation": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "SYMBOL", + "name": "qualified_name" + } + ] + }, + "_script_statement": { "type": "CHOICE", "members": [ + { + "type": "SYMBOL", + "name": "import_declaration" + }, { "type": "SYMBOL", "name": "statement" @@ -232,32 +236,32 @@ "members": [ { "type": "SYMBOL", - "name": "path_expression" + "name": "qualified_name" } ] }, - "path_expression": { + "qualified_name": { "type": "SEQ", "members": [ + { + "type": "SYMBOL", + "name": "identifier" + }, { "type": "REPEAT", "content": { "type": "SEQ", "members": [ - { - "type": "SYMBOL", - "name": "identifier" - }, { "type": "STRING", "value": "." + }, + { + "type": "SYMBOL", + "name": "identifier" } ] } - }, - { - "type": "SYMBOL", - "name": "identifier" } ] }, @@ -291,7 +295,7 @@ } ] }, - "_nl_semicolon": { + "_sep": { "type": "CHOICE", "members": [ { @@ -315,7 +319,11 @@ "value": "\\s" } ], - "conflicts": [], + "conflicts": [ + [ + "qualified_name" + ] + ], "precedences": [], "externals": [], "inline": [], diff --git a/src/node-types.json b/src/node-types.json index 9d1eaf3..dc5de32 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -1,4 +1,19 @@ [ + { + "type": "annotation", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "qualified_name", + "named": true + } + ] + } + }, { "type": "expression", "named": true, @@ -8,14 +23,14 @@ "required": true, "types": [ { - "type": "path_expression", + "type": "qualified_name", "named": true } ] } }, { - "type": "import_statement", + "type": "import_declaration", "named": true, "fields": { "name": { @@ -23,15 +38,11 @@ "required": true, "types": [ { - "type": "*", - "named": false + "type": "qualified_name", + "named": true }, { - "type": ".", - "named": false - }, - { - "type": "identifier", + "type": "wildcard_import", "named": true } ] @@ -65,27 +76,33 @@ } }, { - "type": "package_definition", + "type": "package_declaration", "named": true, "fields": { "name": { - "multiple": true, + "multiple": false, "required": true, "types": [ { - "type": ".", - "named": false - }, - { - "type": "identifier", + "type": "qualified_name", "named": true } ] } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "annotation", + "named": true + } + ] } }, { - "type": "path_expression", + "type": "qualified_name", "named": true, "fields": {}, "children": { @@ -99,25 +116,6 @@ ] } }, - { - "type": "script_part", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "method_declaration", - "named": true - }, - { - "type": "statement", - "named": true - } - ] - } - }, { "type": "source_file", "named": true, @@ -127,15 +125,19 @@ "required": false, "types": [ { - "type": "import_statement", + "type": "import_declaration", "named": true }, { - "type": "package_definition", + "type": "method_declaration", "named": true }, { - "type": "script_part", + "type": "package_declaration", + "named": true + }, + { + "type": "statement", "named": true } ] @@ -156,6 +158,11 @@ ] } }, + { + "type": "wildcard_import", + "named": true, + "fields": {} + }, { "type": "\n", "named": false @@ -172,6 +179,10 @@ "type": ";", "named": false }, + { + "type": "@", + "named": false + }, { "type": "def", "named": false diff --git a/src/parser.c b/src/parser.c index 54e676c..4ada164 100644 --- a/src/parser.c +++ b/src/parser.c @@ -6,94 +6,109 @@ #endif #define LANGUAGE_VERSION 14 -#define STATE_COUNT 52 +#define STATE_COUNT 55 #define LARGE_STATE_COUNT 7 -#define SYMBOL_COUNT 24 +#define SYMBOL_COUNT 29 #define ALIAS_COUNT 0 -#define TOKEN_COUNT 11 +#define TOKEN_COUNT 12 #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 1 -#define MAX_ALIAS_SEQUENCE_LENGTH 6 -#define PRODUCTION_ID_COUNT 9 +#define MAX_ALIAS_SEQUENCE_LENGTH 4 +#define PRODUCTION_ID_COUNT 5 enum { sym_static_modifier = 1, - anon_sym_import = 2, - anon_sym_DOT = 3, - anon_sym_STAR = 4, - sym__shebang_comment = 5, + sym__shebang_comment = 2, + anon_sym_import = 3, + anon_sym_DOT = 4, + anon_sym_STAR = 5, anon_sym_package = 6, - sym_identifier = 7, - anon_sym_def = 8, - anon_sym_LF = 9, - anon_sym_SEMI = 10, - sym_source_file = 11, - sym_import_statement = 12, - sym_package_definition = 13, - sym_script_part = 14, - sym_expression = 15, - sym_path_expression = 16, - sym_statement = 17, - sym_method_declaration = 18, - sym__nl_semicolon = 19, - aux_sym_source_file_repeat1 = 20, - aux_sym_source_file_repeat2 = 21, - aux_sym_import_statement_repeat1 = 22, - aux_sym_path_expression_repeat1 = 23, + anon_sym_AT = 7, + sym_identifier = 8, + anon_sym_def = 9, + anon_sym_LF = 10, + anon_sym_SEMI = 11, + sym_source_file = 12, + sym__script_statements = 13, + sym_import_declaration = 14, + sym_wildcard_import = 15, + sym_package_declaration = 16, + sym__annotations = 17, + sym_annotation = 18, + sym__script_statement = 19, + sym_expression = 20, + sym_qualified_name = 21, + sym_statement = 22, + sym_method_declaration = 23, + sym__sep = 24, + aux_sym_source_file_repeat1 = 25, + aux_sym__script_statements_repeat1 = 26, + aux_sym__annotations_repeat1 = 27, + aux_sym_qualified_name_repeat1 = 28, }; static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", [sym_static_modifier] = "static_modifier", + [sym__shebang_comment] = "_shebang_comment", [anon_sym_import] = "import", [anon_sym_DOT] = ".", [anon_sym_STAR] = "*", - [sym__shebang_comment] = "_shebang_comment", [anon_sym_package] = "package", + [anon_sym_AT] = "@", [sym_identifier] = "identifier", [anon_sym_def] = "def", [anon_sym_LF] = "\n", [anon_sym_SEMI] = ";", [sym_source_file] = "source_file", - [sym_import_statement] = "import_statement", - [sym_package_definition] = "package_definition", - [sym_script_part] = "script_part", + [sym__script_statements] = "_script_statements", + [sym_import_declaration] = "import_declaration", + [sym_wildcard_import] = "wildcard_import", + [sym_package_declaration] = "package_declaration", + [sym__annotations] = "_annotations", + [sym_annotation] = "annotation", + [sym__script_statement] = "_script_statement", [sym_expression] = "expression", - [sym_path_expression] = "path_expression", + [sym_qualified_name] = "qualified_name", [sym_statement] = "statement", [sym_method_declaration] = "method_declaration", - [sym__nl_semicolon] = "_nl_semicolon", + [sym__sep] = "_sep", [aux_sym_source_file_repeat1] = "source_file_repeat1", - [aux_sym_source_file_repeat2] = "source_file_repeat2", - [aux_sym_import_statement_repeat1] = "import_statement_repeat1", - [aux_sym_path_expression_repeat1] = "path_expression_repeat1", + [aux_sym__script_statements_repeat1] = "_script_statements_repeat1", + [aux_sym__annotations_repeat1] = "_annotations_repeat1", + [aux_sym_qualified_name_repeat1] = "qualified_name_repeat1", }; static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, [sym_static_modifier] = sym_static_modifier, + [sym__shebang_comment] = sym__shebang_comment, [anon_sym_import] = anon_sym_import, [anon_sym_DOT] = anon_sym_DOT, [anon_sym_STAR] = anon_sym_STAR, - [sym__shebang_comment] = sym__shebang_comment, [anon_sym_package] = anon_sym_package, + [anon_sym_AT] = anon_sym_AT, [sym_identifier] = sym_identifier, [anon_sym_def] = anon_sym_def, [anon_sym_LF] = anon_sym_LF, [anon_sym_SEMI] = anon_sym_SEMI, [sym_source_file] = sym_source_file, - [sym_import_statement] = sym_import_statement, - [sym_package_definition] = sym_package_definition, - [sym_script_part] = sym_script_part, + [sym__script_statements] = sym__script_statements, + [sym_import_declaration] = sym_import_declaration, + [sym_wildcard_import] = sym_wildcard_import, + [sym_package_declaration] = sym_package_declaration, + [sym__annotations] = sym__annotations, + [sym_annotation] = sym_annotation, + [sym__script_statement] = sym__script_statement, [sym_expression] = sym_expression, - [sym_path_expression] = sym_path_expression, + [sym_qualified_name] = sym_qualified_name, [sym_statement] = sym_statement, [sym_method_declaration] = sym_method_declaration, - [sym__nl_semicolon] = sym__nl_semicolon, + [sym__sep] = sym__sep, [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, - [aux_sym_source_file_repeat2] = aux_sym_source_file_repeat2, - [aux_sym_import_statement_repeat1] = aux_sym_import_statement_repeat1, - [aux_sym_path_expression_repeat1] = aux_sym_path_expression_repeat1, + [aux_sym__script_statements_repeat1] = aux_sym__script_statements_repeat1, + [aux_sym__annotations_repeat1] = aux_sym__annotations_repeat1, + [aux_sym_qualified_name_repeat1] = aux_sym_qualified_name_repeat1, }; static const TSSymbolMetadata ts_symbol_metadata[] = { @@ -105,6 +120,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, + [sym__shebang_comment] = { + .visible = false, + .named = true, + }, [anon_sym_import] = { .visible = true, .named = false, @@ -117,14 +136,14 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, - [sym__shebang_comment] = { - .visible = false, - .named = true, - }, [anon_sym_package] = { .visible = true, .named = false, }, + [anon_sym_AT] = { + .visible = true, + .named = false, + }, [sym_identifier] = { .visible = true, .named = true, @@ -145,23 +164,39 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_import_statement] = { + [sym__script_statements] = { + .visible = false, + .named = true, + }, + [sym_import_declaration] = { .visible = true, .named = true, }, - [sym_package_definition] = { + [sym_wildcard_import] = { .visible = true, .named = true, }, - [sym_script_part] = { + [sym_package_declaration] = { .visible = true, .named = true, }, + [sym__annotations] = { + .visible = false, + .named = true, + }, + [sym_annotation] = { + .visible = true, + .named = true, + }, + [sym__script_statement] = { + .visible = false, + .named = true, + }, [sym_expression] = { .visible = true, .named = true, }, - [sym_path_expression] = { + [sym_qualified_name] = { .visible = true, .named = true, }, @@ -173,7 +208,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym__nl_semicolon] = { + [sym__sep] = { .visible = false, .named = true, }, @@ -181,15 +216,15 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = false, }, - [aux_sym_source_file_repeat2] = { + [aux_sym__script_statements_repeat1] = { .visible = false, .named = false, }, - [aux_sym_import_statement_repeat1] = { + [aux_sym__annotations_repeat1] = { .visible = false, .named = false, }, - [aux_sym_path_expression_repeat1] = { + [aux_sym_qualified_name_repeat1] = { .visible = false, .named = false, }, @@ -209,10 +244,6 @@ static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [2] = {.index = 1, .length = 1}, [3] = {.index = 2, .length = 2}, [4] = {.index = 4, .length = 2}, - [5] = {.index = 6, .length = 3}, - [6] = {.index = 9, .length = 3}, - [7] = {.index = 12, .length = 4}, - [8] = {.index = 16, .length = 4}, }; static const TSFieldMapEntry ts_field_map_entries[] = { @@ -226,24 +257,6 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [4] = {field_name, 2}, {field_name, 3}, - [6] = - {field_name, 1}, - {field_name, 2}, - {field_name, 3}, - [9] = - {field_name, 2}, - {field_name, 3}, - {field_name, 4}, - [12] = - {field_name, 1}, - {field_name, 2}, - {field_name, 3}, - {field_name, 4}, - [16] = - {field_name, 2}, - {field_name, 3}, - {field_name, 4}, - {field_name, 5}, }; static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { @@ -275,20 +288,20 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [17] = 17, [18] = 18, [19] = 19, - [20] = 20, + [20] = 11, [21] = 21, [22] = 22, - [23] = 23, + [23] = 10, [24] = 24, [25] = 25, [26] = 26, [27] = 27, - [28] = 28, - [29] = 29, - [30] = 30, + [28] = 11, + [29] = 10, + [30] = 9, [31] = 31, [32] = 32, - [33] = 33, + [33] = 13, [34] = 34, [35] = 35, [36] = 36, @@ -307,6 +320,9 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [49] = 49, [50] = 50, [51] = 51, + [52] = 52, + [53] = 53, + [54] = 49, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { @@ -314,316 +330,351 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { eof = lexer->eof(lexer); switch (state) { case 0: - if (eof) ADVANCE(10); + if (eof) ADVANCE(17); if (lookahead == '#') ADVANCE(2); - if (lookahead == '*') ADVANCE(14); - if (lookahead == '.') ADVANCE(13); - if (lookahead == ';') ADVANCE(38); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); - if (lookahead == 'p') ADVANCE(17); - if (lookahead == 's') ADVANCE(34); + if (lookahead == '*') ADVANCE(22); + if (lookahead == '.') ADVANCE(21); + if (lookahead == ';') ADVANCE(47); + if (lookahead == '@') ADVANCE(25); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); + if (lookahead == 'p') ADVANCE(26); + if (lookahead == 's') ADVANCE(43); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(7) + lookahead == ' ') SKIP(15) if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 1: - if (lookahead == '\n') ADVANCE(15); + if (lookahead == '\n') ADVANCE(19); if (lookahead != 0) ADVANCE(1); END_STATE(); case 2: if (lookahead == '!') ADVANCE(1); END_STATE(); case 3: - if (lookahead == '*') ADVANCE(14); + if (lookahead == '.') ADVANCE(21); + if (lookahead == '@') ADVANCE(25); + if (lookahead == 'p') ADVANCE(4); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || lookahead == ' ') SKIP(3) - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); END_STATE(); case 4: - if (lookahead == 's') ADVANCE(34); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(4) - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + if (lookahead == 'a') ADVANCE(6); END_STATE(); case 5: - if (eof) ADVANCE(10); - if (lookahead == '\n') ADVANCE(37); - if (lookahead == '.') ADVANCE(13); - if (lookahead == ';') ADVANCE(38); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); - if (lookahead == '\t' || - lookahead == '\r' || - lookahead == ' ') SKIP(5) - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + if (lookahead == 'a') ADVANCE(9); END_STATE(); case 6: - if (eof) ADVANCE(10); - if (lookahead == '#') ADVANCE(2); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); - if (lookahead == 'p') ADVANCE(17); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(8) - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + if (lookahead == 'c') ADVANCE(10); END_STATE(); case 7: - if (eof) ADVANCE(10); - if (lookahead == '*') ADVANCE(14); - if (lookahead == '.') ADVANCE(13); - if (lookahead == ';') ADVANCE(38); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); - if (lookahead == 'p') ADVANCE(17); - if (lookahead == 's') ADVANCE(34); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || lookahead == ' ') SKIP(7) if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 8: - if (eof) ADVANCE(10); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); - if (lookahead == 'p') ADVANCE(17); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(8) - if (('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + if (lookahead == 'e') ADVANCE(23); END_STATE(); case 9: - if (eof) ADVANCE(10); - if (lookahead == 'd') ADVANCE(22); - if (lookahead == 'i') ADVANCE(28); + if (lookahead == 'g') ADVANCE(8); + END_STATE(); + case 10: + if (lookahead == 'k') ADVANCE(5); + END_STATE(); + case 11: + if (lookahead == 's') ADVANCE(43); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(9) + lookahead == ' ') SKIP(11) if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 10: + case 12: + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(12) + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 13: + if (eof) ADVANCE(17); + if (lookahead == '\n') ADVANCE(46); + if (lookahead == '.') ADVANCE(21); + if (lookahead == ';') ADVANCE(47); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') SKIP(13) + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 14: + if (eof) ADVANCE(17); + if (lookahead == '#') ADVANCE(2); + if (lookahead == '@') ADVANCE(25); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); + if (lookahead == 'p') ADVANCE(26); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(16) + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 15: + if (eof) ADVANCE(17); + if (lookahead == '*') ADVANCE(22); + if (lookahead == '.') ADVANCE(21); + if (lookahead == ';') ADVANCE(47); + if (lookahead == '@') ADVANCE(25); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); + if (lookahead == 'p') ADVANCE(26); + if (lookahead == 's') ADVANCE(43); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(15) + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 16: + if (eof) ADVANCE(17); + if (lookahead == '@') ADVANCE(25); + if (lookahead == 'd') ADVANCE(31); + if (lookahead == 'i') ADVANCE(37); + if (lookahead == 'p') ADVANCE(26); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(16) + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 17: ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); - case 11: + case 18: ACCEPT_TOKEN(sym_static_modifier); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 12: + case 19: + ACCEPT_TOKEN(sym__shebang_comment); + END_STATE(); + case 20: ACCEPT_TOKEN(anon_sym_import); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 13: + case 21: ACCEPT_TOKEN(anon_sym_DOT); END_STATE(); - case 14: + case 22: ACCEPT_TOKEN(anon_sym_STAR); END_STATE(); - case 15: - ACCEPT_TOKEN(sym__shebang_comment); + case 23: + ACCEPT_TOKEN(anon_sym_package); END_STATE(); - case 16: + case 24: ACCEPT_TOKEN(anon_sym_package); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 17: + case 25: + ACCEPT_TOKEN(anon_sym_AT); + END_STATE(); + case 26: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(20); + if (lookahead == 'a') ADVANCE(29); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 18: + case 27: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(25); + if (lookahead == 'a') ADVANCE(34); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 19: + case 28: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(32); + if (lookahead == 'a') ADVANCE(41); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('b' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 20: + case 29: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'c') ADVANCE(27); + if (lookahead == 'c') ADVANCE(36); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 21: + case 30: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'c') ADVANCE(11); + if (lookahead == 'c') ADVANCE(18); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 22: + case 31: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'e') ADVANCE(33); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 32: ACCEPT_TOKEN(sym_identifier); if (lookahead == 'e') ADVANCE(24); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 23: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(16); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 24: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'f') ADVANCE(36); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 25: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'g') ADVANCE(23); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 26: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'i') ADVANCE(21); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 27: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'k') ADVANCE(18); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 28: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'm') ADVANCE(30); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 29: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'o') ADVANCE(31); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 30: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'p') ADVANCE(29); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 31: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(33); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); - END_STATE(); - case 32: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(26); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'Z') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 33: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(12); + if (lookahead == 'f') ADVANCE(45); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 34: ACCEPT_TOKEN(sym_identifier); - if (lookahead == 't') ADVANCE(19); + if (lookahead == 'g') ADVANCE(32); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); case 35: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'i') ADVANCE(30); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 36: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'k') ADVANCE(27); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 37: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'm') ADVANCE(39); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 38: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'o') ADVANCE(40); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 39: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'p') ADVANCE(38); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 40: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 'r') ADVANCE(42); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 41: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(35); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 42: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(20); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 43: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == 't') ADVANCE(28); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); + END_STATE(); + case 44: ACCEPT_TOKEN(sym_identifier); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 36: + case 45: ACCEPT_TOKEN(anon_sym_def); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || - ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(44); END_STATE(); - case 37: + case 46: ACCEPT_TOKEN(anon_sym_LF); - if (lookahead == '\n') ADVANCE(37); + if (lookahead == '\n') ADVANCE(46); END_STATE(); - case 38: + case 47: ACCEPT_TOKEN(anon_sym_SEMI); END_STATE(); default: @@ -633,305 +684,240 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { static const TSLexMode ts_lex_modes[STATE_COUNT] = { [0] = {.lex_state = 0}, - [1] = {.lex_state = 6}, - [2] = {.lex_state = 5}, - [3] = {.lex_state = 5}, - [4] = {.lex_state = 5}, - [5] = {.lex_state = 5}, - [6] = {.lex_state = 6}, - [7] = {.lex_state = 9}, - [8] = {.lex_state = 9}, - [9] = {.lex_state = 9}, - [10] = {.lex_state = 9}, - [11] = {.lex_state = 9}, - [12] = {.lex_state = 5}, - [13] = {.lex_state = 5}, - [14] = {.lex_state = 5}, - [15] = {.lex_state = 5}, - [16] = {.lex_state = 5}, - [17] = {.lex_state = 5}, - [18] = {.lex_state = 5}, - [19] = {.lex_state = 5}, - [20] = {.lex_state = 5}, - [21] = {.lex_state = 5}, - [22] = {.lex_state = 5}, - [23] = {.lex_state = 5}, - [24] = {.lex_state = 5}, - [25] = {.lex_state = 5}, - [26] = {.lex_state = 5}, - [27] = {.lex_state = 5}, - [28] = {.lex_state = 5}, - [29] = {.lex_state = 5}, - [30] = {.lex_state = 5}, - [31] = {.lex_state = 5}, - [32] = {.lex_state = 5}, - [33] = {.lex_state = 5}, - [34] = {.lex_state = 5}, - [35] = {.lex_state = 3}, - [36] = {.lex_state = 4}, - [37] = {.lex_state = 5}, - [38] = {.lex_state = 3}, - [39] = {.lex_state = 5}, - [40] = {.lex_state = 3}, - [41] = {.lex_state = 3}, - [42] = {.lex_state = 3}, - [43] = {.lex_state = 5}, + [1] = {.lex_state = 14}, + [2] = {.lex_state = 14}, + [3] = {.lex_state = 13}, + [4] = {.lex_state = 13}, + [5] = {.lex_state = 13}, + [6] = {.lex_state = 13}, + [7] = {.lex_state = 13}, + [8] = {.lex_state = 7}, + [9] = {.lex_state = 13}, + [10] = {.lex_state = 13}, + [11] = {.lex_state = 13}, + [12] = {.lex_state = 13}, + [13] = {.lex_state = 13}, + [14] = {.lex_state = 13}, + [15] = {.lex_state = 13}, + [16] = {.lex_state = 13}, + [17] = {.lex_state = 13}, + [18] = {.lex_state = 13}, + [19] = {.lex_state = 13}, + [20] = {.lex_state = 13}, + [21] = {.lex_state = 13}, + [22] = {.lex_state = 13}, + [23] = {.lex_state = 13}, + [24] = {.lex_state = 13}, + [25] = {.lex_state = 3}, + [26] = {.lex_state = 3}, + [27] = {.lex_state = 3}, + [28] = {.lex_state = 3}, + [29] = {.lex_state = 3}, + [30] = {.lex_state = 3}, + [31] = {.lex_state = 11}, + [32] = {.lex_state = 13}, + [33] = {.lex_state = 3}, + [34] = {.lex_state = 13}, + [35] = {.lex_state = 13}, + [36] = {.lex_state = 13}, + [37] = {.lex_state = 13}, + [38] = {.lex_state = 13}, + [39] = {.lex_state = 13}, + [40] = {.lex_state = 12}, + [41] = {.lex_state = 12}, + [42] = {.lex_state = 12}, + [43] = {.lex_state = 12}, [44] = {.lex_state = 3}, [45] = {.lex_state = 3}, - [46] = {.lex_state = 3}, + [46] = {.lex_state = 0}, [47] = {.lex_state = 0}, - [48] = {.lex_state = 3}, - [49] = {.lex_state = 0}, - [50] = {.lex_state = 3}, - [51] = {.lex_state = 3}, + [48] = {.lex_state = 0}, + [49] = {.lex_state = 12}, + [50] = {.lex_state = 0}, + [51] = {.lex_state = 12}, + [52] = {.lex_state = 0}, + [53] = {.lex_state = 0}, + [54] = {.lex_state = 12}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [0] = { [ts_builtin_sym_end] = ACTIONS(1), [sym_static_modifier] = ACTIONS(1), + [sym__shebang_comment] = ACTIONS(1), [anon_sym_import] = ACTIONS(1), [anon_sym_DOT] = ACTIONS(1), [anon_sym_STAR] = ACTIONS(1), - [sym__shebang_comment] = ACTIONS(1), [anon_sym_package] = ACTIONS(1), + [anon_sym_AT] = ACTIONS(1), [sym_identifier] = ACTIONS(1), [anon_sym_def] = ACTIONS(1), [anon_sym_SEMI] = ACTIONS(1), }, [1] = { [sym_source_file] = STATE(47), - [sym_import_statement] = STATE(25), - [sym_package_definition] = STATE(4), - [sym_script_part] = STATE(20), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [aux_sym_source_file_repeat2] = STATE(11), - [aux_sym_path_expression_repeat1] = STATE(42), + [sym__script_statements] = STATE(46), + [sym_import_declaration] = STATE(15), + [sym_package_declaration] = STATE(5), + [sym__annotations] = STATE(45), + [sym_annotation] = STATE(25), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), [ts_builtin_sym_end] = ACTIONS(3), - [anon_sym_import] = ACTIONS(5), - [sym__shebang_comment] = ACTIONS(7), + [sym__shebang_comment] = ACTIONS(5), + [anon_sym_import] = ACTIONS(7), [anon_sym_package] = ACTIONS(9), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), + [anon_sym_AT] = ACTIONS(11), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), }, [2] = { - [sym_import_statement] = STATE(25), - [sym_script_part] = STATE(21), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [sym__nl_semicolon] = STATE(13), - [aux_sym_source_file_repeat1] = STATE(13), - [aux_sym_source_file_repeat2] = STATE(9), - [aux_sym_path_expression_repeat1] = STATE(42), - [ts_builtin_sym_end] = ACTIONS(15), - [anon_sym_import] = ACTIONS(5), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), - [anon_sym_LF] = ACTIONS(17), - [anon_sym_SEMI] = ACTIONS(19), + [sym__script_statements] = STATE(50), + [sym_import_declaration] = STATE(15), + [sym_package_declaration] = STATE(6), + [sym__annotations] = STATE(45), + [sym_annotation] = STATE(25), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), + [ts_builtin_sym_end] = ACTIONS(17), + [anon_sym_import] = ACTIONS(7), + [anon_sym_package] = ACTIONS(9), + [anon_sym_AT] = ACTIONS(11), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), }, [3] = { - [sym_import_statement] = STATE(25), - [sym_script_part] = STATE(22), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [sym__nl_semicolon] = STATE(13), - [aux_sym_source_file_repeat1] = STATE(13), - [aux_sym_source_file_repeat2] = STATE(8), - [aux_sym_path_expression_repeat1] = STATE(42), - [ts_builtin_sym_end] = ACTIONS(21), - [anon_sym_import] = ACTIONS(5), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), - [anon_sym_LF] = ACTIONS(17), - [anon_sym_SEMI] = ACTIONS(19), + [sym__script_statements] = STATE(48), + [sym_import_declaration] = STATE(15), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), + [sym__sep] = STATE(12), + [aux_sym_source_file_repeat1] = STATE(12), + [ts_builtin_sym_end] = ACTIONS(19), + [anon_sym_import] = ACTIONS(7), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), + [anon_sym_LF] = ACTIONS(21), + [anon_sym_SEMI] = ACTIONS(23), }, [4] = { - [sym_import_statement] = STATE(25), - [sym_script_part] = STATE(19), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [sym__nl_semicolon] = STATE(2), - [aux_sym_source_file_repeat1] = STATE(2), - [aux_sym_source_file_repeat2] = STATE(10), - [aux_sym_path_expression_repeat1] = STATE(42), - [ts_builtin_sym_end] = ACTIONS(23), - [anon_sym_import] = ACTIONS(5), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), - [anon_sym_LF] = ACTIONS(25), - [anon_sym_SEMI] = ACTIONS(27), + [sym__script_statements] = STATE(53), + [sym_import_declaration] = STATE(15), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), + [sym__sep] = STATE(12), + [aux_sym_source_file_repeat1] = STATE(12), + [ts_builtin_sym_end] = ACTIONS(25), + [anon_sym_import] = ACTIONS(7), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), + [anon_sym_LF] = ACTIONS(21), + [anon_sym_SEMI] = ACTIONS(23), }, [5] = { - [sym_import_statement] = STATE(25), - [sym_script_part] = STATE(21), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [sym__nl_semicolon] = STATE(3), - [aux_sym_source_file_repeat1] = STATE(3), - [aux_sym_source_file_repeat2] = STATE(9), - [aux_sym_path_expression_repeat1] = STATE(42), - [ts_builtin_sym_end] = ACTIONS(15), - [anon_sym_import] = ACTIONS(5), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), - [anon_sym_LF] = ACTIONS(29), - [anon_sym_SEMI] = ACTIONS(31), + [sym__script_statements] = STATE(50), + [sym_import_declaration] = STATE(15), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), + [sym__sep] = STATE(4), + [aux_sym_source_file_repeat1] = STATE(4), + [ts_builtin_sym_end] = ACTIONS(17), + [anon_sym_import] = ACTIONS(7), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), + [anon_sym_LF] = ACTIONS(27), + [anon_sym_SEMI] = ACTIONS(29), }, [6] = { - [sym_import_statement] = STATE(25), - [sym_package_definition] = STATE(5), - [sym_script_part] = STATE(19), - [sym_expression] = STATE(33), - [sym_path_expression] = STATE(30), - [sym_statement] = STATE(32), - [sym_method_declaration] = STATE(32), - [aux_sym_source_file_repeat2] = STATE(10), - [aux_sym_path_expression_repeat1] = STATE(42), - [ts_builtin_sym_end] = ACTIONS(23), - [anon_sym_import] = ACTIONS(5), - [anon_sym_package] = ACTIONS(9), - [sym_identifier] = ACTIONS(11), - [anon_sym_def] = ACTIONS(13), + [sym__script_statements] = STATE(53), + [sym_import_declaration] = STATE(15), + [sym__script_statement] = STATE(15), + [sym_expression] = STATE(38), + [sym_qualified_name] = STATE(37), + [sym_statement] = STATE(15), + [sym_method_declaration] = STATE(15), + [sym__sep] = STATE(3), + [aux_sym_source_file_repeat1] = STATE(3), + [ts_builtin_sym_end] = ACTIONS(25), + [anon_sym_import] = ACTIONS(7), + [sym_identifier] = ACTIONS(13), + [anon_sym_def] = ACTIONS(15), + [anon_sym_LF] = ACTIONS(31), + [anon_sym_SEMI] = ACTIONS(33), }, }; static const uint16_t ts_small_parse_table[] = { - [0] = 10, - ACTIONS(33), 1, - ts_builtin_sym_end, - ACTIONS(35), 1, + [0] = 8, + ACTIONS(7), 1, anon_sym_import, - ACTIONS(38), 1, - sym_identifier, - ACTIONS(41), 1, - anon_sym_def, - STATE(7), 1, - aux_sym_source_file_repeat2, - STATE(30), 1, - sym_path_expression, - STATE(33), 1, - sym_expression, - STATE(42), 1, - aux_sym_path_expression_repeat1, - STATE(25), 2, - sym_import_statement, - sym_script_part, - STATE(32), 2, - sym_statement, - sym_method_declaration, - [33] = 11, - ACTIONS(5), 1, - anon_sym_import, - ACTIONS(11), 1, - sym_identifier, ACTIONS(13), 1, - anon_sym_def, - ACTIONS(44), 1, - ts_builtin_sym_end, - STATE(7), 1, - aux_sym_source_file_repeat2, - STATE(18), 1, - sym_script_part, - STATE(25), 1, - sym_import_statement, - STATE(30), 1, - sym_path_expression, - STATE(33), 1, - sym_expression, - STATE(42), 1, - aux_sym_path_expression_repeat1, - STATE(32), 2, - sym_statement, - sym_method_declaration, - [68] = 11, - ACTIONS(5), 1, - anon_sym_import, - ACTIONS(11), 1, sym_identifier, - ACTIONS(13), 1, - anon_sym_def, - ACTIONS(21), 1, - ts_builtin_sym_end, - STATE(7), 1, - aux_sym_source_file_repeat2, - STATE(22), 1, - sym_script_part, - STATE(25), 1, - sym_import_statement, - STATE(30), 1, - sym_path_expression, - STATE(33), 1, - sym_expression, - STATE(42), 1, - aux_sym_path_expression_repeat1, - STATE(32), 2, - sym_statement, - sym_method_declaration, - [103] = 11, - ACTIONS(5), 1, - anon_sym_import, - ACTIONS(11), 1, - sym_identifier, - ACTIONS(13), 1, - anon_sym_def, ACTIONS(15), 1, - ts_builtin_sym_end, - STATE(7), 1, - aux_sym_source_file_repeat2, - STATE(21), 1, - sym_script_part, - STATE(25), 1, - sym_import_statement, - STATE(30), 1, - sym_path_expression, - STATE(33), 1, - sym_expression, - STATE(42), 1, - aux_sym_path_expression_repeat1, - STATE(32), 2, - sym_statement, - sym_method_declaration, - [138] = 11, - ACTIONS(5), 1, - anon_sym_import, - ACTIONS(11), 1, - sym_identifier, - ACTIONS(13), 1, anon_sym_def, - ACTIONS(23), 1, - ts_builtin_sym_end, - STATE(7), 1, - aux_sym_source_file_repeat2, - STATE(19), 1, - sym_script_part, - STATE(25), 1, - sym_import_statement, - STATE(30), 1, - sym_path_expression, - STATE(33), 1, + ACTIONS(37), 1, + anon_sym_SEMI, + STATE(37), 1, + sym_qualified_name, + STATE(38), 1, sym_expression, - STATE(42), 1, - aux_sym_path_expression_repeat1, - STATE(32), 2, + ACTIONS(35), 2, + ts_builtin_sym_end, + anon_sym_LF, + STATE(39), 4, + sym_import_declaration, + sym__script_statement, sym_statement, sym_method_declaration, - [173] = 4, + [29] = 6, + ACTIONS(7), 1, + anon_sym_import, + ACTIONS(13), 1, + sym_identifier, + ACTIONS(15), 1, + anon_sym_def, + STATE(37), 1, + sym_qualified_name, + STATE(38), 1, + sym_expression, + STATE(39), 4, + sym_import_declaration, + sym__script_statement, + sym_statement, + sym_method_declaration, + [51] = 4, + ACTIONS(43), 1, + anon_sym_DOT, + STATE(9), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(39), 2, + ts_builtin_sym_end, + anon_sym_LF, + ACTIONS(41), 4, + anon_sym_import, + sym_identifier, + anon_sym_def, + anon_sym_SEMI, + [68] = 4, ACTIONS(50), 1, anon_sym_DOT, - STATE(12), 1, - aux_sym_import_statement_repeat1, + STATE(11), 1, + aux_sym_qualified_name_repeat1, ACTIONS(46), 2, ts_builtin_sym_end, anon_sym_LF, @@ -940,417 +926,451 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, anon_sym_def, anon_sym_SEMI, - [190] = 5, - ACTIONS(53), 1, + [85] = 4, + ACTIONS(50), 1, + anon_sym_DOT, + STATE(9), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(52), 2, ts_builtin_sym_end, - ACTIONS(57), 1, anon_sym_LF, + ACTIONS(54), 4, + anon_sym_import, + sym_identifier, + anon_sym_def, + anon_sym_SEMI, + [102] = 5, + ACTIONS(56), 1, + ts_builtin_sym_end, ACTIONS(60), 1, + anon_sym_LF, + ACTIONS(63), 1, anon_sym_SEMI, - STATE(13), 2, - sym__nl_semicolon, + STATE(12), 2, + sym__sep, aux_sym_source_file_repeat1, - ACTIONS(55), 3, + ACTIONS(58), 3, anon_sym_import, sym_identifier, anon_sym_def, - [209] = 4, - ACTIONS(67), 1, - anon_sym_DOT, - STATE(12), 1, - aux_sym_import_statement_repeat1, - ACTIONS(63), 2, + [121] = 2, + ACTIONS(39), 2, ts_builtin_sym_end, anon_sym_LF, - ACTIONS(65), 4, - anon_sym_import, - sym_identifier, - anon_sym_def, - anon_sym_SEMI, - [226] = 4, - ACTIONS(67), 1, - anon_sym_DOT, - STATE(14), 1, - aux_sym_import_statement_repeat1, - ACTIONS(69), 2, - ts_builtin_sym_end, - anon_sym_LF, - ACTIONS(71), 4, - anon_sym_import, - sym_identifier, - anon_sym_def, - anon_sym_SEMI, - [243] = 5, - ACTIONS(17), 1, - anon_sym_LF, - ACTIONS(19), 1, - anon_sym_SEMI, - ACTIONS(33), 1, - ts_builtin_sym_end, - STATE(13), 2, - sym__nl_semicolon, - aux_sym_source_file_repeat1, - ACTIONS(73), 3, - anon_sym_import, - sym_identifier, - anon_sym_def, - [262] = 2, - ACTIONS(46), 2, - ts_builtin_sym_end, - anon_sym_LF, - ACTIONS(48), 5, + ACTIONS(41), 5, anon_sym_import, anon_sym_DOT, sym_identifier, anon_sym_def, anon_sym_SEMI, - [274] = 4, - ACTIONS(75), 1, + [133] = 2, + ACTIONS(66), 2, ts_builtin_sym_end, - ACTIONS(77), 1, anon_sym_LF, - ACTIONS(79), 1, + ACTIONS(68), 4, + anon_sym_import, + sym_identifier, + anon_sym_def, anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, - aux_sym_source_file_repeat1, - [288] = 4, - ACTIONS(15), 1, + [144] = 6, + ACTIONS(70), 1, ts_builtin_sym_end, - ACTIONS(77), 1, + ACTIONS(72), 1, anon_sym_LF, - ACTIONS(79), 1, + ACTIONS(74), 1, anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, + STATE(7), 1, + sym__sep, + STATE(17), 1, + aux_sym__script_statements_repeat1, + STATE(22), 1, aux_sym_source_file_repeat1, - [302] = 4, - ACTIONS(23), 1, + [163] = 2, + ACTIONS(76), 2, ts_builtin_sym_end, - ACTIONS(77), 1, anon_sym_LF, - ACTIONS(79), 1, + ACTIONS(78), 4, + anon_sym_import, + sym_identifier, + anon_sym_def, anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, - aux_sym_source_file_repeat1, - [316] = 4, - ACTIONS(21), 1, + [174] = 6, + ACTIONS(72), 1, + anon_sym_LF, + ACTIONS(74), 1, + anon_sym_SEMI, + ACTIONS(80), 1, ts_builtin_sym_end, - ACTIONS(77), 1, - anon_sym_LF, - ACTIONS(79), 1, - anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, + STATE(7), 1, + sym__sep, + STATE(19), 1, + aux_sym__script_statements_repeat1, + STATE(24), 1, aux_sym_source_file_repeat1, - [330] = 4, - ACTIONS(44), 1, - ts_builtin_sym_end, - ACTIONS(77), 1, - anon_sym_LF, - ACTIONS(79), 1, - anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, - aux_sym_source_file_repeat1, - [344] = 4, - ACTIONS(81), 1, + [193] = 4, + ACTIONS(84), 1, anon_sym_DOT, - ACTIONS(83), 1, - anon_sym_LF, - ACTIONS(85), 1, + ACTIONS(86), 1, anon_sym_SEMI, - STATE(12), 1, - aux_sym_import_statement_repeat1, - [357] = 4, - ACTIONS(87), 1, - anon_sym_DOT, - ACTIONS(89), 1, - anon_sym_LF, - ACTIONS(91), 1, - anon_sym_SEMI, - STATE(29), 1, - aux_sym_import_statement_repeat1, - [370] = 3, - ACTIONS(77), 1, - anon_sym_LF, - ACTIONS(79), 1, - anon_sym_SEMI, - STATE(16), 2, - sym__nl_semicolon, - aux_sym_source_file_repeat1, - [381] = 3, - ACTIONS(95), 1, - anon_sym_DOT, - ACTIONS(97), 1, - anon_sym_SEMI, - ACTIONS(93), 2, + STATE(36), 1, + sym_wildcard_import, + ACTIONS(82), 2, ts_builtin_sym_end, anon_sym_LF, - [392] = 3, - ACTIONS(95), 1, + [207] = 5, + ACTIONS(88), 1, + ts_builtin_sym_end, + ACTIONS(90), 1, + anon_sym_LF, + ACTIONS(93), 1, + anon_sym_SEMI, + STATE(8), 1, + sym__sep, + STATE(19), 1, + aux_sym__script_statements_repeat1, + [223] = 4, + ACTIONS(54), 1, + anon_sym_SEMI, + ACTIONS(96), 1, + anon_sym_DOT, + STATE(9), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(52), 2, + ts_builtin_sym_end, + anon_sym_LF, + [237] = 4, + ACTIONS(84), 1, anon_sym_DOT, ACTIONS(101), 1, anon_sym_SEMI, + STATE(35), 1, + sym_wildcard_import, ACTIONS(99), 2, ts_builtin_sym_end, anon_sym_LF, - [403] = 4, + [251] = 4, + ACTIONS(21), 1, + anon_sym_LF, + ACTIONS(23), 1, + anon_sym_SEMI, + ACTIONS(80), 1, + ts_builtin_sym_end, + STATE(12), 2, + sym__sep, + aux_sym_source_file_repeat1, + [265] = 4, + ACTIONS(48), 1, + anon_sym_SEMI, ACTIONS(103), 1, anon_sym_DOT, - ACTIONS(105), 1, + STATE(20), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(46), 2, + ts_builtin_sym_end, anon_sym_LF, - ACTIONS(107), 1, - anon_sym_SEMI, - STATE(23), 1, - aux_sym_import_statement_repeat1, - [416] = 4, - ACTIONS(109), 1, - anon_sym_DOT, - ACTIONS(111), 1, + [279] = 4, + ACTIONS(21), 1, anon_sym_LF, - ACTIONS(113), 1, + ACTIONS(23), 1, anon_sym_SEMI, - STATE(12), 1, - aux_sym_import_statement_repeat1, - [429] = 2, + ACTIONS(106), 1, + ts_builtin_sym_end, + STATE(12), 2, + sym__sep, + aux_sym_source_file_repeat1, + [293] = 3, + ACTIONS(11), 1, + anon_sym_AT, + ACTIONS(108), 1, + anon_sym_package, + STATE(27), 2, + sym_annotation, + aux_sym__annotations_repeat1, + [304] = 3, + ACTIONS(110), 1, + anon_sym_package, + ACTIONS(112), 1, + anon_sym_AT, + STATE(26), 2, + sym_annotation, + aux_sym__annotations_repeat1, + [315] = 3, + ACTIONS(11), 1, + anon_sym_AT, + ACTIONS(115), 1, + anon_sym_package, + STATE(26), 2, + sym_annotation, + aux_sym__annotations_repeat1, + [326] = 3, ACTIONS(117), 1, - anon_sym_SEMI, - ACTIONS(115), 2, - ts_builtin_sym_end, - anon_sym_LF, - [437] = 2, - ACTIONS(121), 1, - anon_sym_SEMI, - ACTIONS(119), 2, - ts_builtin_sym_end, - anon_sym_LF, - [445] = 2, - ACTIONS(125), 1, - anon_sym_SEMI, - ACTIONS(123), 2, - ts_builtin_sym_end, - anon_sym_LF, - [453] = 2, - ACTIONS(129), 1, - anon_sym_SEMI, - ACTIONS(127), 2, - ts_builtin_sym_end, - anon_sym_LF, - [461] = 2, - ACTIONS(131), 1, - anon_sym_LF, - ACTIONS(133), 1, - anon_sym_SEMI, - [468] = 2, - ACTIONS(135), 1, - anon_sym_STAR, - ACTIONS(137), 1, - sym_identifier, - [475] = 2, - ACTIONS(139), 1, + anon_sym_DOT, + STATE(30), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(52), 2, + anon_sym_package, + anon_sym_AT, + [337] = 3, + ACTIONS(117), 1, + anon_sym_DOT, + STATE(28), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(46), 2, + anon_sym_package, + anon_sym_AT, + [348] = 3, + ACTIONS(119), 1, + anon_sym_DOT, + STATE(30), 1, + aux_sym_qualified_name_repeat1, + ACTIONS(39), 2, + anon_sym_package, + anon_sym_AT, + [359] = 3, + ACTIONS(122), 1, sym_static_modifier, - ACTIONS(141), 1, + ACTIONS(124), 1, sym_identifier, - [482] = 2, - ACTIONS(143), 1, - anon_sym_LF, - ACTIONS(145), 1, + STATE(21), 1, + sym_qualified_name, + [369] = 2, + ACTIONS(128), 1, anon_sym_SEMI, - [489] = 2, - ACTIONS(147), 1, - sym_identifier, - STATE(38), 1, - aux_sym_path_expression_repeat1, - [496] = 2, + ACTIONS(126), 2, + ts_builtin_sym_end, + anon_sym_LF, + [377] = 1, + ACTIONS(39), 3, + anon_sym_DOT, + anon_sym_package, + anon_sym_AT, + [383] = 2, + ACTIONS(132), 1, + anon_sym_SEMI, + ACTIONS(130), 2, + ts_builtin_sym_end, + anon_sym_LF, + [391] = 2, + ACTIONS(136), 1, + anon_sym_SEMI, + ACTIONS(134), 2, + ts_builtin_sym_end, + anon_sym_LF, + [399] = 2, + ACTIONS(140), 1, + anon_sym_SEMI, + ACTIONS(138), 2, + ts_builtin_sym_end, + anon_sym_LF, + [407] = 2, + ACTIONS(144), 1, + anon_sym_SEMI, + ACTIONS(142), 2, + ts_builtin_sym_end, + anon_sym_LF, + [415] = 2, + ACTIONS(148), 1, + anon_sym_SEMI, + ACTIONS(146), 2, + ts_builtin_sym_end, + anon_sym_LF, + [423] = 2, ACTIONS(150), 1, + anon_sym_SEMI, + ACTIONS(88), 2, + ts_builtin_sym_end, anon_sym_LF, + [431] = 2, ACTIONS(152), 1, - anon_sym_SEMI, - [503] = 2, - ACTIONS(137), 1, sym_identifier, + STATE(18), 1, + sym_qualified_name, + [438] = 2, ACTIONS(154), 1, - anon_sym_STAR, - [510] = 2, - ACTIONS(137), 1, sym_identifier, + STATE(44), 1, + sym_qualified_name, + [445] = 2, ACTIONS(156), 1, - anon_sym_STAR, - [517] = 2, - ACTIONS(158), 1, sym_identifier, - STATE(38), 1, - aux_sym_path_expression_repeat1, - [524] = 2, + STATE(16), 1, + sym_qualified_name, + [452] = 2, + ACTIONS(156), 1, + sym_identifier, + STATE(14), 1, + sym_qualified_name, + [459] = 1, + ACTIONS(158), 2, + anon_sym_package, + anon_sym_AT, + [464] = 1, ACTIONS(160), 1, - anon_sym_LF, + anon_sym_package, + [468] = 1, + ACTIONS(17), 1, + ts_builtin_sym_end, + [472] = 1, ACTIONS(162), 1, - anon_sym_SEMI, - [531] = 2, - ACTIONS(137), 1, - sym_identifier, + ts_builtin_sym_end, + [476] = 1, ACTIONS(164), 1, - anon_sym_STAR, - [538] = 1, + ts_builtin_sym_end, + [480] = 1, ACTIONS(166), 1, sym_identifier, - [542] = 1, + [484] = 1, + ACTIONS(25), 1, + ts_builtin_sym_end, + [488] = 1, ACTIONS(168), 1, sym_identifier, - [546] = 1, + [492] = 1, ACTIONS(170), 1, + anon_sym_STAR, + [496] = 1, + ACTIONS(19), 1, ts_builtin_sym_end, - [550] = 1, - ACTIONS(137), 1, - sym_identifier, - [554] = 1, + [500] = 1, ACTIONS(172), 1, - anon_sym_DOT, - [558] = 1, - ACTIONS(174), 1, - sym_identifier, - [562] = 1, - ACTIONS(176), 1, sym_identifier, }; static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(7)] = 0, - [SMALL_STATE(8)] = 33, - [SMALL_STATE(9)] = 68, - [SMALL_STATE(10)] = 103, - [SMALL_STATE(11)] = 138, - [SMALL_STATE(12)] = 173, - [SMALL_STATE(13)] = 190, - [SMALL_STATE(14)] = 209, - [SMALL_STATE(15)] = 226, - [SMALL_STATE(16)] = 243, - [SMALL_STATE(17)] = 262, - [SMALL_STATE(18)] = 274, - [SMALL_STATE(19)] = 288, - [SMALL_STATE(20)] = 302, - [SMALL_STATE(21)] = 316, - [SMALL_STATE(22)] = 330, - [SMALL_STATE(23)] = 344, - [SMALL_STATE(24)] = 357, - [SMALL_STATE(25)] = 370, - [SMALL_STATE(26)] = 381, - [SMALL_STATE(27)] = 392, - [SMALL_STATE(28)] = 403, - [SMALL_STATE(29)] = 416, - [SMALL_STATE(30)] = 429, - [SMALL_STATE(31)] = 437, - [SMALL_STATE(32)] = 445, - [SMALL_STATE(33)] = 453, - [SMALL_STATE(34)] = 461, - [SMALL_STATE(35)] = 468, - [SMALL_STATE(36)] = 475, - [SMALL_STATE(37)] = 482, - [SMALL_STATE(38)] = 489, - [SMALL_STATE(39)] = 496, - [SMALL_STATE(40)] = 503, - [SMALL_STATE(41)] = 510, - [SMALL_STATE(42)] = 517, - [SMALL_STATE(43)] = 524, - [SMALL_STATE(44)] = 531, - [SMALL_STATE(45)] = 538, - [SMALL_STATE(46)] = 542, - [SMALL_STATE(47)] = 546, - [SMALL_STATE(48)] = 550, - [SMALL_STATE(49)] = 554, - [SMALL_STATE(50)] = 558, - [SMALL_STATE(51)] = 562, + [SMALL_STATE(8)] = 29, + [SMALL_STATE(9)] = 51, + [SMALL_STATE(10)] = 68, + [SMALL_STATE(11)] = 85, + [SMALL_STATE(12)] = 102, + [SMALL_STATE(13)] = 121, + [SMALL_STATE(14)] = 133, + [SMALL_STATE(15)] = 144, + [SMALL_STATE(16)] = 163, + [SMALL_STATE(17)] = 174, + [SMALL_STATE(18)] = 193, + [SMALL_STATE(19)] = 207, + [SMALL_STATE(20)] = 223, + [SMALL_STATE(21)] = 237, + [SMALL_STATE(22)] = 251, + [SMALL_STATE(23)] = 265, + [SMALL_STATE(24)] = 279, + [SMALL_STATE(25)] = 293, + [SMALL_STATE(26)] = 304, + [SMALL_STATE(27)] = 315, + [SMALL_STATE(28)] = 326, + [SMALL_STATE(29)] = 337, + [SMALL_STATE(30)] = 348, + [SMALL_STATE(31)] = 359, + [SMALL_STATE(32)] = 369, + [SMALL_STATE(33)] = 377, + [SMALL_STATE(34)] = 383, + [SMALL_STATE(35)] = 391, + [SMALL_STATE(36)] = 399, + [SMALL_STATE(37)] = 407, + [SMALL_STATE(38)] = 415, + [SMALL_STATE(39)] = 423, + [SMALL_STATE(40)] = 431, + [SMALL_STATE(41)] = 438, + [SMALL_STATE(42)] = 445, + [SMALL_STATE(43)] = 452, + [SMALL_STATE(44)] = 459, + [SMALL_STATE(45)] = 464, + [SMALL_STATE(46)] = 468, + [SMALL_STATE(47)] = 472, + [SMALL_STATE(48)] = 476, + [SMALL_STATE(49)] = 480, + [SMALL_STATE(50)] = 484, + [SMALL_STATE(51)] = 488, + [SMALL_STATE(52)] = 492, + [SMALL_STATE(53)] = 496, + [SMALL_STATE(54)] = 500, }; static const TSParseActionEntry ts_parse_actions[] = { [0] = {.entry = {.count = 0, .reusable = false}}, [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0), - [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT(36), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), - [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(50), - [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(26), - [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(46), - [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 2), - [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(13), - [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 3), - [23] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1), - [25] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), - [27] = {.entry = {.count = 1, .reusable = false}}, SHIFT(2), - [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [31] = {.entry = {.count = 1, .reusable = false}}, SHIFT(3), - [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat2, 2), - [35] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat2, 2), SHIFT_REPEAT(36), - [38] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat2, 2), SHIFT_REPEAT(26), - [41] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat2, 2), SHIFT_REPEAT(46), - [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 4), - [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_import_statement_repeat1, 2), - [48] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_import_statement_repeat1, 2), - [50] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_import_statement_repeat1, 2), SHIFT_REPEAT(48), - [53] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), - [55] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), - [57] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(13), - [60] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(13), - [63] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_package_definition, 3, .production_id = 3), - [65] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_package_definition, 3, .production_id = 3), - [67] = {.entry = {.count = 1, .reusable = false}}, SHIFT(48), - [69] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_package_definition, 2, .production_id = 1), - [71] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_package_definition, 2, .production_id = 1), - [73] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_source_file_repeat2, 2), - [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 5), - [77] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), - [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), - [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 4, .production_id = 4), - [85] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 4, .production_id = 4), - [87] = {.entry = {.count = 1, .reusable = false}}, SHIFT(35), - [89] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 2, .production_id = 1), - [91] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 2, .production_id = 1), - [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path_expression, 1), - [95] = {.entry = {.count = 1, .reusable = false}}, SHIFT(45), - [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path_expression, 1), - [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path_expression, 2), - [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path_expression, 2), - [103] = {.entry = {.count = 1, .reusable = false}}, SHIFT(41), - [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 3, .production_id = 2), - [107] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 3, .production_id = 2), - [109] = {.entry = {.count = 1, .reusable = false}}, SHIFT(44), - [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 3, .production_id = 3), - [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 3, .production_id = 3), - [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1), - [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 1), - [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_method_declaration, 2, .production_id = 1), - [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_method_declaration, 2, .production_id = 1), - [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_script_part, 1), - [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_script_part, 1), - [127] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_statement, 1), - [129] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_statement, 1), - [131] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 5, .production_id = 6), - [133] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 5, .production_id = 6), - [135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), - [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), - [139] = {.entry = {.count = 1, .reusable = false}}, SHIFT(51), - [141] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), - [143] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 6, .production_id = 8), - [145] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 6, .production_id = 8), - [147] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_expression_repeat1, 2), SHIFT_REPEAT(49), - [150] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 5, .production_id = 7), - [152] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 5, .production_id = 7), - [154] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), - [156] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), - [158] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), - [160] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_statement, 4, .production_id = 5), - [162] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_statement, 4, .production_id = 5), - [164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), - [166] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_path_expression_repeat1, 2), - [168] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), - [170] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), - [174] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), - [176] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), + [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(31), + [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(42), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10), + [15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(51), + [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1), + [19] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 3), + [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [23] = {.entry = {.count = 1, .reusable = false}}, SHIFT(12), + [25] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 2), + [27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [29] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [33] = {.entry = {.count = 1, .reusable = false}}, SHIFT(3), + [35] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 1), + [37] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 1), + [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_qualified_name_repeat1, 2), + [41] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_qualified_name_repeat1, 2), + [43] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_qualified_name_repeat1, 2), SHIFT_REPEAT(49), + [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_qualified_name, 1), + [48] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_qualified_name, 1), + [50] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), + [52] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_qualified_name, 2), + [54] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_qualified_name, 2), + [56] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), + [58] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), + [60] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(12), + [63] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(12), + [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_package_declaration, 3, .production_id = 2), + [68] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_package_declaration, 3, .production_id = 2), + [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__script_statements, 1), + [72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [74] = {.entry = {.count = 1, .reusable = false}}, SHIFT(7), + [76] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_package_declaration, 2, .production_id = 1), + [78] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_package_declaration, 2, .production_id = 1), + [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__script_statements, 2), + [82] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_declaration, 3, .production_id = 2), + [84] = {.entry = {.count = 1, .reusable = false}}, SHIFT(52), + [86] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_declaration, 3, .production_id = 2), + [88] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__script_statements_repeat1, 2), + [90] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__script_statements_repeat1, 2), SHIFT_REPEAT(8), + [93] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym__script_statements_repeat1, 2), SHIFT_REPEAT(8), + [96] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_qualified_name, 2), SHIFT(49), + [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_declaration, 2, .production_id = 1), + [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_declaration, 2, .production_id = 1), + [103] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_qualified_name, 1), SHIFT(49), + [106] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__script_statements, 3), + [108] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__annotations, 1), + [110] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__annotations_repeat1, 2), + [112] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__annotations_repeat1, 2), SHIFT_REPEAT(41), + [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__annotations, 2), + [117] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), + [119] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_qualified_name_repeat1, 2), SHIFT_REPEAT(54), + [122] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), + [124] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23), + [126] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_method_declaration, 2, .production_id = 1), + [128] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_method_declaration, 2, .production_id = 1), + [130] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_wildcard_import, 2), + [132] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_wildcard_import, 2), + [134] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_declaration, 3, .production_id = 3), + [136] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_declaration, 3, .production_id = 3), + [138] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_import_declaration, 4, .production_id = 4), + [140] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_import_declaration, 4, .production_id = 4), + [142] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1), + [144] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 1), + [146] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_statement, 1), + [148] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_statement, 1), + [150] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym__script_statements_repeat1, 2), + [152] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), + [154] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), + [156] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotation, 2), + [160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), + [162] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [164] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 4), + [166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [168] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), }; #ifdef __cplusplus diff --git a/test/corpus/import statements.txt b/test/corpus/import statements.txt index 12bab69..2c6358a 100644 --- a/test/corpus/import statements.txt +++ b/test/corpus/import statements.txt @@ -6,8 +6,9 @@ import wibble -------------------------------------------------------------------------------- (source_file - (import_statement - (identifier))) + (import_declaration + (qualified_name + (identifier)))) ================================================================================ multiple identifier import @@ -17,9 +18,10 @@ import wobble.qq -------------------------------------------------------------------------------- (source_file - (import_statement - (identifier) - (identifier))) + (import_declaration + (qualified_name + (identifier) + (identifier)))) ================================================================================ wildcard import @@ -29,9 +31,11 @@ import flobble.fnurfle.* -------------------------------------------------------------------------------- (source_file - (import_statement - (identifier) - (identifier))) + (import_declaration + (qualified_name + (identifier) + (identifier)) + (wildcard_import))) ================================================================================ multiple imports semicolon separated @@ -40,11 +44,14 @@ import qq.ss; import flobble.*; -------------------------------------------------------------------------------- (source_file - (import_statement - (identifier) - (identifier)) - (import_statement - (identifier))) + (import_declaration + (qualified_name + (identifier) + (identifier))) + (import_declaration + (qualified_name + (identifier)) + (wildcard_import))) ================================================================================ static import @@ -53,7 +60,21 @@ import static qq.q.*; -------------------------------------------------------------------------------- (source_file - (import_statement + (import_declaration (static_modifier) - (identifier) - (identifier))) + (qualified_name + (identifier) + (identifier)) + (wildcard_import))) + +================================================================================ +simple wildcard +================================================================================ +import wibble.*; +-------------------------------------------------------------------------------- + +(source_file + (import_declaration + (qualified_name + (identifier)) + (wildcard_import))) diff --git a/test/corpus/package definition.txt b/test/corpus/package definition.txt index 69502c1..d5009b9 100644 --- a/test/corpus/package definition.txt +++ b/test/corpus/package definition.txt @@ -5,8 +5,9 @@ package flob -------------------------------------------------------------------------------- (source_file - (package_definition - (identifier))) + (package_declaration + (qualified_name + (identifier)))) ================================================================================ Dotted package definition @@ -15,6 +16,7 @@ package flob.wibble -------------------------------------------------------------------------------- (source_file - (package_definition - (identifier) - (identifier))) + (package_declaration + (qualified_name + (identifier) + (identifier)))) diff --git a/test/corpus/shebang.txt b/test/corpus/shebang.txt index 5615067..d4e2765 100644 --- a/test/corpus/shebang.txt +++ b/test/corpus/shebang.txt @@ -6,11 +6,10 @@ hello -------------------------------------------------------------------------------- (source_file - (script_part - (statement - (expression - (path_expression - (identifier)))))) + (statement + (expression + (qualified_name + (identifier))))) ================================================================================ Shebang not ignored after first character @@ -20,14 +19,14 @@ Shebang not ignored after first character (source_file (ERROR - (UNEXPECTED '#') - (identifier) + (UNEXPECTED '#')) + (statement + (expression + (qualified_name + (identifier)))) + (ERROR (UNEXPECTED '/') (identifier) (UNEXPECTED '/') - (identifier)) - (script_part - (statement - (expression - (path_expression - (identifier)))))) + (identifier) + (identifier))) diff --git a/test/corpus/statements.txt b/test/corpus/statements.txt index 1443cc2..a7feff8 100644 --- a/test/corpus/statements.txt +++ b/test/corpus/statements.txt @@ -13,11 +13,10 @@ hello -------------------------------------------------------------------------------- (source_file - (script_part - (statement - (expression - (path_expression - (identifier)))))) + (statement + (expression + (qualified_name + (identifier))))) ================================================================================ statement - Simple method definition @@ -26,9 +25,8 @@ def hello -------------------------------------------------------------------------------- (source_file - (script_part - (method_declaration - (identifier)))) + (method_declaration + (identifier))) ================================================================================ statement - Multiple statements same line @@ -37,19 +35,16 @@ hello;goodbye;def flunk -------------------------------------------------------------------------------- (source_file - (script_part - (statement - (expression - (path_expression - (identifier))))) - (script_part - (statement - (expression - (path_expression - (identifier))))) - (script_part - (method_declaration - (identifier)))) + (statement + (expression + (qualified_name + (identifier)))) + (statement + (expression + (qualified_name + (identifier)))) + (method_declaration + (identifier))) ================================================================================ statement - Multiple Statements, Multiple Lines @@ -60,19 +55,16 @@ goodbye; -------------------------------------------------------------------------------- (source_file - (script_part - (statement - (expression - (path_expression - (identifier))))) - (script_part - (method_declaration - (identifier))) - (script_part - (statement - (expression - (path_expression - (identifier)))))) + (statement + (expression + (qualified_name + (identifier)))) + (method_declaration + (identifier)) + (statement + (expression + (qualified_name + (identifier))))) ================================================================================ statement - path expression multiple parts @@ -81,10 +73,9 @@ wibble.wobble.q -------------------------------------------------------------------------------- (source_file - (script_part - (statement - (expression - (path_expression - (identifier) - (identifier) - (identifier)))))) + (statement + (expression + (qualified_name + (identifier) + (identifier) + (identifier)))))