From 12fba0f98b837d05350d1ded40db07f1f7f898a7 Mon Sep 17 00:00:00 2001 From: jansorg Date: Fri, 12 Feb 2021 12:59:27 +0100 Subject: [PATCH] Initial definition of lexer, parser, language, file type --- .editorconfig | 378 +++++ .run/Run Lexer Tests.run.xml | 24 + README.md | 24 + build.gradle.kts | 48 +- src/grammar/cue.bnf | 169 ++ src/grammar/cue.flex | 210 +++ .../dev/monogon/cue/lang/CueTypes.java | 222 +++ .../dev/monogon/cue/lang/lexer/_CueLexer.java | 993 ++++++++++++ .../monogon/cue/lang/parser/CueParser.java | 1378 +++++++++++++++++ .../monogon/cue/lang/psi/CueAliasExpr.java | 13 + .../dev/monogon/cue/lang/psi/CueArgument.java | 10 + .../monogon/cue/lang/psi/CueArguments.java | 13 + .../monogon/cue/lang/psi/CueAttrTokens.java | 13 + .../monogon/cue/lang/psi/CueAttribute.java | 13 + .../dev/monogon/cue/lang/psi/CueBasicLit.java | 13 + .../monogon/cue/lang/psi/CueBinaryExpr.java | 13 + .../dev/monogon/cue/lang/psi/CueClause.java | 16 + .../dev/monogon/cue/lang/psi/CueClauses.java | 16 + .../cue/lang/psi/CueComprehension.java | 16 + .../monogon/cue/lang/psi/CueDeclaration.java | 16 + .../monogon/cue/lang/psi/CueElementList.java | 13 + .../dev/monogon/cue/lang/psi/CueEllipsis.java | 13 + .../monogon/cue/lang/psi/CueEmbedding.java | 16 + .../monogon/cue/lang/psi/CueExpression.java | 10 + .../dev/monogon/cue/lang/psi/CueField.java | 19 + .../monogon/cue/lang/psi/CueForClause.java | 13 + .../monogon/cue/lang/psi/CueGuardClause.java | 13 + .../monogon/cue/lang/psi/CueImportDecl.java | 13 + .../cue/lang/psi/CueImportLocation.java | 10 + .../monogon/cue/lang/psi/CueImportPath.java | 13 + .../monogon/cue/lang/psi/CueImportSpec.java | 13 + .../dev/monogon/cue/lang/psi/CueIndex.java | 13 + .../cue/lang/psi/CueInterpolation.java | 13 + .../dev/monogon/cue/lang/psi/CueLabel.java | 13 + .../monogon/cue/lang/psi/CueLabelExpr.java | 13 + .../monogon/cue/lang/psi/CueLetClause.java | 13 + .../dev/monogon/cue/lang/psi/CueListLit.java | 16 + .../dev/monogon/cue/lang/psi/CueLiteral.java | 10 + .../cue/lang/psi/CueMultilineBytesLit.java | 13 + .../cue/lang/psi/CueMultilineStringLit.java | 13 + .../dev/monogon/cue/lang/psi/CueOperand.java | 13 + .../monogon/cue/lang/psi/CueOperandName.java | 10 + .../cue/lang/psi/CuePackageClause.java | 10 + .../monogon/cue/lang/psi/CuePrimaryExpr.java | 13 + .../cue/lang/psi/CueQualifiedIdent.java | 10 + .../dev/monogon/cue/lang/psi/CueSelector.java | 13 + .../cue/lang/psi/CueSimpleBytesLit.java | 13 + .../cue/lang/psi/CueSimpleStringLit.java | 13 + .../monogon/cue/lang/psi/CueStartClause.java | 16 + .../monogon/cue/lang/psi/CueStructLit.java | 13 + .../monogon/cue/lang/psi/CueUnaryExpr.java | 13 + .../dev/monogon/cue/lang/psi/CueVisitor.java | 181 +++ .../cue/lang/psi/impl/CueAliasExprImpl.java | 36 + .../cue/lang/psi/impl/CueArgumentImpl.java | 30 + .../cue/lang/psi/impl/CueArgumentsImpl.java | 36 + .../cue/lang/psi/impl/CueAttrTokensImpl.java | 36 + .../cue/lang/psi/impl/CueAttributeImpl.java | 36 + .../cue/lang/psi/impl/CueBasicLitImpl.java | 36 + .../cue/lang/psi/impl/CueBinaryExprImpl.java | 36 + .../cue/lang/psi/impl/CueClauseImpl.java | 42 + .../cue/lang/psi/impl/CueClausesImpl.java | 42 + .../lang/psi/impl/CueComprehensionImpl.java | 42 + .../cue/lang/psi/impl/CueDeclarationImpl.java | 42 + .../cue/lang/psi/impl/CueElementListImpl.java | 36 + .../cue/lang/psi/impl/CueEllipsisImpl.java | 36 + .../cue/lang/psi/impl/CueEmbeddingImpl.java | 42 + .../cue/lang/psi/impl/CueExpressionImpl.java | 30 + .../cue/lang/psi/impl/CueFieldImpl.java | 48 + .../cue/lang/psi/impl/CueForClauseImpl.java | 36 + .../cue/lang/psi/impl/CueGuardClauseImpl.java | 36 + .../cue/lang/psi/impl/CueImportDeclImpl.java | 36 + .../lang/psi/impl/CueImportLocationImpl.java | 30 + .../cue/lang/psi/impl/CueImportPathImpl.java | 36 + .../cue/lang/psi/impl/CueImportSpecImpl.java | 36 + .../cue/lang/psi/impl/CueIndexImpl.java | 36 + .../lang/psi/impl/CueInterpolationImpl.java | 36 + .../cue/lang/psi/impl/CueLabelExprImpl.java | 36 + .../cue/lang/psi/impl/CueLabelImpl.java | 36 + .../cue/lang/psi/impl/CueLetClauseImpl.java | 36 + .../cue/lang/psi/impl/CueListLitImpl.java | 42 + .../cue/lang/psi/impl/CueLiteralImpl.java | 30 + .../psi/impl/CueMultilineBytesLitImpl.java | 36 + .../psi/impl/CueMultilineStringLitImpl.java | 36 + .../cue/lang/psi/impl/CueOperandImpl.java | 36 + .../cue/lang/psi/impl/CueOperandNameImpl.java | 30 + .../lang/psi/impl/CuePackageClauseImpl.java | 30 + .../cue/lang/psi/impl/CuePrimaryExprImpl.java | 36 + .../lang/psi/impl/CueQualifiedIdentImpl.java | 30 + .../cue/lang/psi/impl/CueSelectorImpl.java | 36 + .../lang/psi/impl/CueSimpleBytesLitImpl.java | 36 + .../lang/psi/impl/CueSimpleStringLitImpl.java | 36 + .../cue/lang/psi/impl/CueStartClauseImpl.java | 42 + .../cue/lang/psi/impl/CueStructLitImpl.java | 36 + .../cue/lang/psi/impl/CueUnaryExprImpl.java | 36 + src/main/java/dev/monogon/cue/Icons.java | 4 + src/main/java/dev/monogon/cue/Messages.java | 21 + .../dev/monogon/cue/lang/CueFileType.java | 40 + .../dev/monogon/cue/lang/CueLanguage.java | 19 + .../monogon/cue/lang/CueParserDefinition.java | 59 + .../dev/monogon/cue/lang/CueTokenType.java | 11 + .../dev/monogon/cue/lang/CueTokenTypes.java | 28 + .../highlighter/CueHighlightingColors.java | 29 + .../highlighter/CueSyntaxHighlighter.java | 53 + .../lang/lexer/CueCommaInsertingLexer.java | 79 + .../monogon/cue/lang/lexer/CueFlexLexer.java | 15 + .../cue/lang/lexer/CueMergingLexer.java | 22 + .../cue/lang/parser/CueParserUtil.java | 24 + .../cue/lang/psi/CueCompositeElement.java | 6 + .../cue/lang/psi/CueCompositeElementImpl.java | 11 + .../cue/lang/psi/CueCompositeElementType.java | 12 + .../dev/monogon/cue/lang/psi/CueFile.java | 19 + .../cue/lang/psi/CueFileElementType.java | 12 + src/main/resources/META-INF/plugin.xml | 9 +- .../resources/messages/cuelang.properties | 5 +- .../data/lang/cue/inserting_lexer/bool.cue | 2 + .../data/lang/cue/inserting_lexer/bool.txt | 5 + .../data/lang/cue/inserting_lexer/comment.cue | 2 + .../data/lang/cue/inserting_lexer/comment.txt | 11 + .../lang/cue/inserting_lexer/hello_world.cue | 3 + .../lang/cue/inserting_lexer/hello_world.txt | 9 + .../data/lang/cue/inserting_lexer/null.cue | 1 + .../data/lang/cue/inserting_lexer/null.txt | 2 + .../lang/cue/inserting_lexer/paren_single.cue | 2 + .../lang/cue/inserting_lexer/paren_single.txt | 12 + .../data/lang/cue/inserting_lexer/string.cue | 1 + .../data/lang/cue/inserting_lexer/string.txt | 4 + .../data/lang/cue/inserting_lexer/struct2.cue | 6 + .../data/lang/cue/inserting_lexer/struct2.txt | 26 + .../lang/cue/inserting_lexer/struct_paren.cue | 6 + .../lang/cue/inserting_lexer/struct_paren.txt | 29 + src/test/data/lang/cue/lexer/bool.cue | 2 + src/test/data/lang/cue/lexer/bool.txt | 3 + .../data/lang/cue/lexer/bytes_multiline.cue | 35 + .../data/lang/cue/lexer/bytes_multiline.txt | 291 ++++ src/test/data/lang/cue/lexer/comma.cue | 3 + src/test/data/lang/cue/lexer/comma.txt | 8 + src/test/data/lang/cue/lexer/comments.cue | 3 + src/test/data/lang/cue/lexer/comments.txt | 5 + .../data/lang/cue/lexer/decimal_literatls.cue | 9 + .../data/lang/cue/lexer/decimal_literatls.txt | 20 + src/test/data/lang/cue/lexer/identifiers.cue | 4 + src/test/data/lang/cue/lexer/identifiers.txt | 7 + src/test/data/lang/cue/lexer/integers.cue | 6 + src/test/data/lang/cue/lexer/integers.txt | 11 + .../data/lang/cue/lexer/interpolation.cue | 1 + .../data/lang/cue/lexer/interpolation.txt | 7 + src/test/data/lang/cue/lexer/keywords.cue | 13 + src/test/data/lang/cue/lexer/keywords.txt | 25 + src/test/data/lang/cue/lexer/misc.cue | 3 + src/test/data/lang/cue/lexer/misc.txt | 7 + src/test/data/lang/cue/lexer/null.cue | 1 + src/test/data/lang/cue/lexer/null.txt | 1 + src/test/data/lang/cue/lexer/operators.cue | 34 + src/test/data/lang/cue/lexer/operators.txt | 67 + src/test/data/lang/cue/lexer/string.cue | 1 + src/test/data/lang/cue/lexer/string.txt | 8 + src/test/data/lang/cue/lexer/strings.cue | 24 + src/test/data/lang/cue/lexer/strings.txt | 427 +++++ .../data/lang/cue/lexer/strings_multiline.cue | 25 + .../data/lang/cue/lexer/strings_multiline.txt | 252 +++ src/test/data/lang/cue/lexer/struct_paren.cue | 6 + src/test/data/lang/cue/lexer/struct_paren.txt | 26 + src/test/data/lang/cue/lexer/whitespace.cue | 2 + src/test/data/lang/cue/lexer/whitespace.txt | 15 + .../data/lang/cue/merging_lexer/string.cue | 7 + .../data/lang/cue/merging_lexer/string.txt | 21 + .../data/lang/cue/merging_lexer/struct.cue | 5 + .../data/lang/cue/merging_lexer/struct.txt | 16 + src/test/data/lang/cue/parser/empty_file.cue | 0 src/test/data/lang/cue/parser/empty_file.txt | 2 + src/test/data/lang/cue/parser/hello_world.cue | 3 + src/test/data/lang/cue/parser/hello_world.txt | 11 + .../data/lang/cue/parser/interpolation.cue | 1 + .../data/lang/cue/parser/interpolation.txt | 12 + src/test/data/lang/cue/parser/package.cue | 1 + src/test/data/lang/cue/parser/package.txt | 5 + src/test/data/lang/cue/parser/sort.cue | 48 + src/test/data/lang/cue/parser/sort.txt | 253 +++ src/test/data/lang/cue/parser/string.cue | 1 + src/test/data/lang/cue/parser/string.txt | 6 + src/test/data/lang/cue/parser/struct1.cue | 5 + src/test/data/lang/cue/parser/struct1.txt | 26 + src/test/data/lang/cue/parser/struct2.cue | 6 + src/test/data/lang/cue/parser/struct2.txt | 36 + src/test/data/lang/cue/parser/struct3.cue | 8 + src/test/data/lang/cue/parser/struct3.txt | 57 + src/test/data/lang/cue/parser/struct4.cue | 6 + src/test/data/lang/cue/parser/struct4.txt | 37 + src/test/data/lang/cue/parser/struct5.cue | 6 + src/test/data/lang/cue/parser/struct5.txt | 31 + src/test/data/lang/cue/parser/struct6.cue | 6 + src/test/data/lang/cue/parser/struct6.txt | 40 + src/test/data/psi/highlighting/helloWorld.cue | 3 + .../java/dev/monogon/cue/CueLightTest.java | 16 + src/test/java/dev/monogon/cue/CueTests.java | 66 + .../highlighter/CueSyntaxHighlighterTest.java | 19 + .../lexer/CueCommaInsertingLexerTest.java | 51 + .../cue/lang/lexer/CueFlexLexerTest.java | 51 + .../cue/lang/lexer/CueMergingLexerTest.java | 51 + .../cue/lang/parser/CueParserTest.java | 51 + src/test/resources/testMarker.txt | 0 201 files changed, 8591 insertions(+), 27 deletions(-) create mode 100644 .editorconfig create mode 100644 .run/Run Lexer Tests.run.xml create mode 100644 src/grammar/cue.bnf create mode 100644 src/grammar/cue.flex create mode 100644 src/main/java-gen/dev/monogon/cue/lang/CueTypes.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/lexer/_CueLexer.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/parser/CueParser.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueAliasExpr.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueArgument.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueArguments.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueAttrTokens.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueAttribute.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueBasicLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueBinaryExpr.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueClauses.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueComprehension.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueDeclaration.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueElementList.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueEllipsis.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueEmbedding.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueExpression.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueField.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueForClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueGuardClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueImportDecl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueImportLocation.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueImportPath.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueImportSpec.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueIndex.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueInterpolation.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueLabel.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueLabelExpr.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueLetClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueListLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueLiteral.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueMultilineBytesLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueMultilineStringLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueOperand.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueOperandName.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CuePackageClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CuePrimaryExpr.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueQualifiedIdent.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueSelector.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueSimpleBytesLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueSimpleStringLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueStartClause.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueStructLit.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueUnaryExpr.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/CueVisitor.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueAliasExprImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueArgumentImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueArgumentsImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueAttrTokensImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueAttributeImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueBasicLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueBinaryExprImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueClausesImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueComprehensionImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueDeclarationImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueElementListImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueEllipsisImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueEmbeddingImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueExpressionImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueFieldImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueForClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueGuardClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueImportDeclImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueImportLocationImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueImportPathImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueImportSpecImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueIndexImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueInterpolationImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueLabelExprImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueLabelImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueLetClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueListLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueLiteralImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueMultilineBytesLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueMultilineStringLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueOperandImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueOperandNameImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CuePackageClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CuePrimaryExprImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueQualifiedIdentImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueSelectorImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueSimpleBytesLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueSimpleStringLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueStartClauseImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueStructLitImpl.java create mode 100644 src/main/java-gen/dev/monogon/cue/lang/psi/impl/CueUnaryExprImpl.java create mode 100644 src/main/java/dev/monogon/cue/Icons.java create mode 100644 src/main/java/dev/monogon/cue/Messages.java create mode 100644 src/main/java/dev/monogon/cue/lang/CueFileType.java create mode 100644 src/main/java/dev/monogon/cue/lang/CueLanguage.java create mode 100644 src/main/java/dev/monogon/cue/lang/CueParserDefinition.java create mode 100644 src/main/java/dev/monogon/cue/lang/CueTokenType.java create mode 100644 src/main/java/dev/monogon/cue/lang/CueTokenTypes.java create mode 100644 src/main/java/dev/monogon/cue/lang/highlighter/CueHighlightingColors.java create mode 100644 src/main/java/dev/monogon/cue/lang/highlighter/CueSyntaxHighlighter.java create mode 100644 src/main/java/dev/monogon/cue/lang/lexer/CueCommaInsertingLexer.java create mode 100644 src/main/java/dev/monogon/cue/lang/lexer/CueFlexLexer.java create mode 100644 src/main/java/dev/monogon/cue/lang/lexer/CueMergingLexer.java create mode 100644 src/main/java/dev/monogon/cue/lang/parser/CueParserUtil.java create mode 100644 src/main/java/dev/monogon/cue/lang/psi/CueCompositeElement.java create mode 100644 src/main/java/dev/monogon/cue/lang/psi/CueCompositeElementImpl.java create mode 100644 src/main/java/dev/monogon/cue/lang/psi/CueCompositeElementType.java create mode 100644 src/main/java/dev/monogon/cue/lang/psi/CueFile.java create mode 100644 src/main/java/dev/monogon/cue/lang/psi/CueFileElementType.java create mode 100644 src/test/data/lang/cue/inserting_lexer/bool.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/bool.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/comment.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/comment.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/hello_world.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/hello_world.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/null.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/null.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/paren_single.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/paren_single.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/string.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/string.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/struct2.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/struct2.txt create mode 100644 src/test/data/lang/cue/inserting_lexer/struct_paren.cue create mode 100644 src/test/data/lang/cue/inserting_lexer/struct_paren.txt create mode 100644 src/test/data/lang/cue/lexer/bool.cue create mode 100644 src/test/data/lang/cue/lexer/bool.txt create mode 100644 src/test/data/lang/cue/lexer/bytes_multiline.cue create mode 100644 src/test/data/lang/cue/lexer/bytes_multiline.txt create mode 100644 src/test/data/lang/cue/lexer/comma.cue create mode 100644 src/test/data/lang/cue/lexer/comma.txt create mode 100644 src/test/data/lang/cue/lexer/comments.cue create mode 100644 src/test/data/lang/cue/lexer/comments.txt create mode 100644 src/test/data/lang/cue/lexer/decimal_literatls.cue create mode 100644 src/test/data/lang/cue/lexer/decimal_literatls.txt create mode 100644 src/test/data/lang/cue/lexer/identifiers.cue create mode 100644 src/test/data/lang/cue/lexer/identifiers.txt create mode 100644 src/test/data/lang/cue/lexer/integers.cue create mode 100644 src/test/data/lang/cue/lexer/integers.txt create mode 100644 src/test/data/lang/cue/lexer/interpolation.cue create mode 100644 src/test/data/lang/cue/lexer/interpolation.txt create mode 100644 src/test/data/lang/cue/lexer/keywords.cue create mode 100644 src/test/data/lang/cue/lexer/keywords.txt create mode 100644 src/test/data/lang/cue/lexer/misc.cue create mode 100644 src/test/data/lang/cue/lexer/misc.txt create mode 100644 src/test/data/lang/cue/lexer/null.cue create mode 100644 src/test/data/lang/cue/lexer/null.txt create mode 100644 src/test/data/lang/cue/lexer/operators.cue create mode 100644 src/test/data/lang/cue/lexer/operators.txt create mode 100644 src/test/data/lang/cue/lexer/string.cue create mode 100644 src/test/data/lang/cue/lexer/string.txt create mode 100644 src/test/data/lang/cue/lexer/strings.cue create mode 100644 src/test/data/lang/cue/lexer/strings.txt create mode 100644 src/test/data/lang/cue/lexer/strings_multiline.cue create mode 100644 src/test/data/lang/cue/lexer/strings_multiline.txt create mode 100644 src/test/data/lang/cue/lexer/struct_paren.cue create mode 100644 src/test/data/lang/cue/lexer/struct_paren.txt create mode 100644 src/test/data/lang/cue/lexer/whitespace.cue create mode 100644 src/test/data/lang/cue/lexer/whitespace.txt create mode 100644 src/test/data/lang/cue/merging_lexer/string.cue create mode 100644 src/test/data/lang/cue/merging_lexer/string.txt create mode 100644 src/test/data/lang/cue/merging_lexer/struct.cue create mode 100644 src/test/data/lang/cue/merging_lexer/struct.txt create mode 100644 src/test/data/lang/cue/parser/empty_file.cue create mode 100644 src/test/data/lang/cue/parser/empty_file.txt create mode 100644 src/test/data/lang/cue/parser/hello_world.cue create mode 100644 src/test/data/lang/cue/parser/hello_world.txt create mode 100644 src/test/data/lang/cue/parser/interpolation.cue create mode 100644 src/test/data/lang/cue/parser/interpolation.txt create mode 100644 src/test/data/lang/cue/parser/package.cue create mode 100644 src/test/data/lang/cue/parser/package.txt create mode 100644 src/test/data/lang/cue/parser/sort.cue create mode 100644 src/test/data/lang/cue/parser/sort.txt create mode 100644 src/test/data/lang/cue/parser/string.cue create mode 100644 src/test/data/lang/cue/parser/string.txt create mode 100644 src/test/data/lang/cue/parser/struct1.cue create mode 100644 src/test/data/lang/cue/parser/struct1.txt create mode 100644 src/test/data/lang/cue/parser/struct2.cue create mode 100644 src/test/data/lang/cue/parser/struct2.txt create mode 100644 src/test/data/lang/cue/parser/struct3.cue create mode 100644 src/test/data/lang/cue/parser/struct3.txt create mode 100644 src/test/data/lang/cue/parser/struct4.cue create mode 100644 src/test/data/lang/cue/parser/struct4.txt create mode 100644 src/test/data/lang/cue/parser/struct5.cue create mode 100644 src/test/data/lang/cue/parser/struct5.txt create mode 100644 src/test/data/lang/cue/parser/struct6.cue create mode 100644 src/test/data/lang/cue/parser/struct6.txt create mode 100644 src/test/data/psi/highlighting/helloWorld.cue create mode 100644 src/test/java/dev/monogon/cue/CueLightTest.java create mode 100644 src/test/java/dev/monogon/cue/CueTests.java create mode 100644 src/test/java/dev/monogon/cue/lang/highlighter/CueSyntaxHighlighterTest.java create mode 100644 src/test/java/dev/monogon/cue/lang/lexer/CueCommaInsertingLexerTest.java create mode 100644 src/test/java/dev/monogon/cue/lang/lexer/CueFlexLexerTest.java create mode 100644 src/test/java/dev/monogon/cue/lang/lexer/CueMergingLexerTest.java create mode 100644 src/test/java/dev/monogon/cue/lang/parser/CueParserTest.java create mode 100644 src/test/resources/testMarker.txt diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1075d6f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,378 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 140 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.java] +indent_size = 4 +tab_width = 8 +ij_continuation_indent_size = 4 +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = true +ij_java_align_multiline_binary_operation = true +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_extends_list = true +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = true +ij_java_align_multiline_parenthesized_expression = true +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = true +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = true +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = normal +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = normal +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = on_every_item +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_at_first_column = false +ij_java_builder_methods = none +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = normal +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = true +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_names_in_javadoc = 1 +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_while_brace_force = if_multiline +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = true +ij_java_enum_constants_wrap = off +ij_java_extends_keyword_wrap = normal +ij_java_extends_list_wrap = normal +ij_java_field_annotation_wrap = off +ij_java_field_name_prefix = my +ij_java_finally_on_new_line = true +ij_java_for_brace_force = if_multiline +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = on_every_item +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = if_multiline +ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 0 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = false +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = true +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_at_first_column = false +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = normal +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = on_every_item +ij_java_modifier_list_wrap = false +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_record_header = false +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.tools.**, javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = false +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_record_header = false +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = false +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = true +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_static_field_name_prefix = our +ij_java_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = true +ij_java_ternary_operation_wrap = on_every_item +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = normal +ij_java_throws_list_wrap = on_every_item +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = EscalateVisible +ij_java_while_brace_force = if_multiline +ij_java_while_on_new_line = true +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.gradle.kts, *.kt, *.kts, *.main.kts, *.space.kts}] +ij_continuation_indent_size = 4 +ij_kotlin_align_in_columns_case_branch = false +ij_kotlin_align_multiline_binary_operation = false +ij_kotlin_align_multiline_extends_list = false +ij_kotlin_align_multiline_method_parentheses = false +ij_kotlin_align_multiline_parameters = true +ij_kotlin_align_multiline_parameters_in_calls = false +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_assignment_wrap = normal +ij_kotlin_blank_lines_after_class_header = 0 +ij_kotlin_blank_lines_around_block_when_branches = 0 +ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 +ij_kotlin_block_comment_at_first_column = true +ij_kotlin_call_parameters_new_line_after_left_paren = true +ij_kotlin_call_parameters_right_paren_on_new_line = true +ij_kotlin_call_parameters_wrap = on_every_item +ij_kotlin_catch_on_new_line = false +ij_kotlin_class_annotation_wrap = split_into_lines +ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL +ij_kotlin_continuation_indent_for_chained_calls = false +ij_kotlin_continuation_indent_for_expression_bodies = false +ij_kotlin_continuation_indent_in_argument_lists = false +ij_kotlin_continuation_indent_in_elvis = false +ij_kotlin_continuation_indent_in_if_conditions = false +ij_kotlin_continuation_indent_in_parameter_lists = false +ij_kotlin_continuation_indent_in_supertype_lists = false +ij_kotlin_else_on_new_line = false +ij_kotlin_enum_constants_wrap = off +ij_kotlin_extends_list_wrap = normal +ij_kotlin_field_annotation_wrap = split_into_lines +ij_kotlin_finally_on_new_line = false +ij_kotlin_if_rparen_on_new_line = true +ij_kotlin_import_nested_classes = false +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ +ij_kotlin_insert_whitespaces_in_simple_one_line_method = true +ij_kotlin_keep_blank_lines_before_right_brace = 2 +ij_kotlin_keep_blank_lines_in_code = 2 +ij_kotlin_keep_blank_lines_in_declarations = 2 +ij_kotlin_keep_first_column_comment = false +ij_kotlin_keep_indents_on_empty_lines = false +ij_kotlin_keep_line_breaks = false +ij_kotlin_lbrace_on_next_line = false +ij_kotlin_line_comment_add_space = false +ij_kotlin_line_comment_at_first_column = false +ij_kotlin_method_annotation_wrap = split_into_lines +ij_kotlin_method_call_chain_wrap = normal +ij_kotlin_method_parameters_new_line_after_left_paren = true +ij_kotlin_method_parameters_right_paren_on_new_line = true +ij_kotlin_method_parameters_wrap = on_every_item +ij_kotlin_name_count_to_use_star_import = 2147483647 +ij_kotlin_name_count_to_use_star_import_for_members = 2147483647 +ij_kotlin_packages_to_use_import_on_demand = java.util.*, com.intellij.ui.layout.**, kotlinx.android.synthetic.** +ij_kotlin_parameter_annotation_wrap = off +ij_kotlin_space_after_comma = true +ij_kotlin_space_after_extend_colon = true +ij_kotlin_space_after_type_colon = true +ij_kotlin_space_before_catch_parentheses = true +ij_kotlin_space_before_comma = false +ij_kotlin_space_before_extend_colon = true +ij_kotlin_space_before_for_parentheses = true +ij_kotlin_space_before_if_parentheses = true +ij_kotlin_space_before_lambda_arrow = true +ij_kotlin_space_before_type_colon = false +ij_kotlin_space_before_when_parentheses = true +ij_kotlin_space_before_while_parentheses = true +ij_kotlin_spaces_around_additive_operators = true +ij_kotlin_spaces_around_assignment_operators = true +ij_kotlin_spaces_around_equality_operators = true +ij_kotlin_spaces_around_function_type_arrow = true +ij_kotlin_spaces_around_logical_operators = true +ij_kotlin_spaces_around_multiplicative_operators = true +ij_kotlin_spaces_around_range = false +ij_kotlin_spaces_around_relational_operators = true +ij_kotlin_spaces_around_unary_operator = false +ij_kotlin_spaces_around_when_arrow = true +ij_kotlin_variable_annotation_wrap = off +ij_kotlin_while_on_new_line = false +ij_kotlin_wrap_elvis_expressions = 1 +ij_kotlin_wrap_expression_body_functions = 1 +ij_kotlin_wrap_first_method_in_call_chain = false + +[{*.markdown, *.md}] +indent_size = 4 +tab_width = 4 +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 + +[{*.yaml, *.yml}] +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/.run/Run Lexer Tests.run.xml b/.run/Run Lexer Tests.run.xml new file mode 100644 index 0000000..f7b3068 --- /dev/null +++ b/.run/Run Lexer Tests.run.xml @@ -0,0 +1,24 @@ + + + + + + + false + true + false + + + \ No newline at end of file diff --git a/README.md b/README.md index 701e4eb..09d0463 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,30 @@ **CUE Language** support for the IntelliJ platform. +## Development +### IDE +Development is best in IntelliJ IDEA. + +The following plugins are required for development: + +- [GrammarKit 2020.3.1](https://plugins.jetbrains.com/plugin/6606-grammar-kit) +- Gradle +- Kotlin, for Gradle build file support + +### Lexer +The lexer is generated by JFlex. The definition is at `src/grammar/cue.flex`. + +The following command regenerates the lexer: +```bash +./gradlew generateLexer +``` +### Parser +The parser is generated with JetBrains' GrammarKit. GrammarKit is a plugin for IntelliJ IDEA. +The definition is at `src/grammar/cue.bnf`. + +To update the parser and all related classes, open the `cue.bnf` file in your IDE and choose `Generate Parser` in the context menu of the editor. + ## Useful Link + - [CUE Website](https://cuelang.org/) - [The CUE Language Specification](https://cuelang.org/docs/references/spec/) \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 549f766..4e38445 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,15 @@ import org.jetbrains.changelog.closure import org.jetbrains.changelog.markdownToHTML -plugins { - // Java support - id("java") - // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin - id("org.jetbrains.intellij") version "0.6.5" - // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +plugins { // Java support + id("java") // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin + id("org.jetbrains.intellij") version "0.6.5" // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin id("org.jetbrains.changelog") version "1.1.1" + id("org.jetbrains.grammarkit") version "2020.3.2" } // Import variables from gradle.properties file -val pluginGroup: String by project -// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure. -// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29 +val pluginGroup: String by project // `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure. // Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29 val pluginName_: String by project val pluginVersion: String by project val pluginSinceBuild: String by project @@ -34,6 +30,11 @@ repositories { jcenter() } +// setup additional source folders +sourceSets.main { + java.srcDir("src/main/java-gen") +} + // Configure gradle-intellij-plugin plugin. // Read more: https://github.com/JetBrains/gradle-intellij-plugin intellij { @@ -53,8 +54,7 @@ changelog { version = pluginVersion } -tasks { - // disable building searchable options to speed up build, we currently don't settings UI +tasks { // disable building searchable options to speed up build, we currently don't settings UI buildSearchableOptions { enabled = false } @@ -71,18 +71,14 @@ tasks { untilBuild(pluginUntilBuild) // Extract the section from README.md and provide for the plugin's manifest - pluginDescription( - closure { - File("./plugin-description.md").readText().run { markdownToHTML(this) } - } - ) + pluginDescription(closure { + File("./plugin-description.md").readText().run { markdownToHTML(this) } + }) // Get the latest available change notes from the changelog file - changeNotes( - closure { - changelog.getLatest().toHTML() - } - ) + changeNotes(closure { + changelog.getLatest().toHTML() + }) } runPluginVerifier { @@ -91,10 +87,16 @@ tasks { publishPlugin { dependsOn("patchChangelog") - token(System.getenv("PUBLISH_TOKEN")) - // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 + token(System.getenv("PUBLISH_TOKEN")) // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel channels(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first()) } } + +tasks.register("generateLexer") { + source = "src/grammar/cue.flex" + targetDir = "src/main/java-gen/dev/monogon/cue/lang/lexer" + targetClass = "_CueLexerGen" + purgeOldFiles = true +} diff --git a/src/grammar/cue.bnf b/src/grammar/cue.bnf new file mode 100644 index 0000000..93406d9 --- /dev/null +++ b/src/grammar/cue.bnf @@ -0,0 +1,169 @@ +/* +GrammarKit BNF grammar for CUE. +It tries to remain as close as possible to the original grammar. +Please not the following important differences: +- CUE has ":" to start a rule, GrammarKit has "::=" +- in CUE's grammar {a} means 0 or more "a", but in GrammarKit {} it's just a grouping element. + GrammarKit's most-similar equivalent: {}* +- GrammarKit doesn't support left-recursive rules + */ + +{ + generate=[java="8"] + consumeTokenMethod(".*")="consumeTokenFast" + generateTokenAccessors=false + + parserClass="dev.monogon.cue.lang.parser.CueParser" + parserUtilClass="dev.monogon.cue.lang.parser.CueParserUtil" + + tokenTypeClass="dev.monogon.cue.lang.CueTokenType" + elementTypeHolderClass="dev.monogon.cue.lang.CueTypes" + elementTypeClass="dev.monogon.cue.lang.psi.CueCompositeElementType" + + implements="dev.monogon.cue.lang.psi.CueCompositeElement" + extends="dev.monogon.cue.lang.psi.CueCompositeElementImpl" + + psiClassPrefix="Cue" + psiImplClassSuffix="Impl" + psiPackage="dev.monogon.cue.lang.psi" + psiImplPackage="dev.monogon.cue.lang.psi.impl" + + tokens=[ + NEWLINE = '\n' + + COMMA = ',' + IDENTIFIER = 'IDENTIFIER' + INT_LIT = 'INT_LIT' + FLOAT_LIT = 'FLOAT_LIT' + NULL_LIT = 'NULL_LIT' + BOOL_LIT = 'BOOL_LIT' + KEYWORD = "KEYWORD" + + REL_OP = "REL_OP" + ADD_OP = "ADD_OP" + MUL_OP = "MUL_OP" + PIPE = "|" + AMP = "&" + PIPE_PIPE = "||" + AMP_AMP = "&&" + EQ_EQ = "==" + OPERATOR = "OPERATOR" + + // we're using _END tokens for string terminating tokens, + // because CueCommaInsertingLexer needs to know where string literals end + SINGLE_QUOTE = "SINGLE_QUOTE" + SINGLE_QUOTE_END = "SINGLE_QUOTE_END" + DOUBLE_QUOTE = "DOUBLE_QUOTE" + DOUBLE_QUOTE_END = "DOUBLE_QUOTE_END" + UNICODE_VALUE = "UNICODE_VALUE" + BYTE_VALUE = "BYTE_VALUE" + MULTILINE_STRING_START = "\"\"\"" + MULTILINE_STRING_END = "\"\"\"" + MULTILINE_BYTES_START = "'''" + MULTILINE_BYTES_END = "'''" + + INTERPOLATION_START = "\\(" + INTERPOLATION_END = ")" + + LEFT_CURLY="{" + RIGHT_CURLY="}" + COLON=":" + ELLIPSIS_TOKEN="..." + EQ="=" + QMARK="?" + LEFT_BRACKET="[" + RIGHT_BRACKET="]" + AT="@" + LEFT_PAREN="(" + RIGHT_PAREN=")" + ] +} + +// https://cuelang.org/docs/references/spec/#source-file-organization +private file ::= [ PackageClause "," ] { ImportDecl "," }* { Declaration "," }* +PackageClause ::= "package" PackageName +private PackageName ::= IDENTIFIER + +ImportDecl ::= "import" ( ImportSpec | "(" { ImportSpec "," }* ")" ) +ImportSpec ::= [ PackageName ] ImportPath +ImportLocation ::= { UNICODE_VALUE }* +ImportPath ::= "\"" ImportLocation [ ":" IDENTIFIER ] "\"" + +simple_string_lit ::= DOUBLE_QUOTE { UNICODE_VALUE | interpolation }* DOUBLE_QUOTE_END {extends=Literal} +simple_bytes_lit ::= SINGLE_QUOTE { UNICODE_VALUE | interpolation }* SINGLE_QUOTE_END {extends=Literal} +// fixme it might be good to keep escaped chars as tokens, not just UNICODE_VALUE, for highlighting and error reporting +multiline_string_lit ::= MULTILINE_STRING_START NEWLINE { UNICODE_VALUE | interpolation | NEWLINE }* NEWLINE* MULTILINE_STRING_END {extends=Literal} +// fixme it might be good to keep escaped chars as tokens, not just UNICODE_VALUE, for highlighting and error reporting +multiline_bytes_lit ::= MULTILINE_BYTES_START NEWLINE { UNICODE_VALUE | BYTE_VALUE | interpolation | NEWLINE }* NEWLINE* MULTILINE_BYTES_END {extends=Literal} + +interpolation ::= INTERPOLATION_START Expression INTERPOLATION_END + +private string_lit ::= simple_string_lit + | multiline_string_lit + | simple_bytes_lit + | multiline_bytes_lit + | "#" string_lit "#" + +// https://cuelang.org/docs/references/spec/#structs +StructLit ::= "{" { Declaration "," }* "}" {extends=Literal} +Declaration ::= Field | Ellipsis | Embedding | LetClause | attribute +Ellipsis ::= "..." [ Expression ] {extends=Declaration} +Embedding ::= Comprehension | AliasExpr {extends=Declaration} +Field ::= Label ":" { Label ":" }* Expression { attribute }* {extends=Declaration} +Label ::= [ IDENTIFIER "=" ] LabelExpr +LabelExpr ::= LabelName [ "?" ] | "[" AliasExpr "]" +private LabelName ::= IDENTIFIER | simple_string_lit + +attribute ::= "@" IDENTIFIER "(" attr_tokens ")" +attr_tokens ::= { <> // fixme psi element for attr_token? + | "(" attr_tokens ")" + | "[" attr_tokens "]" + | "{" attr_tokens "}" + }* + +// https://cuelang.org/docs/references/spec/#attributes +AliasExpr ::= Expression | IDENTIFIER "=" Expression { extends=Expression } + +// fixme added closing ] at the end, bug in grammar +ListLit ::= "[" [ ElementList [ "," [ Ellipsis ] ] [ "," ] ] "]" {extends=Literal} +ElementList ::= Embedding { "," Embedding }* + +// https://cuelang.org/docs/references/spec/#expressions +Operand ::= Literal | OperandName | "(" Expression ")" {extends=PrimaryExpr} +Literal ::= BasicLit | ListLit | StructLit {extends=Operand} +BasicLit ::= INT_LIT | FLOAT_LIT | string_lit | NULL_LIT | BOOL_LIT | BOTTOM_LIT | TOP_LIT {extends=Literal} +OperandName ::= IDENTIFIER | QualifiedIdent {extends=Operand} + +QualifiedIdent ::= PackageName "." IDENTIFIER {extends=Operand} + +// https://cuelang.org/docs/references/spec/#primary-expressions +//PrimaryExpr ::= Operand | PrimaryExpr Selector | PrimaryExpr Index | PrimaryExpr Slice | PrimaryExpr Arguments +// fixme this is a simple rewrite as non-left-recursive for now +PrimaryExpr ::= Operand {Selector | Index | Slice | Arguments}* {extends=Expression} + +Selector ::= "." (IDENTIFIER | simple_string_lit) {extends=PrimaryExpr} +Index ::= "[" Expression "]" {extends=PrimaryExpr} +Argument ::= Expression {extends=PrimaryExpr} +Arguments ::= "(" [ ( Argument { "," Argument }* ) [ "," ] ] ")" {extends=PrimaryExpr} +// fixme Slice is missing + +// https://cuelang.org/docs/references/spec/#operators +Expression ::= UnaryExpr | BinaryExpr // fixme extra root? +UnaryExpr ::= PrimaryExpr | unary_op UnaryExpr { extends=Expression } +BinaryExpr ::= Expression binary_op Expression { extends=Expression } + +private binary_op ::= PIPE | AMP | PIPE_PIPE | AMP_AMP | EQ_EQ | rel_op | add_op | mul_op //"|" | "&" | "||" | "&&" | "==" | rel_op | add_op | mul_op +private rel_op ::= REL_OP //"!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" +private add_op ::= ADD_OP //"+" | "-" +private mul_op ::= MUL_OP //"*" | "/" | "div" | "mod" | "quo" | "rem" +private unary_op ::= ADD_OP | "!" | "*" | rel_op // "+" | "-" | "!" | "*" | rel_op + +// https://cuelang.org/docs/references/spec/#comprehensions +Comprehension ::= Clauses StructLit + +Clauses ::= StartClause { [ "," ] Clause }* +StartClause ::= ForClause | GuardClause +Clause ::= StartClause | LetClause +ForClause ::= "for" IDENTIFIER [ "," IDENTIFIER ] "in" Expression +GuardClause ::= "if" Expression +LetClause ::= "let" IDENTIFIER "=" Expression \ No newline at end of file diff --git a/src/grammar/cue.flex b/src/grammar/cue.flex new file mode 100644 index 0000000..eb3b36e --- /dev/null +++ b/src/grammar/cue.flex @@ -0,0 +1,210 @@ +package dev.monogon.cue.lang.lexer; + +import com.intellij.lexer.FlexLexer; +import com.intellij.psi.tree.IElementType; +import com.intellij.util.containers.IntStack; + +import static com.intellij.psi.TokenType.BAD_CHARACTER; +import static com.intellij.psi.TokenType.WHITE_SPACE; +import static dev.monogon.cue.lang.CueTypes.*; +import static dev.monogon.cue.lang.CueTokenTypes.*; + +%% + +%{ + public _CueLexer() { + this((java.io.Reader)null); + } + + private final IntStack stateStack = new IntStack(100); + + private void pushState(int state) { + int currentState = yystate(); + if (currentState == YYINITIAL && !stateStack.empty()) { + throw new IllegalStateException("Can't push initial state into the not empty stack"); + } + stateStack.push(currentState); + yybegin(state); + } + + private void popState() { + assert !stateStack.empty() : "States stack is empty"; + yybegin(stateStack.pop()); + } + + /** Called when an instance is reset, e.g. on incremental lexer restart */ + protected void onReset() { + stateStack.clear(); + } +%} + +%class _CueLexer +%implements FlexLexer +%unicode +%public +//%debug + +%function advance +%type IElementType + +// White space, formed from spaces (U+0020), horizontal tabs (U+0009), carriage returns (U+000D), and newlines (U+000A) +// IntelliJ: tokenizing newlines, which are whitespace, as separate tokens to simplify out CueCommaInsertingLexer +WHITE_SPACE=[ \t\r] +WHITE_SPACE_NEWLINE=[\n] + +// https://cuelang.org/docs/references/spec/#characters +newline = \n /* the Unicode code point U+000A */ +unicode_char = [^\n] /* an arbitrary Unicode code point except newline */ +unicode_letter = [\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}] /* a Unicode code point classified as "Letter" */ +unicode_digit = [\p{Nd}] /* a Unicode code point classified as "Number, decimal digit" */ + +// https://cuelang.org/docs/references/spec/#letters-and-digits +letter = [_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}] // _ plus {unicode_letter} +decimal_digit = [0-9] +octal_digit = [0-7] +hex_digit = [0-9A-Fa-f] +binary_digit = [01] +letter_digit = [_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nd}] // extension: letter or digit + +// https://cuelang.org/docs/references/spec/#commas +comma = [,] + +// https://cuelang.org/docs/references/spec/#identifiers +identifier = ("#" | "_#")? {letter} {letter_digit}* + +// https://cuelang.org/docs/references/spec/#letters-and-digits +decimal_lit = [1-9] ("_"? {decimal_digit})* +decimals = {decimal_digit} ("_"? {decimal_digit})* +si_lit = {decimals} ("." {decimals})? {multiplier} + | "." {decimals} {multiplier} +binary_lit = "0b" {binary_digit} ("_"? {binary_digit})* +hex_lit = "0" [xX] {hex_digit} ("_"? {hex_digit})* +octal_lit = "0o" {octal_digit} ("_"? {octal_digit})* +multiplier = [KMGTP] "i"? + +// https://cuelang.org/docs/references/spec/#decimal-floating-point-literals +// fixme the grammar has "decimal_lit", but that's already defined above +float_lit = {decimals} "." {decimals}? {exponent}? + | {decimals} {exponent} + | "." {decimals} {exponent}? +exponent = [eE] [+-]? {decimals} + +// https://cuelang.org/docs/references/spec/#null +null_lit = "null" + +// fixme undefined in spec +bool_lit = "true" | "false" + +// https://cuelang.org/docs/references/spec/#keywords +keyword_preamble = "package" | "import" +keyword_comprehensions = "for" | "in" | "if" | "let" +//keyword_arithmetic = "div" | "mod" | "quo" | "rem" + +// https://cuelang.org/docs/references/spec/#operators-and-punctuation +// most operators are matched below +operators = "?" | "!" + | "_|_" + | "." + +// https://cuelang.org/docs/references/spec/#string-and-byte-sequence-literals +escaped_char = "\\" "#"* [abfnrtv/\\'\"] +byte_value = {octal_byte_value} | {hex_byte_value} +octal_byte_value = "\\" {octal_digit} {3} +hex_byte_value = "\\x" {hex_digit} {2} +little_u_value = "\\u" {hex_digit} {4} +big_u_value = "\\U" {hex_digit} {8} +unicode_value = {unicode_char} | {little_u_value} | {big_u_value} | {escaped_char} + +interpolation_start = "\\(" +interpolation_end = ")" + +%state STRING_LITERAL +%state STRING_MULTILINE +%state BYTE_LITERAL +%state BYTES_MULTILINE +%state EXPRESSION + +%% + { + "\"" { popState(); return DOUBLE_QUOTE_END; } +} + { + "'" { popState(); return SINGLE_QUOTE_END; } + {byte_value} { return BYTE_VALUE; } +} + { + // matching \n as newline token, because the closing triple-quote must come after it + {newline} { return NEWLINE; } + "\"\"\"" { popState(); return MULTILINE_STRING_END; } +} + { + // matching \n as newline token, because the closing triple-quote must come after it + {newline} { return NEWLINE; } + "'''" { popState(); return MULTILINE_BYTES_END; } +} + { + {interpolation_start} { pushState(EXPRESSION); return INTERPOLATION_START; } + // fixme decide if we want to lex whitespace in strings as unicode_value or whitespace, might be needed for in-string-content search and tokenizing + {unicode_value} { return UNICODE_VALUE; } +} + + { + {interpolation_end} { popState(); return INTERPOLATION_END; } +} + + { + {keyword_preamble} | + {keyword_comprehensions} + { return KEYWORD; } // for now, a single token + + {null_lit} { return NULL_LIT; } + {bool_lit} { return BOOL_LIT; } + +// operator tokens + "{" { return LEFT_CURLY; } + "}" { return RIGHT_CURLY; } + ":" { return COLON; } + "..." { return ELLIPSIS_TOKEN; } + "," { return COMMA; } + "=" { return EQ; } + "?" { return QMARK; } + "[" { return LEFT_BRACKET; } + "]" { return RIGHT_BRACKET; } + "@" { return AT; } + "(" { return LEFT_PAREN; } + ")" { return RIGHT_PAREN; } + + "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" + { return REL_OP; } + "+" | "-" + { return ADD_OP; } + "*" | "/" | "div" | "mod" | "quo" | "rem" + { return MUL_OP; } + "|" { return PIPE; } + "&" { return AMP; } + "||" { return PIPE_PIPE; } + "&&" { return AMP_AMP; } + "==" { return EQ_EQ; } + {operators} { return OPERATOR; } // for now, a single token +// end of operators + {identifier} { return IDENTIFIER; } + + {float_lit} { return FLOAT_LIT; } + {decimal_lit} + | {si_lit} + | {octal_lit} + | {binary_lit} + | {hex_lit} { return INT_LIT; } + + "\"" { pushState(STRING_LITERAL); return DOUBLE_QUOTE; } + "'" { pushState(BYTE_LITERAL); return SINGLE_QUOTE; } + "\"\"\"" / {newline} { pushState(STRING_MULTILINE); return MULTILINE_STRING_START; } + "'''" / {newline} { pushState(BYTES_MULTILINE); return MULTILINE_BYTES_START; } + + "//" {unicode_char}* { return COMMENT; } +} + +// all states +{WHITE_SPACE_NEWLINE} { return WHITE_SPACE_NEWLINE; } +{WHITE_SPACE} { return WHITE_SPACE; } +[^] { return BAD_CHARACTER; } diff --git a/src/main/java-gen/dev/monogon/cue/lang/CueTypes.java b/src/main/java-gen/dev/monogon/cue/lang/CueTypes.java new file mode 100644 index 0000000..defdbcf --- /dev/null +++ b/src/main/java-gen/dev/monogon/cue/lang/CueTypes.java @@ -0,0 +1,222 @@ +// This is a generated file. Not intended for manual editing. +package dev.monogon.cue.lang; + +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.PsiElement; +import com.intellij.lang.ASTNode; +import dev.monogon.cue.lang.psi.CueCompositeElementType; +import dev.monogon.cue.lang.psi.impl.*; + +public interface CueTypes { + + IElementType ALIAS_EXPR = new CueCompositeElementType("ALIAS_EXPR"); + IElementType ARGUMENT = new CueCompositeElementType("ARGUMENT"); + IElementType ARGUMENTS = new CueCompositeElementType("ARGUMENTS"); + IElementType ATTRIBUTE = new CueCompositeElementType("ATTRIBUTE"); + IElementType ATTR_TOKENS = new CueCompositeElementType("ATTR_TOKENS"); + IElementType BASIC_LIT = new CueCompositeElementType("BASIC_LIT"); + IElementType BINARY_EXPR = new CueCompositeElementType("BINARY_EXPR"); + IElementType CLAUSE = new CueCompositeElementType("CLAUSE"); + IElementType CLAUSES = new CueCompositeElementType("CLAUSES"); + IElementType COMPREHENSION = new CueCompositeElementType("COMPREHENSION"); + IElementType DECLARATION = new CueCompositeElementType("DECLARATION"); + IElementType ELEMENT_LIST = new CueCompositeElementType("ELEMENT_LIST"); + IElementType ELLIPSIS = new CueCompositeElementType("ELLIPSIS"); + IElementType EMBEDDING = new CueCompositeElementType("EMBEDDING"); + IElementType EXPRESSION = new CueCompositeElementType("EXPRESSION"); + IElementType FIELD = new CueCompositeElementType("FIELD"); + IElementType FOR_CLAUSE = new CueCompositeElementType("FOR_CLAUSE"); + IElementType GUARD_CLAUSE = new CueCompositeElementType("GUARD_CLAUSE"); + IElementType IMPORT_DECL = new CueCompositeElementType("IMPORT_DECL"); + IElementType IMPORT_LOCATION = new CueCompositeElementType("IMPORT_LOCATION"); + IElementType IMPORT_PATH = new CueCompositeElementType("IMPORT_PATH"); + IElementType IMPORT_SPEC = new CueCompositeElementType("IMPORT_SPEC"); + IElementType INDEX = new CueCompositeElementType("INDEX"); + IElementType INTERPOLATION = new CueCompositeElementType("INTERPOLATION"); + IElementType LABEL = new CueCompositeElementType("LABEL"); + IElementType LABEL_EXPR = new CueCompositeElementType("LABEL_EXPR"); + IElementType LET_CLAUSE = new CueCompositeElementType("LET_CLAUSE"); + IElementType LIST_LIT = new CueCompositeElementType("LIST_LIT"); + IElementType LITERAL = new CueCompositeElementType("LITERAL"); + IElementType MULTILINE_BYTES_LIT = new CueCompositeElementType("MULTILINE_BYTES_LIT"); + IElementType MULTILINE_STRING_LIT = new CueCompositeElementType("MULTILINE_STRING_LIT"); + IElementType OPERAND = new CueCompositeElementType("OPERAND"); + IElementType OPERAND_NAME = new CueCompositeElementType("OPERAND_NAME"); + IElementType PACKAGE_CLAUSE = new CueCompositeElementType("PACKAGE_CLAUSE"); + IElementType PRIMARY_EXPR = new CueCompositeElementType("PRIMARY_EXPR"); + IElementType QUALIFIED_IDENT = new CueCompositeElementType("QUALIFIED_IDENT"); + IElementType SELECTOR = new CueCompositeElementType("SELECTOR"); + IElementType SIMPLE_BYTES_LIT = new CueCompositeElementType("SIMPLE_BYTES_LIT"); + IElementType SIMPLE_STRING_LIT = new CueCompositeElementType("SIMPLE_STRING_LIT"); + IElementType START_CLAUSE = new CueCompositeElementType("START_CLAUSE"); + IElementType STRUCT_LIT = new CueCompositeElementType("STRUCT_LIT"); + IElementType UNARY_EXPR = new CueCompositeElementType("UNARY_EXPR"); + + IElementType ADD_OP = new CueTokenType("ADD_OP"); + IElementType AMP = new CueTokenType("&"); + IElementType AMP_AMP = new CueTokenType("&&"); + IElementType AT = new CueTokenType("@"); + IElementType BOOL_LIT = new CueTokenType("BOOL_LIT"); + IElementType BOTTOM_LIT = new CueTokenType("BOTTOM_LIT"); + IElementType BYTE_VALUE = new CueTokenType("BYTE_VALUE"); + IElementType COLON = new CueTokenType(":"); + IElementType COMMA = new CueTokenType(","); + IElementType DOUBLE_QUOTE = new CueTokenType("DOUBLE_QUOTE"); + IElementType DOUBLE_QUOTE_END = new CueTokenType("DOUBLE_QUOTE_END"); + IElementType ELLIPSIS_TOKEN = new CueTokenType("..."); + IElementType EQ = new CueTokenType("="); + IElementType EQ_EQ = new CueTokenType("=="); + IElementType FLOAT_LIT = new CueTokenType("FLOAT_LIT"); + IElementType IDENTIFIER = new CueTokenType("IDENTIFIER"); + IElementType INTERPOLATION_END = new CueTokenType("INTERPOLATION_END"); + IElementType INTERPOLATION_START = new CueTokenType("\\\\("); + IElementType INT_LIT = new CueTokenType("INT_LIT"); + IElementType KEYWORD = new CueTokenType("KEYWORD"); + IElementType LEFT_BRACKET = new CueTokenType("["); + IElementType LEFT_CURLY = new CueTokenType("{"); + IElementType LEFT_PAREN = new CueTokenType("("); + IElementType MULTILINE_BYTES_END = new CueTokenType("'''"); + IElementType MULTILINE_BYTES_START = new CueTokenType("MULTILINE_BYTES_START"); + IElementType MULTILINE_STRING_END = new CueTokenType("\"\"\""); + IElementType MULTILINE_STRING_START = new CueTokenType("MULTILINE_STRING_START"); + IElementType MUL_OP = new CueTokenType("MUL_OP"); + IElementType NEWLINE = new CueTokenType("\\n"); + IElementType NULL_LIT = new CueTokenType("NULL_LIT"); + IElementType OPERATOR = new CueTokenType("OPERATOR"); + IElementType PIPE = new CueTokenType("|"); + IElementType PIPE_PIPE = new CueTokenType("||"); + IElementType QMARK = new CueTokenType("?"); + IElementType REL_OP = new CueTokenType("REL_OP"); + IElementType RIGHT_BRACKET = new CueTokenType("]"); + IElementType RIGHT_CURLY = new CueTokenType("}"); + IElementType RIGHT_PAREN = new CueTokenType(")"); + IElementType SINGLE_QUOTE = new CueTokenType("SINGLE_QUOTE"); + IElementType SINGLE_QUOTE_END = new CueTokenType("SINGLE_QUOTE_END"); + IElementType SLICE = new CueTokenType("Slice"); + IElementType TOP_LIT = new CueTokenType("TOP_LIT"); + IElementType UNICODE_VALUE = new CueTokenType("UNICODE_VALUE"); + + class Factory { + public static PsiElement createElement(ASTNode node) { + IElementType type = node.getElementType(); + if (type == ALIAS_EXPR) { + return new CueAliasExprImpl(node); + } + else if (type == ARGUMENTS) { + return new CueArgumentsImpl(node); + } + else if (type == ATTRIBUTE) { + return new CueAttributeImpl(node); + } + else if (type == ATTR_TOKENS) { + return new CueAttrTokensImpl(node); + } + else if (type == BASIC_LIT) { + return new CueBasicLitImpl(node); + } + else if (type == BINARY_EXPR) { + return new CueBinaryExprImpl(node); + } + else if (type == CLAUSE) { + return new CueClauseImpl(node); + } + else if (type == CLAUSES) { + return new CueClausesImpl(node); + } + else if (type == COMPREHENSION) { + return new CueComprehensionImpl(node); + } + else if (type == DECLARATION) { + return new CueDeclarationImpl(node); + } + else if (type == ELEMENT_LIST) { + return new CueElementListImpl(node); + } + else if (type == ELLIPSIS) { + return new CueEllipsisImpl(node); + } + else if (type == EMBEDDING) { + return new CueEmbeddingImpl(node); + } + else if (type == FIELD) { + return new CueFieldImpl(node); + } + else if (type == FOR_CLAUSE) { + return new CueForClauseImpl(node); + } + else if (type == GUARD_CLAUSE) { + return new CueGuardClauseImpl(node); + } + else if (type == IMPORT_DECL) { + return new CueImportDeclImpl(node); + } + else if (type == IMPORT_LOCATION) { + return new CueImportLocationImpl(node); + } + else if (type == IMPORT_PATH) { + return new CueImportPathImpl(node); + } + else if (type == IMPORT_SPEC) { + return new CueImportSpecImpl(node); + } + else if (type == INDEX) { + return new CueIndexImpl(node); + } + else if (type == INTERPOLATION) { + return new CueInterpolationImpl(node); + } + else if (type == LABEL) { + return new CueLabelImpl(node); + } + else if (type == LABEL_EXPR) { + return new CueLabelExprImpl(node); + } + else if (type == LET_CLAUSE) { + return new CueLetClauseImpl(node); + } + else if (type == LIST_LIT) { + return new CueListLitImpl(node); + } + else if (type == MULTILINE_BYTES_LIT) { + return new CueMultilineBytesLitImpl(node); + } + else if (type == MULTILINE_STRING_LIT) { + return new CueMultilineStringLitImpl(node); + } + else if (type == OPERAND) { + return new CueOperandImpl(node); + } + else if (type == OPERAND_NAME) { + return new CueOperandNameImpl(node); + } + else if (type == PACKAGE_CLAUSE) { + return new CuePackageClauseImpl(node); + } + else if (type == PRIMARY_EXPR) { + return new CuePrimaryExprImpl(node); + } + else if (type == QUALIFIED_IDENT) { + return new CueQualifiedIdentImpl(node); + } + else if (type == SELECTOR) { + return new CueSelectorImpl(node); + } + else if (type == SIMPLE_BYTES_LIT) { + return new CueSimpleBytesLitImpl(node); + } + else if (type == SIMPLE_STRING_LIT) { + return new CueSimpleStringLitImpl(node); + } + else if (type == START_CLAUSE) { + return new CueStartClauseImpl(node); + } + else if (type == STRUCT_LIT) { + return new CueStructLitImpl(node); + } + else if (type == UNARY_EXPR) { + return new CueUnaryExprImpl(node); + } + throw new AssertionError("Unknown element type: " + type); + } + } +} diff --git a/src/main/java-gen/dev/monogon/cue/lang/lexer/_CueLexer.java b/src/main/java-gen/dev/monogon/cue/lang/lexer/_CueLexer.java new file mode 100644 index 0000000..57889be --- /dev/null +++ b/src/main/java-gen/dev/monogon/cue/lang/lexer/_CueLexer.java @@ -0,0 +1,993 @@ +/* The following code was generated by JFlex 1.7.0-1 tweaked for IntelliJ platform */ + +package dev.monogon.cue.lang.lexer; + +import com.intellij.lexer.FlexLexer; +import com.intellij.psi.tree.IElementType; +import com.intellij.util.containers.IntStack; + +import static com.intellij.psi.TokenType.BAD_CHARACTER; +import static com.intellij.psi.TokenType.WHITE_SPACE; +import static dev.monogon.cue.lang.CueTypes.*; +import static dev.monogon.cue.lang.CueTokenTypes.*; + + +/** + * This class is a scanner generated by + * JFlex 1.7.0-1 + * from the specification file /home/jansorg/self-employment/customers/nexenta-cuelang/intellij-cue/src/grammar/cue.flex + */ +public class _CueLexer implements FlexLexer { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + public static final int STRING_LITERAL = 2; + public static final int STRING_MULTILINE = 4; + public static final int BYTE_LITERAL = 6; + public static final int BYTES_MULTILINE = 8; + public static final int EXPRESSION = 10; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 + }; + + /** + * Translates characters to character classes + * Chosen bits are [11, 6, 4] + * Total runtime size is 14272 bytes + */ + public static int ZZ_CMAP(int ch) { + return ZZ_CMAP_A[(ZZ_CMAP_Y[(ZZ_CMAP_Z[ch>>10]<<6)|((ch>>4)&0x3f)]<<4)|(ch&0xf)]; + } + + /* The ZZ_CMAP_Z table has 1088 entries */ + static final char ZZ_CMAP_Z[] = zzUnpackCMap( + "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10\2\11\1\12\1\13\6\14\1\15\23\14\1\16"+ + "\1\14\1\17\1\20\12\14\1\21\10\11\1\22\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1"+ + "\32\1\33\1\34\1\35\2\11\1\14\1\36\3\11\1\37\10\11\1\40\1\41\5\14\1\42\1\43"+ + "\11\11\1\44\2\11\1\45\5\11\1\46\4\11\1\47\1\50\4\11\51\14\1\51\3\14\1\52\1"+ + "\53\4\14\1\54\12\11\1\55\u0381\11"); + + /* The ZZ_CMAP_Y table has 2944 entries */ + static final char ZZ_CMAP_Y[] = zzUnpackCMap( + "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7\2\1\1\10\1\11\1\12\1\13\1\12\1\13\34\12\1"+ + "\14\1\15\1\16\10\1\1\17\1\20\1\12\1\21\4\12\1\22\10\12\1\23\12\12\1\24\1\12"+ + "\1\25\1\24\1\12\1\26\4\1\1\12\1\27\1\30\2\1\2\12\1\27\1\1\1\31\1\24\5\12\1"+ + "\32\1\33\1\34\1\1\1\35\1\12\1\1\1\36\5\12\1\37\1\40\1\41\1\12\1\27\1\42\1"+ + "\12\1\43\1\44\1\1\1\12\1\45\4\1\1\12\1\46\4\1\1\47\2\12\1\50\1\1\1\51\1\52"+ + "\1\24\1\53\1\54\1\55\1\56\1\57\1\60\1\52\1\15\1\61\1\54\1\55\1\62\1\1\1\63"+ + "\1\64\1\65\1\66\1\21\1\55\1\67\1\1\1\70\1\52\1\71\1\72\1\54\1\55\1\67\1\1"+ + "\1\60\1\52\1\40\1\73\1\74\1\75\1\76\1\1\1\70\1\64\1\1\1\77\1\35\1\55\1\50"+ + "\1\1\1\100\1\52\1\1\1\101\1\35\1\55\1\102\1\1\1\57\1\52\1\103\1\77\1\35\1"+ + "\12\1\104\1\57\1\105\1\52\1\106\1\107\1\110\1\12\1\111\1\112\1\1\1\64\1\1"+ + "\1\24\2\12\1\113\1\112\1\114\2\1\1\115\1\116\1\117\1\120\1\121\1\122\2\1\1"+ + "\70\1\1\1\114\1\1\1\123\1\12\1\124\1\1\1\125\7\1\2\12\1\27\1\126\1\114\1\127"+ + "\1\130\1\131\1\132\1\114\2\12\1\133\2\12\1\134\24\12\1\135\1\136\2\12\1\135"+ + "\2\12\1\137\1\140\1\13\3\12\1\140\3\12\1\27\2\1\1\12\1\1\5\12\1\141\1\24\45"+ + "\12\1\142\1\12\1\24\1\27\4\12\1\27\1\143\1\144\1\15\1\12\1\15\1\12\1\15\1"+ + "\144\1\70\3\12\1\145\1\1\1\146\1\114\2\1\1\114\5\12\1\26\1\147\1\12\1\150"+ + "\4\12\1\37\1\12\1\151\2\1\1\64\1\12\1\152\1\153\2\12\1\154\1\12\1\76\1\114"+ + "\2\1\1\12\1\112\3\12\1\153\2\1\2\114\1\155\5\1\1\107\2\12\1\145\1\156\1\114"+ + "\2\1\1\157\1\12\1\160\1\41\2\12\1\37\1\1\2\12\1\145\1\1\1\161\1\41\1\12\1"+ + "\152\1\45\5\1\1\162\1\163\14\12\4\1\21\12\1\141\2\12\1\141\1\164\1\12\1\152"+ + "\3\12\1\165\1\166\1\167\1\124\1\166\7\1\1\170\1\1\1\124\6\1\1\171\1\172\1"+ + "\173\1\174\1\175\3\1\1\176\147\1\2\12\1\151\2\12\1\151\10\12\1\177\1\200\2"+ + "\12\1\133\3\12\1\201\1\1\1\12\1\112\4\202\4\1\1\126\35\1\1\203\2\1\1\204\1"+ + "\24\4\12\1\205\1\24\4\12\1\134\1\107\1\12\1\152\1\24\4\12\1\151\1\1\1\12\1"+ + "\27\3\1\1\12\40\1\133\12\1\37\4\1\135\12\1\37\2\1\10\12\1\124\4\1\2\12\1\152"+ + "\20\12\1\124\1\12\1\206\1\1\2\12\1\151\1\126\1\12\1\152\4\12\1\37\2\1\1\207"+ + "\1\210\5\12\1\211\1\12\1\151\1\26\3\1\1\207\1\212\1\12\1\30\1\1\3\12\1\145"+ + "\1\210\2\12\1\145\1\1\1\114\1\1\1\213\1\41\1\12\1\37\1\12\1\112\1\1\1\12\1"+ + "\124\1\47\2\12\1\30\1\126\1\114\1\214\1\215\2\12\1\45\1\1\1\216\1\114\1\12"+ + "\1\217\3\12\1\220\1\221\1\222\1\27\1\65\1\223\1\224\1\202\2\12\1\134\1\37"+ + "\7\12\1\30\1\114\72\12\1\145\1\12\1\225\2\12\1\154\20\1\26\12\1\152\6\12\1"+ + "\76\2\1\1\112\1\226\1\55\1\227\1\230\6\12\1\15\1\1\1\157\25\12\1\152\1\1\4"+ + "\12\1\210\2\12\1\26\2\1\1\154\7\1\1\214\7\12\1\124\1\1\1\114\1\24\1\27\1\24"+ + "\1\27\1\231\4\12\1\151\1\232\1\233\2\1\1\234\1\12\1\13\1\235\2\152\2\1\7\12"+ + "\1\27\30\1\1\12\1\124\3\12\1\70\2\1\2\12\1\1\1\12\1\236\2\12\1\37\1\12\1\152"+ + "\2\12\1\237\3\1\11\12\1\152\1\114\2\12\1\237\1\12\1\154\2\12\1\26\3\12\1\145"+ + "\11\1\23\12\1\112\1\12\1\37\1\26\11\1\1\240\2\12\1\241\1\12\1\37\1\12\1\112"+ + "\1\12\1\151\4\1\1\12\1\242\1\12\1\37\1\12\1\76\4\1\3\12\1\243\4\1\1\70\1\244"+ + "\1\12\1\145\2\1\1\12\1\124\1\12\1\124\2\1\1\123\1\12\1\153\1\1\3\12\1\37\1"+ + "\12\1\37\1\12\1\30\1\12\1\15\6\1\4\12\1\45\3\1\3\12\1\30\3\12\1\30\60\1\1"+ + "\157\2\12\1\26\2\1\1\64\1\1\1\157\2\12\2\1\1\12\1\45\1\114\1\157\1\12\1\112"+ + "\1\64\1\1\2\12\1\245\1\157\2\12\1\30\1\246\1\247\2\1\1\12\1\21\1\154\5\1\1"+ + "\250\1\251\1\45\2\12\1\151\1\1\1\114\1\72\1\54\1\55\1\67\1\1\1\252\1\15\11"+ + "\1\3\12\1\153\1\253\1\114\2\1\3\12\1\1\1\254\1\114\12\1\2\12\1\151\2\1\1\255"+ + "\2\1\3\12\1\1\1\256\1\114\2\1\2\12\1\27\1\1\1\114\3\1\1\12\1\76\1\1\1\114"+ + "\26\1\4\12\1\114\1\126\34\1\3\12\1\45\20\1\1\55\1\12\1\151\1\1\1\70\1\114"+ + "\1\1\1\210\1\12\67\1\71\12\1\76\16\1\14\12\1\145\53\1\2\12\1\151\75\1\44\12"+ + "\1\112\33\1\43\12\1\45\1\12\1\151\1\114\6\1\1\12\1\152\1\1\3\12\1\1\1\145"+ + "\1\114\1\157\1\257\1\12\67\1\4\12\1\153\1\70\3\1\1\157\4\1\1\70\1\1\76\12"+ + "\1\124\1\1\57\12\1\30\20\1\1\15\77\1\6\12\1\27\1\124\1\45\1\76\66\1\5\12\1"+ + "\214\3\12\1\144\1\260\1\261\1\262\3\12\1\263\1\264\1\12\1\265\1\266\1\35\24"+ + "\12\1\267\1\12\1\35\1\134\1\12\1\134\1\12\1\214\1\12\1\214\1\151\1\12\1\151"+ + "\1\12\1\55\1\12\1\55\1\12\1\270\3\271\14\12\1\153\3\1\4\12\1\145\1\114\112"+ + "\1\1\262\1\12\1\272\1\273\1\274\1\275\1\276\1\277\1\300\1\154\1\301\1\154"+ + "\24\1\55\12\1\112\2\1\103\12\1\153\15\12\1\152\150\12\1\15\25\1\41\12\1\152"+ + "\36\1"); + + /* The ZZ_CMAP_A table has 3104 entries */ + static final char ZZ_CMAP_A[] = zzUnpackCMap( + "\11\0\1\1\1\2\2\0\1\1\22\0\1\1\1\44\1\55\1\13\2\0\1\73\1\56\1\53\1\54\1\70"+ + "\1\24\1\12\1\24\1\15\1\47\1\11\1\14\6\7\2\6\1\61\1\0\1\66\1\62\1\66\1\43\1"+ + "\65\4\10\1\23\1\10\1\21\3\3\1\21\1\3\1\21\2\3\1\21\3\3\1\21\1\52\2\3\1\17"+ + "\2\3\1\63\1\46\1\64\1\0\1\5\1\0\1\34\1\16\1\37\1\71\1\32\1\33\1\41\1\3\1\22"+ + "\1\3\1\40\1\27\1\42\1\25\1\20\1\36\1\72\1\31\1\35\1\30\1\26\1\50\1\3\1\51"+ + "\2\3\1\57\1\45\1\60\1\67\13\0\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0\12\3\4\0\14"+ + "\3\16\0\5\3\7\0\1\3\1\0\1\3\1\0\5\3\1\0\2\3\2\0\4\3\1\0\1\3\6\0\1\3\1\0\3"+ + "\3\1\0\1\3\1\0\4\3\1\0\23\3\1\0\13\3\10\0\6\3\1\0\26\3\2\0\1\3\6\0\10\3\10"+ + "\0\13\3\5\0\3\3\15\0\12\4\4\0\6\3\1\0\1\3\17\0\2\3\7\0\2\3\12\4\3\3\2\0\2"+ + "\3\1\0\16\3\15\0\11\3\13\0\1\3\16\0\12\4\6\3\4\0\2\3\4\0\1\3\5\0\6\3\4\0\1"+ + "\3\11\0\1\3\3\0\1\3\7\0\11\3\7\0\5\3\1\0\10\3\6\0\26\3\3\0\1\3\2\0\1\3\7\0"+ + "\12\3\4\0\12\4\1\3\4\0\10\3\2\0\2\3\2\0\26\3\1\0\7\3\1\0\1\3\3\0\4\3\3\0\1"+ + "\3\20\0\1\3\15\0\2\3\1\0\1\3\5\0\6\3\4\0\2\3\1\0\2\3\1\0\2\3\1\0\2\3\17\0"+ + "\4\3\1\0\1\3\7\0\12\4\2\0\3\3\20\0\11\3\1\0\2\3\1\0\2\3\1\0\5\3\3\0\1\3\2"+ + "\0\1\3\30\0\1\3\13\0\10\3\2\0\1\3\3\0\1\3\1\0\6\3\3\0\3\3\1\0\4\3\3\0\2\3"+ + "\1\0\1\3\1\0\2\3\3\0\2\3\3\0\3\3\3\0\14\3\13\0\10\3\1\0\2\3\10\0\3\3\5\0\1"+ + "\3\4\0\10\3\1\0\6\3\1\0\5\3\3\0\1\3\3\0\2\3\15\0\13\3\2\0\1\3\6\0\3\3\10\0"+ + "\1\3\12\0\6\3\5\0\22\3\3\0\10\3\1\0\11\3\1\0\1\3\2\0\7\3\11\0\1\3\1\0\2\3"+ + "\14\0\12\4\7\0\2\3\1\0\1\3\2\0\2\3\1\0\1\3\2\0\1\3\6\0\4\3\1\0\7\3\1\0\3\3"+ + "\1\0\1\3\1\0\1\3\2\0\2\3\1\0\4\3\1\0\2\3\11\0\1\3\2\0\5\3\1\0\1\3\11\0\12"+ + "\4\2\0\14\3\1\0\24\3\13\0\5\3\22\0\7\3\4\0\4\3\3\0\1\3\3\0\2\3\7\0\3\3\4\0"+ + "\15\3\14\0\1\3\1\0\6\3\1\0\1\3\5\0\1\3\2\0\13\3\1\0\15\3\1\0\4\3\2\0\7\3\1"+ + "\0\1\3\1\0\4\3\2\0\1\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0\4\3\2\0\16\3\2\0\6\3\2"+ + "\0\15\3\2\0\1\3\1\0\10\3\7\0\15\3\1\0\6\3\23\0\1\3\4\0\1\3\3\0\5\3\2\0\22"+ + "\3\1\0\1\3\5\0\17\3\1\0\16\3\2\0\5\3\13\0\14\3\13\0\1\3\15\0\7\3\7\0\16\3"+ + "\15\0\2\3\12\4\3\0\3\3\11\0\4\3\1\0\4\3\3\0\2\3\11\0\10\3\1\0\1\3\1\0\1\3"+ + "\1\0\1\3\1\0\6\3\1\0\7\3\1\0\1\3\3\0\3\3\1\0\7\3\3\0\4\3\2\0\6\3\5\0\1\3\15"+ + "\0\1\3\2\0\1\3\4\0\1\3\2\0\12\3\1\0\1\3\3\0\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1"+ + "\0\4\3\1\0\13\3\2\0\4\3\5\0\5\3\4\0\1\3\4\0\2\3\13\0\5\3\6\0\4\3\3\0\2\3\14"+ + "\0\10\3\7\0\10\3\1\0\7\3\6\0\2\3\12\0\5\3\5\0\2\3\3\0\7\3\6\0\3\3\12\4\2\3"+ + "\13\0\11\3\2\0\27\3\2\0\7\3\1\0\3\3\1\0\4\3\1\0\4\3\2\0\6\3\3\0\1\3\1\0\1"+ + "\3\2\0\5\3\1\0\12\3\12\4\5\3\1\0\3\3\1\0\10\3\4\0\7\3\3\0\1\3\3\0\2\3\1\0"+ + "\1\3\3\0\2\3\2\0\5\3\2\0\1\3\1\0\1\3\30\0\3\3\3\0\6\3\2\0\6\3\2\0\6\3\11\0"+ + "\7\3\4\0\5\3\3\0\5\3\5\0\1\3\1\0\10\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0\2\3\1\0"+ + "\12\3\6\0\12\3\2\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0\14\3\1\0\16\3\1\0\2\3\1"+ + "\0\2\3\1\0\10\3\6\0\4\3\4\0\16\3\2\0\1\3\1\0\14\3\1\0\2\3\3\0\1\3\2\0\4\3"+ + "\1\0\2\3\12\0\10\3\6\0\6\3\1\0\3\3\1\0\12\3\3\0\1\3\12\0\4\3\13\0\12\4\1\3"+ + "\1\0\1\3\3\0\7\3\1\0\1\3\1\0\4\3\1\0\17\3\1\0\2\3\14\0\3\3\7\0\4\3\11\0\2"+ + "\3\1\0\1\3\20\0\4\3\10\0\1\3\13\0\10\3\5\0\3\3\2\0\1\3\2\0\2\3\2\0\4\3\1\0"+ + "\14\3\1\0\1\3\1\0\7\3\1\0\21\3\1\0\4\3\2\0\10\3\1\0\7\3\1\0\14\3\1\0\4\3\1"+ + "\0\5\3\1\0\1\3\3\0\14\3\2\0\13\3\1\0\10\3\2\0\22\4\1\0\2\3\1\0\1\3\2\0\1\3"+ + "\1\0\12\3\1\0\4\3\1\0\1\3\1\0\1\3\6\0\1\3\4\0\1\3\1\0\1\3\1\0\1\3\1\0\3\3"+ + "\1\0\2\3\1\0\1\3\2\0\1\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\2\3\1\0\1\3\2"+ + "\0\4\3\1\0\7\3\1\0\4\3\1\0\4\3\1\0\1\3\1\0\12\3\1\0\5\3\1\0\3\3\1\0\5\3\1"+ + "\0\5\3"); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\6\0\1\1\1\2\1\3\2\4\1\5\1\1\1\6"+ + "\1\1\1\7\1\4\1\10\7\4\1\11\1\7\1\12"+ + "\1\13\1\14\1\15\1\16\1\17\1\20\1\21\1\22"+ + "\1\23\1\24\1\25\1\26\1\27\1\13\2\4\1\30"+ + "\2\31\1\32\1\33\2\31\1\34\1\31\1\35\3\0"+ + "\1\36\1\5\6\0\1\36\1\0\1\37\11\4\1\27"+ + "\1\40\1\41\2\0\1\42\2\4\1\43\3\0\1\44"+ + "\4\0\1\7\1\5\1\36\1\0\3\5\1\0\1\45"+ + "\3\4\1\13\2\4\4\0\1\46\2\0\1\47\1\4"+ + "\1\50\1\51\1\4\1\52\1\53\2\0\1\54\1\4"+ + "\2\0\1\4"; + + private static int [] zzUnpackAction() { + int [] result = new int[130]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\74\0\170\0\264\0\360\0\u012c\0\u0168\0\u0168"+ + "\0\u0168\0\u01a4\0\u01e0\0\u021c\0\u0258\0\u0168\0\u0294\0\u02d0"+ + "\0\u030c\0\u0168\0\u0348\0\u0384\0\u03c0\0\u03fc\0\u0438\0\u0474"+ + "\0\u04b0\0\u0168\0\u04ec\0\u0528\0\u0564\0\u0168\0\u0168\0\u05a0"+ + "\0\u05dc\0\u0168\0\u0168\0\u0168\0\u0618\0\u0168\0\u0168\0\u0168"+ + "\0\u0654\0\u0168\0\u0690\0\u06cc\0\u0708\0\u0168\0\u0744\0\u0168"+ + "\0\u0168\0\u0780\0\u07bc\0\u0168\0\u07f8\0\u0168\0\u0294\0\u0834"+ + "\0\u0870\0\u08ac\0\u08e8\0\u0924\0\u0960\0\u099c\0\u09d8\0\u0a14"+ + "\0\u0a50\0\u0a8c\0\u0ac8\0\u01a4\0\u0b04\0\u0b40\0\u0b7c\0\u0bb8"+ + "\0\u0bf4\0\u0c30\0\u0c6c\0\u0ca8\0\u0ce4\0\u0168\0\u0168\0\u0d20"+ + "\0\u0d5c\0\u0d98\0\u0168\0\u0dd4\0\u0e10\0\u0168\0\u0e4c\0\u0e88"+ + "\0\u0ec4\0\u0168\0\u0f00\0\u0f3c\0\u0f78\0\u0fb4\0\u0168\0\u0168"+ + "\0\u0ff0\0\u102c\0\u1068\0\u10a4\0\u10e0\0\u111c\0\u0168\0\u1158"+ + "\0\u1194\0\u11d0\0\u01a4\0\u120c\0\u1248\0\u1284\0\u12c0\0\u12fc"+ + "\0\u1338\0\u0168\0\u1374\0\u13b0\0\u0168\0\u13ec\0\u01a4\0\u01a4"+ + "\0\u1428\0\u0168\0\u0168\0\u1464\0\u14a0\0\u0168\0\u14dc\0\u1518"+ + "\0\u1554\0\u1590"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[130]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\7\1\10\1\11\1\12\1\7\1\13\2\14\1\12"+ + "\1\15\1\16\1\17\1\14\1\20\4\12\1\21\1\12"+ + "\1\22\1\23\1\12\1\24\1\25\1\26\1\12\1\27"+ + "\2\12\1\30\3\12\1\31\1\32\1\33\1\34\1\7"+ + "\1\35\3\12\1\36\1\37\1\40\1\41\1\42\1\43"+ + "\1\44\1\45\1\46\1\47\1\50\1\51\1\7\1\52"+ + "\1\53\1\54\1\55\2\56\1\11\43\56\1\57\6\56"+ + "\1\60\20\56\1\61\43\56\1\57\6\56\1\62\20\56"+ + "\1\11\43\56\1\63\7\56\1\64\17\56\1\61\43\56"+ + "\1\57\7\56\1\65\15\56\1\7\1\10\1\11\1\12"+ + "\1\7\1\13\2\14\1\12\1\15\1\16\1\17\1\14"+ + "\1\20\4\12\1\21\1\12\1\22\1\23\1\12\1\24"+ + "\1\25\1\26\1\12\1\27\2\12\1\30\3\12\1\31"+ + "\1\32\1\33\1\34\1\7\1\35\3\12\1\36\1\66"+ + "\1\40\1\41\1\42\1\43\1\44\1\45\1\46\1\47"+ + "\1\50\1\51\1\7\1\52\1\53\1\54\1\55\77\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\16\12\5\0"+ + "\3\12\16\0\2\12\4\0\7\12\1\0\1\67\1\12"+ + "\1\0\6\12\1\0\16\12\2\0\1\70\2\0\3\12"+ + "\16\0\2\12\6\0\1\71\2\14\1\0\1\14\2\0"+ + "\1\14\1\72\3\0\1\73\1\0\1\74\6\0\1\74"+ + "\46\0\1\75\2\76\1\0\1\76\2\0\1\76\1\72"+ + "\1\77\1\100\1\101\1\73\1\0\1\74\6\0\1\74"+ + "\16\0\1\100\25\0\1\12\1\0\1\12\2\0\1\12"+ + "\5\0\6\12\1\0\16\12\5\0\3\12\16\0\2\12"+ + "\7\0\2\102\1\0\1\102\2\0\1\102\1\103\61\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\1\104\5\12"+ + "\1\104\6\12\1\105\5\0\3\12\16\0\2\12\4\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\1\12\1\106"+ + "\14\12\5\0\3\12\16\0\2\12\4\0\7\12\2\0"+ + "\1\12\1\0\6\12\1\0\5\12\1\107\10\12\5\0"+ + "\3\12\16\0\2\12\4\0\7\12\2\0\1\12\1\0"+ + "\6\12\1\0\4\12\1\110\11\12\5\0\3\12\16\0"+ + "\2\12\4\0\7\12\2\0\1\12\1\0\6\12\1\0"+ + "\5\12\1\111\10\12\5\0\3\12\16\0\2\12\4\0"+ + "\7\12\2\0\1\12\1\0\2\12\1\112\3\12\1\0"+ + "\7\12\1\113\6\12\5\0\3\12\16\0\2\12\4\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\7\12\1\114"+ + "\6\12\5\0\3\12\16\0\2\12\4\0\7\12\2\0"+ + "\1\12\1\0\2\12\1\115\3\12\1\0\16\12\5\0"+ + "\3\12\16\0\2\12\63\0\1\116\4\0\1\116\51\0"+ + "\1\117\75\0\1\120\101\0\1\121\74\0\1\122\77\0"+ + "\1\123\4\0\1\116\66\0\1\116\14\0\7\12\2\0"+ + "\1\12\1\0\4\12\1\124\1\12\1\0\16\12\5\0"+ + "\3\12\16\0\2\12\4\0\7\12\2\0\1\12\1\0"+ + "\6\12\1\0\1\12\1\125\14\12\5\0\3\12\16\0"+ + "\2\12\74\0\1\126\13\0\1\127\2\0\1\56\6\0"+ + "\1\56\1\130\1\0\2\56\1\0\2\56\11\0\3\56"+ + "\1\0\1\131\1\132\1\0\2\56\72\0\1\133\25\0"+ + "\1\134\1\0\1\134\1\0\1\127\1\134\1\0\1\56"+ + "\6\0\1\56\1\130\1\0\2\56\1\0\2\56\11\0"+ + "\3\56\1\135\1\131\1\132\1\0\2\56\73\0\1\136"+ + "\22\0\1\137\74\0\2\14\1\0\1\14\2\0\1\14"+ + "\65\0\2\102\1\0\1\102\2\0\1\102\6\0\1\74"+ + "\6\0\1\74\63\0\1\140\57\0\2\141\1\0\1\141"+ + "\2\0\1\141\7\0\1\142\55\0\2\76\1\0\1\76"+ + "\2\0\1\76\64\0\1\75\2\76\1\0\1\76\2\0"+ + "\1\76\1\72\3\0\1\73\1\0\1\74\6\0\1\74"+ + "\52\0\1\143\2\0\1\143\65\0\4\144\2\0\1\144"+ + "\1\0\1\144\4\0\1\144\6\0\3\144\2\0\1\144"+ + "\31\0\1\144\11\0\1\145\1\0\1\145\2\0\1\145"+ + "\64\0\1\146\2\102\1\0\1\102\2\0\1\102\4\0"+ + "\1\73\1\0\1\74\6\0\1\74\56\0\1\147\61\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\11\12\1\150"+ + "\4\12\5\0\3\12\16\0\2\12\4\0\7\12\2\0"+ + "\1\12\1\0\6\12\1\0\2\12\1\151\13\12\5\0"+ + "\3\12\16\0\2\12\4\0\7\12\2\0\1\12\1\0"+ + "\6\12\1\0\3\12\1\104\12\12\5\0\3\12\16\0"+ + "\2\12\4\0\7\12\2\0\1\12\1\0\6\12\1\0"+ + "\1\12\1\152\14\12\5\0\3\12\16\0\2\12\4\0"+ + "\7\12\2\0\1\12\1\0\6\12\1\0\15\12\1\153"+ + "\5\0\3\12\16\0\2\12\4\0\7\12\2\0\1\12"+ + "\1\0\6\12\1\0\4\12\1\104\11\12\5\0\3\12"+ + "\16\0\2\12\4\0\7\12\2\0\1\12\1\0\6\12"+ + "\1\0\2\12\1\154\13\12\5\0\3\12\16\0\2\12"+ + "\4\0\7\12\2\0\1\12\1\0\6\12\1\0\12\12"+ + "\1\155\3\12\5\0\3\12\16\0\2\12\4\0\7\12"+ + "\2\0\1\12\1\0\6\12\1\0\16\12\5\0\3\12"+ + "\16\0\1\153\1\12\1\0\2\120\1\0\71\120\55\0"+ + "\1\156\74\0\1\157\20\0\7\12\2\0\1\12\1\0"+ + "\6\12\1\0\16\12\5\0\1\153\2\12\16\0\2\12"+ + "\4\0\7\12\2\0\1\12\1\0\2\12\1\153\3\12"+ + "\1\0\16\12\5\0\3\12\16\0\2\12\14\0\1\127"+ + "\2\0\1\56\6\0\1\56\2\0\2\56\1\0\2\56"+ + "\11\0\3\56\4\0\2\56\23\0\4\160\2\0\1\160"+ + "\1\0\1\160\4\0\1\160\6\0\3\160\2\0\1\160"+ + "\31\0\1\160\10\0\4\161\2\0\1\161\1\0\1\161"+ + "\4\0\1\161\6\0\3\161\2\0\1\161\31\0\1\161"+ + "\57\0\1\162\25\0\1\163\1\0\1\163\2\0\1\163"+ + "\65\0\4\164\2\0\1\164\1\0\1\164\4\0\1\164"+ + "\6\0\3\164\2\0\1\164\31\0\1\164\60\0\1\165"+ + "\22\0\1\142\2\141\1\0\1\141\2\0\1\141\65\0"+ + "\2\141\1\0\1\141\2\0\1\141\64\0\1\77\3\0"+ + "\1\143\2\0\1\143\64\0\1\100\4\144\2\0\1\144"+ + "\1\0\1\144\4\0\1\144\6\0\3\144\2\0\1\144"+ + "\31\0\1\144\7\0\1\101\1\0\1\145\1\0\1\145"+ + "\2\0\1\145\65\0\2\102\1\0\1\102\2\0\1\102"+ + "\62\0\7\12\2\0\1\12\1\0\2\12\1\166\3\12"+ + "\1\0\16\12\5\0\3\12\16\0\2\12\4\0\7\12"+ + "\2\0\1\12\1\0\6\12\1\0\2\12\1\167\13\12"+ + "\5\0\3\12\16\0\2\12\4\0\7\12\2\0\1\12"+ + "\1\0\6\12\1\0\5\12\1\170\10\12\5\0\3\12"+ + "\16\0\2\12\4\0\7\12\2\0\1\12\1\0\6\12"+ + "\1\0\10\12\1\152\5\12\5\0\3\12\16\0\2\12"+ + "\4\0\7\12\2\0\1\12\1\0\6\12\1\0\13\12"+ + "\1\171\2\12\5\0\3\12\16\0\2\12\3\0\1\172"+ + "\73\0\1\173\77\0\4\174\2\0\1\174\1\0\1\174"+ + "\4\0\1\174\6\0\3\174\2\0\1\174\31\0\1\174"+ + "\10\0\4\175\2\0\1\175\1\0\1\175\4\0\1\175"+ + "\6\0\3\175\2\0\1\175\31\0\1\175\11\0\1\176"+ + "\1\0\1\176\2\0\1\176\65\0\4\176\2\0\1\176"+ + "\1\0\1\176\4\0\1\176\6\0\3\176\2\0\1\176"+ + "\31\0\1\176\5\0\7\12\2\0\1\12\1\0\6\12"+ + "\1\0\4\12\1\107\11\12\5\0\3\12\16\0\2\12"+ + "\4\0\7\12\2\0\1\12\1\0\6\12\1\0\7\12"+ + "\1\177\6\12\5\0\3\12\16\0\2\12\7\0\4\200"+ + "\2\0\1\200\1\0\1\200\4\0\1\200\6\0\3\200"+ + "\2\0\1\200\31\0\1\200\10\0\4\201\2\0\1\201"+ + "\1\0\1\201\4\0\1\201\6\0\3\201\2\0\1\201"+ + "\31\0\1\201\5\0\7\12\2\0\1\12\1\0\6\12"+ + "\1\0\14\12\1\202\1\12\5\0\3\12\16\0\2\12"+ + "\7\0\4\56\2\0\1\56\1\0\1\56\4\0\1\56"+ + "\6\0\3\56\2\0\1\56\31\0\1\56\10\0\4\130"+ + "\2\0\1\130\1\0\1\130\4\0\1\130\6\0\3\130"+ + "\2\0\1\130\31\0\1\130\5\0\7\12\2\0\1\12"+ + "\1\0\6\12\1\0\5\12\1\104\10\12\5\0\3\12"+ + "\16\0\2\12\1\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[5580]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String[] ZZ_ERROR_MSG = { + "Unknown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\6\0\3\11\4\1\1\11\3\1\1\11\7\1\1\11"+ + "\3\1\2\11\2\1\3\11\1\1\3\11\1\1\1\11"+ + "\3\1\1\11\1\1\2\11\2\1\1\11\1\1\1\11"+ + "\3\0\2\1\6\0\1\1\1\0\12\1\2\11\1\1"+ + "\2\0\1\11\2\1\1\11\3\0\1\11\4\0\2\11"+ + "\1\1\1\0\3\1\1\0\1\11\6\1\4\0\1\11"+ + "\2\0\1\11\4\1\2\11\2\0\1\11\1\1\2\0"+ + "\1\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[130]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private CharSequence zzBuffer = ""; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + public _CueLexer() { + this((java.io.Reader)null); + } + + private final IntStack stateStack = new IntStack(100); + + private void pushState(int state) { + int currentState = yystate(); + if (currentState == YYINITIAL && !stateStack.empty()) { + throw new IllegalStateException("Can't push initial state into the not empty stack"); + } + stateStack.push(currentState); + yybegin(state); + } + + private void popState() { + assert !stateStack.empty() : "States stack is empty"; + yybegin(stateStack.pop()); + } + + /** Called when an instance is reset, e.g. on incremental lexer restart */ + protected void onReset() { + stateStack.clear(); + } + + + /** + * Creates a new scanner + * + * @param in the java.io.Reader to read input from. + */ + public _CueLexer(java.io.Reader in) { + this.zzReader = in; + } + + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + int size = 0; + for (int i = 0, length = packed.length(); i < length; i += 2) { + size += packed.charAt(i); + } + char[] map = new char[size]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < packed.length()) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + public final int getTokenStart() { + return zzStartRead; + } + + public final int getTokenEnd() { + return getTokenStart() + yylength(); + } + + public void reset(CharSequence buffer, int start, int end, int initialState) { + zzBuffer = buffer; + zzCurrentPos = zzMarkedPos = zzStartRead = start; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = end; + yybegin(initialState); + } + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + return true; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final CharSequence yytext() { + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer.charAt(zzStartRead+pos); + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public IElementType advance() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + CharSequence zzBufferL = zzBuffer; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); + zzCurrentPosL += Character.charCount(zzInput); + } + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); + zzCurrentPosL += Character.charCount(zzInput); + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + ZZ_CMAP(zzInput) ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } + else { + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return BAD_CHARACTER; + } + // fall through + case 45: break; + case 2: + { return WHITE_SPACE; + } + // fall through + case 46: break; + case 3: + { return WHITE_SPACE_NEWLINE; + } + // fall through + case 47: break; + case 4: + { return IDENTIFIER; + } + // fall through + case 48: break; + case 5: + { return INT_LIT; + } + // fall through + case 49: break; + case 6: + { return COMMA; + } + // fall through + case 50: break; + case 7: + { return OPERATOR; + } + // fall through + case 51: break; + case 8: + { return ADD_OP; + } + // fall through + case 52: break; + case 9: + { return QMARK; + } + // fall through + case 53: break; + case 10: + { return PIPE; + } + // fall through + case 54: break; + case 11: + { return MUL_OP; + } + // fall through + case 55: break; + case 12: + { return LEFT_PAREN; + } + // fall through + case 56: break; + case 13: + { return RIGHT_PAREN; + } + // fall through + case 57: break; + case 14: + { pushState(STRING_LITERAL); return DOUBLE_QUOTE; + } + // fall through + case 58: break; + case 15: + { pushState(BYTE_LITERAL); return SINGLE_QUOTE; + } + // fall through + case 59: break; + case 16: + { return LEFT_CURLY; + } + // fall through + case 60: break; + case 17: + { return RIGHT_CURLY; + } + // fall through + case 61: break; + case 18: + { return COLON; + } + // fall through + case 62: break; + case 19: + { return EQ; + } + // fall through + case 63: break; + case 20: + { return LEFT_BRACKET; + } + // fall through + case 64: break; + case 21: + { return RIGHT_BRACKET; + } + // fall through + case 65: break; + case 22: + { return AT; + } + // fall through + case 66: break; + case 23: + { return REL_OP; + } + // fall through + case 67: break; + case 24: + { return AMP; + } + // fall through + case 68: break; + case 25: + { return UNICODE_VALUE; + } + // fall through + case 69: break; + case 26: + { popState(); return DOUBLE_QUOTE_END; + } + // fall through + case 70: break; + case 27: + { return NEWLINE; + } + // fall through + case 71: break; + case 28: + { popState(); return SINGLE_QUOTE_END; + } + // fall through + case 72: break; + case 29: + { popState(); return INTERPOLATION_END; + } + // fall through + case 73: break; + case 30: + { return FLOAT_LIT; + } + // fall through + case 74: break; + case 31: + { return KEYWORD; + } + // fall through + case 75: break; + case 32: + { return PIPE_PIPE; + } + // fall through + case 76: break; + case 33: + { return COMMENT; + } + // fall through + case 77: break; + case 34: + { return EQ_EQ; + } + // fall through + case 78: break; + case 35: + { return AMP_AMP; + } + // fall through + case 79: break; + case 36: + { pushState(EXPRESSION); return INTERPOLATION_START; + } + // fall through + case 80: break; + case 37: + { return ELLIPSIS_TOKEN; + } + // fall through + case 81: break; + case 38: + { popState(); return MULTILINE_STRING_END; + } + // fall through + case 82: break; + case 39: + { popState(); return MULTILINE_BYTES_END; + } + // fall through + case 83: break; + case 40: + { return NULL_LIT; + } + // fall through + case 84: break; + case 41: + { return BOOL_LIT; + } + // fall through + case 85: break; + case 42: + // lookahead expression with fixed base length + zzMarkedPos = Character.offsetByCodePoints + (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 3); + { pushState(STRING_MULTILINE); return MULTILINE_STRING_START; + } + // fall through + case 86: break; + case 43: + // lookahead expression with fixed base length + zzMarkedPos = Character.offsetByCodePoints + (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 3); + { pushState(BYTES_MULTILINE); return MULTILINE_BYTES_START; + } + // fall through + case 87: break; + case 44: + { return BYTE_VALUE; + } + // fall through + case 88: break; + default: + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java-gen/dev/monogon/cue/lang/parser/CueParser.java b/src/main/java-gen/dev/monogon/cue/lang/parser/CueParser.java new file mode 100644 index 0000000..6c3c62e --- /dev/null +++ b/src/main/java-gen/dev/monogon/cue/lang/parser/CueParser.java @@ -0,0 +1,1378 @@ +// This is a generated file. Not intended for manual editing. +package dev.monogon.cue.lang.parser; + +import com.intellij.lang.PsiBuilder; +import com.intellij.lang.PsiBuilder.Marker; +import static dev.monogon.cue.lang.CueTypes.*; +import static dev.monogon.cue.lang.parser.CueParserUtil.*; +import com.intellij.psi.tree.IElementType; +import com.intellij.lang.ASTNode; +import com.intellij.psi.tree.TokenSet; +import com.intellij.lang.PsiParser; +import com.intellij.lang.LightPsiParser; + +@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) +public class CueParser implements PsiParser, LightPsiParser { + + public ASTNode parse(IElementType t, PsiBuilder b) { + parseLight(t, b); + return b.getTreeBuilt(); + } + + public void parseLight(IElementType t, PsiBuilder b) { + boolean r; + b = adapt_builder_(t, b, this, EXTENDS_SETS_); + Marker m = enter_section_(b, 0, _COLLAPSE_, null); + r = parse_root_(t, b); + exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); + } + + protected boolean parse_root_(IElementType t, PsiBuilder b) { + return parse_root_(t, b, 0); + } + + static boolean parse_root_(IElementType t, PsiBuilder b, int l) { + return file(b, l + 1); + } + + public static final TokenSet[] EXTENDS_SETS_ = new TokenSet[] { + create_token_set_(DECLARATION, ELLIPSIS, EMBEDDING, FIELD), + create_token_set_(ALIAS_EXPR, ARGUMENT, ARGUMENTS, BASIC_LIT, + BINARY_EXPR, EXPRESSION, INDEX, LIST_LIT, + LITERAL, MULTILINE_BYTES_LIT, MULTILINE_STRING_LIT, OPERAND, + OPERAND_NAME, PRIMARY_EXPR, QUALIFIED_IDENT, SELECTOR, + SIMPLE_BYTES_LIT, SIMPLE_STRING_LIT, STRUCT_LIT, UNARY_EXPR), + }; + + /* ********************************************************** */ + // Expression | IDENTIFIER "=" Expression + public static boolean AliasExpr(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "AliasExpr")) return false; + boolean r; + Marker m = enter_section_(b, l, _COLLAPSE_, ALIAS_EXPR, ""); + r = Expression(b, l + 1, -1); + if (!r) r = AliasExpr_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // IDENTIFIER "=" Expression + private static boolean AliasExpr_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "AliasExpr_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, IDENTIFIER, EQ); + r = r && Expression(b, l + 1, -1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // Expression + public static boolean Argument(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Argument")) return false; + boolean r; + Marker m = enter_section_(b, l, _COLLAPSE_, ARGUMENT, ""); + r = Expression(b, l + 1, -1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // "(" [ ( Argument { "," Argument }* ) [ "," ] ] ")" + public static boolean Arguments(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments")) return false; + if (!nextTokenIsFast(b, LEFT_PAREN)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, LEFT_PAREN); + r = r && Arguments_1(b, l + 1); + r = r && consumeToken(b, RIGHT_PAREN); + exit_section_(b, m, ARGUMENTS, r); + return r; + } + + // [ ( Argument { "," Argument }* ) [ "," ] ] + private static boolean Arguments_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1")) return false; + Arguments_1_0(b, l + 1); + return true; + } + + // ( Argument { "," Argument }* ) [ "," ] + private static boolean Arguments_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Arguments_1_0_0(b, l + 1); + r = r && Arguments_1_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // Argument { "," Argument }* + private static boolean Arguments_1_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1_0_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Argument(b, l + 1); + r = r && Arguments_1_0_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // { "," Argument }* + private static boolean Arguments_1_0_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1_0_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!Arguments_1_0_0_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Arguments_1_0_0_1", c)) break; + } + return true; + } + + // "," Argument + private static boolean Arguments_1_0_0_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1_0_0_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, COMMA); + r = r && Argument(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // [ "," ] + private static boolean Arguments_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Arguments_1_0_1")) return false; + consumeTokenFast(b, COMMA); + return true; + } + + /* ********************************************************** */ + // INT_LIT | FLOAT_LIT | string_lit | NULL_LIT | BOOL_LIT | BOTTOM_LIT | TOP_LIT + public static boolean BasicLit(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "BasicLit")) return false; + boolean r; + Marker m = enter_section_(b, l, _COLLAPSE_, BASIC_LIT, ""); + r = consumeTokenFast(b, INT_LIT); + if (!r) r = consumeTokenFast(b, FLOAT_LIT); + if (!r) r = string_lit(b, l + 1); + if (!r) r = consumeTokenFast(b, NULL_LIT); + if (!r) r = consumeTokenFast(b, BOOL_LIT); + if (!r) r = consumeTokenFast(b, BOTTOM_LIT); + if (!r) r = consumeTokenFast(b, TOP_LIT); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // StartClause | LetClause + public static boolean Clause(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Clause")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, CLAUSE, ""); + r = StartClause(b, l + 1); + if (!r) r = LetClause(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // StartClause { [ "," ] Clause }* + public static boolean Clauses(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Clauses")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, CLAUSES, ""); + r = StartClause(b, l + 1); + r = r && Clauses_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // { [ "," ] Clause }* + private static boolean Clauses_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Clauses_1")) return false; + while (true) { + int c = current_position_(b); + if (!Clauses_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Clauses_1", c)) break; + } + return true; + } + + // [ "," ] Clause + private static boolean Clauses_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Clauses_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Clauses_1_0_0(b, l + 1); + r = r && Clause(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // [ "," ] + private static boolean Clauses_1_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Clauses_1_0_0")) return false; + consumeTokenFast(b, COMMA); + return true; + } + + /* ********************************************************** */ + // Clauses StructLit + public static boolean Comprehension(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Comprehension")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, COMPREHENSION, ""); + r = Clauses(b, l + 1); + r = r && StructLit(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // Field | Ellipsis | Embedding | LetClause | attribute + public static boolean Declaration(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Declaration")) return false; + boolean r; + Marker m = enter_section_(b, l, _COLLAPSE_, DECLARATION, ""); + r = Field(b, l + 1); + if (!r) r = Ellipsis(b, l + 1); + if (!r) r = Embedding(b, l + 1); + if (!r) r = LetClause(b, l + 1); + if (!r) r = attribute(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // Embedding { "," Embedding }* + public static boolean ElementList(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ElementList")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, ELEMENT_LIST, ""); + r = Embedding(b, l + 1); + r = r && ElementList_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // { "," Embedding }* + private static boolean ElementList_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ElementList_1")) return false; + while (true) { + int c = current_position_(b); + if (!ElementList_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ElementList_1", c)) break; + } + return true; + } + + // "," Embedding + private static boolean ElementList_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ElementList_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, COMMA); + r = r && Embedding(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // "..." [ Expression ] + public static boolean Ellipsis(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Ellipsis")) return false; + if (!nextTokenIsFast(b, ELLIPSIS_TOKEN)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, ELLIPSIS_TOKEN); + r = r && Ellipsis_1(b, l + 1); + exit_section_(b, m, ELLIPSIS, r); + return r; + } + + // [ Expression ] + private static boolean Ellipsis_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Ellipsis_1")) return false; + Expression(b, l + 1, -1); + return true; + } + + /* ********************************************************** */ + // Comprehension | AliasExpr + public static boolean Embedding(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Embedding")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, EMBEDDING, ""); + r = Comprehension(b, l + 1); + if (!r) r = AliasExpr(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // Label ":" { Label ":" }* Expression { attribute }* + public static boolean Field(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Field")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, FIELD, ""); + r = Label(b, l + 1); + r = r && consumeToken(b, COLON); + r = r && Field_2(b, l + 1); + r = r && Expression(b, l + 1, -1); + r = r && Field_4(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // { Label ":" }* + private static boolean Field_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Field_2")) return false; + while (true) { + int c = current_position_(b); + if (!Field_2_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Field_2", c)) break; + } + return true; + } + + // Label ":" + private static boolean Field_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Field_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Label(b, l + 1); + r = r && consumeToken(b, COLON); + exit_section_(b, m, null, r); + return r; + } + + // { attribute }* + private static boolean Field_4(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Field_4")) return false; + while (true) { + int c = current_position_(b); + if (!Field_4_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Field_4", c)) break; + } + return true; + } + + // { attribute } + private static boolean Field_4_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Field_4_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = attribute(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // "for" IDENTIFIER [ "," IDENTIFIER ] "in" Expression + public static boolean ForClause(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ForClause")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, FOR_CLAUSE, ""); + r = consumeTokenFast(b, "for"); + r = r && consumeToken(b, IDENTIFIER); + r = r && ForClause_2(b, l + 1); + r = r && consumeToken(b, "in"); + r = r && Expression(b, l + 1, -1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // [ "," IDENTIFIER ] + private static boolean ForClause_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ForClause_2")) return false; + ForClause_2_0(b, l + 1); + return true; + } + + // "," IDENTIFIER + private static boolean ForClause_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ForClause_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, COMMA, IDENTIFIER); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // "if" Expression + public static boolean GuardClause(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "GuardClause")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, GUARD_CLAUSE, ""); + r = consumeTokenFast(b, "if"); + r = r && Expression(b, l + 1, -1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // "import" ( ImportSpec | "(" { ImportSpec "," }* ")" ) + public static boolean ImportDecl(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportDecl")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, IMPORT_DECL, ""); + r = consumeTokenFast(b, "import"); + r = r && ImportDecl_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // ImportSpec | "(" { ImportSpec "," }* ")" + private static boolean ImportDecl_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportDecl_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = ImportSpec(b, l + 1); + if (!r) r = ImportDecl_1_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // "(" { ImportSpec "," }* ")" + private static boolean ImportDecl_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportDecl_1_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, LEFT_PAREN); + r = r && ImportDecl_1_1_1(b, l + 1); + r = r && consumeToken(b, RIGHT_PAREN); + exit_section_(b, m, null, r); + return r; + } + + // { ImportSpec "," }* + private static boolean ImportDecl_1_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportDecl_1_1_1")) return false; + while (true) { + int c = current_position_(b); + if (!ImportDecl_1_1_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ImportDecl_1_1_1", c)) break; + } + return true; + } + + // ImportSpec "," + private static boolean ImportDecl_1_1_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportDecl_1_1_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = ImportSpec(b, l + 1); + r = r && consumeToken(b, COMMA); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // { UNICODE_VALUE }* + public static boolean ImportLocation(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportLocation")) return false; + Marker m = enter_section_(b, l, _NONE_, IMPORT_LOCATION, ""); + while (true) { + int c = current_position_(b); + if (!ImportLocation_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ImportLocation", c)) break; + } + exit_section_(b, l, m, true, false, null); + return true; + } + + // { UNICODE_VALUE } + private static boolean ImportLocation_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportLocation_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, UNICODE_VALUE); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // "\"" ImportLocation [ ":" IDENTIFIER ] "\"" + public static boolean ImportPath(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportPath")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, IMPORT_PATH, ""); + r = consumeTokenFast(b, "\""); + r = r && ImportLocation(b, l + 1); + r = r && ImportPath_2(b, l + 1); + r = r && consumeToken(b, "\""); + exit_section_(b, l, m, r, false, null); + return r; + } + + // [ ":" IDENTIFIER ] + private static boolean ImportPath_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportPath_2")) return false; + ImportPath_2_0(b, l + 1); + return true; + } + + // ":" IDENTIFIER + private static boolean ImportPath_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportPath_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, COLON, IDENTIFIER); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // [ PackageName ] ImportPath + public static boolean ImportSpec(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportSpec")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, IMPORT_SPEC, ""); + r = ImportSpec_0(b, l + 1); + r = r && ImportPath(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // [ PackageName ] + private static boolean ImportSpec_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportSpec_0")) return false; + PackageName(b, l + 1); + return true; + } + + /* ********************************************************** */ + // "[" Expression "]" + public static boolean Index(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Index")) return false; + if (!nextTokenIsFast(b, LEFT_BRACKET)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, LEFT_BRACKET); + r = r && Expression(b, l + 1, -1); + r = r && consumeToken(b, RIGHT_BRACKET); + exit_section_(b, m, INDEX, r); + return r; + } + + /* ********************************************************** */ + // [ IDENTIFIER "=" ] LabelExpr + public static boolean Label(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Label")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, LABEL, "