From e49370a43672330b5adba74006e8b87789a23b9f Mon Sep 17 00:00:00 2001 From: Shannon Pamperl Date: Fri, 3 Jan 2025 12:11:16 -0600 Subject: [PATCH 1/4] Add TOML language parser --- rewrite-toml/build.gradle.kts | 25 + rewrite-toml/src/main/antlr/TomlLexer.g4 | 153 ++ rewrite-toml/src/main/antlr/TomlParser.g4 | 137 ++ .../java/org/openrewrite/toml/Assertions.java | 52 + .../org/openrewrite/toml/TomlIsoVisitor.java | 46 + .../java/org/openrewrite/toml/TomlParser.java | 117 + .../toml/TomlParsingException.java | 31 + .../org/openrewrite/toml/TomlVisitor.java | 119 ++ .../toml/internal/TomlParserVisitor.java | 517 +++++ .../toml/internal/TomlPrinter.java | 151 ++ .../toml/internal/grammar/TomlLexer.interp | 176 ++ .../toml/internal/grammar/TomlLexer.java | 585 +++++ .../toml/internal/grammar/TomlLexer.tokens | 41 + .../toml/internal/grammar/TomlParser.interp | 96 + .../toml/internal/grammar/TomlParser.java | 1886 +++++++++++++++++ .../toml/internal/grammar/TomlParser.tokens | 41 + .../grammar/TomlParserBaseListener.java | 307 +++ .../grammar/TomlParserBaseVisitor.java | 177 ++ .../internal/grammar/TomlParserListener.java | 235 ++ .../internal/grammar/TomlParserVisitor.java | 154 ++ .../toml/internal/package-info.java | 21 + .../openrewrite/toml/marker/ArrayTable.java | 28 + .../openrewrite/toml/marker/InlineTable.java | 28 + .../openrewrite/toml/marker/package-info.java | 21 + .../org/openrewrite/toml/package-info.java | 21 + .../org/openrewrite/toml/tree/Comment.java | 28 + .../java/org/openrewrite/toml/tree/Space.java | 270 +++ .../java/org/openrewrite/toml/tree/Toml.java | 358 ++++ .../org/openrewrite/toml/tree/TomlKey.java | 19 + .../toml/tree/TomlRightPadded.java | 118 ++ .../org/openrewrite/toml/tree/TomlType.java | 29 + .../org/openrewrite/toml/tree/TomlValue.java | 19 + .../openrewrite/toml/tree/package-info.java | 21 + .../org/openrewrite/toml/TomlParserTest.java | 341 +++ settings.gradle.kts | 1 + 35 files changed, 6369 insertions(+) create mode 100644 rewrite-toml/build.gradle.kts create mode 100644 rewrite-toml/src/main/antlr/TomlLexer.g4 create mode 100644 rewrite-toml/src/main/antlr/TomlParser.g4 create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/Assertions.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/TomlIsoVisitor.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/TomlParser.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/TomlParsingException.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/TomlVisitor.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlParserVisitor.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.interp create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.tokens create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.interp create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.tokens create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/internal/package-info.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/marker/ArrayTable.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/marker/InlineTable.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/marker/package-info.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/package-info.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/Comment.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/Space.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlKey.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlType.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlValue.java create mode 100644 rewrite-toml/src/main/java/org/openrewrite/toml/tree/package-info.java create mode 100644 rewrite-toml/src/test/java/org/openrewrite/toml/TomlParserTest.java diff --git a/rewrite-toml/build.gradle.kts b/rewrite-toml/build.gradle.kts new file mode 100644 index 00000000000..13534f609c6 --- /dev/null +++ b/rewrite-toml/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("org.openrewrite.build.language-library") +} + +tasks.register("generateAntlrSources") { + mainClass.set("org.antlr.v4.Tool") + + args = listOf( + "-o", "src/main/java/org/openrewrite/toml/internal/grammar", + "-package", "org.openrewrite.toml.internal.grammar", + "-visitor" + ) + fileTree("src/main/antlr").matching { include("**/*.g4") }.map { it.path } + + classpath = sourceSets["main"].runtimeClasspath +} + +dependencies { + implementation(project(":rewrite-core")) + implementation("org.antlr:antlr4-runtime:4.11.1") + implementation("io.micrometer:micrometer-core:1.9.+") + + compileOnly(project(":rewrite-test")) + + testImplementation(project(":rewrite-test")) +} diff --git a/rewrite-toml/src/main/antlr/TomlLexer.g4 b/rewrite-toml/src/main/antlr/TomlLexer.g4 new file mode 100644 index 00000000000..acebee19662 --- /dev/null +++ b/rewrite-toml/src/main/antlr/TomlLexer.g4 @@ -0,0 +1,153 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar TomlLexer; + +channels { + COMMENTS_CHANNEL +} + +WS : [ \t]+ -> skip; +NL : ('\r'? '\n')+; +COMMENT : '#' (~[\r\n])* -> channel(COMMENTS_CHANNEL); +L_BRACKET : '['; +DOUBLE_L_BRACKET : '[['; +R_BRACKET : ']'; +DOUBLE_R_BRACKET : ']]'; +EQUALS : '=' -> pushMode(SIMPLE_VALUE_MODE); +DOT : '.'; +COMMA : ',' -> skip; + +fragment DIGIT : [0-9]; +fragment ALPHA : [A-Za-z]; + +// strings +fragment ESC : '\\' (["\\/bfnrt] | UNICODE | EX_UNICODE); +fragment UNICODE : 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; +fragment EX_UNICODE: + 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT +; +BASIC_STRING : '"' (ESC | ~["\\\n])*? '"'; +LITERAL_STRING : '\'' (~['\n])*? '\''; + +// keys +UNQUOTED_KEY: (ALPHA | DIGIT | '-' | '_')+; + +mode SIMPLE_VALUE_MODE; + +VALUE_WS: WS -> skip; + +L_BRACE : '{' -> mode(INLINE_TABLE_MODE); +ARRAY_START : L_BRACKET -> type(L_BRACKET), mode(ARRAY_MODE); + +// booleans +BOOLEAN: ('true' | 'false') -> popMode; + +// strings +fragment ML_ESC : '\\' '\r'? '\n' | ESC; +VALUE_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING), popMode; +ML_BASIC_STRING : '"""' (ML_ESC | ~["\\])*? '"""' -> popMode; +VALUE_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING), popMode; +ML_LITERAL_STRING : '\'\'\'' (.)*? '\'\'\'' -> popMode; + +// floating point numbers +fragment EXP : ('e' | 'E') [+-]? ZERO_PREFIXABLE_INT; +fragment ZERO_PREFIXABLE_INT : DIGIT (DIGIT | '_' DIGIT)*; +fragment FRAC : '.' ZERO_PREFIXABLE_INT; +FLOAT : DEC_INT ( EXP | FRAC EXP?) -> popMode; +INF : [+-]? 'inf' -> popMode; +NAN : [+-]? 'nan' -> popMode; + +// integers +fragment HEX_DIGIT : [A-Fa-f] | DIGIT; +fragment DIGIT_1_9 : [1-9]; +fragment DIGIT_0_7 : [0-7]; +fragment DIGIT_0_1 : [0-1]; +DEC_INT : [+-]? (DIGIT | (DIGIT_1_9 (DIGIT | '_' DIGIT)+)) -> popMode; +HEX_INT : '0x' HEX_DIGIT (HEX_DIGIT | '_' HEX_DIGIT)* -> popMode; +OCT_INT : '0o' DIGIT_0_7 (DIGIT_0_7 | '_' DIGIT_0_7)* -> popMode; +BIN_INT : '0b' DIGIT_0_1 (DIGIT_0_1 | '_' DIGIT_0_1)* -> popMode; + +// dates +fragment YEAR : DIGIT DIGIT DIGIT DIGIT; +fragment MONTH : DIGIT DIGIT; +fragment DAY : DIGIT DIGIT; +fragment DELIM : 'T' | 't' | ' '; +fragment HOUR : DIGIT DIGIT; +fragment MINUTE : DIGIT DIGIT; +fragment SECOND : DIGIT DIGIT; +fragment SECFRAC : '.' DIGIT+; +fragment NUMOFFSET : ('+' | '-') HOUR ':' MINUTE; +fragment OFFSET : 'Z' | NUMOFFSET; +fragment PARTIAL_TIME : HOUR ':' MINUTE ':' SECOND SECFRAC?; +fragment FULL_DATE : YEAR '-' MONTH '-' DAY; +fragment FULL_TIME : PARTIAL_TIME OFFSET; +OFFSET_DATE_TIME : FULL_DATE DELIM FULL_TIME -> popMode; +LOCAL_DATE_TIME : FULL_DATE DELIM PARTIAL_TIME -> popMode; +LOCAL_DATE : FULL_DATE -> popMode; +LOCAL_TIME : PARTIAL_TIME -> popMode; + +mode INLINE_TABLE_MODE; + +INLINE_TABLE_WS : WS -> skip; +INLINE_TABLE_KEY_DOT : DOT -> type(DOT); +INLINE_TABLE_COMMA : COMMA -> type(COMMA); +R_BRACE : '}' -> popMode; + +INLINE_TABLE_KEY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING); +INLINE_TABLE_KEY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING); +INLINE_TABLE_KEY_UNQUOTED : UNQUOTED_KEY -> type(UNQUOTED_KEY); + +INLINE_TABLE_EQUALS: EQUALS -> type(EQUALS), pushMode(SIMPLE_VALUE_MODE); + +mode ARRAY_MODE; + +ARRAY_WS : WS -> skip; +ARRAY_NL : NL -> type(NL); +ARRAY_COMMENT : COMMENT -> type(COMMENT); +ARRAY_COMMA : COMMA -> type(COMMA); + +ARRAY_INLINE_TABLE_START : L_BRACE -> type(L_BRACE), pushMode(INLINE_TABLE_MODE); +NESTED_ARRAY_START : L_BRACKET -> type(L_BRACKET), pushMode(ARRAY_MODE); +ARRAY_END : R_BRACKET -> type(R_BRACKET), popMode; + +ARRAY_BOOLEAN: BOOLEAN -> type(BOOLEAN); + +ARRAY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING); +ARRAY_ML_BASIC_STRING : ML_BASIC_STRING -> type(ML_BASIC_STRING); +ARRAY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING); +ARRAY_ML_LITERAL_STRING : ML_LITERAL_STRING -> type(ML_LITERAL_STRING); + +ARRAY_FLOAT : FLOAT -> type(FLOAT); +ARRAY_INF : INF -> type(INF); +ARRAY_NAN : NAN -> type(NAN); + +ARRAY_DEC_INT : DEC_INT -> type(DEC_INT); +ARRAY_HEX_INT : HEX_INT -> type(HEX_INT); +ARRAY_OCT_INT : OCT_INT -> type(OCT_INT); +ARRAY_BIN_INT : BIN_INT -> type(BIN_INT); + +ARRAY_OFFSET_DATE_TIME : OFFSET_DATE_TIME -> type(OFFSET_DATE_TIME); +ARRAY_LOCAL_DATE_TIME : LOCAL_DATE_TIME -> type(LOCAL_DATE_TIME); +ARRAY_LOCAL_DATE : LOCAL_DATE -> type(LOCAL_DATE); +ARRAY_LOCAL_TIME : LOCAL_TIME -> type(LOCAL_TIME); diff --git a/rewrite-toml/src/main/antlr/TomlParser.g4 b/rewrite-toml/src/main/antlr/TomlParser.g4 new file mode 100644 index 00000000000..46e51369ef8 --- /dev/null +++ b/rewrite-toml/src/main/antlr/TomlParser.g4 @@ -0,0 +1,137 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +parser grammar TomlParser; + +options { + tokenVocab = TomlLexer; +} + +document + : expression? (NL expression?)* EOF + ; + +expression + : keyValue comment? + | table comment? + | comment + ; + +comment + : COMMENT + ; + +keyValue + : key EQUALS value + ; + +key + : simpleKey + | dottedKey + ; + +simpleKey + : quotedKey + | unquotedKey + ; + +unquotedKey + : UNQUOTED_KEY + ; + +quotedKey + : BASIC_STRING + | LITERAL_STRING + ; + +dottedKey + : simpleKey (DOT simpleKey)+ + ; + +value + : string + | integer + | floatingPoint + | bool + | dateTime + | array + | inlineTable + ; + +string + : BASIC_STRING + | ML_BASIC_STRING + | LITERAL_STRING + | ML_LITERAL_STRING + ; + +integer + : DEC_INT + | HEX_INT + | OCT_INT + | BIN_INT + ; + +floatingPoint + : FLOAT + | INF + | NAN + ; + +bool + : BOOLEAN + ; + +dateTime + : OFFSET_DATE_TIME + | LOCAL_DATE_TIME + | LOCAL_DATE + | LOCAL_TIME + ; + +commentOrNl + : COMMENT NL + | NL + ; + +array + : L_BRACKET commentOrNl* R_BRACKET + | L_BRACKET commentOrNl* value (COMMA commentOrNl* value COMMA?)* commentOrNl* R_BRACKET + ; + +table + : standardTable + | arrayTable + ; + +standardTable + : L_BRACKET key R_BRACKET (commentOrNl* expression)* + ; + +inlineTable + : L_BRACE commentOrNl* R_BRACE + | L_BRACE commentOrNl* keyValue (COMMA commentOrNl* keyValue COMMA?)* commentOrNl* R_BRACE + ; + +arrayTable + : DOUBLE_L_BRACKET key DOUBLE_R_BRACKET (commentOrNl* expression)* + ; diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/Assertions.java b/rewrite-toml/src/main/java/org/openrewrite/toml/Assertions.java new file mode 100644 index 00000000000..85de7b6d79c --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/Assertions.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import org.intellij.lang.annotations.Language; +import org.openrewrite.internal.lang.Nullable; +import org.openrewrite.test.SourceSpec; +import org.openrewrite.test.SourceSpecs; +import org.openrewrite.toml.tree.Toml; + +import java.util.function.Consumer; + +public class Assertions { + private Assertions() { + } + + public static SourceSpecs toml(@Language("toml") @Nullable String before) { + return Assertions.toml(before, s -> { + }); + } + + public static SourceSpecs toml(@Language("toml") @Nullable String before, Consumer> spec) { + SourceSpec toml = new SourceSpec<>(Toml.Document.class, null, TomlParser.builder(), before, null); + spec.accept(toml); + return toml; + } + + public static SourceSpecs toml(@Language("toml") @Nullable String before, @Language("toml") @Nullable String after) { + return toml(before, after, s -> { + }); + } + + public static SourceSpecs toml(@Language("toml") @Nullable String before, @Language("toml") @Nullable String after, + Consumer> spec) { + SourceSpec toml = new SourceSpec<>(Toml.Document.class, null, TomlParser.builder(), before, s -> after); + spec.accept(toml); + return toml; + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/TomlIsoVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlIsoVisitor.java new file mode 100644 index 00000000000..fff819fd1af --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlIsoVisitor.java @@ -0,0 +1,46 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import org.openrewrite.toml.tree.Toml; + +public class TomlIsoVisitor

extends TomlVisitor

{ + + @Override + public Toml.Array visitArray(Toml.Array array, P p) { + return (Toml.Array) super.visitArray(array, p); + } + + @Override + public Toml.Document visitDocument(Toml.Document document, P p) { + return (Toml.Document) super.visitDocument(document, p); + } + + @Override + public Toml.Identifier visitIdentifier(Toml.Identifier identifier, P p) { + return (Toml.Identifier) super.visitIdentifier(identifier, p); + } + + @Override + public Toml.KeyValue visitKeyValue(Toml.KeyValue keyValue, P p) { + return (Toml.KeyValue) super.visitKeyValue(keyValue, p); + } + + @Override + public Toml.Literal visitLiteral(Toml.Literal literal, P p) { + return (Toml.Literal) super.visitLiteral(literal, p); + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParser.java b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParser.java new file mode 100644 index 00000000000..37b2ac6f826 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParser.java @@ -0,0 +1,117 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import org.antlr.v4.runtime.*; +import org.intellij.lang.annotations.Language; +import org.openrewrite.ExecutionContext; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.Parser; +import org.openrewrite.SourceFile; +import org.openrewrite.internal.lang.Nullable; +import org.openrewrite.toml.internal.TomlParserVisitor; +import org.openrewrite.toml.internal.grammar.TomlLexer; +import org.openrewrite.toml.tree.Toml; +import org.openrewrite.tree.ParseError; +import org.openrewrite.tree.ParsingEventListener; +import org.openrewrite.tree.ParsingExecutionContextView; + +import java.io.InputStream; +import java.nio.file.Path; +import java.util.stream.Stream; + +public class TomlParser implements Parser { + @Override + public Stream parseInputs(Iterable sourceFiles, @Nullable Path relativeTo, ExecutionContext ctx) { + ParsingEventListener parsingListener = ParsingExecutionContextView.view(ctx).getParsingListener(); + return acceptedInputs(sourceFiles).map(input -> { + parsingListener.startedParsing(input); + try (InputStream sourceStream = input.getSource(ctx)) { + TomlLexer lexer = new TomlLexer(CharStreams.fromStream(sourceStream)); + lexer.removeErrorListeners(); + lexer.addErrorListener(new ForwardingErrorListener(input.getPath(), ctx)); + + org.openrewrite.toml.internal.grammar.TomlParser parser = new org.openrewrite.toml.internal.grammar.TomlParser(new CommonTokenStream(lexer)); + parser.removeErrorListeners(); + parser.addErrorListener(new ForwardingErrorListener(input.getPath(), ctx)); + + Toml.Document document = new TomlParserVisitor( + input.getRelativePath(relativeTo), + input.getFileAttributes(), + input.getSource(ctx) + ).visitDocument(parser.document()); + parsingListener.parsed(input, document); + return requirePrintEqualsInput(document, input, relativeTo, ctx); + } catch (Throwable t) { + ctx.getOnError().accept(t); + return ParseError.build(this, input, relativeTo, ctx, t); + } + }); + } + + @Override + public Stream parse(@Language("toml") String... sources) { + return parse(new InMemoryExecutionContext(), sources); + } + + @Override + public boolean accept(Path path) { + return path.toString().endsWith(".toml"); + } + + @Override + public Path sourcePathFromSourceText(Path prefix, String sourceCode) { + return prefix.resolve("file.toml"); + } + + private static class ForwardingErrorListener extends BaseErrorListener { + private final Path sourcePath; + private final ExecutionContext ctx; + + private ForwardingErrorListener(Path sourcePath, ExecutionContext ctx) { + this.sourcePath = sourcePath; + this.ctx = ctx; + } + + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, + int line, int charPositionInLine, String msg, RecognitionException e) { + ctx.getOnError().accept(new TomlParsingException(sourcePath, + String.format("Syntax error in %s at line %d:%d %s.", sourcePath, line, charPositionInLine, msg), e)); + } + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Parser.Builder { + + public Builder() { + super(Toml.Document.class); + } + + @Override + public TomlParser build() { + return new TomlParser(); + } + + @Override + public String getDslName() { + return "toml"; + } + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParsingException.java b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParsingException.java new file mode 100644 index 00000000000..2de5c34fafe --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlParsingException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import java.nio.file.Path; + +public class TomlParsingException extends Exception { + private final Path sourcePath; + + public TomlParsingException(Path sourcePath, String message, Throwable t) { + super(message, t); + this.sourcePath = sourcePath; + } + + public Path getSourcePath() { + return sourcePath; + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/TomlVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlVisitor.java new file mode 100644 index 00000000000..b3707132e10 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/TomlVisitor.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import org.openrewrite.Cursor; +import org.openrewrite.SourceFile; +import org.openrewrite.TreeVisitor; +import org.openrewrite.internal.ListUtils; +import org.openrewrite.internal.lang.Nullable; +import org.openrewrite.toml.tree.*; + +public class TomlVisitor

extends TreeVisitor { + + @Override + public boolean isAcceptable(SourceFile sourceFile, P p) { + return sourceFile instanceof Toml.Document; + } + + @Override + public String getLanguage() { + return "toml"; + } + + public Toml visitArray(Toml.Array array, P p) { + Toml.Array a = array; + a = a.withPrefix(visitSpace(a.getPrefix(), p)); + a = a.withMarkers(visitMarkers(a.getMarkers(), p)); + a = a.withValues(ListUtils.map(a.getValues(), v -> (TomlValue) visit(v, p))); + return a; + } + + public Toml visitDocument(Toml.Document document, P p) { + Toml.Document d = document; + d = d.withPrefix(visitSpace(d.getPrefix(), p)); + d = d.withMarkers(visitMarkers(d.getMarkers(), p)); + d = d.withValues(ListUtils.map(d.getValues(), v -> (TomlValue) visit(v, p))); + d = d.withEof(visitSpace(d.getEof(), p)); + return d; + } + + public Toml visitEmpty(Toml.Empty empty, P p) { + Toml.Empty e = empty; + e = e.withPrefix(visitSpace(e.getPrefix(), p)); + e = e.withMarkers(visitMarkers(e.getMarkers(), p)); + return e; + } + + public Toml visitIdentifier(Toml.Identifier identifier, P p) { + Toml.Identifier i = identifier; + i = i.withPrefix(visitSpace(i.getPrefix(), p)); + i = i.withMarkers(visitMarkers(i.getMarkers(), p)); + return i; + } + + public Toml visitKeyValue(Toml.KeyValue keyValue, P p) { + Toml.KeyValue kv = keyValue; + kv = kv.withPrefix(visitSpace(kv.getPrefix(), p)); + kv = kv.withMarkers(visitMarkers(kv.getMarkers(), p)); + kv = kv.getPadding().withKey(visitRightPadded(kv.getPadding().getKey(), p)); + kv = kv.withValue(visit(kv.getValue(), p)); + return kv; + } + + public Toml visitLiteral(Toml.Literal literal, P p) { + Toml.Literal l = literal; + l = l.withPrefix(visitSpace(l.getPrefix(), p)); + l = l.withMarkers(visitMarkers(l.getMarkers(), p)); + return l; + } + + public Space visitSpace(Space space, P p) { + return space; + } + + public Toml visitTable(Toml.Table table, P p) { + Toml.Table t = table; + t = t.withPrefix(visitSpace(t.getPrefix(), p)); + t = t.withMarkers(visitMarkers(t.getMarkers(), p)); + t = t.withValues(ListUtils.map(t.getValues(), v -> visit(v, p))); + return t; + } + + public TomlRightPadded visitRightPadded(@Nullable TomlRightPadded right, P p) { + if (right == null) { + //noinspection ConstantConditions + return null; + } + + setCursor(new Cursor(getCursor(), right)); + + T t = right.getElement(); + if (t instanceof Toml) { + //noinspection unchecked + t = visitAndCast((Toml) right.getElement(), p); + } + + setCursor(getCursor().getParent()); + if (t == null) { + //noinspection ConstantConditions + return null; + } + + Space after = visitSpace(right.getAfter(), p); + return (after == right.getAfter() && t == right.getElement()) ? right : new TomlRightPadded<>(t, after, right.getMarkers()); + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlParserVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlParserVisitor.java new file mode 100644 index 00000000000..e72c3f29f44 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlParserVisitor.java @@ -0,0 +1,517 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.internal; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.RuleNode; +import org.antlr.v4.runtime.tree.TerminalNode; +import org.jspecify.annotations.Nullable; +import org.openrewrite.FileAttributes; +import org.openrewrite.internal.EncodingDetectingInputStream; +import org.openrewrite.marker.Markers; +import org.openrewrite.toml.internal.grammar.TomlParser; +import org.openrewrite.toml.internal.grammar.TomlParserBaseVisitor; +import org.openrewrite.toml.marker.ArrayTable; +import org.openrewrite.toml.marker.InlineTable; +import org.openrewrite.toml.tree.*; + +import java.nio.charset.Charset; +import java.nio.file.Path; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.BiFunction; + +import static org.openrewrite.Tree.randomId; + +public class TomlParserVisitor extends TomlParserBaseVisitor { + private final Path path; + private final String source; + private final Charset charset; + private final boolean charsetBomMarked; + + @Nullable + private final FileAttributes fileAttributes; + + private int cursor = 0; + private int codePointCursor = 0; + + public TomlParserVisitor(Path path, @Nullable FileAttributes fileAttributes, EncodingDetectingInputStream source) { + this.path = path; + this.fileAttributes = fileAttributes; + this.source = source.readFully(); + this.charset = source.getCharset(); + this.charsetBomMarked = source.isCharsetBomMarked(); + } + + @Override + public Toml visitChildren(RuleNode node) { + Toml result = defaultResult(); + int n = node.getChildCount(); + for (int i = 0; i < n; i++) { + if (!shouldVisitNextChild(node, result)) { + break; + } + + ParseTree c = node.getChild(i); + if (c instanceof TomlParser.CommentContext) { + continue; + } + + Toml childResult = c.accept(this); + result = aggregateResult(result, childResult); + } + + return result; + } + + @Override + public Toml.Document visitDocument(TomlParser.DocumentContext ctx) { + if (!ctx.children.isEmpty() && ctx.children.get(0) instanceof TerminalNode && ((TerminalNode) ctx.children.get(0)).getSymbol().getType() == TomlParser.EOF) { + new Toml.Document( + randomId(), + path, + Space.EMPTY, + Markers.EMPTY, + charset.name(), + charsetBomMarked, + null, + fileAttributes, + Collections.emptyList(), + Space.EMPTY + ); + } + + List elements = new ArrayList<>(); + // The last element is a "TerminalNode" which we are uninterested in + for (int i = 0; i < ctx.children.size() - 1; i++) { + TomlValue element = (TomlValue) visit(ctx.children.get(i)); + if (element != null) { + elements.add(element); + } + } + + return new Toml.Document( + randomId(), + path, + Space.EMPTY, + Markers.EMPTY, + charset.name(), + charsetBomMarked, + null, + fileAttributes, + elements, + Space.format(source, cursor, source.length()) + ); + } + + @Override + public Toml.Identifier visitKey(TomlParser.KeyContext ctx) { + return (Toml.Identifier) super.visitKey(ctx); + } + + @Override + public Toml.Identifier visitSimpleKey(TomlParser.SimpleKeyContext ctx) { + return convert(ctx, (c, prefix) -> new Toml.Identifier( + randomId(), + prefix, + Markers.EMPTY, + c.getText(), + c.getText() + )); + } + + @Override + public Toml.Identifier visitDottedKey(TomlParser.DottedKeyContext ctx) { + Space prefix = prefix(ctx); + StringBuilder text = new StringBuilder(); + StringBuilder key = new StringBuilder(); + for (ParseTree child : ctx.children) { + Space space = sourceBefore(child.getText()); + text.append(space.getWhitespace()).append(child.getText()); + key.append(child.getText()); + } + return new Toml.Identifier( + randomId(), + prefix, + Markers.EMPTY, + text.toString(), + key.toString() + ); + } + + @Override + public Toml.KeyValue visitKeyValue(TomlParser.KeyValueContext ctx) { + return convert(ctx, (c, prefix) -> new Toml.KeyValue( + randomId(), + prefix, + Markers.EMPTY, + TomlRightPadded.build((TomlKey) visitKey(c.key())).withAfter(sourceBefore("=")), + visitValue(c.value()) + )); + } + + @Override + public Toml visitString(TomlParser.StringContext ctx) { + return convert(ctx, (c, prefix) -> { + String string = c.getText(); + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.String, + string, + string.substring(1, string.length() - 1) + ); + }); + } + + @Override + public Toml visitInteger(TomlParser.IntegerContext ctx) { + return convert(ctx, (c, prefix) -> { + String rawNumber = c.getText(); + String number = rawNumber.replace("_", ""); + Long numberValue = rawNumber.startsWith("0x") ? Long.parseLong(number.substring(2), 16) : + rawNumber.startsWith("0o") ? Long.parseLong(number.substring(2), 8) : + rawNumber.startsWith("0b") ? Long.parseLong(number.substring(2), 2) : + Long.parseLong(number); + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.Integer, + rawNumber, + numberValue + ); + }); + } + + @Override + public Toml visitFloatingPoint(TomlParser.FloatingPointContext ctx) { + return convert(ctx, (c, prefix) -> { + String rawNumber = c.getText(); + if (c.NAN() != null) { + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.Float, + rawNumber, + Double.NaN + ); + } else if (c.INF() != null) { + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.Float, + rawNumber, + source.charAt(cursor) == '-' ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY + ); + } + + String number = rawNumber.replace("_", ""); + Double numberValue = Double.parseDouble(number); + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.Float, + rawNumber, + numberValue + ); + }); + } + + @Override + public Toml visitBool(TomlParser.BoolContext ctx) { + return convert(ctx, (c, prefix) -> { + String bool = c.getText(); + Boolean boolValue = Boolean.parseBoolean(bool); + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.Boolean, + bool, + boolValue + ); + }); + } + + private static final DateTimeFormatter RFC3339_OFFSET_DATE_TIME; + + static { + RFC3339_OFFSET_DATE_TIME = new DateTimeFormatterBuilder() + .parseCaseInsensitive() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral(' ') + .append(DateTimeFormatter.ISO_LOCAL_TIME) + .parseLenient() + .appendOffsetId() + .parseStrict() + .toFormatter(); + } + + @Override + public Toml visitDateTime(TomlParser.DateTimeContext ctx) { + return convert(ctx, (c, prefix) -> { + String dateTime = c.getText(); + if (c.OFFSET_DATE_TIME() != null) { + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.OffsetDateTime, + dateTime, + dateTime.contains("T") ? OffsetDateTime.parse(dateTime) : OffsetDateTime.parse(dateTime, RFC3339_OFFSET_DATE_TIME) + ); + } else if (c.LOCAL_DATE_TIME() != null) { + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.LocalDateTime, + dateTime, + LocalDateTime.parse(dateTime) + ); + } else if (c.LOCAL_DATE() != null) { + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.LocalDate, + dateTime, + LocalDate.parse(dateTime) + ); + } + + return new Toml.Literal( + randomId(), + prefix, + Markers.EMPTY, + TomlType.Primitive.LocalTime, + dateTime, + LocalTime.parse(dateTime) + ); + }); + } + + @Override + public Toml visitArray(TomlParser.ArrayContext ctx) { + return convert(ctx, (c, prefix) -> { + sourceBefore("["); + List values = c.value(); + List> elements = new ArrayList<>(); + for (int i = 0; i < values.size(); i++) { + Toml element = visit(values.get(i)); + if (i == values.size() - 1) { + if (positionOfNext(",", ']') >= 0) { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore(","))); + elements.add(TomlRightPadded.build((Toml) new Toml.Empty(randomId(), Space.EMPTY, Markers.EMPTY)).withAfter(sourceBefore("]"))); + } else { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore("]"))); + } + } else { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore(","))); + } + } + + return new Toml.Array( + randomId(), + prefix, + Markers.EMPTY, + elements + ); + }); + } + + @Override + public Toml visitInlineTable(TomlParser.InlineTableContext ctx) { + return convert(ctx, (c, prefix) -> { + sourceBefore("{"); + List values = c.keyValue(); + List> elements = new ArrayList<>(); + for (int i = 0; i < values.size(); i++) { + Toml element = visit(values.get(i)); + if (i == values.size() - 1) { + if (positionOfNext(",", '}') >= 0) { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore(","))); + elements.add(TomlRightPadded.build((Toml) new Toml.Empty(randomId(), Space.EMPTY, Markers.EMPTY)).withAfter(sourceBefore("}"))); + } else { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore("}"))); + } + } else { + elements.add(TomlRightPadded.build(element).withAfter(sourceBefore(","))); + } + } + + return new Toml.Table( + randomId(), + prefix, + Markers.build(Collections.singletonList(new InlineTable(randomId()))), + null, + elements + ); + }); + } + + @Override + public Toml visitStandardTable(TomlParser.StandardTableContext ctx) { + return convert(ctx, (c, prefix) -> { + sourceBefore("["); + Toml.Identifier tableName = visitKey(c.key()); + TomlRightPadded nameRightPadded = TomlRightPadded.build(tableName).withAfter(sourceBefore("]")); + + List values = c.expression(); + List> elements = new ArrayList<>(); + for (int i = 0; i < values.size(); i++) { + elements.add(TomlRightPadded.build(visit(values.get(i)))); + } + + return new Toml.Table( + randomId(), + prefix, + Markers.EMPTY, + nameRightPadded, + elements + ); + }); + } + + @Override + public Toml visitArrayTable(TomlParser.ArrayTableContext ctx) { + return convert(ctx, (c, prefix) -> { + sourceBefore("[["); + Toml.Identifier tableName = visitKey(c.key()); + TomlRightPadded nameRightPadded = TomlRightPadded.build(tableName).withAfter(sourceBefore("]]")); + + List values = c.expression(); + List> elements = new ArrayList<>(); + for (int i = 0; i < values.size(); i++) { + elements.add(TomlRightPadded.build(visit(values.get(i)))); + } + + return new Toml.Table( + randomId(), + prefix, + Markers.build(Collections.singletonList(new ArrayTable(randomId()))), + nameRightPadded, + elements + ); + }); + } + + private Space prefix(ParserRuleContext ctx) { + return prefix(ctx.getStart()); + } + + private Space prefix(@Nullable TerminalNode terminalNode) { + return terminalNode == null ? Space.EMPTY : prefix(terminalNode.getSymbol()); + } + + private Space prefix(Token token) { + int start = token.getStartIndex(); + if (start < codePointCursor) { + return Space.EMPTY; + } + return Space.format(source, cursor, advanceCursor(start)); + } + + public int advanceCursor(int newCodePointIndex) { + for (; codePointCursor < newCodePointIndex; codePointCursor++) { + cursor = source.offsetByCodePoints(cursor, 1); + } + return cursor; + } + + private @Nullable T convert(C ctx, BiFunction conversion) { + if (ctx == null) { + return null; + } + + T t = conversion.apply(ctx, prefix(ctx)); + if (ctx.getStop() != null) { + advanceCursor(ctx.getStop().getStopIndex() + 1); + } + + return t; + } + + private T convert(TerminalNode node, BiFunction conversion) { + T t = conversion.apply(node, prefix(node)); + advanceCursor(node.getSymbol().getStopIndex() + 1); + return t; + } + + private void skip(TerminalNode node) { + advanceCursor(node.getSymbol().getStopIndex() + 1); + } + + /** + * @return Source from cursor to next occurrence of untilDelim, + * and if not found in the remaining source, the empty String. If stop is reached before + * untilDelim return the empty String. + */ + private Space sourceBefore(String untilDelim) { + int delimIndex = positionOfNext(untilDelim, null); + if (delimIndex < 0) { + return Space.EMPTY; // unable to find this delimiter + } + + Space space = Space.format(source, cursor, delimIndex); + advanceCursor(codePointCursor + Character.codePointCount(source, cursor, delimIndex) + untilDelim.length()); + return space; + } + + private int positionOfNext(String untilDelim, @Nullable Character stop) { + boolean inSingleLineComment = false; + + int delimIndex = cursor; + for (; delimIndex < source.length() - untilDelim.length() + 1; delimIndex++) { + if (inSingleLineComment) { + if (source.charAt(delimIndex) == '\n') { + inSingleLineComment = false; + } + } else { + if (source.charAt(delimIndex) == '#') { + inSingleLineComment = true; + delimIndex++; + } + + if (!inSingleLineComment) { + if (stop != null && source.charAt(delimIndex) == stop) { + return -1; // reached stop word before finding the delimiter + } + + if (source.startsWith(untilDelim, delimIndex)) { + break; // found it! + } + } + } + } + + return delimIndex > source.length() - untilDelim.length() ? -1 : delimIndex; + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java new file mode 100644 index 00000000000..88de816e9ef --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java @@ -0,0 +1,151 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.internal; + +import org.openrewrite.Cursor; +import org.openrewrite.PrintOutputCapture; +import org.openrewrite.marker.Marker; +import org.openrewrite.marker.Markers; +import org.openrewrite.toml.TomlVisitor; +import org.openrewrite.toml.marker.ArrayTable; +import org.openrewrite.toml.marker.InlineTable; +import org.openrewrite.toml.tree.Comment; +import org.openrewrite.toml.tree.Space; +import org.openrewrite.toml.tree.Toml; +import org.openrewrite.toml.tree.TomlRightPadded; + +import java.util.List; +import java.util.function.UnaryOperator; + +public class TomlPrinter

extends TomlVisitor> { + + public Toml visitArray(Toml.Array array, PrintOutputCapture

p) { + beforeSyntax(array, p); + p.append("["); + visitRightPadded(array.getPadding().getValues(), ",", p); + p.append("]"); + afterSyntax(array, p); + return array; + } + + public Toml visitDocument(Toml.Document document, PrintOutputCapture

p) { + beforeSyntax(document, p); + visit(document.getValues(), p); + visitSpace(document.getEof(), p); + afterSyntax(document, p); + return document; + } + + public Toml visitEmpty(Toml.Empty empty, PrintOutputCapture

p) { + beforeSyntax(empty, p); + afterSyntax(empty, p); + return empty; + } + + public Toml visitIdentifier(Toml.Identifier identifier, PrintOutputCapture

p) { + beforeSyntax(identifier, p); + p.append(identifier.getSource()); + afterSyntax(identifier, p); + return identifier; + } + + public Toml visitKeyValue(Toml.KeyValue keyValue, PrintOutputCapture

p) { + beforeSyntax(keyValue, p); + visitRightPadded(keyValue.getPadding().getKey(), p); + p.append("="); + visit(keyValue.getValue(), p); + afterSyntax(keyValue, p); + return keyValue; + } + + public Toml visitLiteral(Toml.Literal literal, PrintOutputCapture

p) { + beforeSyntax(literal, p); + p.append(literal.getSource()); + afterSyntax(literal, p); + return literal; + } + + @Override + public Space visitSpace(Space space, PrintOutputCapture

p) { + p.append(space.getWhitespace()); + for (Comment comment : space.getComments()) { + visitMarkers(comment.getMarkers(), p); + p.append("#").append(comment.getText()).append(comment.getSuffix()); + } + return space; + } + + @Override + public Toml visitTable(Toml.Table table, PrintOutputCapture

p) { + beforeSyntax(table, p); + if (table.getMarkers().findFirst(InlineTable.class).isPresent()) { + p.append("{"); + visitRightPadded(table.getPadding().getValues(), ",", p); + p.append("}"); + } else if (table.getMarkers().findFirst(ArrayTable.class).isPresent()) { + p.append("[["); + visitRightPadded(table.getName(), p); + p.append("]]"); + visitRightPadded(table.getPadding().getValues(), "", p); + } else { + p.append("["); + visitRightPadded(table.getName(), p); + p.append("]"); + visitRightPadded(table.getPadding().getValues(), "", p); + } + afterSyntax(table, p); + return table; + } + + protected void visitRightPadded(List> nodes, String suffixBetween, PrintOutputCapture

p) { + for (int i = 0; i < nodes.size(); i++) { + TomlRightPadded node = nodes.get(i); + visit(node.getElement(), p); + visitSpace(node.getAfter(), p); + if (i < nodes.size() - 1) { + p.append(suffixBetween); + } + } + } + + private static final UnaryOperator TOML_MARKER_WRAPPER = + out -> "~~" + out + (out.isEmpty() ? "" : "~~") + ">"; + + protected void beforeSyntax(Toml t, PrintOutputCapture

p) { + beforeSyntax(t.getPrefix(), t.getMarkers(), p); + } + + protected void beforeSyntax(Space prefix, Markers markers, PrintOutputCapture

p) { + for (Marker marker : markers.getMarkers()) { + p.append(p.getMarkerPrinter().beforePrefix(marker, new Cursor(getCursor(), marker), TOML_MARKER_WRAPPER)); + } + visitSpace(prefix, p); + visitMarkers(markers, p); + for (Marker marker : markers.getMarkers()) { + p.append(p.getMarkerPrinter().beforeSyntax(marker, new Cursor(getCursor(), marker), TOML_MARKER_WRAPPER)); + } + } + + protected void afterSyntax(Toml t, PrintOutputCapture

p) { + afterSyntax(t.getMarkers(), p); + } + + protected void afterSyntax(Markers markers, PrintOutputCapture

p) { + for (Marker marker : markers.getMarkers()) { + p.append(p.getMarkerPrinter().afterSyntax(marker, new Cursor(getCursor(), marker), TOML_MARKER_WRAPPER)); + } + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.interp b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.interp new file mode 100644 index 00000000000..e1b1838c219 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.interp @@ -0,0 +1,176 @@ +token literal names: +null +null +null +null +'[' +'[[' +']' +']]' +'=' +'.' +',' +null +null +null +null +'{' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +'}' +null + +token symbolic names: +null +WS +NL +COMMENT +L_BRACKET +DOUBLE_L_BRACKET +R_BRACKET +DOUBLE_R_BRACKET +EQUALS +DOT +COMMA +BASIC_STRING +LITERAL_STRING +UNQUOTED_KEY +VALUE_WS +L_BRACE +BOOLEAN +ML_BASIC_STRING +ML_LITERAL_STRING +FLOAT +INF +NAN +DEC_INT +HEX_INT +OCT_INT +BIN_INT +OFFSET_DATE_TIME +LOCAL_DATE_TIME +LOCAL_DATE +LOCAL_TIME +INLINE_TABLE_WS +R_BRACE +ARRAY_WS + +rule names: +WS +NL +COMMENT +L_BRACKET +DOUBLE_L_BRACKET +R_BRACKET +DOUBLE_R_BRACKET +EQUALS +DOT +COMMA +DIGIT +ALPHA +ESC +UNICODE +EX_UNICODE +BASIC_STRING +LITERAL_STRING +UNQUOTED_KEY +VALUE_WS +L_BRACE +ARRAY_START +BOOLEAN +ML_ESC +VALUE_BASIC_STRING +ML_BASIC_STRING +VALUE_LITERAL_STRING +ML_LITERAL_STRING +EXP +ZERO_PREFIXABLE_INT +FRAC +FLOAT +INF +NAN +HEX_DIGIT +DIGIT_1_9 +DIGIT_0_7 +DIGIT_0_1 +DEC_INT +HEX_INT +OCT_INT +BIN_INT +YEAR +MONTH +DAY +DELIM +HOUR +MINUTE +SECOND +SECFRAC +NUMOFFSET +OFFSET +PARTIAL_TIME +FULL_DATE +FULL_TIME +OFFSET_DATE_TIME +LOCAL_DATE_TIME +LOCAL_DATE +LOCAL_TIME +INLINE_TABLE_WS +INLINE_TABLE_KEY_DOT +INLINE_TABLE_COMMA +R_BRACE +INLINE_TABLE_KEY_BASIC_STRING +INLINE_TABLE_KEY_LITERAL_STRING +INLINE_TABLE_KEY_UNQUOTED +INLINE_TABLE_EQUALS +ARRAY_WS +ARRAY_NL +ARRAY_COMMENT +ARRAY_COMMA +ARRAY_INLINE_TABLE_START +NESTED_ARRAY_START +ARRAY_END +ARRAY_BOOLEAN +ARRAY_BASIC_STRING +ARRAY_ML_BASIC_STRING +ARRAY_LITERAL_STRING +ARRAY_ML_LITERAL_STRING +ARRAY_FLOAT +ARRAY_INF +ARRAY_NAN +ARRAY_DEC_INT +ARRAY_HEX_INT +ARRAY_OCT_INT +ARRAY_BIN_INT +ARRAY_OFFSET_DATE_TIME +ARRAY_LOCAL_DATE_TIME +ARRAY_LOCAL_DATE +ARRAY_LOCAL_TIME + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN +null +null +COMMENTS_CHANNEL + +mode names: +DEFAULT_MODE +SIMPLE_VALUE_MODE +INLINE_TABLE_MODE +ARRAY_MODE + +atn: +[4, 0, 32, 671, 6, -1, 6, -1, 6, -1, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 1, 0, 4, 0, 184, 8, 0, 11, 0, 12, 0, 185, 1, 0, 1, 0, 1, 1, 3, 1, 191, 8, 1, 1, 1, 4, 1, 194, 8, 1, 11, 1, 12, 1, 195, 1, 2, 1, 2, 5, 2, 200, 8, 2, 10, 2, 12, 2, 203, 9, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 235, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 5, 15, 256, 8, 15, 10, 15, 12, 15, 259, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 5, 16, 265, 8, 16, 10, 16, 12, 16, 268, 9, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 4, 17, 275, 8, 17, 11, 17, 12, 17, 276, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 301, 8, 21, 1, 21, 1, 21, 1, 22, 1, 22, 3, 22, 307, 8, 22, 1, 22, 1, 22, 3, 22, 311, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 5, 24, 324, 8, 24, 10, 24, 12, 24, 327, 9, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 5, 26, 345, 8, 26, 10, 26, 12, 26, 348, 9, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 3, 27, 358, 8, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 5, 28, 366, 8, 28, 10, 28, 12, 28, 369, 9, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 3, 30, 378, 8, 30, 3, 30, 380, 8, 30, 1, 30, 1, 30, 1, 31, 3, 31, 385, 8, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 3, 32, 394, 8, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 3, 33, 404, 8, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 3, 37, 413, 8, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 4, 37, 420, 8, 37, 11, 37, 12, 37, 421, 3, 37, 424, 8, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 435, 8, 38, 10, 38, 12, 38, 438, 9, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 5, 39, 449, 8, 39, 10, 39, 12, 39, 452, 9, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 5, 40, 463, 8, 40, 10, 40, 12, 40, 466, 9, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 4, 48, 494, 8, 48, 11, 48, 12, 48, 495, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 3, 50, 505, 8, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 3, 51, 513, 8, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 76, 1, 76, 1, 77, 1, 77, 1, 77, 1, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 79, 1, 79, 1, 79, 1, 79, 1, 80, 1, 80, 1, 80, 1, 80, 1, 81, 1, 81, 1, 81, 1, 81, 1, 82, 1, 82, 1, 82, 1, 82, 1, 83, 1, 83, 1, 83, 1, 83, 1, 84, 1, 84, 1, 84, 1, 84, 1, 85, 1, 85, 1, 85, 1, 85, 1, 86, 1, 86, 1, 86, 1, 86, 1, 87, 1, 87, 1, 87, 1, 87, 1, 88, 1, 88, 1, 88, 1, 88, 4, 257, 266, 325, 346, 0, 89, 4, 1, 6, 2, 8, 3, 10, 4, 12, 5, 14, 6, 16, 7, 18, 8, 20, 9, 22, 10, 24, 0, 26, 0, 28, 0, 30, 0, 32, 0, 34, 11, 36, 12, 38, 13, 40, 14, 42, 15, 44, 0, 46, 16, 48, 0, 50, 0, 52, 17, 54, 0, 56, 18, 58, 0, 60, 0, 62, 0, 64, 19, 66, 20, 68, 21, 70, 0, 72, 0, 74, 0, 76, 0, 78, 22, 80, 23, 82, 24, 84, 25, 86, 0, 88, 0, 90, 0, 92, 0, 94, 0, 96, 0, 98, 0, 100, 0, 102, 0, 104, 0, 106, 0, 108, 0, 110, 0, 112, 26, 114, 27, 116, 28, 118, 29, 120, 30, 122, 0, 124, 0, 126, 31, 128, 0, 130, 0, 132, 0, 134, 0, 136, 32, 138, 0, 140, 0, 142, 0, 144, 0, 146, 0, 148, 0, 150, 0, 152, 0, 154, 0, 156, 0, 158, 0, 160, 0, 162, 0, 164, 0, 166, 0, 168, 0, 170, 0, 172, 0, 174, 0, 176, 0, 178, 0, 180, 0, 4, 0, 1, 2, 3, 16, 2, 0, 9, 9, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 10, 10, 34, 34, 92, 92, 2, 0, 10, 10, 39, 39, 2, 0, 45, 45, 95, 95, 2, 0, 34, 34, 92, 92, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 2, 0, 65, 70, 97, 102, 1, 0, 49, 57, 1, 0, 48, 55, 1, 0, 48, 49, 3, 0, 32, 32, 84, 84, 116, 116, 680, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 1, 40, 1, 0, 0, 0, 1, 42, 1, 0, 0, 0, 1, 44, 1, 0, 0, 0, 1, 46, 1, 0, 0, 0, 1, 50, 1, 0, 0, 0, 1, 52, 1, 0, 0, 0, 1, 54, 1, 0, 0, 0, 1, 56, 1, 0, 0, 0, 1, 64, 1, 0, 0, 0, 1, 66, 1, 0, 0, 0, 1, 68, 1, 0, 0, 0, 1, 78, 1, 0, 0, 0, 1, 80, 1, 0, 0, 0, 1, 82, 1, 0, 0, 0, 1, 84, 1, 0, 0, 0, 1, 112, 1, 0, 0, 0, 1, 114, 1, 0, 0, 0, 1, 116, 1, 0, 0, 0, 1, 118, 1, 0, 0, 0, 2, 120, 1, 0, 0, 0, 2, 122, 1, 0, 0, 0, 2, 124, 1, 0, 0, 0, 2, 126, 1, 0, 0, 0, 2, 128, 1, 0, 0, 0, 2, 130, 1, 0, 0, 0, 2, 132, 1, 0, 0, 0, 2, 134, 1, 0, 0, 0, 3, 136, 1, 0, 0, 0, 3, 138, 1, 0, 0, 0, 3, 140, 1, 0, 0, 0, 3, 142, 1, 0, 0, 0, 3, 144, 1, 0, 0, 0, 3, 146, 1, 0, 0, 0, 3, 148, 1, 0, 0, 0, 3, 150, 1, 0, 0, 0, 3, 152, 1, 0, 0, 0, 3, 154, 1, 0, 0, 0, 3, 156, 1, 0, 0, 0, 3, 158, 1, 0, 0, 0, 3, 160, 1, 0, 0, 0, 3, 162, 1, 0, 0, 0, 3, 164, 1, 0, 0, 0, 3, 166, 1, 0, 0, 0, 3, 168, 1, 0, 0, 0, 3, 170, 1, 0, 0, 0, 3, 172, 1, 0, 0, 0, 3, 174, 1, 0, 0, 0, 3, 176, 1, 0, 0, 0, 3, 178, 1, 0, 0, 0, 3, 180, 1, 0, 0, 0, 4, 183, 1, 0, 0, 0, 6, 193, 1, 0, 0, 0, 8, 197, 1, 0, 0, 0, 10, 206, 1, 0, 0, 0, 12, 208, 1, 0, 0, 0, 14, 211, 1, 0, 0, 0, 16, 213, 1, 0, 0, 0, 18, 216, 1, 0, 0, 0, 20, 220, 1, 0, 0, 0, 22, 222, 1, 0, 0, 0, 24, 226, 1, 0, 0, 0, 26, 228, 1, 0, 0, 0, 28, 230, 1, 0, 0, 0, 30, 236, 1, 0, 0, 0, 32, 242, 1, 0, 0, 0, 34, 252, 1, 0, 0, 0, 36, 262, 1, 0, 0, 0, 38, 274, 1, 0, 0, 0, 40, 278, 1, 0, 0, 0, 42, 282, 1, 0, 0, 0, 44, 286, 1, 0, 0, 0, 46, 300, 1, 0, 0, 0, 48, 310, 1, 0, 0, 0, 50, 312, 1, 0, 0, 0, 52, 317, 1, 0, 0, 0, 54, 334, 1, 0, 0, 0, 56, 339, 1, 0, 0, 0, 58, 355, 1, 0, 0, 0, 60, 361, 1, 0, 0, 0, 62, 370, 1, 0, 0, 0, 64, 373, 1, 0, 0, 0, 66, 384, 1, 0, 0, 0, 68, 393, 1, 0, 0, 0, 70, 403, 1, 0, 0, 0, 72, 405, 1, 0, 0, 0, 74, 407, 1, 0, 0, 0, 76, 409, 1, 0, 0, 0, 78, 412, 1, 0, 0, 0, 80, 427, 1, 0, 0, 0, 82, 441, 1, 0, 0, 0, 84, 455, 1, 0, 0, 0, 86, 469, 1, 0, 0, 0, 88, 474, 1, 0, 0, 0, 90, 477, 1, 0, 0, 0, 92, 480, 1, 0, 0, 0, 94, 482, 1, 0, 0, 0, 96, 485, 1, 0, 0, 0, 98, 488, 1, 0, 0, 0, 100, 491, 1, 0, 0, 0, 102, 497, 1, 0, 0, 0, 104, 504, 1, 0, 0, 0, 106, 506, 1, 0, 0, 0, 108, 514, 1, 0, 0, 0, 110, 520, 1, 0, 0, 0, 112, 523, 1, 0, 0, 0, 114, 529, 1, 0, 0, 0, 116, 535, 1, 0, 0, 0, 118, 539, 1, 0, 0, 0, 120, 543, 1, 0, 0, 0, 122, 547, 1, 0, 0, 0, 124, 551, 1, 0, 0, 0, 126, 555, 1, 0, 0, 0, 128, 559, 1, 0, 0, 0, 130, 563, 1, 0, 0, 0, 132, 567, 1, 0, 0, 0, 134, 571, 1, 0, 0, 0, 136, 576, 1, 0, 0, 0, 138, 580, 1, 0, 0, 0, 140, 584, 1, 0, 0, 0, 142, 588, 1, 0, 0, 0, 144, 592, 1, 0, 0, 0, 146, 597, 1, 0, 0, 0, 148, 602, 1, 0, 0, 0, 150, 607, 1, 0, 0, 0, 152, 611, 1, 0, 0, 0, 154, 615, 1, 0, 0, 0, 156, 619, 1, 0, 0, 0, 158, 623, 1, 0, 0, 0, 160, 627, 1, 0, 0, 0, 162, 631, 1, 0, 0, 0, 164, 635, 1, 0, 0, 0, 166, 639, 1, 0, 0, 0, 168, 643, 1, 0, 0, 0, 170, 647, 1, 0, 0, 0, 172, 651, 1, 0, 0, 0, 174, 655, 1, 0, 0, 0, 176, 659, 1, 0, 0, 0, 178, 663, 1, 0, 0, 0, 180, 667, 1, 0, 0, 0, 182, 184, 7, 0, 0, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 188, 6, 0, 0, 0, 188, 5, 1, 0, 0, 0, 189, 191, 5, 13, 0, 0, 190, 189, 1, 0, 0, 0, 190, 191, 1, 0, 0, 0, 191, 192, 1, 0, 0, 0, 192, 194, 5, 10, 0, 0, 193, 190, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 7, 1, 0, 0, 0, 197, 201, 5, 35, 0, 0, 198, 200, 8, 1, 0, 0, 199, 198, 1, 0, 0, 0, 200, 203, 1, 0, 0, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 204, 1, 0, 0, 0, 203, 201, 1, 0, 0, 0, 204, 205, 6, 2, 1, 0, 205, 9, 1, 0, 0, 0, 206, 207, 5, 91, 0, 0, 207, 11, 1, 0, 0, 0, 208, 209, 5, 91, 0, 0, 209, 210, 5, 91, 0, 0, 210, 13, 1, 0, 0, 0, 211, 212, 5, 93, 0, 0, 212, 15, 1, 0, 0, 0, 213, 214, 5, 93, 0, 0, 214, 215, 5, 93, 0, 0, 215, 17, 1, 0, 0, 0, 216, 217, 5, 61, 0, 0, 217, 218, 1, 0, 0, 0, 218, 219, 6, 7, 2, 0, 219, 19, 1, 0, 0, 0, 220, 221, 5, 46, 0, 0, 221, 21, 1, 0, 0, 0, 222, 223, 5, 44, 0, 0, 223, 224, 1, 0, 0, 0, 224, 225, 6, 9, 0, 0, 225, 23, 1, 0, 0, 0, 226, 227, 7, 2, 0, 0, 227, 25, 1, 0, 0, 0, 228, 229, 7, 3, 0, 0, 229, 27, 1, 0, 0, 0, 230, 234, 5, 92, 0, 0, 231, 235, 7, 4, 0, 0, 232, 235, 3, 30, 13, 0, 233, 235, 3, 32, 14, 0, 234, 231, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 234, 233, 1, 0, 0, 0, 235, 29, 1, 0, 0, 0, 236, 237, 5, 117, 0, 0, 237, 238, 3, 70, 33, 0, 238, 239, 3, 70, 33, 0, 239, 240, 3, 70, 33, 0, 240, 241, 3, 70, 33, 0, 241, 31, 1, 0, 0, 0, 242, 243, 5, 85, 0, 0, 243, 244, 3, 70, 33, 0, 244, 245, 3, 70, 33, 0, 245, 246, 3, 70, 33, 0, 246, 247, 3, 70, 33, 0, 247, 248, 3, 70, 33, 0, 248, 249, 3, 70, 33, 0, 249, 250, 3, 70, 33, 0, 250, 251, 3, 70, 33, 0, 251, 33, 1, 0, 0, 0, 252, 257, 5, 34, 0, 0, 253, 256, 3, 28, 12, 0, 254, 256, 8, 5, 0, 0, 255, 253, 1, 0, 0, 0, 255, 254, 1, 0, 0, 0, 256, 259, 1, 0, 0, 0, 257, 258, 1, 0, 0, 0, 257, 255, 1, 0, 0, 0, 258, 260, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 260, 261, 5, 34, 0, 0, 261, 35, 1, 0, 0, 0, 262, 266, 5, 39, 0, 0, 263, 265, 8, 6, 0, 0, 264, 263, 1, 0, 0, 0, 265, 268, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 266, 264, 1, 0, 0, 0, 267, 269, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 269, 270, 5, 39, 0, 0, 270, 37, 1, 0, 0, 0, 271, 275, 3, 26, 11, 0, 272, 275, 3, 24, 10, 0, 273, 275, 7, 7, 0, 0, 274, 271, 1, 0, 0, 0, 274, 272, 1, 0, 0, 0, 274, 273, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 274, 1, 0, 0, 0, 276, 277, 1, 0, 0, 0, 277, 39, 1, 0, 0, 0, 278, 279, 3, 4, 0, 0, 279, 280, 1, 0, 0, 0, 280, 281, 6, 18, 0, 0, 281, 41, 1, 0, 0, 0, 282, 283, 5, 123, 0, 0, 283, 284, 1, 0, 0, 0, 284, 285, 6, 19, 3, 0, 285, 43, 1, 0, 0, 0, 286, 287, 3, 10, 3, 0, 287, 288, 1, 0, 0, 0, 288, 289, 6, 20, 4, 0, 289, 290, 6, 20, 5, 0, 290, 45, 1, 0, 0, 0, 291, 292, 5, 116, 0, 0, 292, 293, 5, 114, 0, 0, 293, 294, 5, 117, 0, 0, 294, 301, 5, 101, 0, 0, 295, 296, 5, 102, 0, 0, 296, 297, 5, 97, 0, 0, 297, 298, 5, 108, 0, 0, 298, 299, 5, 115, 0, 0, 299, 301, 5, 101, 0, 0, 300, 291, 1, 0, 0, 0, 300, 295, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 303, 6, 21, 6, 0, 303, 47, 1, 0, 0, 0, 304, 306, 5, 92, 0, 0, 305, 307, 5, 13, 0, 0, 306, 305, 1, 0, 0, 0, 306, 307, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 311, 5, 10, 0, 0, 309, 311, 3, 28, 12, 0, 310, 304, 1, 0, 0, 0, 310, 309, 1, 0, 0, 0, 311, 49, 1, 0, 0, 0, 312, 313, 3, 34, 15, 0, 313, 314, 1, 0, 0, 0, 314, 315, 6, 23, 7, 0, 315, 316, 6, 23, 6, 0, 316, 51, 1, 0, 0, 0, 317, 318, 5, 34, 0, 0, 318, 319, 5, 34, 0, 0, 319, 320, 5, 34, 0, 0, 320, 325, 1, 0, 0, 0, 321, 324, 3, 48, 22, 0, 322, 324, 8, 8, 0, 0, 323, 321, 1, 0, 0, 0, 323, 322, 1, 0, 0, 0, 324, 327, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 326, 328, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 328, 329, 5, 34, 0, 0, 329, 330, 5, 34, 0, 0, 330, 331, 5, 34, 0, 0, 331, 332, 1, 0, 0, 0, 332, 333, 6, 24, 6, 0, 333, 53, 1, 0, 0, 0, 334, 335, 3, 36, 16, 0, 335, 336, 1, 0, 0, 0, 336, 337, 6, 25, 8, 0, 337, 338, 6, 25, 6, 0, 338, 55, 1, 0, 0, 0, 339, 340, 5, 39, 0, 0, 340, 341, 5, 39, 0, 0, 341, 342, 5, 39, 0, 0, 342, 346, 1, 0, 0, 0, 343, 345, 9, 0, 0, 0, 344, 343, 1, 0, 0, 0, 345, 348, 1, 0, 0, 0, 346, 347, 1, 0, 0, 0, 346, 344, 1, 0, 0, 0, 347, 349, 1, 0, 0, 0, 348, 346, 1, 0, 0, 0, 349, 350, 5, 39, 0, 0, 350, 351, 5, 39, 0, 0, 351, 352, 5, 39, 0, 0, 352, 353, 1, 0, 0, 0, 353, 354, 6, 26, 6, 0, 354, 57, 1, 0, 0, 0, 355, 357, 7, 9, 0, 0, 356, 358, 7, 10, 0, 0, 357, 356, 1, 0, 0, 0, 357, 358, 1, 0, 0, 0, 358, 359, 1, 0, 0, 0, 359, 360, 3, 60, 28, 0, 360, 59, 1, 0, 0, 0, 361, 367, 3, 24, 10, 0, 362, 366, 3, 24, 10, 0, 363, 364, 5, 95, 0, 0, 364, 366, 3, 24, 10, 0, 365, 362, 1, 0, 0, 0, 365, 363, 1, 0, 0, 0, 366, 369, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 367, 368, 1, 0, 0, 0, 368, 61, 1, 0, 0, 0, 369, 367, 1, 0, 0, 0, 370, 371, 5, 46, 0, 0, 371, 372, 3, 60, 28, 0, 372, 63, 1, 0, 0, 0, 373, 379, 3, 78, 37, 0, 374, 380, 3, 58, 27, 0, 375, 377, 3, 62, 29, 0, 376, 378, 3, 58, 27, 0, 377, 376, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 380, 1, 0, 0, 0, 379, 374, 1, 0, 0, 0, 379, 375, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 382, 6, 30, 6, 0, 382, 65, 1, 0, 0, 0, 383, 385, 7, 10, 0, 0, 384, 383, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 387, 5, 105, 0, 0, 387, 388, 5, 110, 0, 0, 388, 389, 5, 102, 0, 0, 389, 390, 1, 0, 0, 0, 390, 391, 6, 31, 6, 0, 391, 67, 1, 0, 0, 0, 392, 394, 7, 10, 0, 0, 393, 392, 1, 0, 0, 0, 393, 394, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 395, 396, 5, 110, 0, 0, 396, 397, 5, 97, 0, 0, 397, 398, 5, 110, 0, 0, 398, 399, 1, 0, 0, 0, 399, 400, 6, 32, 6, 0, 400, 69, 1, 0, 0, 0, 401, 404, 7, 11, 0, 0, 402, 404, 3, 24, 10, 0, 403, 401, 1, 0, 0, 0, 403, 402, 1, 0, 0, 0, 404, 71, 1, 0, 0, 0, 405, 406, 7, 12, 0, 0, 406, 73, 1, 0, 0, 0, 407, 408, 7, 13, 0, 0, 408, 75, 1, 0, 0, 0, 409, 410, 7, 14, 0, 0, 410, 77, 1, 0, 0, 0, 411, 413, 7, 10, 0, 0, 412, 411, 1, 0, 0, 0, 412, 413, 1, 0, 0, 0, 413, 423, 1, 0, 0, 0, 414, 424, 3, 24, 10, 0, 415, 419, 3, 72, 34, 0, 416, 420, 3, 24, 10, 0, 417, 418, 5, 95, 0, 0, 418, 420, 3, 24, 10, 0, 419, 416, 1, 0, 0, 0, 419, 417, 1, 0, 0, 0, 420, 421, 1, 0, 0, 0, 421, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 424, 1, 0, 0, 0, 423, 414, 1, 0, 0, 0, 423, 415, 1, 0, 0, 0, 424, 425, 1, 0, 0, 0, 425, 426, 6, 37, 6, 0, 426, 79, 1, 0, 0, 0, 427, 428, 5, 48, 0, 0, 428, 429, 5, 120, 0, 0, 429, 430, 1, 0, 0, 0, 430, 436, 3, 70, 33, 0, 431, 435, 3, 70, 33, 0, 432, 433, 5, 95, 0, 0, 433, 435, 3, 70, 33, 0, 434, 431, 1, 0, 0, 0, 434, 432, 1, 0, 0, 0, 435, 438, 1, 0, 0, 0, 436, 434, 1, 0, 0, 0, 436, 437, 1, 0, 0, 0, 437, 439, 1, 0, 0, 0, 438, 436, 1, 0, 0, 0, 439, 440, 6, 38, 6, 0, 440, 81, 1, 0, 0, 0, 441, 442, 5, 48, 0, 0, 442, 443, 5, 111, 0, 0, 443, 444, 1, 0, 0, 0, 444, 450, 3, 74, 35, 0, 445, 449, 3, 74, 35, 0, 446, 447, 5, 95, 0, 0, 447, 449, 3, 74, 35, 0, 448, 445, 1, 0, 0, 0, 448, 446, 1, 0, 0, 0, 449, 452, 1, 0, 0, 0, 450, 448, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 451, 453, 1, 0, 0, 0, 452, 450, 1, 0, 0, 0, 453, 454, 6, 39, 6, 0, 454, 83, 1, 0, 0, 0, 455, 456, 5, 48, 0, 0, 456, 457, 5, 98, 0, 0, 457, 458, 1, 0, 0, 0, 458, 464, 3, 76, 36, 0, 459, 463, 3, 76, 36, 0, 460, 461, 5, 95, 0, 0, 461, 463, 3, 76, 36, 0, 462, 459, 1, 0, 0, 0, 462, 460, 1, 0, 0, 0, 463, 466, 1, 0, 0, 0, 464, 462, 1, 0, 0, 0, 464, 465, 1, 0, 0, 0, 465, 467, 1, 0, 0, 0, 466, 464, 1, 0, 0, 0, 467, 468, 6, 40, 6, 0, 468, 85, 1, 0, 0, 0, 469, 470, 3, 24, 10, 0, 470, 471, 3, 24, 10, 0, 471, 472, 3, 24, 10, 0, 472, 473, 3, 24, 10, 0, 473, 87, 1, 0, 0, 0, 474, 475, 3, 24, 10, 0, 475, 476, 3, 24, 10, 0, 476, 89, 1, 0, 0, 0, 477, 478, 3, 24, 10, 0, 478, 479, 3, 24, 10, 0, 479, 91, 1, 0, 0, 0, 480, 481, 7, 15, 0, 0, 481, 93, 1, 0, 0, 0, 482, 483, 3, 24, 10, 0, 483, 484, 3, 24, 10, 0, 484, 95, 1, 0, 0, 0, 485, 486, 3, 24, 10, 0, 486, 487, 3, 24, 10, 0, 487, 97, 1, 0, 0, 0, 488, 489, 3, 24, 10, 0, 489, 490, 3, 24, 10, 0, 490, 99, 1, 0, 0, 0, 491, 493, 5, 46, 0, 0, 492, 494, 3, 24, 10, 0, 493, 492, 1, 0, 0, 0, 494, 495, 1, 0, 0, 0, 495, 493, 1, 0, 0, 0, 495, 496, 1, 0, 0, 0, 496, 101, 1, 0, 0, 0, 497, 498, 7, 10, 0, 0, 498, 499, 3, 94, 45, 0, 499, 500, 5, 58, 0, 0, 500, 501, 3, 96, 46, 0, 501, 103, 1, 0, 0, 0, 502, 505, 5, 90, 0, 0, 503, 505, 3, 102, 49, 0, 504, 502, 1, 0, 0, 0, 504, 503, 1, 0, 0, 0, 505, 105, 1, 0, 0, 0, 506, 507, 3, 94, 45, 0, 507, 508, 5, 58, 0, 0, 508, 509, 3, 96, 46, 0, 509, 510, 5, 58, 0, 0, 510, 512, 3, 98, 47, 0, 511, 513, 3, 100, 48, 0, 512, 511, 1, 0, 0, 0, 512, 513, 1, 0, 0, 0, 513, 107, 1, 0, 0, 0, 514, 515, 3, 86, 41, 0, 515, 516, 5, 45, 0, 0, 516, 517, 3, 88, 42, 0, 517, 518, 5, 45, 0, 0, 518, 519, 3, 90, 43, 0, 519, 109, 1, 0, 0, 0, 520, 521, 3, 106, 51, 0, 521, 522, 3, 104, 50, 0, 522, 111, 1, 0, 0, 0, 523, 524, 3, 108, 52, 0, 524, 525, 3, 92, 44, 0, 525, 526, 3, 110, 53, 0, 526, 527, 1, 0, 0, 0, 527, 528, 6, 54, 6, 0, 528, 113, 1, 0, 0, 0, 529, 530, 3, 108, 52, 0, 530, 531, 3, 92, 44, 0, 531, 532, 3, 106, 51, 0, 532, 533, 1, 0, 0, 0, 533, 534, 6, 55, 6, 0, 534, 115, 1, 0, 0, 0, 535, 536, 3, 108, 52, 0, 536, 537, 1, 0, 0, 0, 537, 538, 6, 56, 6, 0, 538, 117, 1, 0, 0, 0, 539, 540, 3, 106, 51, 0, 540, 541, 1, 0, 0, 0, 541, 542, 6, 57, 6, 0, 542, 119, 1, 0, 0, 0, 543, 544, 3, 4, 0, 0, 544, 545, 1, 0, 0, 0, 545, 546, 6, 58, 0, 0, 546, 121, 1, 0, 0, 0, 547, 548, 3, 20, 8, 0, 548, 549, 1, 0, 0, 0, 549, 550, 6, 59, 9, 0, 550, 123, 1, 0, 0, 0, 551, 552, 3, 22, 9, 0, 552, 553, 1, 0, 0, 0, 553, 554, 6, 60, 10, 0, 554, 125, 1, 0, 0, 0, 555, 556, 5, 125, 0, 0, 556, 557, 1, 0, 0, 0, 557, 558, 6, 61, 6, 0, 558, 127, 1, 0, 0, 0, 559, 560, 3, 34, 15, 0, 560, 561, 1, 0, 0, 0, 561, 562, 6, 62, 7, 0, 562, 129, 1, 0, 0, 0, 563, 564, 3, 36, 16, 0, 564, 565, 1, 0, 0, 0, 565, 566, 6, 63, 8, 0, 566, 131, 1, 0, 0, 0, 567, 568, 3, 38, 17, 0, 568, 569, 1, 0, 0, 0, 569, 570, 6, 64, 11, 0, 570, 133, 1, 0, 0, 0, 571, 572, 3, 18, 7, 0, 572, 573, 1, 0, 0, 0, 573, 574, 6, 65, 12, 0, 574, 575, 6, 65, 2, 0, 575, 135, 1, 0, 0, 0, 576, 577, 3, 4, 0, 0, 577, 578, 1, 0, 0, 0, 578, 579, 6, 66, 0, 0, 579, 137, 1, 0, 0, 0, 580, 581, 3, 6, 1, 0, 581, 582, 1, 0, 0, 0, 582, 583, 6, 67, 13, 0, 583, 139, 1, 0, 0, 0, 584, 585, 3, 8, 2, 0, 585, 586, 1, 0, 0, 0, 586, 587, 6, 68, 14, 0, 587, 141, 1, 0, 0, 0, 588, 589, 3, 22, 9, 0, 589, 590, 1, 0, 0, 0, 590, 591, 6, 69, 10, 0, 591, 143, 1, 0, 0, 0, 592, 593, 3, 42, 19, 0, 593, 594, 1, 0, 0, 0, 594, 595, 6, 70, 15, 0, 595, 596, 6, 70, 16, 0, 596, 145, 1, 0, 0, 0, 597, 598, 3, 10, 3, 0, 598, 599, 1, 0, 0, 0, 599, 600, 6, 71, 4, 0, 600, 601, 6, 71, 17, 0, 601, 147, 1, 0, 0, 0, 602, 603, 3, 14, 5, 0, 603, 604, 1, 0, 0, 0, 604, 605, 6, 72, 18, 0, 605, 606, 6, 72, 6, 0, 606, 149, 1, 0, 0, 0, 607, 608, 3, 46, 21, 0, 608, 609, 1, 0, 0, 0, 609, 610, 6, 73, 19, 0, 610, 151, 1, 0, 0, 0, 611, 612, 3, 34, 15, 0, 612, 613, 1, 0, 0, 0, 613, 614, 6, 74, 7, 0, 614, 153, 1, 0, 0, 0, 615, 616, 3, 52, 24, 0, 616, 617, 1, 0, 0, 0, 617, 618, 6, 75, 20, 0, 618, 155, 1, 0, 0, 0, 619, 620, 3, 36, 16, 0, 620, 621, 1, 0, 0, 0, 621, 622, 6, 76, 8, 0, 622, 157, 1, 0, 0, 0, 623, 624, 3, 56, 26, 0, 624, 625, 1, 0, 0, 0, 625, 626, 6, 77, 21, 0, 626, 159, 1, 0, 0, 0, 627, 628, 3, 64, 30, 0, 628, 629, 1, 0, 0, 0, 629, 630, 6, 78, 22, 0, 630, 161, 1, 0, 0, 0, 631, 632, 3, 66, 31, 0, 632, 633, 1, 0, 0, 0, 633, 634, 6, 79, 23, 0, 634, 163, 1, 0, 0, 0, 635, 636, 3, 68, 32, 0, 636, 637, 1, 0, 0, 0, 637, 638, 6, 80, 24, 0, 638, 165, 1, 0, 0, 0, 639, 640, 3, 78, 37, 0, 640, 641, 1, 0, 0, 0, 641, 642, 6, 81, 25, 0, 642, 167, 1, 0, 0, 0, 643, 644, 3, 80, 38, 0, 644, 645, 1, 0, 0, 0, 645, 646, 6, 82, 26, 0, 646, 169, 1, 0, 0, 0, 647, 648, 3, 82, 39, 0, 648, 649, 1, 0, 0, 0, 649, 650, 6, 83, 27, 0, 650, 171, 1, 0, 0, 0, 651, 652, 3, 84, 40, 0, 652, 653, 1, 0, 0, 0, 653, 654, 6, 84, 28, 0, 654, 173, 1, 0, 0, 0, 655, 656, 3, 112, 54, 0, 656, 657, 1, 0, 0, 0, 657, 658, 6, 85, 29, 0, 658, 175, 1, 0, 0, 0, 659, 660, 3, 114, 55, 0, 660, 661, 1, 0, 0, 0, 661, 662, 6, 86, 30, 0, 662, 177, 1, 0, 0, 0, 663, 664, 3, 116, 56, 0, 664, 665, 1, 0, 0, 0, 665, 666, 6, 87, 31, 0, 666, 179, 1, 0, 0, 0, 667, 668, 3, 118, 57, 0, 668, 669, 1, 0, 0, 0, 669, 670, 6, 88, 32, 0, 670, 181, 1, 0, 0, 0, 41, 0, 1, 2, 3, 185, 190, 195, 201, 234, 255, 257, 266, 274, 276, 300, 306, 310, 323, 325, 346, 357, 365, 367, 377, 379, 384, 393, 403, 412, 419, 421, 423, 434, 436, 448, 450, 462, 464, 495, 504, 512, 33, 6, 0, 0, 0, 2, 0, 5, 1, 0, 2, 2, 0, 7, 4, 0, 2, 3, 0, 4, 0, 0, 7, 11, 0, 7, 12, 0, 7, 9, 0, 7, 10, 0, 7, 13, 0, 7, 8, 0, 7, 2, 0, 7, 3, 0, 7, 15, 0, 5, 2, 0, 5, 3, 0, 7, 6, 0, 7, 16, 0, 7, 17, 0, 7, 18, 0, 7, 19, 0, 7, 20, 0, 7, 21, 0, 7, 22, 0, 7, 23, 0, 7, 24, 0, 7, 25, 0, 7, 26, 0, 7, 27, 0, 7, 28, 0, 7, 29, 0] \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java new file mode 100644 index 00000000000..f8c5585f801 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java @@ -0,0 +1,585 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class TomlLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.11.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + WS=1, NL=2, COMMENT=3, L_BRACKET=4, DOUBLE_L_BRACKET=5, R_BRACKET=6, DOUBLE_R_BRACKET=7, + EQUALS=8, DOT=9, COMMA=10, BASIC_STRING=11, LITERAL_STRING=12, UNQUOTED_KEY=13, + VALUE_WS=14, L_BRACE=15, BOOLEAN=16, ML_BASIC_STRING=17, ML_LITERAL_STRING=18, + FLOAT=19, INF=20, NAN=21, DEC_INT=22, HEX_INT=23, OCT_INT=24, BIN_INT=25, + OFFSET_DATE_TIME=26, LOCAL_DATE_TIME=27, LOCAL_DATE=28, LOCAL_TIME=29, + INLINE_TABLE_WS=30, R_BRACE=31, ARRAY_WS=32; + public static final int + COMMENTS_CHANNEL=2; + public static final int + SIMPLE_VALUE_MODE=1, INLINE_TABLE_MODE=2, ARRAY_MODE=3; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", "COMMENTS_CHANNEL" + }; + + public static String[] modeNames = { + "DEFAULT_MODE", "SIMPLE_VALUE_MODE", "INLINE_TABLE_MODE", "ARRAY_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "WS", "NL", "COMMENT", "L_BRACKET", "DOUBLE_L_BRACKET", "R_BRACKET", + "DOUBLE_R_BRACKET", "EQUALS", "DOT", "COMMA", "DIGIT", "ALPHA", "ESC", + "UNICODE", "EX_UNICODE", "BASIC_STRING", "LITERAL_STRING", "UNQUOTED_KEY", + "VALUE_WS", "L_BRACE", "ARRAY_START", "BOOLEAN", "ML_ESC", "VALUE_BASIC_STRING", + "ML_BASIC_STRING", "VALUE_LITERAL_STRING", "ML_LITERAL_STRING", "EXP", + "ZERO_PREFIXABLE_INT", "FRAC", "FLOAT", "INF", "NAN", "HEX_DIGIT", "DIGIT_1_9", + "DIGIT_0_7", "DIGIT_0_1", "DEC_INT", "HEX_INT", "OCT_INT", "BIN_INT", + "YEAR", "MONTH", "DAY", "DELIM", "HOUR", "MINUTE", "SECOND", "SECFRAC", + "NUMOFFSET", "OFFSET", "PARTIAL_TIME", "FULL_DATE", "FULL_TIME", "OFFSET_DATE_TIME", + "LOCAL_DATE_TIME", "LOCAL_DATE", "LOCAL_TIME", "INLINE_TABLE_WS", "INLINE_TABLE_KEY_DOT", + "INLINE_TABLE_COMMA", "R_BRACE", "INLINE_TABLE_KEY_BASIC_STRING", "INLINE_TABLE_KEY_LITERAL_STRING", + "INLINE_TABLE_KEY_UNQUOTED", "INLINE_TABLE_EQUALS", "ARRAY_WS", "ARRAY_NL", + "ARRAY_COMMENT", "ARRAY_COMMA", "ARRAY_INLINE_TABLE_START", "NESTED_ARRAY_START", + "ARRAY_END", "ARRAY_BOOLEAN", "ARRAY_BASIC_STRING", "ARRAY_ML_BASIC_STRING", + "ARRAY_LITERAL_STRING", "ARRAY_ML_LITERAL_STRING", "ARRAY_FLOAT", "ARRAY_INF", + "ARRAY_NAN", "ARRAY_DEC_INT", "ARRAY_HEX_INT", "ARRAY_OCT_INT", "ARRAY_BIN_INT", + "ARRAY_OFFSET_DATE_TIME", "ARRAY_LOCAL_DATE_TIME", "ARRAY_LOCAL_DATE", + "ARRAY_LOCAL_TIME" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, null, "'['", "'[['", "']'", "']]'", "'='", "'.'", "','", + null, null, null, null, "'{'", null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, "'}'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "WS", "NL", "COMMENT", "L_BRACKET", "DOUBLE_L_BRACKET", "R_BRACKET", + "DOUBLE_R_BRACKET", "EQUALS", "DOT", "COMMA", "BASIC_STRING", "LITERAL_STRING", + "UNQUOTED_KEY", "VALUE_WS", "L_BRACE", "BOOLEAN", "ML_BASIC_STRING", + "ML_LITERAL_STRING", "FLOAT", "INF", "NAN", "DEC_INT", "HEX_INT", "OCT_INT", + "BIN_INT", "OFFSET_DATE_TIME", "LOCAL_DATE_TIME", "LOCAL_DATE", "LOCAL_TIME", + "INLINE_TABLE_WS", "R_BRACE", "ARRAY_WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public TomlLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "TomlLexer.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000 \u029f\u0006\uffff\uffff\u0006\uffff\uffff\u0006\uffff\uffff"+ + "\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ + "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ + "\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+ + "\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+ + "\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ + "\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ + "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ + "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ + "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ + "#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002"+ + "(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007+\u0002,\u0007,\u0002"+ + "-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u00070\u00021\u00071\u0002"+ + "2\u00072\u00023\u00073\u00024\u00074\u00025\u00075\u00026\u00076\u0002"+ + "7\u00077\u00028\u00078\u00029\u00079\u0002:\u0007:\u0002;\u0007;\u0002"+ + "<\u0007<\u0002=\u0007=\u0002>\u0007>\u0002?\u0007?\u0002@\u0007@\u0002"+ + "A\u0007A\u0002B\u0007B\u0002C\u0007C\u0002D\u0007D\u0002E\u0007E\u0002"+ + "F\u0007F\u0002G\u0007G\u0002H\u0007H\u0002I\u0007I\u0002J\u0007J\u0002"+ + "K\u0007K\u0002L\u0007L\u0002M\u0007M\u0002N\u0007N\u0002O\u0007O\u0002"+ + "P\u0007P\u0002Q\u0007Q\u0002R\u0007R\u0002S\u0007S\u0002T\u0007T\u0002"+ + "U\u0007U\u0002V\u0007V\u0002W\u0007W\u0002X\u0007X\u0001\u0000\u0004\u0000"+ + "\u00b8\b\u0000\u000b\u0000\f\u0000\u00b9\u0001\u0000\u0001\u0000\u0001"+ + "\u0001\u0003\u0001\u00bf\b\u0001\u0001\u0001\u0004\u0001\u00c2\b\u0001"+ + "\u000b\u0001\f\u0001\u00c3\u0001\u0002\u0001\u0002\u0005\u0002\u00c8\b"+ + "\u0002\n\u0002\f\u0002\u00cb\t\u0002\u0001\u0002\u0001\u0002\u0001\u0003"+ + "\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001"+ + "\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0003\f\u00eb"+ + "\b\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0005"+ + "\u000f\u0100\b\u000f\n\u000f\f\u000f\u0103\t\u000f\u0001\u000f\u0001\u000f"+ + "\u0001\u0010\u0001\u0010\u0005\u0010\u0109\b\u0010\n\u0010\f\u0010\u010c"+ + "\t\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0004"+ + "\u0011\u0113\b\u0011\u000b\u0011\f\u0011\u0114\u0001\u0012\u0001\u0012"+ + "\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015"+ + "\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015"+ + "\u0001\u0015\u0001\u0015\u0003\u0015\u012d\b\u0015\u0001\u0015\u0001\u0015"+ + "\u0001\u0016\u0001\u0016\u0003\u0016\u0133\b\u0016\u0001\u0016\u0001\u0016"+ + "\u0003\u0016\u0137\b\u0016\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017"+ + "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018"+ + "\u0001\u0018\u0005\u0018\u0144\b\u0018\n\u0018\f\u0018\u0147\t\u0018\u0001"+ + "\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001"+ + "\u0019\u0001\u0019\u0001\u0019\u0001\u0019\u0001\u0019\u0001\u001a\u0001"+ + "\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0005\u001a\u0159\b\u001a\n"+ + "\u001a\f\u001a\u015c\t\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ + "\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0003\u001b\u0166"+ + "\b\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001\u001c\u0001"+ + "\u001c\u0005\u001c\u016e\b\u001c\n\u001c\f\u001c\u0171\t\u001c\u0001\u001d"+ + "\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e"+ + "\u0003\u001e\u017a\b\u001e\u0003\u001e\u017c\b\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001f\u0003\u001f\u0181\b\u001f\u0001\u001f\u0001\u001f\u0001"+ + "\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001 \u0003 \u018a\b \u0001"+ + " \u0001 \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0003!\u0194\b!\u0001"+ + "\"\u0001\"\u0001#\u0001#\u0001$\u0001$\u0001%\u0003%\u019d\b%\u0001%\u0001"+ + "%\u0001%\u0001%\u0001%\u0004%\u01a4\b%\u000b%\f%\u01a5\u0003%\u01a8\b"+ + "%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001&\u0001&\u0001&\u0001&\u0005"+ + "&\u01b3\b&\n&\f&\u01b6\t&\u0001&\u0001&\u0001\'\u0001\'\u0001\'\u0001"+ + "\'\u0001\'\u0001\'\u0001\'\u0005\'\u01c1\b\'\n\'\f\'\u01c4\t\'\u0001\'"+ + "\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001(\u0001(\u0001(\u0005(\u01cf"+ + "\b(\n(\f(\u01d2\t(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001)\u0001"+ + "*\u0001*\u0001*\u0001+\u0001+\u0001+\u0001,\u0001,\u0001-\u0001-\u0001"+ + "-\u0001.\u0001.\u0001.\u0001/\u0001/\u0001/\u00010\u00010\u00040\u01ee"+ + "\b0\u000b0\f0\u01ef\u00011\u00011\u00011\u00011\u00011\u00012\u00012\u0003"+ + "2\u01f9\b2\u00013\u00013\u00013\u00013\u00013\u00013\u00033\u0201\b3\u0001"+ + "4\u00014\u00014\u00014\u00014\u00014\u00015\u00015\u00015\u00016\u0001"+ + "6\u00016\u00016\u00016\u00016\u00017\u00017\u00017\u00017\u00017\u0001"+ + "7\u00018\u00018\u00018\u00018\u00019\u00019\u00019\u00019\u0001:\u0001"+ + ":\u0001:\u0001:\u0001;\u0001;\u0001;\u0001;\u0001<\u0001<\u0001<\u0001"+ + "<\u0001=\u0001=\u0001=\u0001=\u0001>\u0001>\u0001>\u0001>\u0001?\u0001"+ + "?\u0001?\u0001?\u0001@\u0001@\u0001@\u0001@\u0001A\u0001A\u0001A\u0001"+ + "A\u0001A\u0001B\u0001B\u0001B\u0001B\u0001C\u0001C\u0001C\u0001C\u0001"+ + "D\u0001D\u0001D\u0001D\u0001E\u0001E\u0001E\u0001E\u0001F\u0001F\u0001"+ + "F\u0001F\u0001F\u0001G\u0001G\u0001G\u0001G\u0001G\u0001H\u0001H\u0001"+ + "H\u0001H\u0001H\u0001I\u0001I\u0001I\u0001I\u0001J\u0001J\u0001J\u0001"+ + "J\u0001K\u0001K\u0001K\u0001K\u0001L\u0001L\u0001L\u0001L\u0001M\u0001"+ + "M\u0001M\u0001M\u0001N\u0001N\u0001N\u0001N\u0001O\u0001O\u0001O\u0001"+ + "O\u0001P\u0001P\u0001P\u0001P\u0001Q\u0001Q\u0001Q\u0001Q\u0001R\u0001"+ + "R\u0001R\u0001R\u0001S\u0001S\u0001S\u0001S\u0001T\u0001T\u0001T\u0001"+ + "T\u0001U\u0001U\u0001U\u0001U\u0001V\u0001V\u0001V\u0001V\u0001W\u0001"+ + "W\u0001W\u0001W\u0001X\u0001X\u0001X\u0001X\u0004\u0101\u010a\u0145\u015a"+ + "\u0000Y\u0004\u0001\u0006\u0002\b\u0003\n\u0004\f\u0005\u000e\u0006\u0010"+ + "\u0007\u0012\b\u0014\t\u0016\n\u0018\u0000\u001a\u0000\u001c\u0000\u001e"+ + "\u0000 \u0000\"\u000b$\f&\r(\u000e*\u000f,\u0000.\u00100\u00002\u0000"+ + "4\u00116\u00008\u0012:\u0000<\u0000>\u0000@\u0013B\u0014D\u0015F\u0000"+ + "H\u0000J\u0000L\u0000N\u0016P\u0017R\u0018T\u0019V\u0000X\u0000Z\u0000"+ + "\\\u0000^\u0000`\u0000b\u0000d\u0000f\u0000h\u0000j\u0000l\u0000n\u0000"+ + "p\u001ar\u001bt\u001cv\u001dx\u001ez\u0000|\u0000~\u001f\u0080\u0000\u0082"+ + "\u0000\u0084\u0000\u0086\u0000\u0088 \u008a\u0000\u008c\u0000\u008e\u0000"+ + "\u0090\u0000\u0092\u0000\u0094\u0000\u0096\u0000\u0098\u0000\u009a\u0000"+ + "\u009c\u0000\u009e\u0000\u00a0\u0000\u00a2\u0000\u00a4\u0000\u00a6\u0000"+ + "\u00a8\u0000\u00aa\u0000\u00ac\u0000\u00ae\u0000\u00b0\u0000\u00b2\u0000"+ + "\u00b4\u0000\u0004\u0000\u0001\u0002\u0003\u0010\u0002\u0000\t\t \u0002"+ + "\u0000\n\n\r\r\u0001\u000009\u0002\u0000AZaz\b\u0000\"\"//\\\\bbffnnr"+ + "rtt\u0003\u0000\n\n\"\"\\\\\u0002\u0000\n\n\'\'\u0002\u0000--__\u0002"+ + "\u0000\"\"\\\\\u0002\u0000EEee\u0002\u0000++--\u0002\u0000AFaf\u0001\u0000"+ + "19\u0001\u000007\u0001\u000001\u0003\u0000 TTtt\u02a8\u0000\u0004\u0001"+ + "\u0000\u0000\u0000\u0000\u0006\u0001\u0000\u0000\u0000\u0000\b\u0001\u0000"+ + "\u0000\u0000\u0000\n\u0001\u0000\u0000\u0000\u0000\f\u0001\u0000\u0000"+ + "\u0000\u0000\u000e\u0001\u0000\u0000\u0000\u0000\u0010\u0001\u0000\u0000"+ + "\u0000\u0000\u0012\u0001\u0000\u0000\u0000\u0000\u0014\u0001\u0000\u0000"+ + "\u0000\u0000\u0016\u0001\u0000\u0000\u0000\u0000\"\u0001\u0000\u0000\u0000"+ + "\u0000$\u0001\u0000\u0000\u0000\u0000&\u0001\u0000\u0000\u0000\u0001("+ + "\u0001\u0000\u0000\u0000\u0001*\u0001\u0000\u0000\u0000\u0001,\u0001\u0000"+ + "\u0000\u0000\u0001.\u0001\u0000\u0000\u0000\u00012\u0001\u0000\u0000\u0000"+ + "\u00014\u0001\u0000\u0000\u0000\u00016\u0001\u0000\u0000\u0000\u00018"+ + "\u0001\u0000\u0000\u0000\u0001@\u0001\u0000\u0000\u0000\u0001B\u0001\u0000"+ + "\u0000\u0000\u0001D\u0001\u0000\u0000\u0000\u0001N\u0001\u0000\u0000\u0000"+ + "\u0001P\u0001\u0000\u0000\u0000\u0001R\u0001\u0000\u0000\u0000\u0001T"+ + "\u0001\u0000\u0000\u0000\u0001p\u0001\u0000\u0000\u0000\u0001r\u0001\u0000"+ + "\u0000\u0000\u0001t\u0001\u0000\u0000\u0000\u0001v\u0001\u0000\u0000\u0000"+ + "\u0002x\u0001\u0000\u0000\u0000\u0002z\u0001\u0000\u0000\u0000\u0002|"+ + "\u0001\u0000\u0000\u0000\u0002~\u0001\u0000\u0000\u0000\u0002\u0080\u0001"+ + "\u0000\u0000\u0000\u0002\u0082\u0001\u0000\u0000\u0000\u0002\u0084\u0001"+ + "\u0000\u0000\u0000\u0002\u0086\u0001\u0000\u0000\u0000\u0003\u0088\u0001"+ + "\u0000\u0000\u0000\u0003\u008a\u0001\u0000\u0000\u0000\u0003\u008c\u0001"+ + "\u0000\u0000\u0000\u0003\u008e\u0001\u0000\u0000\u0000\u0003\u0090\u0001"+ + "\u0000\u0000\u0000\u0003\u0092\u0001\u0000\u0000\u0000\u0003\u0094\u0001"+ + "\u0000\u0000\u0000\u0003\u0096\u0001\u0000\u0000\u0000\u0003\u0098\u0001"+ + "\u0000\u0000\u0000\u0003\u009a\u0001\u0000\u0000\u0000\u0003\u009c\u0001"+ + "\u0000\u0000\u0000\u0003\u009e\u0001\u0000\u0000\u0000\u0003\u00a0\u0001"+ + "\u0000\u0000\u0000\u0003\u00a2\u0001\u0000\u0000\u0000\u0003\u00a4\u0001"+ + "\u0000\u0000\u0000\u0003\u00a6\u0001\u0000\u0000\u0000\u0003\u00a8\u0001"+ + "\u0000\u0000\u0000\u0003\u00aa\u0001\u0000\u0000\u0000\u0003\u00ac\u0001"+ + "\u0000\u0000\u0000\u0003\u00ae\u0001\u0000\u0000\u0000\u0003\u00b0\u0001"+ + "\u0000\u0000\u0000\u0003\u00b2\u0001\u0000\u0000\u0000\u0003\u00b4\u0001"+ + "\u0000\u0000\u0000\u0004\u00b7\u0001\u0000\u0000\u0000\u0006\u00c1\u0001"+ + "\u0000\u0000\u0000\b\u00c5\u0001\u0000\u0000\u0000\n\u00ce\u0001\u0000"+ + "\u0000\u0000\f\u00d0\u0001\u0000\u0000\u0000\u000e\u00d3\u0001\u0000\u0000"+ + "\u0000\u0010\u00d5\u0001\u0000\u0000\u0000\u0012\u00d8\u0001\u0000\u0000"+ + "\u0000\u0014\u00dc\u0001\u0000\u0000\u0000\u0016\u00de\u0001\u0000\u0000"+ + "\u0000\u0018\u00e2\u0001\u0000\u0000\u0000\u001a\u00e4\u0001\u0000\u0000"+ + "\u0000\u001c\u00e6\u0001\u0000\u0000\u0000\u001e\u00ec\u0001\u0000\u0000"+ + "\u0000 \u00f2\u0001\u0000\u0000\u0000\"\u00fc\u0001\u0000\u0000\u0000"+ + "$\u0106\u0001\u0000\u0000\u0000&\u0112\u0001\u0000\u0000\u0000(\u0116"+ + "\u0001\u0000\u0000\u0000*\u011a\u0001\u0000\u0000\u0000,\u011e\u0001\u0000"+ + "\u0000\u0000.\u012c\u0001\u0000\u0000\u00000\u0136\u0001\u0000\u0000\u0000"+ + "2\u0138\u0001\u0000\u0000\u00004\u013d\u0001\u0000\u0000\u00006\u014e"+ + "\u0001\u0000\u0000\u00008\u0153\u0001\u0000\u0000\u0000:\u0163\u0001\u0000"+ + "\u0000\u0000<\u0169\u0001\u0000\u0000\u0000>\u0172\u0001\u0000\u0000\u0000"+ + "@\u0175\u0001\u0000\u0000\u0000B\u0180\u0001\u0000\u0000\u0000D\u0189"+ + "\u0001\u0000\u0000\u0000F\u0193\u0001\u0000\u0000\u0000H\u0195\u0001\u0000"+ + "\u0000\u0000J\u0197\u0001\u0000\u0000\u0000L\u0199\u0001\u0000\u0000\u0000"+ + "N\u019c\u0001\u0000\u0000\u0000P\u01ab\u0001\u0000\u0000\u0000R\u01b9"+ + "\u0001\u0000\u0000\u0000T\u01c7\u0001\u0000\u0000\u0000V\u01d5\u0001\u0000"+ + "\u0000\u0000X\u01da\u0001\u0000\u0000\u0000Z\u01dd\u0001\u0000\u0000\u0000"+ + "\\\u01e0\u0001\u0000\u0000\u0000^\u01e2\u0001\u0000\u0000\u0000`\u01e5"+ + "\u0001\u0000\u0000\u0000b\u01e8\u0001\u0000\u0000\u0000d\u01eb\u0001\u0000"+ + "\u0000\u0000f\u01f1\u0001\u0000\u0000\u0000h\u01f8\u0001\u0000\u0000\u0000"+ + "j\u01fa\u0001\u0000\u0000\u0000l\u0202\u0001\u0000\u0000\u0000n\u0208"+ + "\u0001\u0000\u0000\u0000p\u020b\u0001\u0000\u0000\u0000r\u0211\u0001\u0000"+ + "\u0000\u0000t\u0217\u0001\u0000\u0000\u0000v\u021b\u0001\u0000\u0000\u0000"+ + "x\u021f\u0001\u0000\u0000\u0000z\u0223\u0001\u0000\u0000\u0000|\u0227"+ + "\u0001\u0000\u0000\u0000~\u022b\u0001\u0000\u0000\u0000\u0080\u022f\u0001"+ + "\u0000\u0000\u0000\u0082\u0233\u0001\u0000\u0000\u0000\u0084\u0237\u0001"+ + "\u0000\u0000\u0000\u0086\u023b\u0001\u0000\u0000\u0000\u0088\u0240\u0001"+ + "\u0000\u0000\u0000\u008a\u0244\u0001\u0000\u0000\u0000\u008c\u0248\u0001"+ + "\u0000\u0000\u0000\u008e\u024c\u0001\u0000\u0000\u0000\u0090\u0250\u0001"+ + "\u0000\u0000\u0000\u0092\u0255\u0001\u0000\u0000\u0000\u0094\u025a\u0001"+ + "\u0000\u0000\u0000\u0096\u025f\u0001\u0000\u0000\u0000\u0098\u0263\u0001"+ + "\u0000\u0000\u0000\u009a\u0267\u0001\u0000\u0000\u0000\u009c\u026b\u0001"+ + "\u0000\u0000\u0000\u009e\u026f\u0001\u0000\u0000\u0000\u00a0\u0273\u0001"+ + "\u0000\u0000\u0000\u00a2\u0277\u0001\u0000\u0000\u0000\u00a4\u027b\u0001"+ + "\u0000\u0000\u0000\u00a6\u027f\u0001\u0000\u0000\u0000\u00a8\u0283\u0001"+ + "\u0000\u0000\u0000\u00aa\u0287\u0001\u0000\u0000\u0000\u00ac\u028b\u0001"+ + "\u0000\u0000\u0000\u00ae\u028f\u0001\u0000\u0000\u0000\u00b0\u0293\u0001"+ + "\u0000\u0000\u0000\u00b2\u0297\u0001\u0000\u0000\u0000\u00b4\u029b\u0001"+ + "\u0000\u0000\u0000\u00b6\u00b8\u0007\u0000\u0000\u0000\u00b7\u00b6\u0001"+ + "\u0000\u0000\u0000\u00b8\u00b9\u0001\u0000\u0000\u0000\u00b9\u00b7\u0001"+ + "\u0000\u0000\u0000\u00b9\u00ba\u0001\u0000\u0000\u0000\u00ba\u00bb\u0001"+ + "\u0000\u0000\u0000\u00bb\u00bc\u0006\u0000\u0000\u0000\u00bc\u0005\u0001"+ + "\u0000\u0000\u0000\u00bd\u00bf\u0005\r\u0000\u0000\u00be\u00bd\u0001\u0000"+ + "\u0000\u0000\u00be\u00bf\u0001\u0000\u0000\u0000\u00bf\u00c0\u0001\u0000"+ + "\u0000\u0000\u00c0\u00c2\u0005\n\u0000\u0000\u00c1\u00be\u0001\u0000\u0000"+ + "\u0000\u00c2\u00c3\u0001\u0000\u0000\u0000\u00c3\u00c1\u0001\u0000\u0000"+ + "\u0000\u00c3\u00c4\u0001\u0000\u0000\u0000\u00c4\u0007\u0001\u0000\u0000"+ + "\u0000\u00c5\u00c9\u0005#\u0000\u0000\u00c6\u00c8\b\u0001\u0000\u0000"+ + "\u00c7\u00c6\u0001\u0000\u0000\u0000\u00c8\u00cb\u0001\u0000\u0000\u0000"+ + "\u00c9\u00c7\u0001\u0000\u0000\u0000\u00c9\u00ca\u0001\u0000\u0000\u0000"+ + "\u00ca\u00cc\u0001\u0000\u0000\u0000\u00cb\u00c9\u0001\u0000\u0000\u0000"+ + "\u00cc\u00cd\u0006\u0002\u0001\u0000\u00cd\t\u0001\u0000\u0000\u0000\u00ce"+ + "\u00cf\u0005[\u0000\u0000\u00cf\u000b\u0001\u0000\u0000\u0000\u00d0\u00d1"+ + "\u0005[\u0000\u0000\u00d1\u00d2\u0005[\u0000\u0000\u00d2\r\u0001\u0000"+ + "\u0000\u0000\u00d3\u00d4\u0005]\u0000\u0000\u00d4\u000f\u0001\u0000\u0000"+ + "\u0000\u00d5\u00d6\u0005]\u0000\u0000\u00d6\u00d7\u0005]\u0000\u0000\u00d7"+ + "\u0011\u0001\u0000\u0000\u0000\u00d8\u00d9\u0005=\u0000\u0000\u00d9\u00da"+ + "\u0001\u0000\u0000\u0000\u00da\u00db\u0006\u0007\u0002\u0000\u00db\u0013"+ + "\u0001\u0000\u0000\u0000\u00dc\u00dd\u0005.\u0000\u0000\u00dd\u0015\u0001"+ + "\u0000\u0000\u0000\u00de\u00df\u0005,\u0000\u0000\u00df\u00e0\u0001\u0000"+ + "\u0000\u0000\u00e0\u00e1\u0006\t\u0000\u0000\u00e1\u0017\u0001\u0000\u0000"+ + "\u0000\u00e2\u00e3\u0007\u0002\u0000\u0000\u00e3\u0019\u0001\u0000\u0000"+ + "\u0000\u00e4\u00e5\u0007\u0003\u0000\u0000\u00e5\u001b\u0001\u0000\u0000"+ + "\u0000\u00e6\u00ea\u0005\\\u0000\u0000\u00e7\u00eb\u0007\u0004\u0000\u0000"+ + "\u00e8\u00eb\u0003\u001e\r\u0000\u00e9\u00eb\u0003 \u000e\u0000\u00ea"+ + "\u00e7\u0001\u0000\u0000\u0000\u00ea\u00e8\u0001\u0000\u0000\u0000\u00ea"+ + "\u00e9\u0001\u0000\u0000\u0000\u00eb\u001d\u0001\u0000\u0000\u0000\u00ec"+ + "\u00ed\u0005u\u0000\u0000\u00ed\u00ee\u0003F!\u0000\u00ee\u00ef\u0003"+ + "F!\u0000\u00ef\u00f0\u0003F!\u0000\u00f0\u00f1\u0003F!\u0000\u00f1\u001f"+ + "\u0001\u0000\u0000\u0000\u00f2\u00f3\u0005U\u0000\u0000\u00f3\u00f4\u0003"+ + "F!\u0000\u00f4\u00f5\u0003F!\u0000\u00f5\u00f6\u0003F!\u0000\u00f6\u00f7"+ + "\u0003F!\u0000\u00f7\u00f8\u0003F!\u0000\u00f8\u00f9\u0003F!\u0000\u00f9"+ + "\u00fa\u0003F!\u0000\u00fa\u00fb\u0003F!\u0000\u00fb!\u0001\u0000\u0000"+ + "\u0000\u00fc\u0101\u0005\"\u0000\u0000\u00fd\u0100\u0003\u001c\f\u0000"+ + "\u00fe\u0100\b\u0005\u0000\u0000\u00ff\u00fd\u0001\u0000\u0000\u0000\u00ff"+ + "\u00fe\u0001\u0000\u0000\u0000\u0100\u0103\u0001\u0000\u0000\u0000\u0101"+ + "\u0102\u0001\u0000\u0000\u0000\u0101\u00ff\u0001\u0000\u0000\u0000\u0102"+ + "\u0104\u0001\u0000\u0000\u0000\u0103\u0101\u0001\u0000\u0000\u0000\u0104"+ + "\u0105\u0005\"\u0000\u0000\u0105#\u0001\u0000\u0000\u0000\u0106\u010a"+ + "\u0005\'\u0000\u0000\u0107\u0109\b\u0006\u0000\u0000\u0108\u0107\u0001"+ + "\u0000\u0000\u0000\u0109\u010c\u0001\u0000\u0000\u0000\u010a\u010b\u0001"+ + "\u0000\u0000\u0000\u010a\u0108\u0001\u0000\u0000\u0000\u010b\u010d\u0001"+ + "\u0000\u0000\u0000\u010c\u010a\u0001\u0000\u0000\u0000\u010d\u010e\u0005"+ + "\'\u0000\u0000\u010e%\u0001\u0000\u0000\u0000\u010f\u0113\u0003\u001a"+ + "\u000b\u0000\u0110\u0113\u0003\u0018\n\u0000\u0111\u0113\u0007\u0007\u0000"+ + "\u0000\u0112\u010f\u0001\u0000\u0000\u0000\u0112\u0110\u0001\u0000\u0000"+ + "\u0000\u0112\u0111\u0001\u0000\u0000\u0000\u0113\u0114\u0001\u0000\u0000"+ + "\u0000\u0114\u0112\u0001\u0000\u0000\u0000\u0114\u0115\u0001\u0000\u0000"+ + "\u0000\u0115\'\u0001\u0000\u0000\u0000\u0116\u0117\u0003\u0004\u0000\u0000"+ + "\u0117\u0118\u0001\u0000\u0000\u0000\u0118\u0119\u0006\u0012\u0000\u0000"+ + "\u0119)\u0001\u0000\u0000\u0000\u011a\u011b\u0005{\u0000\u0000\u011b\u011c"+ + "\u0001\u0000\u0000\u0000\u011c\u011d\u0006\u0013\u0003\u0000\u011d+\u0001"+ + "\u0000\u0000\u0000\u011e\u011f\u0003\n\u0003\u0000\u011f\u0120\u0001\u0000"+ + "\u0000\u0000\u0120\u0121\u0006\u0014\u0004\u0000\u0121\u0122\u0006\u0014"+ + "\u0005\u0000\u0122-\u0001\u0000\u0000\u0000\u0123\u0124\u0005t\u0000\u0000"+ + "\u0124\u0125\u0005r\u0000\u0000\u0125\u0126\u0005u\u0000\u0000\u0126\u012d"+ + "\u0005e\u0000\u0000\u0127\u0128\u0005f\u0000\u0000\u0128\u0129\u0005a"+ + "\u0000\u0000\u0129\u012a\u0005l\u0000\u0000\u012a\u012b\u0005s\u0000\u0000"+ + "\u012b\u012d\u0005e\u0000\u0000\u012c\u0123\u0001\u0000\u0000\u0000\u012c"+ + "\u0127\u0001\u0000\u0000\u0000\u012d\u012e\u0001\u0000\u0000\u0000\u012e"+ + "\u012f\u0006\u0015\u0006\u0000\u012f/\u0001\u0000\u0000\u0000\u0130\u0132"+ + "\u0005\\\u0000\u0000\u0131\u0133\u0005\r\u0000\u0000\u0132\u0131\u0001"+ + "\u0000\u0000\u0000\u0132\u0133\u0001\u0000\u0000\u0000\u0133\u0134\u0001"+ + "\u0000\u0000\u0000\u0134\u0137\u0005\n\u0000\u0000\u0135\u0137\u0003\u001c"+ + "\f\u0000\u0136\u0130\u0001\u0000\u0000\u0000\u0136\u0135\u0001\u0000\u0000"+ + "\u0000\u01371\u0001\u0000\u0000\u0000\u0138\u0139\u0003\"\u000f\u0000"+ + "\u0139\u013a\u0001\u0000\u0000\u0000\u013a\u013b\u0006\u0017\u0007\u0000"+ + "\u013b\u013c\u0006\u0017\u0006\u0000\u013c3\u0001\u0000\u0000\u0000\u013d"+ + "\u013e\u0005\"\u0000\u0000\u013e\u013f\u0005\"\u0000\u0000\u013f\u0140"+ + "\u0005\"\u0000\u0000\u0140\u0145\u0001\u0000\u0000\u0000\u0141\u0144\u0003"+ + "0\u0016\u0000\u0142\u0144\b\b\u0000\u0000\u0143\u0141\u0001\u0000\u0000"+ + "\u0000\u0143\u0142\u0001\u0000\u0000\u0000\u0144\u0147\u0001\u0000\u0000"+ + "\u0000\u0145\u0146\u0001\u0000\u0000\u0000\u0145\u0143\u0001\u0000\u0000"+ + "\u0000\u0146\u0148\u0001\u0000\u0000\u0000\u0147\u0145\u0001\u0000\u0000"+ + "\u0000\u0148\u0149\u0005\"\u0000\u0000\u0149\u014a\u0005\"\u0000\u0000"+ + "\u014a\u014b\u0005\"\u0000\u0000\u014b\u014c\u0001\u0000\u0000\u0000\u014c"+ + "\u014d\u0006\u0018\u0006\u0000\u014d5\u0001\u0000\u0000\u0000\u014e\u014f"+ + "\u0003$\u0010\u0000\u014f\u0150\u0001\u0000\u0000\u0000\u0150\u0151\u0006"+ + "\u0019\b\u0000\u0151\u0152\u0006\u0019\u0006\u0000\u01527\u0001\u0000"+ + "\u0000\u0000\u0153\u0154\u0005\'\u0000\u0000\u0154\u0155\u0005\'\u0000"+ + "\u0000\u0155\u0156\u0005\'\u0000\u0000\u0156\u015a\u0001\u0000\u0000\u0000"+ + "\u0157\u0159\t\u0000\u0000\u0000\u0158\u0157\u0001\u0000\u0000\u0000\u0159"+ + "\u015c\u0001\u0000\u0000\u0000\u015a\u015b\u0001\u0000\u0000\u0000\u015a"+ + "\u0158\u0001\u0000\u0000\u0000\u015b\u015d\u0001\u0000\u0000\u0000\u015c"+ + "\u015a\u0001\u0000\u0000\u0000\u015d\u015e\u0005\'\u0000\u0000\u015e\u015f"+ + "\u0005\'\u0000\u0000\u015f\u0160\u0005\'\u0000\u0000\u0160\u0161\u0001"+ + "\u0000\u0000\u0000\u0161\u0162\u0006\u001a\u0006\u0000\u01629\u0001\u0000"+ + "\u0000\u0000\u0163\u0165\u0007\t\u0000\u0000\u0164\u0166\u0007\n\u0000"+ + "\u0000\u0165\u0164\u0001\u0000\u0000\u0000\u0165\u0166\u0001\u0000\u0000"+ + "\u0000\u0166\u0167\u0001\u0000\u0000\u0000\u0167\u0168\u0003<\u001c\u0000"+ + "\u0168;\u0001\u0000\u0000\u0000\u0169\u016f\u0003\u0018\n\u0000\u016a"+ + "\u016e\u0003\u0018\n\u0000\u016b\u016c\u0005_\u0000\u0000\u016c\u016e"+ + "\u0003\u0018\n\u0000\u016d\u016a\u0001\u0000\u0000\u0000\u016d\u016b\u0001"+ + "\u0000\u0000\u0000\u016e\u0171\u0001\u0000\u0000\u0000\u016f\u016d\u0001"+ + "\u0000\u0000\u0000\u016f\u0170\u0001\u0000\u0000\u0000\u0170=\u0001\u0000"+ + "\u0000\u0000\u0171\u016f\u0001\u0000\u0000\u0000\u0172\u0173\u0005.\u0000"+ + "\u0000\u0173\u0174\u0003<\u001c\u0000\u0174?\u0001\u0000\u0000\u0000\u0175"+ + "\u017b\u0003N%\u0000\u0176\u017c\u0003:\u001b\u0000\u0177\u0179\u0003"+ + ">\u001d\u0000\u0178\u017a\u0003:\u001b\u0000\u0179\u0178\u0001\u0000\u0000"+ + "\u0000\u0179\u017a\u0001\u0000\u0000\u0000\u017a\u017c\u0001\u0000\u0000"+ + "\u0000\u017b\u0176\u0001\u0000\u0000\u0000\u017b\u0177\u0001\u0000\u0000"+ + "\u0000\u017c\u017d\u0001\u0000\u0000\u0000\u017d\u017e\u0006\u001e\u0006"+ + "\u0000\u017eA\u0001\u0000\u0000\u0000\u017f\u0181\u0007\n\u0000\u0000"+ + "\u0180\u017f\u0001\u0000\u0000\u0000\u0180\u0181\u0001\u0000\u0000\u0000"+ + "\u0181\u0182\u0001\u0000\u0000\u0000\u0182\u0183\u0005i\u0000\u0000\u0183"+ + "\u0184\u0005n\u0000\u0000\u0184\u0185\u0005f\u0000\u0000\u0185\u0186\u0001"+ + "\u0000\u0000\u0000\u0186\u0187\u0006\u001f\u0006\u0000\u0187C\u0001\u0000"+ + "\u0000\u0000\u0188\u018a\u0007\n\u0000\u0000\u0189\u0188\u0001\u0000\u0000"+ + "\u0000\u0189\u018a\u0001\u0000\u0000\u0000\u018a\u018b\u0001\u0000\u0000"+ + "\u0000\u018b\u018c\u0005n\u0000\u0000\u018c\u018d\u0005a\u0000\u0000\u018d"+ + "\u018e\u0005n\u0000\u0000\u018e\u018f\u0001\u0000\u0000\u0000\u018f\u0190"+ + "\u0006 \u0006\u0000\u0190E\u0001\u0000\u0000\u0000\u0191\u0194\u0007\u000b"+ + "\u0000\u0000\u0192\u0194\u0003\u0018\n\u0000\u0193\u0191\u0001\u0000\u0000"+ + "\u0000\u0193\u0192\u0001\u0000\u0000\u0000\u0194G\u0001\u0000\u0000\u0000"+ + "\u0195\u0196\u0007\f\u0000\u0000\u0196I\u0001\u0000\u0000\u0000\u0197"+ + "\u0198\u0007\r\u0000\u0000\u0198K\u0001\u0000\u0000\u0000\u0199\u019a"+ + "\u0007\u000e\u0000\u0000\u019aM\u0001\u0000\u0000\u0000\u019b\u019d\u0007"+ + "\n\u0000\u0000\u019c\u019b\u0001\u0000\u0000\u0000\u019c\u019d\u0001\u0000"+ + "\u0000\u0000\u019d\u01a7\u0001\u0000\u0000\u0000\u019e\u01a8\u0003\u0018"+ + "\n\u0000\u019f\u01a3\u0003H\"\u0000\u01a0\u01a4\u0003\u0018\n\u0000\u01a1"+ + "\u01a2\u0005_\u0000\u0000\u01a2\u01a4\u0003\u0018\n\u0000\u01a3\u01a0"+ + "\u0001\u0000\u0000\u0000\u01a3\u01a1\u0001\u0000\u0000\u0000\u01a4\u01a5"+ + "\u0001\u0000\u0000\u0000\u01a5\u01a3\u0001\u0000\u0000\u0000\u01a5\u01a6"+ + "\u0001\u0000\u0000\u0000\u01a6\u01a8\u0001\u0000\u0000\u0000\u01a7\u019e"+ + "\u0001\u0000\u0000\u0000\u01a7\u019f\u0001\u0000\u0000\u0000\u01a8\u01a9"+ + "\u0001\u0000\u0000\u0000\u01a9\u01aa\u0006%\u0006\u0000\u01aaO\u0001\u0000"+ + "\u0000\u0000\u01ab\u01ac\u00050\u0000\u0000\u01ac\u01ad\u0005x\u0000\u0000"+ + "\u01ad\u01ae\u0001\u0000\u0000\u0000\u01ae\u01b4\u0003F!\u0000\u01af\u01b3"+ + "\u0003F!\u0000\u01b0\u01b1\u0005_\u0000\u0000\u01b1\u01b3\u0003F!\u0000"+ + "\u01b2\u01af\u0001\u0000\u0000\u0000\u01b2\u01b0\u0001\u0000\u0000\u0000"+ + "\u01b3\u01b6\u0001\u0000\u0000\u0000\u01b4\u01b2\u0001\u0000\u0000\u0000"+ + "\u01b4\u01b5\u0001\u0000\u0000\u0000\u01b5\u01b7\u0001\u0000\u0000\u0000"+ + "\u01b6\u01b4\u0001\u0000\u0000\u0000\u01b7\u01b8\u0006&\u0006\u0000\u01b8"+ + "Q\u0001\u0000\u0000\u0000\u01b9\u01ba\u00050\u0000\u0000\u01ba\u01bb\u0005"+ + "o\u0000\u0000\u01bb\u01bc\u0001\u0000\u0000\u0000\u01bc\u01c2\u0003J#"+ + "\u0000\u01bd\u01c1\u0003J#\u0000\u01be\u01bf\u0005_\u0000\u0000\u01bf"+ + "\u01c1\u0003J#\u0000\u01c0\u01bd\u0001\u0000\u0000\u0000\u01c0\u01be\u0001"+ + "\u0000\u0000\u0000\u01c1\u01c4\u0001\u0000\u0000\u0000\u01c2\u01c0\u0001"+ + "\u0000\u0000\u0000\u01c2\u01c3\u0001\u0000\u0000\u0000\u01c3\u01c5\u0001"+ + "\u0000\u0000\u0000\u01c4\u01c2\u0001\u0000\u0000\u0000\u01c5\u01c6\u0006"+ + "\'\u0006\u0000\u01c6S\u0001\u0000\u0000\u0000\u01c7\u01c8\u00050\u0000"+ + "\u0000\u01c8\u01c9\u0005b\u0000\u0000\u01c9\u01ca\u0001\u0000\u0000\u0000"+ + "\u01ca\u01d0\u0003L$\u0000\u01cb\u01cf\u0003L$\u0000\u01cc\u01cd\u0005"+ + "_\u0000\u0000\u01cd\u01cf\u0003L$\u0000\u01ce\u01cb\u0001\u0000\u0000"+ + "\u0000\u01ce\u01cc\u0001\u0000\u0000\u0000\u01cf\u01d2\u0001\u0000\u0000"+ + "\u0000\u01d0\u01ce\u0001\u0000\u0000\u0000\u01d0\u01d1\u0001\u0000\u0000"+ + "\u0000\u01d1\u01d3\u0001\u0000\u0000\u0000\u01d2\u01d0\u0001\u0000\u0000"+ + "\u0000\u01d3\u01d4\u0006(\u0006\u0000\u01d4U\u0001\u0000\u0000\u0000\u01d5"+ + "\u01d6\u0003\u0018\n\u0000\u01d6\u01d7\u0003\u0018\n\u0000\u01d7\u01d8"+ + "\u0003\u0018\n\u0000\u01d8\u01d9\u0003\u0018\n\u0000\u01d9W\u0001\u0000"+ + "\u0000\u0000\u01da\u01db\u0003\u0018\n\u0000\u01db\u01dc\u0003\u0018\n"+ + "\u0000\u01dcY\u0001\u0000\u0000\u0000\u01dd\u01de\u0003\u0018\n\u0000"+ + "\u01de\u01df\u0003\u0018\n\u0000\u01df[\u0001\u0000\u0000\u0000\u01e0"+ + "\u01e1\u0007\u000f\u0000\u0000\u01e1]\u0001\u0000\u0000\u0000\u01e2\u01e3"+ + "\u0003\u0018\n\u0000\u01e3\u01e4\u0003\u0018\n\u0000\u01e4_\u0001\u0000"+ + "\u0000\u0000\u01e5\u01e6\u0003\u0018\n\u0000\u01e6\u01e7\u0003\u0018\n"+ + "\u0000\u01e7a\u0001\u0000\u0000\u0000\u01e8\u01e9\u0003\u0018\n\u0000"+ + "\u01e9\u01ea\u0003\u0018\n\u0000\u01eac\u0001\u0000\u0000\u0000\u01eb"+ + "\u01ed\u0005.\u0000\u0000\u01ec\u01ee\u0003\u0018\n\u0000\u01ed\u01ec"+ + "\u0001\u0000\u0000\u0000\u01ee\u01ef\u0001\u0000\u0000\u0000\u01ef\u01ed"+ + "\u0001\u0000\u0000\u0000\u01ef\u01f0\u0001\u0000\u0000\u0000\u01f0e\u0001"+ + "\u0000\u0000\u0000\u01f1\u01f2\u0007\n\u0000\u0000\u01f2\u01f3\u0003^"+ + "-\u0000\u01f3\u01f4\u0005:\u0000\u0000\u01f4\u01f5\u0003`.\u0000\u01f5"+ + "g\u0001\u0000\u0000\u0000\u01f6\u01f9\u0005Z\u0000\u0000\u01f7\u01f9\u0003"+ + "f1\u0000\u01f8\u01f6\u0001\u0000\u0000\u0000\u01f8\u01f7\u0001\u0000\u0000"+ + "\u0000\u01f9i\u0001\u0000\u0000\u0000\u01fa\u01fb\u0003^-\u0000\u01fb"+ + "\u01fc\u0005:\u0000\u0000\u01fc\u01fd\u0003`.\u0000\u01fd\u01fe\u0005"+ + ":\u0000\u0000\u01fe\u0200\u0003b/\u0000\u01ff\u0201\u0003d0\u0000\u0200"+ + "\u01ff\u0001\u0000\u0000\u0000\u0200\u0201\u0001\u0000\u0000\u0000\u0201"+ + "k\u0001\u0000\u0000\u0000\u0202\u0203\u0003V)\u0000\u0203\u0204\u0005"+ + "-\u0000\u0000\u0204\u0205\u0003X*\u0000\u0205\u0206\u0005-\u0000\u0000"+ + "\u0206\u0207\u0003Z+\u0000\u0207m\u0001\u0000\u0000\u0000\u0208\u0209"+ + "\u0003j3\u0000\u0209\u020a\u0003h2\u0000\u020ao\u0001\u0000\u0000\u0000"+ + "\u020b\u020c\u0003l4\u0000\u020c\u020d\u0003\\,\u0000\u020d\u020e\u0003"+ + "n5\u0000\u020e\u020f\u0001\u0000\u0000\u0000\u020f\u0210\u00066\u0006"+ + "\u0000\u0210q\u0001\u0000\u0000\u0000\u0211\u0212\u0003l4\u0000\u0212"+ + "\u0213\u0003\\,\u0000\u0213\u0214\u0003j3\u0000\u0214\u0215\u0001\u0000"+ + "\u0000\u0000\u0215\u0216\u00067\u0006\u0000\u0216s\u0001\u0000\u0000\u0000"+ + "\u0217\u0218\u0003l4\u0000\u0218\u0219\u0001\u0000\u0000\u0000\u0219\u021a"+ + "\u00068\u0006\u0000\u021au\u0001\u0000\u0000\u0000\u021b\u021c\u0003j"+ + "3\u0000\u021c\u021d\u0001\u0000\u0000\u0000\u021d\u021e\u00069\u0006\u0000"+ + "\u021ew\u0001\u0000\u0000\u0000\u021f\u0220\u0003\u0004\u0000\u0000\u0220"+ + "\u0221\u0001\u0000\u0000\u0000\u0221\u0222\u0006:\u0000\u0000\u0222y\u0001"+ + "\u0000\u0000\u0000\u0223\u0224\u0003\u0014\b\u0000\u0224\u0225\u0001\u0000"+ + "\u0000\u0000\u0225\u0226\u0006;\t\u0000\u0226{\u0001\u0000\u0000\u0000"+ + "\u0227\u0228\u0003\u0016\t\u0000\u0228\u0229\u0001\u0000\u0000\u0000\u0229"+ + "\u022a\u0006<\n\u0000\u022a}\u0001\u0000\u0000\u0000\u022b\u022c\u0005"+ + "}\u0000\u0000\u022c\u022d\u0001\u0000\u0000\u0000\u022d\u022e\u0006=\u0006"+ + "\u0000\u022e\u007f\u0001\u0000\u0000\u0000\u022f\u0230\u0003\"\u000f\u0000"+ + "\u0230\u0231\u0001\u0000\u0000\u0000\u0231\u0232\u0006>\u0007\u0000\u0232"+ + "\u0081\u0001\u0000\u0000\u0000\u0233\u0234\u0003$\u0010\u0000\u0234\u0235"+ + "\u0001\u0000\u0000\u0000\u0235\u0236\u0006?\b\u0000\u0236\u0083\u0001"+ + "\u0000\u0000\u0000\u0237\u0238\u0003&\u0011\u0000\u0238\u0239\u0001\u0000"+ + "\u0000\u0000\u0239\u023a\u0006@\u000b\u0000\u023a\u0085\u0001\u0000\u0000"+ + "\u0000\u023b\u023c\u0003\u0012\u0007\u0000\u023c\u023d\u0001\u0000\u0000"+ + "\u0000\u023d\u023e\u0006A\f\u0000\u023e\u023f\u0006A\u0002\u0000\u023f"+ + "\u0087\u0001\u0000\u0000\u0000\u0240\u0241\u0003\u0004\u0000\u0000\u0241"+ + "\u0242\u0001\u0000\u0000\u0000\u0242\u0243\u0006B\u0000\u0000\u0243\u0089"+ + "\u0001\u0000\u0000\u0000\u0244\u0245\u0003\u0006\u0001\u0000\u0245\u0246"+ + "\u0001\u0000\u0000\u0000\u0246\u0247\u0006C\r\u0000\u0247\u008b\u0001"+ + "\u0000\u0000\u0000\u0248\u0249\u0003\b\u0002\u0000\u0249\u024a\u0001\u0000"+ + "\u0000\u0000\u024a\u024b\u0006D\u000e\u0000\u024b\u008d\u0001\u0000\u0000"+ + "\u0000\u024c\u024d\u0003\u0016\t\u0000\u024d\u024e\u0001\u0000\u0000\u0000"+ + "\u024e\u024f\u0006E\n\u0000\u024f\u008f\u0001\u0000\u0000\u0000\u0250"+ + "\u0251\u0003*\u0013\u0000\u0251\u0252\u0001\u0000\u0000\u0000\u0252\u0253"+ + "\u0006F\u000f\u0000\u0253\u0254\u0006F\u0010\u0000\u0254\u0091\u0001\u0000"+ + "\u0000\u0000\u0255\u0256\u0003\n\u0003\u0000\u0256\u0257\u0001\u0000\u0000"+ + "\u0000\u0257\u0258\u0006G\u0004\u0000\u0258\u0259\u0006G\u0011\u0000\u0259"+ + "\u0093\u0001\u0000\u0000\u0000\u025a\u025b\u0003\u000e\u0005\u0000\u025b"+ + "\u025c\u0001\u0000\u0000\u0000\u025c\u025d\u0006H\u0012\u0000\u025d\u025e"+ + "\u0006H\u0006\u0000\u025e\u0095\u0001\u0000\u0000\u0000\u025f\u0260\u0003"+ + ".\u0015\u0000\u0260\u0261\u0001\u0000\u0000\u0000\u0261\u0262\u0006I\u0013"+ + "\u0000\u0262\u0097\u0001\u0000\u0000\u0000\u0263\u0264\u0003\"\u000f\u0000"+ + "\u0264\u0265\u0001\u0000\u0000\u0000\u0265\u0266\u0006J\u0007\u0000\u0266"+ + "\u0099\u0001\u0000\u0000\u0000\u0267\u0268\u00034\u0018\u0000\u0268\u0269"+ + "\u0001\u0000\u0000\u0000\u0269\u026a\u0006K\u0014\u0000\u026a\u009b\u0001"+ + "\u0000\u0000\u0000\u026b\u026c\u0003$\u0010\u0000\u026c\u026d\u0001\u0000"+ + "\u0000\u0000\u026d\u026e\u0006L\b\u0000\u026e\u009d\u0001\u0000\u0000"+ + "\u0000\u026f\u0270\u00038\u001a\u0000\u0270\u0271\u0001\u0000\u0000\u0000"+ + "\u0271\u0272\u0006M\u0015\u0000\u0272\u009f\u0001\u0000\u0000\u0000\u0273"+ + "\u0274\u0003@\u001e\u0000\u0274\u0275\u0001\u0000\u0000\u0000\u0275\u0276"+ + "\u0006N\u0016\u0000\u0276\u00a1\u0001\u0000\u0000\u0000\u0277\u0278\u0003"+ + "B\u001f\u0000\u0278\u0279\u0001\u0000\u0000\u0000\u0279\u027a\u0006O\u0017"+ + "\u0000\u027a\u00a3\u0001\u0000\u0000\u0000\u027b\u027c\u0003D \u0000\u027c"+ + "\u027d\u0001\u0000\u0000\u0000\u027d\u027e\u0006P\u0018\u0000\u027e\u00a5"+ + "\u0001\u0000\u0000\u0000\u027f\u0280\u0003N%\u0000\u0280\u0281\u0001\u0000"+ + "\u0000\u0000\u0281\u0282\u0006Q\u0019\u0000\u0282\u00a7\u0001\u0000\u0000"+ + "\u0000\u0283\u0284\u0003P&\u0000\u0284\u0285\u0001\u0000\u0000\u0000\u0285"+ + "\u0286\u0006R\u001a\u0000\u0286\u00a9\u0001\u0000\u0000\u0000\u0287\u0288"+ + "\u0003R\'\u0000\u0288\u0289\u0001\u0000\u0000\u0000\u0289\u028a\u0006"+ + "S\u001b\u0000\u028a\u00ab\u0001\u0000\u0000\u0000\u028b\u028c\u0003T("+ + "\u0000\u028c\u028d\u0001\u0000\u0000\u0000\u028d\u028e\u0006T\u001c\u0000"+ + "\u028e\u00ad\u0001\u0000\u0000\u0000\u028f\u0290\u0003p6\u0000\u0290\u0291"+ + "\u0001\u0000\u0000\u0000\u0291\u0292\u0006U\u001d\u0000\u0292\u00af\u0001"+ + "\u0000\u0000\u0000\u0293\u0294\u0003r7\u0000\u0294\u0295\u0001\u0000\u0000"+ + "\u0000\u0295\u0296\u0006V\u001e\u0000\u0296\u00b1\u0001\u0000\u0000\u0000"+ + "\u0297\u0298\u0003t8\u0000\u0298\u0299\u0001\u0000\u0000\u0000\u0299\u029a"+ + "\u0006W\u001f\u0000\u029a\u00b3\u0001\u0000\u0000\u0000\u029b\u029c\u0003"+ + "v9\u0000\u029c\u029d\u0001\u0000\u0000\u0000\u029d\u029e\u0006X \u0000"+ + "\u029e\u00b5\u0001\u0000\u0000\u0000)\u0000\u0001\u0002\u0003\u00b9\u00be"+ + "\u00c3\u00c9\u00ea\u00ff\u0101\u010a\u0112\u0114\u012c\u0132\u0136\u0143"+ + "\u0145\u015a\u0165\u016d\u016f\u0179\u017b\u0180\u0189\u0193\u019c\u01a3"+ + "\u01a5\u01a7\u01b2\u01b4\u01c0\u01c2\u01ce\u01d0\u01ef\u01f8\u0200!\u0006"+ + "\u0000\u0000\u0000\u0002\u0000\u0005\u0001\u0000\u0002\u0002\u0000\u0007"+ + "\u0004\u0000\u0002\u0003\u0000\u0004\u0000\u0000\u0007\u000b\u0000\u0007"+ + "\f\u0000\u0007\t\u0000\u0007\n\u0000\u0007\r\u0000\u0007\b\u0000\u0007"+ + "\u0002\u0000\u0007\u0003\u0000\u0007\u000f\u0000\u0005\u0002\u0000\u0005"+ + "\u0003\u0000\u0007\u0006\u0000\u0007\u0010\u0000\u0007\u0011\u0000\u0007"+ + "\u0012\u0000\u0007\u0013\u0000\u0007\u0014\u0000\u0007\u0015\u0000\u0007"+ + "\u0016\u0000\u0007\u0017\u0000\u0007\u0018\u0000\u0007\u0019\u0000\u0007"+ + "\u001a\u0000\u0007\u001b\u0000\u0007\u001c\u0000\u0007\u001d\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.tokens b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.tokens new file mode 100644 index 00000000000..080a49ecbae --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.tokens @@ -0,0 +1,41 @@ +WS=1 +NL=2 +COMMENT=3 +L_BRACKET=4 +DOUBLE_L_BRACKET=5 +R_BRACKET=6 +DOUBLE_R_BRACKET=7 +EQUALS=8 +DOT=9 +COMMA=10 +BASIC_STRING=11 +LITERAL_STRING=12 +UNQUOTED_KEY=13 +VALUE_WS=14 +L_BRACE=15 +BOOLEAN=16 +ML_BASIC_STRING=17 +ML_LITERAL_STRING=18 +FLOAT=19 +INF=20 +NAN=21 +DEC_INT=22 +HEX_INT=23 +OCT_INT=24 +BIN_INT=25 +OFFSET_DATE_TIME=26 +LOCAL_DATE_TIME=27 +LOCAL_DATE=28 +LOCAL_TIME=29 +INLINE_TABLE_WS=30 +R_BRACE=31 +ARRAY_WS=32 +'['=4 +'[['=5 +']'=6 +']]'=7 +'='=8 +'.'=9 +','=10 +'{'=15 +'}'=31 diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.interp b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.interp new file mode 100644 index 00000000000..826b7607270 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.interp @@ -0,0 +1,96 @@ +token literal names: +null +null +null +null +'[' +'[[' +']' +']]' +'=' +'.' +',' +null +null +null +null +'{' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +'}' +null + +token symbolic names: +null +WS +NL +COMMENT +L_BRACKET +DOUBLE_L_BRACKET +R_BRACKET +DOUBLE_R_BRACKET +EQUALS +DOT +COMMA +BASIC_STRING +LITERAL_STRING +UNQUOTED_KEY +VALUE_WS +L_BRACE +BOOLEAN +ML_BASIC_STRING +ML_LITERAL_STRING +FLOAT +INF +NAN +DEC_INT +HEX_INT +OCT_INT +BIN_INT +OFFSET_DATE_TIME +LOCAL_DATE_TIME +LOCAL_DATE +LOCAL_TIME +INLINE_TABLE_WS +R_BRACE +ARRAY_WS + +rule names: +document +expression +comment +keyValue +key +simpleKey +unquotedKey +quotedKey +dottedKey +value +string +integer +floatingPoint +bool +dateTime +commentOrNl +array +table +standardTable +inlineTable +arrayTable + + +atn: +[4, 1, 32, 235, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 3, 0, 44, 8, 0, 1, 0, 1, 0, 3, 0, 48, 8, 0, 5, 0, 50, 8, 0, 10, 0, 12, 0, 53, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 59, 8, 1, 1, 1, 1, 1, 3, 1, 63, 8, 1, 1, 1, 3, 1, 66, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 3, 4, 76, 8, 4, 1, 5, 1, 5, 3, 5, 80, 8, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 4, 8, 89, 8, 8, 11, 8, 12, 8, 90, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 100, 8, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 3, 15, 115, 8, 15, 1, 16, 1, 16, 5, 16, 119, 8, 16, 10, 16, 12, 16, 122, 9, 16, 1, 16, 1, 16, 1, 16, 5, 16, 127, 8, 16, 10, 16, 12, 16, 130, 9, 16, 1, 16, 1, 16, 1, 16, 5, 16, 135, 8, 16, 10, 16, 12, 16, 138, 9, 16, 1, 16, 1, 16, 3, 16, 142, 8, 16, 5, 16, 144, 8, 16, 10, 16, 12, 16, 147, 9, 16, 1, 16, 5, 16, 150, 8, 16, 10, 16, 12, 16, 153, 9, 16, 1, 16, 1, 16, 3, 16, 157, 8, 16, 1, 17, 1, 17, 3, 17, 161, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 167, 8, 18, 10, 18, 12, 18, 170, 9, 18, 1, 18, 5, 18, 173, 8, 18, 10, 18, 12, 18, 176, 9, 18, 1, 19, 1, 19, 5, 19, 180, 8, 19, 10, 19, 12, 19, 183, 9, 19, 1, 19, 1, 19, 1, 19, 5, 19, 188, 8, 19, 10, 19, 12, 19, 191, 9, 19, 1, 19, 1, 19, 1, 19, 5, 19, 196, 8, 19, 10, 19, 12, 19, 199, 9, 19, 1, 19, 1, 19, 3, 19, 203, 8, 19, 5, 19, 205, 8, 19, 10, 19, 12, 19, 208, 9, 19, 1, 19, 5, 19, 211, 8, 19, 10, 19, 12, 19, 214, 9, 19, 1, 19, 1, 19, 3, 19, 218, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 5, 20, 224, 8, 20, 10, 20, 12, 20, 227, 9, 20, 1, 20, 5, 20, 230, 8, 20, 10, 20, 12, 20, 233, 9, 20, 1, 20, 0, 0, 21, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 0, 5, 1, 0, 11, 12, 2, 0, 11, 12, 17, 18, 1, 0, 22, 25, 1, 0, 19, 21, 1, 0, 26, 29, 249, 0, 43, 1, 0, 0, 0, 2, 65, 1, 0, 0, 0, 4, 67, 1, 0, 0, 0, 6, 69, 1, 0, 0, 0, 8, 75, 1, 0, 0, 0, 10, 79, 1, 0, 0, 0, 12, 81, 1, 0, 0, 0, 14, 83, 1, 0, 0, 0, 16, 85, 1, 0, 0, 0, 18, 99, 1, 0, 0, 0, 20, 101, 1, 0, 0, 0, 22, 103, 1, 0, 0, 0, 24, 105, 1, 0, 0, 0, 26, 107, 1, 0, 0, 0, 28, 109, 1, 0, 0, 0, 30, 114, 1, 0, 0, 0, 32, 156, 1, 0, 0, 0, 34, 160, 1, 0, 0, 0, 36, 162, 1, 0, 0, 0, 38, 217, 1, 0, 0, 0, 40, 219, 1, 0, 0, 0, 42, 44, 3, 2, 1, 0, 43, 42, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 51, 1, 0, 0, 0, 45, 47, 5, 2, 0, 0, 46, 48, 3, 2, 1, 0, 47, 46, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 50, 1, 0, 0, 0, 49, 45, 1, 0, 0, 0, 50, 53, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 54, 55, 5, 0, 0, 1, 55, 1, 1, 0, 0, 0, 56, 58, 3, 6, 3, 0, 57, 59, 3, 4, 2, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 66, 1, 0, 0, 0, 60, 62, 3, 34, 17, 0, 61, 63, 3, 4, 2, 0, 62, 61, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 66, 1, 0, 0, 0, 64, 66, 3, 4, 2, 0, 65, 56, 1, 0, 0, 0, 65, 60, 1, 0, 0, 0, 65, 64, 1, 0, 0, 0, 66, 3, 1, 0, 0, 0, 67, 68, 5, 3, 0, 0, 68, 5, 1, 0, 0, 0, 69, 70, 3, 8, 4, 0, 70, 71, 5, 8, 0, 0, 71, 72, 3, 18, 9, 0, 72, 7, 1, 0, 0, 0, 73, 76, 3, 10, 5, 0, 74, 76, 3, 16, 8, 0, 75, 73, 1, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 9, 1, 0, 0, 0, 77, 80, 3, 14, 7, 0, 78, 80, 3, 12, 6, 0, 79, 77, 1, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 11, 1, 0, 0, 0, 81, 82, 5, 13, 0, 0, 82, 13, 1, 0, 0, 0, 83, 84, 7, 0, 0, 0, 84, 15, 1, 0, 0, 0, 85, 88, 3, 10, 5, 0, 86, 87, 5, 9, 0, 0, 87, 89, 3, 10, 5, 0, 88, 86, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 17, 1, 0, 0, 0, 92, 100, 3, 20, 10, 0, 93, 100, 3, 22, 11, 0, 94, 100, 3, 24, 12, 0, 95, 100, 3, 26, 13, 0, 96, 100, 3, 28, 14, 0, 97, 100, 3, 32, 16, 0, 98, 100, 3, 38, 19, 0, 99, 92, 1, 0, 0, 0, 99, 93, 1, 0, 0, 0, 99, 94, 1, 0, 0, 0, 99, 95, 1, 0, 0, 0, 99, 96, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 19, 1, 0, 0, 0, 101, 102, 7, 1, 0, 0, 102, 21, 1, 0, 0, 0, 103, 104, 7, 2, 0, 0, 104, 23, 1, 0, 0, 0, 105, 106, 7, 3, 0, 0, 106, 25, 1, 0, 0, 0, 107, 108, 5, 16, 0, 0, 108, 27, 1, 0, 0, 0, 109, 110, 7, 4, 0, 0, 110, 29, 1, 0, 0, 0, 111, 112, 5, 3, 0, 0, 112, 115, 5, 2, 0, 0, 113, 115, 5, 2, 0, 0, 114, 111, 1, 0, 0, 0, 114, 113, 1, 0, 0, 0, 115, 31, 1, 0, 0, 0, 116, 120, 5, 4, 0, 0, 117, 119, 3, 30, 15, 0, 118, 117, 1, 0, 0, 0, 119, 122, 1, 0, 0, 0, 120, 118, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 123, 1, 0, 0, 0, 122, 120, 1, 0, 0, 0, 123, 157, 5, 6, 0, 0, 124, 128, 5, 4, 0, 0, 125, 127, 3, 30, 15, 0, 126, 125, 1, 0, 0, 0, 127, 130, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 131, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 131, 145, 3, 18, 9, 0, 132, 136, 5, 10, 0, 0, 133, 135, 3, 30, 15, 0, 134, 133, 1, 0, 0, 0, 135, 138, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 139, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 139, 141, 3, 18, 9, 0, 140, 142, 5, 10, 0, 0, 141, 140, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 144, 1, 0, 0, 0, 143, 132, 1, 0, 0, 0, 144, 147, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 151, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 148, 150, 3, 30, 15, 0, 149, 148, 1, 0, 0, 0, 150, 153, 1, 0, 0, 0, 151, 149, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 154, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 154, 155, 5, 6, 0, 0, 155, 157, 1, 0, 0, 0, 156, 116, 1, 0, 0, 0, 156, 124, 1, 0, 0, 0, 157, 33, 1, 0, 0, 0, 158, 161, 3, 36, 18, 0, 159, 161, 3, 40, 20, 0, 160, 158, 1, 0, 0, 0, 160, 159, 1, 0, 0, 0, 161, 35, 1, 0, 0, 0, 162, 163, 5, 4, 0, 0, 163, 164, 3, 8, 4, 0, 164, 174, 5, 6, 0, 0, 165, 167, 3, 30, 15, 0, 166, 165, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 173, 3, 2, 1, 0, 172, 168, 1, 0, 0, 0, 173, 176, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, 37, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 177, 181, 5, 15, 0, 0, 178, 180, 3, 30, 15, 0, 179, 178, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 184, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 218, 5, 31, 0, 0, 185, 189, 5, 15, 0, 0, 186, 188, 3, 30, 15, 0, 187, 186, 1, 0, 0, 0, 188, 191, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 189, 190, 1, 0, 0, 0, 190, 192, 1, 0, 0, 0, 191, 189, 1, 0, 0, 0, 192, 206, 3, 6, 3, 0, 193, 197, 5, 10, 0, 0, 194, 196, 3, 30, 15, 0, 195, 194, 1, 0, 0, 0, 196, 199, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 200, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 200, 202, 3, 6, 3, 0, 201, 203, 5, 10, 0, 0, 202, 201, 1, 0, 0, 0, 202, 203, 1, 0, 0, 0, 203, 205, 1, 0, 0, 0, 204, 193, 1, 0, 0, 0, 205, 208, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 206, 207, 1, 0, 0, 0, 207, 212, 1, 0, 0, 0, 208, 206, 1, 0, 0, 0, 209, 211, 3, 30, 15, 0, 210, 209, 1, 0, 0, 0, 211, 214, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, 212, 213, 1, 0, 0, 0, 213, 215, 1, 0, 0, 0, 214, 212, 1, 0, 0, 0, 215, 216, 5, 31, 0, 0, 216, 218, 1, 0, 0, 0, 217, 177, 1, 0, 0, 0, 217, 185, 1, 0, 0, 0, 218, 39, 1, 0, 0, 0, 219, 220, 5, 5, 0, 0, 220, 221, 3, 8, 4, 0, 221, 231, 5, 7, 0, 0, 222, 224, 3, 30, 15, 0, 223, 222, 1, 0, 0, 0, 224, 227, 1, 0, 0, 0, 225, 223, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 228, 1, 0, 0, 0, 227, 225, 1, 0, 0, 0, 228, 230, 3, 2, 1, 0, 229, 225, 1, 0, 0, 0, 230, 233, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 232, 1, 0, 0, 0, 232, 41, 1, 0, 0, 0, 233, 231, 1, 0, 0, 0, 30, 43, 47, 51, 58, 62, 65, 75, 79, 90, 99, 114, 120, 128, 136, 141, 145, 151, 156, 160, 168, 174, 181, 189, 197, 202, 206, 212, 217, 225, 231] \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java new file mode 100644 index 00000000000..13ba230fc50 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java @@ -0,0 +1,1886 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.ParserATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.tree.ParseTreeListener; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.List; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class TomlParser extends Parser { + static { RuntimeMetaData.checkVersion("4.11.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + WS=1, NL=2, COMMENT=3, L_BRACKET=4, DOUBLE_L_BRACKET=5, R_BRACKET=6, DOUBLE_R_BRACKET=7, + EQUALS=8, DOT=9, COMMA=10, BASIC_STRING=11, LITERAL_STRING=12, UNQUOTED_KEY=13, + VALUE_WS=14, L_BRACE=15, BOOLEAN=16, ML_BASIC_STRING=17, ML_LITERAL_STRING=18, + FLOAT=19, INF=20, NAN=21, DEC_INT=22, HEX_INT=23, OCT_INT=24, BIN_INT=25, + OFFSET_DATE_TIME=26, LOCAL_DATE_TIME=27, LOCAL_DATE=28, LOCAL_TIME=29, + INLINE_TABLE_WS=30, R_BRACE=31, ARRAY_WS=32; + public static final int + RULE_document = 0, RULE_expression = 1, RULE_comment = 2, RULE_keyValue = 3, + RULE_key = 4, RULE_simpleKey = 5, RULE_unquotedKey = 6, RULE_quotedKey = 7, + RULE_dottedKey = 8, RULE_value = 9, RULE_string = 10, RULE_integer = 11, + RULE_floatingPoint = 12, RULE_bool = 13, RULE_dateTime = 14, RULE_commentOrNl = 15, + RULE_array = 16, RULE_table = 17, RULE_standardTable = 18, RULE_inlineTable = 19, + RULE_arrayTable = 20; + private static String[] makeRuleNames() { + return new String[] { + "document", "expression", "comment", "keyValue", "key", "simpleKey", + "unquotedKey", "quotedKey", "dottedKey", "value", "string", "integer", + "floatingPoint", "bool", "dateTime", "commentOrNl", "array", "table", + "standardTable", "inlineTable", "arrayTable" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, null, "'['", "'[['", "']'", "']]'", "'='", "'.'", "','", + null, null, null, null, "'{'", null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, "'}'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "WS", "NL", "COMMENT", "L_BRACKET", "DOUBLE_L_BRACKET", "R_BRACKET", + "DOUBLE_R_BRACKET", "EQUALS", "DOT", "COMMA", "BASIC_STRING", "LITERAL_STRING", + "UNQUOTED_KEY", "VALUE_WS", "L_BRACE", "BOOLEAN", "ML_BASIC_STRING", + "ML_LITERAL_STRING", "FLOAT", "INF", "NAN", "DEC_INT", "HEX_INT", "OCT_INT", + "BIN_INT", "OFFSET_DATE_TIME", "LOCAL_DATE_TIME", "LOCAL_DATE", "LOCAL_TIME", + "INLINE_TABLE_WS", "R_BRACE", "ARRAY_WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "java-escape"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public TomlParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class DocumentContext extends ParserRuleContext { + public TerminalNode EOF() { return getToken(TomlParser.EOF, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List NL() { return getTokens(TomlParser.NL); } + public TerminalNode NL(int i) { + return getToken(TomlParser.NL, i); + } + public DocumentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_document; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterDocument(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitDocument(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitDocument(this); + else return visitor.visitChildren(this); + } + } + + public final DocumentContext document() throws RecognitionException { + DocumentContext _localctx = new DocumentContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_document); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(43); + _errHandler.sync(this); + _la = _input.LA(1); + if (((_la) & ~0x3f) == 0 && ((1L << _la) & 14392L) != 0) { + { + setState(42); + expression(); + } + } + + setState(51); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL) { + { + { + setState(45); + match(NL); + setState(47); + _errHandler.sync(this); + _la = _input.LA(1); + if (((_la) & ~0x3f) == 0 && ((1L << _la) & 14392L) != 0) { + { + setState(46); + expression(); + } + } + + } + } + setState(53); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(54); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public KeyValueContext keyValue() { + return getRuleContext(KeyValueContext.class,0); + } + public CommentContext comment() { + return getRuleContext(CommentContext.class,0); + } + public TableContext table() { + return getRuleContext(TableContext.class,0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_expression); + try { + setState(65); + _errHandler.sync(this); + switch (_input.LA(1)) { + case BASIC_STRING: + case LITERAL_STRING: + case UNQUOTED_KEY: + enterOuterAlt(_localctx, 1); + { + setState(56); + keyValue(); + setState(58); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + { + setState(57); + comment(); + } + break; + } + } + break; + case L_BRACKET: + case DOUBLE_L_BRACKET: + enterOuterAlt(_localctx, 2); + { + setState(60); + table(); + setState(62); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) { + case 1: + { + setState(61); + comment(); + } + break; + } + } + break; + case COMMENT: + enterOuterAlt(_localctx, 3); + { + setState(64); + comment(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CommentContext extends ParserRuleContext { + public TerminalNode COMMENT() { return getToken(TomlParser.COMMENT, 0); } + public CommentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_comment; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterComment(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitComment(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitComment(this); + else return visitor.visitChildren(this); + } + } + + public final CommentContext comment() throws RecognitionException { + CommentContext _localctx = new CommentContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_comment); + try { + enterOuterAlt(_localctx, 1); + { + setState(67); + match(COMMENT); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class KeyValueContext extends ParserRuleContext { + public KeyContext key() { + return getRuleContext(KeyContext.class,0); + } + public TerminalNode EQUALS() { return getToken(TomlParser.EQUALS, 0); } + public ValueContext value() { + return getRuleContext(ValueContext.class,0); + } + public KeyValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_keyValue; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterKeyValue(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitKeyValue(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitKeyValue(this); + else return visitor.visitChildren(this); + } + } + + public final KeyValueContext keyValue() throws RecognitionException { + KeyValueContext _localctx = new KeyValueContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_keyValue); + try { + enterOuterAlt(_localctx, 1); + { + setState(69); + key(); + setState(70); + match(EQUALS); + setState(71); + value(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class KeyContext extends ParserRuleContext { + public SimpleKeyContext simpleKey() { + return getRuleContext(SimpleKeyContext.class,0); + } + public DottedKeyContext dottedKey() { + return getRuleContext(DottedKeyContext.class,0); + } + public KeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_key; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterKey(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitKey(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitKey(this); + else return visitor.visitChildren(this); + } + } + + public final KeyContext key() throws RecognitionException { + KeyContext _localctx = new KeyContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_key); + try { + setState(75); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(73); + simpleKey(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(74); + dottedKey(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SimpleKeyContext extends ParserRuleContext { + public QuotedKeyContext quotedKey() { + return getRuleContext(QuotedKeyContext.class,0); + } + public UnquotedKeyContext unquotedKey() { + return getRuleContext(UnquotedKeyContext.class,0); + } + public SimpleKeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_simpleKey; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterSimpleKey(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitSimpleKey(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitSimpleKey(this); + else return visitor.visitChildren(this); + } + } + + public final SimpleKeyContext simpleKey() throws RecognitionException { + SimpleKeyContext _localctx = new SimpleKeyContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_simpleKey); + try { + setState(79); + _errHandler.sync(this); + switch (_input.LA(1)) { + case BASIC_STRING: + case LITERAL_STRING: + enterOuterAlt(_localctx, 1); + { + setState(77); + quotedKey(); + } + break; + case UNQUOTED_KEY: + enterOuterAlt(_localctx, 2); + { + setState(78); + unquotedKey(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class UnquotedKeyContext extends ParserRuleContext { + public TerminalNode UNQUOTED_KEY() { return getToken(TomlParser.UNQUOTED_KEY, 0); } + public UnquotedKeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_unquotedKey; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterUnquotedKey(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitUnquotedKey(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitUnquotedKey(this); + else return visitor.visitChildren(this); + } + } + + public final UnquotedKeyContext unquotedKey() throws RecognitionException { + UnquotedKeyContext _localctx = new UnquotedKeyContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_unquotedKey); + try { + enterOuterAlt(_localctx, 1); + { + setState(81); + match(UNQUOTED_KEY); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class QuotedKeyContext extends ParserRuleContext { + public TerminalNode BASIC_STRING() { return getToken(TomlParser.BASIC_STRING, 0); } + public TerminalNode LITERAL_STRING() { return getToken(TomlParser.LITERAL_STRING, 0); } + public QuotedKeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_quotedKey; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterQuotedKey(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitQuotedKey(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitQuotedKey(this); + else return visitor.visitChildren(this); + } + } + + public final QuotedKeyContext quotedKey() throws RecognitionException { + QuotedKeyContext _localctx = new QuotedKeyContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_quotedKey); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(83); + _la = _input.LA(1); + if ( !(_la==BASIC_STRING || _la==LITERAL_STRING) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DottedKeyContext extends ParserRuleContext { + public List simpleKey() { + return getRuleContexts(SimpleKeyContext.class); + } + public SimpleKeyContext simpleKey(int i) { + return getRuleContext(SimpleKeyContext.class,i); + } + public List DOT() { return getTokens(TomlParser.DOT); } + public TerminalNode DOT(int i) { + return getToken(TomlParser.DOT, i); + } + public DottedKeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dottedKey; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterDottedKey(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitDottedKey(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitDottedKey(this); + else return visitor.visitChildren(this); + } + } + + public final DottedKeyContext dottedKey() throws RecognitionException { + DottedKeyContext _localctx = new DottedKeyContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_dottedKey); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(85); + simpleKey(); + setState(88); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(86); + match(DOT); + setState(87); + simpleKey(); + } + } + setState(90); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==DOT ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueContext extends ParserRuleContext { + public StringContext string() { + return getRuleContext(StringContext.class,0); + } + public IntegerContext integer() { + return getRuleContext(IntegerContext.class,0); + } + public FloatingPointContext floatingPoint() { + return getRuleContext(FloatingPointContext.class,0); + } + public BoolContext bool() { + return getRuleContext(BoolContext.class,0); + } + public DateTimeContext dateTime() { + return getRuleContext(DateTimeContext.class,0); + } + public ArrayContext array() { + return getRuleContext(ArrayContext.class,0); + } + public InlineTableContext inlineTable() { + return getRuleContext(InlineTableContext.class,0); + } + public ValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_value; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterValue(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitValue(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitValue(this); + else return visitor.visitChildren(this); + } + } + + public final ValueContext value() throws RecognitionException { + ValueContext _localctx = new ValueContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_value); + try { + setState(99); + _errHandler.sync(this); + switch (_input.LA(1)) { + case BASIC_STRING: + case LITERAL_STRING: + case ML_BASIC_STRING: + case ML_LITERAL_STRING: + enterOuterAlt(_localctx, 1); + { + setState(92); + string(); + } + break; + case DEC_INT: + case HEX_INT: + case OCT_INT: + case BIN_INT: + enterOuterAlt(_localctx, 2); + { + setState(93); + integer(); + } + break; + case FLOAT: + case INF: + case NAN: + enterOuterAlt(_localctx, 3); + { + setState(94); + floatingPoint(); + } + break; + case BOOLEAN: + enterOuterAlt(_localctx, 4); + { + setState(95); + bool(); + } + break; + case OFFSET_DATE_TIME: + case LOCAL_DATE_TIME: + case LOCAL_DATE: + case LOCAL_TIME: + enterOuterAlt(_localctx, 5); + { + setState(96); + dateTime(); + } + break; + case L_BRACKET: + enterOuterAlt(_localctx, 6); + { + setState(97); + array(); + } + break; + case L_BRACE: + enterOuterAlt(_localctx, 7); + { + setState(98); + inlineTable(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StringContext extends ParserRuleContext { + public TerminalNode BASIC_STRING() { return getToken(TomlParser.BASIC_STRING, 0); } + public TerminalNode ML_BASIC_STRING() { return getToken(TomlParser.ML_BASIC_STRING, 0); } + public TerminalNode LITERAL_STRING() { return getToken(TomlParser.LITERAL_STRING, 0); } + public TerminalNode ML_LITERAL_STRING() { return getToken(TomlParser.ML_LITERAL_STRING, 0); } + public StringContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_string; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterString(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitString(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitString(this); + else return visitor.visitChildren(this); + } + } + + public final StringContext string() throws RecognitionException { + StringContext _localctx = new StringContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_string); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(101); + _la = _input.LA(1); + if ( !(((_la) & ~0x3f) == 0 && ((1L << _la) & 399360L) != 0) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IntegerContext extends ParserRuleContext { + public TerminalNode DEC_INT() { return getToken(TomlParser.DEC_INT, 0); } + public TerminalNode HEX_INT() { return getToken(TomlParser.HEX_INT, 0); } + public TerminalNode OCT_INT() { return getToken(TomlParser.OCT_INT, 0); } + public TerminalNode BIN_INT() { return getToken(TomlParser.BIN_INT, 0); } + public IntegerContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_integer; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterInteger(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitInteger(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitInteger(this); + else return visitor.visitChildren(this); + } + } + + public final IntegerContext integer() throws RecognitionException { + IntegerContext _localctx = new IntegerContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_integer); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(103); + _la = _input.LA(1); + if ( !(((_la) & ~0x3f) == 0 && ((1L << _la) & 62914560L) != 0) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FloatingPointContext extends ParserRuleContext { + public TerminalNode FLOAT() { return getToken(TomlParser.FLOAT, 0); } + public TerminalNode INF() { return getToken(TomlParser.INF, 0); } + public TerminalNode NAN() { return getToken(TomlParser.NAN, 0); } + public FloatingPointContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_floatingPoint; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterFloatingPoint(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitFloatingPoint(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitFloatingPoint(this); + else return visitor.visitChildren(this); + } + } + + public final FloatingPointContext floatingPoint() throws RecognitionException { + FloatingPointContext _localctx = new FloatingPointContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_floatingPoint); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(105); + _la = _input.LA(1); + if ( !(((_la) & ~0x3f) == 0 && ((1L << _la) & 3670016L) != 0) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BoolContext extends ParserRuleContext { + public TerminalNode BOOLEAN() { return getToken(TomlParser.BOOLEAN, 0); } + public BoolContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_bool; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterBool(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitBool(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitBool(this); + else return visitor.visitChildren(this); + } + } + + public final BoolContext bool() throws RecognitionException { + BoolContext _localctx = new BoolContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_bool); + try { + enterOuterAlt(_localctx, 1); + { + setState(107); + match(BOOLEAN); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DateTimeContext extends ParserRuleContext { + public TerminalNode OFFSET_DATE_TIME() { return getToken(TomlParser.OFFSET_DATE_TIME, 0); } + public TerminalNode LOCAL_DATE_TIME() { return getToken(TomlParser.LOCAL_DATE_TIME, 0); } + public TerminalNode LOCAL_DATE() { return getToken(TomlParser.LOCAL_DATE, 0); } + public TerminalNode LOCAL_TIME() { return getToken(TomlParser.LOCAL_TIME, 0); } + public DateTimeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_dateTime; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterDateTime(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitDateTime(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitDateTime(this); + else return visitor.visitChildren(this); + } + } + + public final DateTimeContext dateTime() throws RecognitionException { + DateTimeContext _localctx = new DateTimeContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_dateTime); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(109); + _la = _input.LA(1); + if ( !(((_la) & ~0x3f) == 0 && ((1L << _la) & 1006632960L) != 0) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class CommentOrNlContext extends ParserRuleContext { + public TerminalNode COMMENT() { return getToken(TomlParser.COMMENT, 0); } + public TerminalNode NL() { return getToken(TomlParser.NL, 0); } + public CommentOrNlContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_commentOrNl; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterCommentOrNl(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitCommentOrNl(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitCommentOrNl(this); + else return visitor.visitChildren(this); + } + } + + public final CommentOrNlContext commentOrNl() throws RecognitionException { + CommentOrNlContext _localctx = new CommentOrNlContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_commentOrNl); + try { + setState(114); + _errHandler.sync(this); + switch (_input.LA(1)) { + case COMMENT: + enterOuterAlt(_localctx, 1); + { + setState(111); + match(COMMENT); + setState(112); + match(NL); + } + break; + case NL: + enterOuterAlt(_localctx, 2); + { + setState(113); + match(NL); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArrayContext extends ParserRuleContext { + public TerminalNode L_BRACKET() { return getToken(TomlParser.L_BRACKET, 0); } + public TerminalNode R_BRACKET() { return getToken(TomlParser.R_BRACKET, 0); } + public List commentOrNl() { + return getRuleContexts(CommentOrNlContext.class); + } + public CommentOrNlContext commentOrNl(int i) { + return getRuleContext(CommentOrNlContext.class,i); + } + public List value() { + return getRuleContexts(ValueContext.class); + } + public ValueContext value(int i) { + return getRuleContext(ValueContext.class,i); + } + public List COMMA() { return getTokens(TomlParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(TomlParser.COMMA, i); + } + public ArrayContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_array; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterArray(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitArray(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitArray(this); + else return visitor.visitChildren(this); + } + } + + public final ArrayContext array() throws RecognitionException { + ArrayContext _localctx = new ArrayContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_array); + int _la; + try { + setState(156); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(116); + match(L_BRACKET); + setState(120); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(117); + commentOrNl(); + } + } + setState(122); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(123); + match(R_BRACKET); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(124); + match(L_BRACKET); + setState(128); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(125); + commentOrNl(); + } + } + setState(130); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(131); + value(); + setState(145); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(132); + match(COMMA); + setState(136); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(133); + commentOrNl(); + } + } + setState(138); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(139); + value(); + setState(141); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { + case 1: + { + setState(140); + match(COMMA); + } + break; + } + } + } + setState(147); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(151); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(148); + commentOrNl(); + } + } + setState(153); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(154); + match(R_BRACKET); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TableContext extends ParserRuleContext { + public StandardTableContext standardTable() { + return getRuleContext(StandardTableContext.class,0); + } + public ArrayTableContext arrayTable() { + return getRuleContext(ArrayTableContext.class,0); + } + public TableContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_table; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterTable(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitTable(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitTable(this); + else return visitor.visitChildren(this); + } + } + + public final TableContext table() throws RecognitionException { + TableContext _localctx = new TableContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_table); + try { + setState(160); + _errHandler.sync(this); + switch (_input.LA(1)) { + case L_BRACKET: + enterOuterAlt(_localctx, 1); + { + setState(158); + standardTable(); + } + break; + case DOUBLE_L_BRACKET: + enterOuterAlt(_localctx, 2); + { + setState(159); + arrayTable(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StandardTableContext extends ParserRuleContext { + public TerminalNode L_BRACKET() { return getToken(TomlParser.L_BRACKET, 0); } + public KeyContext key() { + return getRuleContext(KeyContext.class,0); + } + public TerminalNode R_BRACKET() { return getToken(TomlParser.R_BRACKET, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List commentOrNl() { + return getRuleContexts(CommentOrNlContext.class); + } + public CommentOrNlContext commentOrNl(int i) { + return getRuleContext(CommentOrNlContext.class,i); + } + public StandardTableContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_standardTable; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterStandardTable(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitStandardTable(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitStandardTable(this); + else return visitor.visitChildren(this); + } + } + + public final StandardTableContext standardTable() throws RecognitionException { + StandardTableContext _localctx = new StandardTableContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_standardTable); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(162); + match(L_BRACKET); + setState(163); + key(); + setState(164); + match(R_BRACKET); + setState(174); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,20,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(168); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,19,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(165); + commentOrNl(); + } + } + } + setState(170); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,19,_ctx); + } + setState(171); + expression(); + } + } + } + setState(176); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,20,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class InlineTableContext extends ParserRuleContext { + public TerminalNode L_BRACE() { return getToken(TomlParser.L_BRACE, 0); } + public TerminalNode R_BRACE() { return getToken(TomlParser.R_BRACE, 0); } + public List commentOrNl() { + return getRuleContexts(CommentOrNlContext.class); + } + public CommentOrNlContext commentOrNl(int i) { + return getRuleContext(CommentOrNlContext.class,i); + } + public List keyValue() { + return getRuleContexts(KeyValueContext.class); + } + public KeyValueContext keyValue(int i) { + return getRuleContext(KeyValueContext.class,i); + } + public List COMMA() { return getTokens(TomlParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(TomlParser.COMMA, i); + } + public InlineTableContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_inlineTable; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterInlineTable(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitInlineTable(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitInlineTable(this); + else return visitor.visitChildren(this); + } + } + + public final InlineTableContext inlineTable() throws RecognitionException { + InlineTableContext _localctx = new InlineTableContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_inlineTable); + int _la; + try { + setState(217); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(177); + match(L_BRACE); + setState(181); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(178); + commentOrNl(); + } + } + setState(183); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(184); + match(R_BRACE); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(185); + match(L_BRACE); + setState(189); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(186); + commentOrNl(); + } + } + setState(191); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(192); + keyValue(); + setState(206); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(193); + match(COMMA); + setState(197); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(194); + commentOrNl(); + } + } + setState(199); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(200); + keyValue(); + setState(202); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + case 1: + { + setState(201); + match(COMMA); + } + break; + } + } + } + setState(208); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(212); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==NL || _la==COMMENT) { + { + { + setState(209); + commentOrNl(); + } + } + setState(214); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(215); + match(R_BRACE); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArrayTableContext extends ParserRuleContext { + public TerminalNode DOUBLE_L_BRACKET() { return getToken(TomlParser.DOUBLE_L_BRACKET, 0); } + public KeyContext key() { + return getRuleContext(KeyContext.class,0); + } + public TerminalNode DOUBLE_R_BRACKET() { return getToken(TomlParser.DOUBLE_R_BRACKET, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List commentOrNl() { + return getRuleContexts(CommentOrNlContext.class); + } + public CommentOrNlContext commentOrNl(int i) { + return getRuleContext(CommentOrNlContext.class,i); + } + public ArrayTableContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_arrayTable; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).enterArrayTable(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof TomlParserListener ) ((TomlParserListener)listener).exitArrayTable(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof TomlParserVisitor ) return ((TomlParserVisitor)visitor).visitArrayTable(this); + else return visitor.visitChildren(this); + } + } + + public final ArrayTableContext arrayTable() throws RecognitionException { + ArrayTableContext _localctx = new ArrayTableContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_arrayTable); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(219); + match(DOUBLE_L_BRACKET); + setState(220); + key(); + setState(221); + match(DOUBLE_R_BRACKET); + setState(231); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,29,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(225); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,28,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(222); + commentOrNl(); + } + } + } + setState(227); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,28,_ctx); + } + setState(228); + expression(); + } + } + } + setState(233); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,29,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u0001 \u00eb\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ + "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ + "\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+ + "\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+ + "\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0001\u0000\u0003\u0000"+ + ",\b\u0000\u0001\u0000\u0001\u0000\u0003\u00000\b\u0000\u0005\u00002\b"+ + "\u0000\n\u0000\f\u00005\t\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001"+ + "\u0001\u0003\u0001;\b\u0001\u0001\u0001\u0001\u0001\u0003\u0001?\b\u0001"+ + "\u0001\u0001\u0003\u0001B\b\u0001\u0001\u0002\u0001\u0002\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0003\u0004"+ + "L\b\u0004\u0001\u0005\u0001\u0005\u0003\u0005P\b\u0005\u0001\u0006\u0001"+ + "\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\b\u0004\bY\b\b\u000b"+ + "\b\f\bZ\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0003"+ + "\td\b\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001"+ + "\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f"+ + "\u0003\u000fs\b\u000f\u0001\u0010\u0001\u0010\u0005\u0010w\b\u0010\n\u0010"+ + "\f\u0010z\t\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0005\u0010\u007f"+ + "\b\u0010\n\u0010\f\u0010\u0082\t\u0010\u0001\u0010\u0001\u0010\u0001\u0010"+ + "\u0005\u0010\u0087\b\u0010\n\u0010\f\u0010\u008a\t\u0010\u0001\u0010\u0001"+ + "\u0010\u0003\u0010\u008e\b\u0010\u0005\u0010\u0090\b\u0010\n\u0010\f\u0010"+ + "\u0093\t\u0010\u0001\u0010\u0005\u0010\u0096\b\u0010\n\u0010\f\u0010\u0099"+ + "\t\u0010\u0001\u0010\u0001\u0010\u0003\u0010\u009d\b\u0010\u0001\u0011"+ + "\u0001\u0011\u0003\u0011\u00a1\b\u0011\u0001\u0012\u0001\u0012\u0001\u0012"+ + "\u0001\u0012\u0005\u0012\u00a7\b\u0012\n\u0012\f\u0012\u00aa\t\u0012\u0001"+ + "\u0012\u0005\u0012\u00ad\b\u0012\n\u0012\f\u0012\u00b0\t\u0012\u0001\u0013"+ + "\u0001\u0013\u0005\u0013\u00b4\b\u0013\n\u0013\f\u0013\u00b7\t\u0013\u0001"+ + "\u0013\u0001\u0013\u0001\u0013\u0005\u0013\u00bc\b\u0013\n\u0013\f\u0013"+ + "\u00bf\t\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0005\u0013\u00c4\b"+ + "\u0013\n\u0013\f\u0013\u00c7\t\u0013\u0001\u0013\u0001\u0013\u0003\u0013"+ + "\u00cb\b\u0013\u0005\u0013\u00cd\b\u0013\n\u0013\f\u0013\u00d0\t\u0013"+ + "\u0001\u0013\u0005\u0013\u00d3\b\u0013\n\u0013\f\u0013\u00d6\t\u0013\u0001"+ + "\u0013\u0001\u0013\u0003\u0013\u00da\b\u0013\u0001\u0014\u0001\u0014\u0001"+ + "\u0014\u0001\u0014\u0005\u0014\u00e0\b\u0014\n\u0014\f\u0014\u00e3\t\u0014"+ + "\u0001\u0014\u0005\u0014\u00e6\b\u0014\n\u0014\f\u0014\u00e9\t\u0014\u0001"+ + "\u0014\u0000\u0000\u0015\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012"+ + "\u0014\u0016\u0018\u001a\u001c\u001e \"$&(\u0000\u0005\u0001\u0000\u000b"+ + "\f\u0002\u0000\u000b\f\u0011\u0012\u0001\u0000\u0016\u0019\u0001\u0000"+ + "\u0013\u0015\u0001\u0000\u001a\u001d\u00f9\u0000+\u0001\u0000\u0000\u0000"+ + "\u0002A\u0001\u0000\u0000\u0000\u0004C\u0001\u0000\u0000\u0000\u0006E"+ + "\u0001\u0000\u0000\u0000\bK\u0001\u0000\u0000\u0000\nO\u0001\u0000\u0000"+ + "\u0000\fQ\u0001\u0000\u0000\u0000\u000eS\u0001\u0000\u0000\u0000\u0010"+ + "U\u0001\u0000\u0000\u0000\u0012c\u0001\u0000\u0000\u0000\u0014e\u0001"+ + "\u0000\u0000\u0000\u0016g\u0001\u0000\u0000\u0000\u0018i\u0001\u0000\u0000"+ + "\u0000\u001ak\u0001\u0000\u0000\u0000\u001cm\u0001\u0000\u0000\u0000\u001e"+ + "r\u0001\u0000\u0000\u0000 \u009c\u0001\u0000\u0000\u0000\"\u00a0\u0001"+ + "\u0000\u0000\u0000$\u00a2\u0001\u0000\u0000\u0000&\u00d9\u0001\u0000\u0000"+ + "\u0000(\u00db\u0001\u0000\u0000\u0000*,\u0003\u0002\u0001\u0000+*\u0001"+ + "\u0000\u0000\u0000+,\u0001\u0000\u0000\u0000,3\u0001\u0000\u0000\u0000"+ + "-/\u0005\u0002\u0000\u0000.0\u0003\u0002\u0001\u0000/.\u0001\u0000\u0000"+ + "\u0000/0\u0001\u0000\u0000\u000002\u0001\u0000\u0000\u00001-\u0001\u0000"+ + "\u0000\u000025\u0001\u0000\u0000\u000031\u0001\u0000\u0000\u000034\u0001"+ + "\u0000\u0000\u000046\u0001\u0000\u0000\u000053\u0001\u0000\u0000\u0000"+ + "67\u0005\u0000\u0000\u00017\u0001\u0001\u0000\u0000\u00008:\u0003\u0006"+ + "\u0003\u00009;\u0003\u0004\u0002\u0000:9\u0001\u0000\u0000\u0000:;\u0001"+ + "\u0000\u0000\u0000;B\u0001\u0000\u0000\u0000<>\u0003\"\u0011\u0000=?\u0003"+ + "\u0004\u0002\u0000>=\u0001\u0000\u0000\u0000>?\u0001\u0000\u0000\u0000"+ + "?B\u0001\u0000\u0000\u0000@B\u0003\u0004\u0002\u0000A8\u0001\u0000\u0000"+ + "\u0000A<\u0001\u0000\u0000\u0000A@\u0001\u0000\u0000\u0000B\u0003\u0001"+ + "\u0000\u0000\u0000CD\u0005\u0003\u0000\u0000D\u0005\u0001\u0000\u0000"+ + "\u0000EF\u0003\b\u0004\u0000FG\u0005\b\u0000\u0000GH\u0003\u0012\t\u0000"+ + "H\u0007\u0001\u0000\u0000\u0000IL\u0003\n\u0005\u0000JL\u0003\u0010\b"+ + "\u0000KI\u0001\u0000\u0000\u0000KJ\u0001\u0000\u0000\u0000L\t\u0001\u0000"+ + "\u0000\u0000MP\u0003\u000e\u0007\u0000NP\u0003\f\u0006\u0000OM\u0001\u0000"+ + "\u0000\u0000ON\u0001\u0000\u0000\u0000P\u000b\u0001\u0000\u0000\u0000"+ + "QR\u0005\r\u0000\u0000R\r\u0001\u0000\u0000\u0000ST\u0007\u0000\u0000"+ + "\u0000T\u000f\u0001\u0000\u0000\u0000UX\u0003\n\u0005\u0000VW\u0005\t"+ + "\u0000\u0000WY\u0003\n\u0005\u0000XV\u0001\u0000\u0000\u0000YZ\u0001\u0000"+ + "\u0000\u0000ZX\u0001\u0000\u0000\u0000Z[\u0001\u0000\u0000\u0000[\u0011"+ + "\u0001\u0000\u0000\u0000\\d\u0003\u0014\n\u0000]d\u0003\u0016\u000b\u0000"+ + "^d\u0003\u0018\f\u0000_d\u0003\u001a\r\u0000`d\u0003\u001c\u000e\u0000"+ + "ad\u0003 \u0010\u0000bd\u0003&\u0013\u0000c\\\u0001\u0000\u0000\u0000"+ + "c]\u0001\u0000\u0000\u0000c^\u0001\u0000\u0000\u0000c_\u0001\u0000\u0000"+ + "\u0000c`\u0001\u0000\u0000\u0000ca\u0001\u0000\u0000\u0000cb\u0001\u0000"+ + "\u0000\u0000d\u0013\u0001\u0000\u0000\u0000ef\u0007\u0001\u0000\u0000"+ + "f\u0015\u0001\u0000\u0000\u0000gh\u0007\u0002\u0000\u0000h\u0017\u0001"+ + "\u0000\u0000\u0000ij\u0007\u0003\u0000\u0000j\u0019\u0001\u0000\u0000"+ + "\u0000kl\u0005\u0010\u0000\u0000l\u001b\u0001\u0000\u0000\u0000mn\u0007"+ + "\u0004\u0000\u0000n\u001d\u0001\u0000\u0000\u0000op\u0005\u0003\u0000"+ + "\u0000ps\u0005\u0002\u0000\u0000qs\u0005\u0002\u0000\u0000ro\u0001\u0000"+ + "\u0000\u0000rq\u0001\u0000\u0000\u0000s\u001f\u0001\u0000\u0000\u0000"+ + "tx\u0005\u0004\u0000\u0000uw\u0003\u001e\u000f\u0000vu\u0001\u0000\u0000"+ + "\u0000wz\u0001\u0000\u0000\u0000xv\u0001\u0000\u0000\u0000xy\u0001\u0000"+ + "\u0000\u0000y{\u0001\u0000\u0000\u0000zx\u0001\u0000\u0000\u0000{\u009d"+ + "\u0005\u0006\u0000\u0000|\u0080\u0005\u0004\u0000\u0000}\u007f\u0003\u001e"+ + "\u000f\u0000~}\u0001\u0000\u0000\u0000\u007f\u0082\u0001\u0000\u0000\u0000"+ + "\u0080~\u0001\u0000\u0000\u0000\u0080\u0081\u0001\u0000\u0000\u0000\u0081"+ + "\u0083\u0001\u0000\u0000\u0000\u0082\u0080\u0001\u0000\u0000\u0000\u0083"+ + "\u0091\u0003\u0012\t\u0000\u0084\u0088\u0005\n\u0000\u0000\u0085\u0087"+ + "\u0003\u001e\u000f\u0000\u0086\u0085\u0001\u0000\u0000\u0000\u0087\u008a"+ + "\u0001\u0000\u0000\u0000\u0088\u0086\u0001\u0000\u0000\u0000\u0088\u0089"+ + "\u0001\u0000\u0000\u0000\u0089\u008b\u0001\u0000\u0000\u0000\u008a\u0088"+ + "\u0001\u0000\u0000\u0000\u008b\u008d\u0003\u0012\t\u0000\u008c\u008e\u0005"+ + "\n\u0000\u0000\u008d\u008c\u0001\u0000\u0000\u0000\u008d\u008e\u0001\u0000"+ + "\u0000\u0000\u008e\u0090\u0001\u0000\u0000\u0000\u008f\u0084\u0001\u0000"+ + "\u0000\u0000\u0090\u0093\u0001\u0000\u0000\u0000\u0091\u008f\u0001\u0000"+ + "\u0000\u0000\u0091\u0092\u0001\u0000\u0000\u0000\u0092\u0097\u0001\u0000"+ + "\u0000\u0000\u0093\u0091\u0001\u0000\u0000\u0000\u0094\u0096\u0003\u001e"+ + "\u000f\u0000\u0095\u0094\u0001\u0000\u0000\u0000\u0096\u0099\u0001\u0000"+ + "\u0000\u0000\u0097\u0095\u0001\u0000\u0000\u0000\u0097\u0098\u0001\u0000"+ + "\u0000\u0000\u0098\u009a\u0001\u0000\u0000\u0000\u0099\u0097\u0001\u0000"+ + "\u0000\u0000\u009a\u009b\u0005\u0006\u0000\u0000\u009b\u009d\u0001\u0000"+ + "\u0000\u0000\u009ct\u0001\u0000\u0000\u0000\u009c|\u0001\u0000\u0000\u0000"+ + "\u009d!\u0001\u0000\u0000\u0000\u009e\u00a1\u0003$\u0012\u0000\u009f\u00a1"+ + "\u0003(\u0014\u0000\u00a0\u009e\u0001\u0000\u0000\u0000\u00a0\u009f\u0001"+ + "\u0000\u0000\u0000\u00a1#\u0001\u0000\u0000\u0000\u00a2\u00a3\u0005\u0004"+ + "\u0000\u0000\u00a3\u00a4\u0003\b\u0004\u0000\u00a4\u00ae\u0005\u0006\u0000"+ + "\u0000\u00a5\u00a7\u0003\u001e\u000f\u0000\u00a6\u00a5\u0001\u0000\u0000"+ + "\u0000\u00a7\u00aa\u0001\u0000\u0000\u0000\u00a8\u00a6\u0001\u0000\u0000"+ + "\u0000\u00a8\u00a9\u0001\u0000\u0000\u0000\u00a9\u00ab\u0001\u0000\u0000"+ + "\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00ab\u00ad\u0003\u0002\u0001"+ + "\u0000\u00ac\u00a8\u0001\u0000\u0000\u0000\u00ad\u00b0\u0001\u0000\u0000"+ + "\u0000\u00ae\u00ac\u0001\u0000\u0000\u0000\u00ae\u00af\u0001\u0000\u0000"+ + "\u0000\u00af%\u0001\u0000\u0000\u0000\u00b0\u00ae\u0001\u0000\u0000\u0000"+ + "\u00b1\u00b5\u0005\u000f\u0000\u0000\u00b2\u00b4\u0003\u001e\u000f\u0000"+ + "\u00b3\u00b2\u0001\u0000\u0000\u0000\u00b4\u00b7\u0001\u0000\u0000\u0000"+ + "\u00b5\u00b3\u0001\u0000\u0000\u0000\u00b5\u00b6\u0001\u0000\u0000\u0000"+ + "\u00b6\u00b8\u0001\u0000\u0000\u0000\u00b7\u00b5\u0001\u0000\u0000\u0000"+ + "\u00b8\u00da\u0005\u001f\u0000\u0000\u00b9\u00bd\u0005\u000f\u0000\u0000"+ + "\u00ba\u00bc\u0003\u001e\u000f\u0000\u00bb\u00ba\u0001\u0000\u0000\u0000"+ + "\u00bc\u00bf\u0001\u0000\u0000\u0000\u00bd\u00bb\u0001\u0000\u0000\u0000"+ + "\u00bd\u00be\u0001\u0000\u0000\u0000\u00be\u00c0\u0001\u0000\u0000\u0000"+ + "\u00bf\u00bd\u0001\u0000\u0000\u0000\u00c0\u00ce\u0003\u0006\u0003\u0000"+ + "\u00c1\u00c5\u0005\n\u0000\u0000\u00c2\u00c4\u0003\u001e\u000f\u0000\u00c3"+ + "\u00c2\u0001\u0000\u0000\u0000\u00c4\u00c7\u0001\u0000\u0000\u0000\u00c5"+ + "\u00c3\u0001\u0000\u0000\u0000\u00c5\u00c6\u0001\u0000\u0000\u0000\u00c6"+ + "\u00c8\u0001\u0000\u0000\u0000\u00c7\u00c5\u0001\u0000\u0000\u0000\u00c8"+ + "\u00ca\u0003\u0006\u0003\u0000\u00c9\u00cb\u0005\n\u0000\u0000\u00ca\u00c9"+ + "\u0001\u0000\u0000\u0000\u00ca\u00cb\u0001\u0000\u0000\u0000\u00cb\u00cd"+ + "\u0001\u0000\u0000\u0000\u00cc\u00c1\u0001\u0000\u0000\u0000\u00cd\u00d0"+ + "\u0001\u0000\u0000\u0000\u00ce\u00cc\u0001\u0000\u0000\u0000\u00ce\u00cf"+ + "\u0001\u0000\u0000\u0000\u00cf\u00d4\u0001\u0000\u0000\u0000\u00d0\u00ce"+ + "\u0001\u0000\u0000\u0000\u00d1\u00d3\u0003\u001e\u000f\u0000\u00d2\u00d1"+ + "\u0001\u0000\u0000\u0000\u00d3\u00d6\u0001\u0000\u0000\u0000\u00d4\u00d2"+ + "\u0001\u0000\u0000\u0000\u00d4\u00d5\u0001\u0000\u0000\u0000\u00d5\u00d7"+ + "\u0001\u0000\u0000\u0000\u00d6\u00d4\u0001\u0000\u0000\u0000\u00d7\u00d8"+ + "\u0005\u001f\u0000\u0000\u00d8\u00da\u0001\u0000\u0000\u0000\u00d9\u00b1"+ + "\u0001\u0000\u0000\u0000\u00d9\u00b9\u0001\u0000\u0000\u0000\u00da\'\u0001"+ + "\u0000\u0000\u0000\u00db\u00dc\u0005\u0005\u0000\u0000\u00dc\u00dd\u0003"+ + "\b\u0004\u0000\u00dd\u00e7\u0005\u0007\u0000\u0000\u00de\u00e0\u0003\u001e"+ + "\u000f\u0000\u00df\u00de\u0001\u0000\u0000\u0000\u00e0\u00e3\u0001\u0000"+ + "\u0000\u0000\u00e1\u00df\u0001\u0000\u0000\u0000\u00e1\u00e2\u0001\u0000"+ + "\u0000\u0000\u00e2\u00e4\u0001\u0000\u0000\u0000\u00e3\u00e1\u0001\u0000"+ + "\u0000\u0000\u00e4\u00e6\u0003\u0002\u0001\u0000\u00e5\u00e1\u0001\u0000"+ + "\u0000\u0000\u00e6\u00e9\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001\u0000"+ + "\u0000\u0000\u00e7\u00e8\u0001\u0000\u0000\u0000\u00e8)\u0001\u0000\u0000"+ + "\u0000\u00e9\u00e7\u0001\u0000\u0000\u0000\u001e+/3:>AKOZcrx\u0080\u0088"+ + "\u008d\u0091\u0097\u009c\u00a0\u00a8\u00ae\u00b5\u00bd\u00c5\u00ca\u00ce"+ + "\u00d4\u00d9\u00e1\u00e7"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.tokens b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.tokens new file mode 100644 index 00000000000..080a49ecbae --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.tokens @@ -0,0 +1,41 @@ +WS=1 +NL=2 +COMMENT=3 +L_BRACKET=4 +DOUBLE_L_BRACKET=5 +R_BRACKET=6 +DOUBLE_R_BRACKET=7 +EQUALS=8 +DOT=9 +COMMA=10 +BASIC_STRING=11 +LITERAL_STRING=12 +UNQUOTED_KEY=13 +VALUE_WS=14 +L_BRACE=15 +BOOLEAN=16 +ML_BASIC_STRING=17 +ML_LITERAL_STRING=18 +FLOAT=19 +INF=20 +NAN=21 +DEC_INT=22 +HEX_INT=23 +OCT_INT=24 +BIN_INT=25 +OFFSET_DATE_TIME=26 +LOCAL_DATE_TIME=27 +LOCAL_DATE=28 +LOCAL_TIME=29 +INLINE_TABLE_WS=30 +R_BRACE=31 +ARRAY_WS=32 +'['=4 +'[['=5 +']'=6 +']]'=7 +'='=8 +'.'=9 +','=10 +'{'=15 +'}'=31 diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java new file mode 100644 index 00000000000..ca57f4cc77c --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java @@ -0,0 +1,307 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link TomlParserListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class TomlParserBaseListener implements TomlParserListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDocument(TomlParser.DocumentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDocument(TomlParser.DocumentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExpression(TomlParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExpression(TomlParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterComment(TomlParser.CommentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitComment(TomlParser.CommentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterKeyValue(TomlParser.KeyValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitKeyValue(TomlParser.KeyValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterKey(TomlParser.KeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitKey(TomlParser.KeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSimpleKey(TomlParser.SimpleKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSimpleKey(TomlParser.SimpleKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnquotedKey(TomlParser.UnquotedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnquotedKey(TomlParser.UnquotedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterQuotedKey(TomlParser.QuotedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitQuotedKey(TomlParser.QuotedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDottedKey(TomlParser.DottedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDottedKey(TomlParser.DottedKeyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterValue(TomlParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitValue(TomlParser.ValueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterString(TomlParser.StringContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitString(TomlParser.StringContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInteger(TomlParser.IntegerContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInteger(TomlParser.IntegerContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFloatingPoint(TomlParser.FloatingPointContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFloatingPoint(TomlParser.FloatingPointContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBool(TomlParser.BoolContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBool(TomlParser.BoolContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDateTime(TomlParser.DateTimeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDateTime(TomlParser.DateTimeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCommentOrNl(TomlParser.CommentOrNlContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCommentOrNl(TomlParser.CommentOrNlContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArray(TomlParser.ArrayContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArray(TomlParser.ArrayContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTable(TomlParser.TableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTable(TomlParser.TableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStandardTable(TomlParser.StandardTableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStandardTable(TomlParser.StandardTableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInlineTable(TomlParser.InlineTableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInlineTable(TomlParser.InlineTableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArrayTable(TomlParser.ArrayTableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArrayTable(TomlParser.ArrayTableContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java new file mode 100644 index 00000000000..92405461133 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java @@ -0,0 +1,177 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link TomlParserVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class TomlParserBaseVisitor extends AbstractParseTreeVisitor implements TomlParserVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDocument(TomlParser.DocumentContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression(TomlParser.ExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitComment(TomlParser.CommentContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitKeyValue(TomlParser.KeyValueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitKey(TomlParser.KeyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSimpleKey(TomlParser.SimpleKeyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnquotedKey(TomlParser.UnquotedKeyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitQuotedKey(TomlParser.QuotedKeyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDottedKey(TomlParser.DottedKeyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitValue(TomlParser.ValueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitString(TomlParser.StringContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitInteger(TomlParser.IntegerContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFloatingPoint(TomlParser.FloatingPointContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBool(TomlParser.BoolContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDateTime(TomlParser.DateTimeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCommentOrNl(TomlParser.CommentOrNlContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArray(TomlParser.ArrayContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTable(TomlParser.TableContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStandardTable(TomlParser.StandardTableContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitInlineTable(TomlParser.InlineTableContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArrayTable(TomlParser.ArrayTableContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java new file mode 100644 index 00000000000..06e33c2eb68 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java @@ -0,0 +1,235 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link TomlParser}. + */ +public interface TomlParserListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link TomlParser#document}. + * @param ctx the parse tree + */ + void enterDocument(TomlParser.DocumentContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#document}. + * @param ctx the parse tree + */ + void exitDocument(TomlParser.DocumentContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(TomlParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(TomlParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#comment}. + * @param ctx the parse tree + */ + void enterComment(TomlParser.CommentContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#comment}. + * @param ctx the parse tree + */ + void exitComment(TomlParser.CommentContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#keyValue}. + * @param ctx the parse tree + */ + void enterKeyValue(TomlParser.KeyValueContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#keyValue}. + * @param ctx the parse tree + */ + void exitKeyValue(TomlParser.KeyValueContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#key}. + * @param ctx the parse tree + */ + void enterKey(TomlParser.KeyContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#key}. + * @param ctx the parse tree + */ + void exitKey(TomlParser.KeyContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#simpleKey}. + * @param ctx the parse tree + */ + void enterSimpleKey(TomlParser.SimpleKeyContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#simpleKey}. + * @param ctx the parse tree + */ + void exitSimpleKey(TomlParser.SimpleKeyContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#unquotedKey}. + * @param ctx the parse tree + */ + void enterUnquotedKey(TomlParser.UnquotedKeyContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#unquotedKey}. + * @param ctx the parse tree + */ + void exitUnquotedKey(TomlParser.UnquotedKeyContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#quotedKey}. + * @param ctx the parse tree + */ + void enterQuotedKey(TomlParser.QuotedKeyContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#quotedKey}. + * @param ctx the parse tree + */ + void exitQuotedKey(TomlParser.QuotedKeyContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#dottedKey}. + * @param ctx the parse tree + */ + void enterDottedKey(TomlParser.DottedKeyContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#dottedKey}. + * @param ctx the parse tree + */ + void exitDottedKey(TomlParser.DottedKeyContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#value}. + * @param ctx the parse tree + */ + void enterValue(TomlParser.ValueContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#value}. + * @param ctx the parse tree + */ + void exitValue(TomlParser.ValueContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#string}. + * @param ctx the parse tree + */ + void enterString(TomlParser.StringContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#string}. + * @param ctx the parse tree + */ + void exitString(TomlParser.StringContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#integer}. + * @param ctx the parse tree + */ + void enterInteger(TomlParser.IntegerContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#integer}. + * @param ctx the parse tree + */ + void exitInteger(TomlParser.IntegerContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#floatingPoint}. + * @param ctx the parse tree + */ + void enterFloatingPoint(TomlParser.FloatingPointContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#floatingPoint}. + * @param ctx the parse tree + */ + void exitFloatingPoint(TomlParser.FloatingPointContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#bool}. + * @param ctx the parse tree + */ + void enterBool(TomlParser.BoolContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#bool}. + * @param ctx the parse tree + */ + void exitBool(TomlParser.BoolContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#dateTime}. + * @param ctx the parse tree + */ + void enterDateTime(TomlParser.DateTimeContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#dateTime}. + * @param ctx the parse tree + */ + void exitDateTime(TomlParser.DateTimeContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#commentOrNl}. + * @param ctx the parse tree + */ + void enterCommentOrNl(TomlParser.CommentOrNlContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#commentOrNl}. + * @param ctx the parse tree + */ + void exitCommentOrNl(TomlParser.CommentOrNlContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#array}. + * @param ctx the parse tree + */ + void enterArray(TomlParser.ArrayContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#array}. + * @param ctx the parse tree + */ + void exitArray(TomlParser.ArrayContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#table}. + * @param ctx the parse tree + */ + void enterTable(TomlParser.TableContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#table}. + * @param ctx the parse tree + */ + void exitTable(TomlParser.TableContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#standardTable}. + * @param ctx the parse tree + */ + void enterStandardTable(TomlParser.StandardTableContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#standardTable}. + * @param ctx the parse tree + */ + void exitStandardTable(TomlParser.StandardTableContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#inlineTable}. + * @param ctx the parse tree + */ + void enterInlineTable(TomlParser.InlineTableContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#inlineTable}. + * @param ctx the parse tree + */ + void exitInlineTable(TomlParser.InlineTableContext ctx); + /** + * Enter a parse tree produced by {@link TomlParser#arrayTable}. + * @param ctx the parse tree + */ + void enterArrayTable(TomlParser.ArrayTableContext ctx); + /** + * Exit a parse tree produced by {@link TomlParser#arrayTable}. + * @param ctx the parse tree + */ + void exitArrayTable(TomlParser.ArrayTableContext ctx); +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java new file mode 100644 index 00000000000..1c6547fa80b --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java @@ -0,0 +1,154 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated from java-escape by ANTLR 4.11.1 +package org.openrewrite.toml.internal.grammar; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link TomlParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface TomlParserVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link TomlParser#document}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDocument(TomlParser.DocumentContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(TomlParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#comment}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitComment(TomlParser.CommentContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#keyValue}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitKeyValue(TomlParser.KeyValueContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#key}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitKey(TomlParser.KeyContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#simpleKey}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimpleKey(TomlParser.SimpleKeyContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#unquotedKey}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnquotedKey(TomlParser.UnquotedKeyContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#quotedKey}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitQuotedKey(TomlParser.QuotedKeyContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#dottedKey}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDottedKey(TomlParser.DottedKeyContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#value}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValue(TomlParser.ValueContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#string}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitString(TomlParser.StringContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#integer}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInteger(TomlParser.IntegerContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#floatingPoint}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFloatingPoint(TomlParser.FloatingPointContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#bool}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBool(TomlParser.BoolContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#dateTime}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDateTime(TomlParser.DateTimeContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#commentOrNl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCommentOrNl(TomlParser.CommentOrNlContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#array}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArray(TomlParser.ArrayContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#table}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTable(TomlParser.TableContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#standardTable}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStandardTable(TomlParser.StandardTableContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#inlineTable}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInlineTable(TomlParser.InlineTableContext ctx); + /** + * Visit a parse tree produced by {@link TomlParser#arrayTable}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArrayTable(TomlParser.ArrayTableContext ctx); +} \ No newline at end of file diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/package-info.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/package-info.java new file mode 100644 index 00000000000..0dc7d998012 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +@NonNullFields +package org.openrewrite.toml.internal; + +import org.jspecify.annotations.NullMarked; +import org.openrewrite.internal.lang.NonNullFields; diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/marker/ArrayTable.java b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/ArrayTable.java new file mode 100644 index 00000000000..d64194c1f75 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/ArrayTable.java @@ -0,0 +1,28 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.marker; + +import lombok.Value; +import lombok.With; +import org.openrewrite.marker.Marker; + +import java.util.UUID; + +@Value +@With +public class ArrayTable implements Marker { + UUID id; +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/marker/InlineTable.java b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/InlineTable.java new file mode 100644 index 00000000000..c444fed4f1e --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/InlineTable.java @@ -0,0 +1,28 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.marker; + +import lombok.Value; +import lombok.With; +import org.openrewrite.marker.Marker; + +import java.util.UUID; + +@Value +@With +public class InlineTable implements Marker { + UUID id; +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/marker/package-info.java b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/package-info.java new file mode 100644 index 00000000000..f660c6bdfc4 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/marker/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +@NonNullFields +package org.openrewrite.toml.marker; + +import org.jspecify.annotations.NullMarked; +import org.openrewrite.internal.lang.NonNullFields; diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/package-info.java b/rewrite-toml/src/main/java/org/openrewrite/toml/package-info.java new file mode 100644 index 00000000000..17c795873d3 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +@NonNullFields +package org.openrewrite.toml; + +import org.jspecify.annotations.NullMarked; +import org.openrewrite.internal.lang.NonNullFields; diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Comment.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Comment.java new file mode 100644 index 00000000000..64d0f5afc64 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Comment.java @@ -0,0 +1,28 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +import lombok.Value; +import lombok.With; +import org.openrewrite.marker.Markers; + +@Value +@With +public class Comment { + String text; + String suffix; + Markers markers; +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Space.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Space.java new file mode 100644 index 00000000000..c79702a444d --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Space.java @@ -0,0 +1,270 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import lombok.EqualsAndHashCode; +import org.jspecify.annotations.Nullable; +import org.openrewrite.marker.Markers; + +import java.util.*; + +import static java.util.Collections.emptyList; + +/** + * Wherever whitespace can occur in JSON, so can comments (at least block style comments). + * So whitespace and comments are like peanut butter and jelly. + */ +@EqualsAndHashCode +@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@ref") +public class Space { + public static final Space EMPTY = new Space("", emptyList()); + public static final Space SINGLE_SPACE = new Space(" ", emptyList()); + + private final List comments; + + @Nullable + private final String whitespace; + + /* + * Most occurrences of spaces will have no comments or markers and will be repeated frequently throughout a source file. + * e.g.: a single space between keywords, or the common indentation of every line in a block. + * So use flyweights to avoid storing many instances of functionally identical spaces + */ + private static final Map flyweights = Collections.synchronizedMap(new WeakHashMap<>()); + + private Space(@Nullable String whitespace, List comments) { + this.comments = comments; + this.whitespace = whitespace == null || whitespace.isEmpty() ? null : whitespace; + } + + @JsonCreator + public static Space build(@Nullable String whitespace, List comments) { + if (comments.isEmpty()) { + if (whitespace == null || whitespace.isEmpty()) { + return Space.EMPTY; + } else if (whitespace.length() <= 100) { + //noinspection StringOperationCanBeSimplified + return flyweights.computeIfAbsent(whitespace, k -> new Space(new String(whitespace), comments)); + } + } + return new Space(whitespace, comments); + } + + public String getIndent() { + if (!comments.isEmpty()) { + return getWhitespaceIndent(comments.get(comments.size() - 1).getSuffix()); + } + return getWhitespaceIndent(whitespace); + } + + public String getLastWhitespace() { + if (!comments.isEmpty()) { + return comments.get(comments.size() - 1).getSuffix(); + } + return whitespace == null ? "" : whitespace; + } + + private String getWhitespaceIndent(@Nullable String whitespace) { + if (whitespace == null) { + return ""; + } + int lastNewline = whitespace.lastIndexOf('\n'); + if (lastNewline >= 0) { + return whitespace.substring(lastNewline + 1); + } else if (lastNewline == whitespace.length() - 1) { + return ""; + } + return whitespace; + } + + public List getComments() { + return comments; + } + + public String getWhitespace() { + return whitespace == null ? "" : whitespace; + } + + public boolean hasComment(String comment) { + for (Comment c : comments) { + if (c.getText().equals(comment)) { + return true; + } + } + return false; + } + + public Space withComments(List comments) { + if (comments == this.comments) { + return this; + } + if (comments.isEmpty() && (whitespace == null || whitespace.isEmpty())) { + return Space.EMPTY; + } + return build(whitespace, comments); + } + + public Space withWhitespace(String whitespace) { + if (comments.isEmpty() && whitespace.isEmpty()) { + return Space.EMPTY; + } + if ((whitespace.isEmpty() && this.whitespace == null) || whitespace.equals(this.whitespace)) { + return this; + } + return build(whitespace, comments); + } + + public boolean isEmpty() { + return this == EMPTY; + } + + public static Space firstPrefix(@Nullable List trees) { + return trees == null || trees.isEmpty() ? Space.EMPTY : trees.iterator().next().getPrefix(); + } + + public static Space format(String formatting) { + return format(formatting, 0, formatting.length()); + } + + public static Space format(String formatting, int beginIndex, int toIndex) { + if (beginIndex == toIndex) { + return Space.EMPTY; + } else if (toIndex == beginIndex + 1 && ' ' == formatting.charAt(beginIndex)) { + return Space.SINGLE_SPACE; + } else { + rangeCheck(formatting.length(), beginIndex, toIndex); + } + + StringBuilder prefix = new StringBuilder(); + StringBuilder comment = new StringBuilder(); + List comments = new ArrayList<>(1); + + boolean inSingleLineComment = false; + + for (int i = beginIndex; i < toIndex; i++) { + char c = formatting.charAt(i); + switch (c) { + case '#': + if (inSingleLineComment) { + comment.append(c); + } else { + inSingleLineComment = true; + comment.setLength(0); + } + break; + case '\r': + case '\n': + if (inSingleLineComment) { + inSingleLineComment = false; + comments.add(new Comment(comment.toString(), prefix.toString(), Markers.EMPTY)); + prefix.setLength(0); + comment.setLength(0); + prefix.append(c); + } else { + prefix.append(c); + } + break; + default: + if (inSingleLineComment) { + comment.append(c); + } else { + prefix.append(c); + } + } + } + // If a file ends with a single-line comment there may be no terminating newline + if (comment.length() > 0) { + comments.add(new Comment(comment.toString(), prefix.toString(), Markers.EMPTY)); + prefix.setLength(0); + } + + // Shift the whitespace on each comment forward to be a suffix of the comment before it, and the + // whitespace on the first comment to be the whitespace of the tree element. The remaining prefix is the suffix + // of the last comment. + String whitespace = prefix.toString(); + if (!comments.isEmpty()) { + for (int i = comments.size() - 1; i >= 0; i--) { + Comment c = comments.get(i); + String next = c.getSuffix(); + comments.set(i, c.withSuffix(whitespace)); + whitespace = next; + } + } + + return build(whitespace, comments); + } + + static void rangeCheck(int arrayLength, int fromIndex, int toIndex) { + if (fromIndex > toIndex) { + throw new IllegalArgumentException( + "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); + } + if (fromIndex < 0) { + throw new StringIndexOutOfBoundsException(fromIndex); + } + if (toIndex > arrayLength) { + throw new StringIndexOutOfBoundsException(toIndex); + } + } + + public static List formatFirstPrefix(List trees, Space prefix) { + if (!trees.isEmpty() && !trees.get(0).getPrefix().equals(prefix)) { + List formattedTrees = new ArrayList<>(trees); + formattedTrees.set(0, formattedTrees.get(0).withPrefix(prefix)); + return formattedTrees; + } + + return trees; + } + + private static final String[] spaces = { + "·₁", "·₂", "·₃", "·₄", "·₅", "·₆", "·₇", "·₈", "·₉", "·₊" + }; + + private static final String[] tabs = { + "-₁", "-₂", "-₃", "-₄", "-₅", "-₆", "-₇", "-₈", "-₉", "-₊" + }; + + @Override + public String toString() { + StringBuilder printedWs = new StringBuilder(); + int lastNewline = 0; + if (whitespace != null) { + char[] charArray = whitespace.toCharArray(); + for (int i = 0; i < charArray.length; i++) { + char c = charArray[i]; + if (c == '\n') { + printedWs.append("\\n"); + lastNewline = i + 1; + } else if (c == '\r') { + printedWs.append("\\r"); + lastNewline = i + 1; + } else if (c == ' ') { + printedWs.append(spaces[(i - lastNewline) % 10]); + } else if (c == '\t') { + printedWs.append(tabs[(i - lastNewline) % 10]); + } + } + } + + return "Space(" + + "comments=<" + (comments.size() == 1 ? "1 comment" : comments.size() + " comments") + + ">, whitespace='" + printedWs + "')"; + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java new file mode 100644 index 00000000000..b2852ad40b0 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java @@ -0,0 +1,358 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +import lombok.*; +import lombok.experimental.NonFinal; +import org.openrewrite.*; +import org.openrewrite.internal.lang.Nullable; +import org.openrewrite.marker.Markers; +import org.openrewrite.toml.TomlVisitor; +import org.openrewrite.toml.internal.TomlPrinter; + +import java.lang.ref.WeakReference; +import java.nio.charset.Charset; +import java.nio.file.Path; +import java.util.List; +import java.util.UUID; + +public interface Toml extends Tree { + + @SuppressWarnings("unchecked") + @Override + default R accept(TreeVisitor v, P p) { + return (R) acceptToml(v.adapt(TomlVisitor.class), p); + } + + @Nullable + default

Toml acceptToml(TomlVisitor

v, P p) { + return v.defaultValue(this, p); + } + + @Override + default

boolean isAcceptable(TreeVisitor v, P p) { + return v.isAdaptableTo(TomlVisitor.class); + } + + Space getPrefix(); + + J withPrefix(Space prefix); + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @RequiredArgsConstructor + @AllArgsConstructor(access = AccessLevel.PRIVATE) + class Array implements Toml { + @Nullable + @NonFinal + transient WeakReference padding; + + @With + @EqualsAndHashCode.Include + UUID id; + + @With + Space prefix; + + @With + Markers markers; + + List> values; + + public List getValues() { + return TomlRightPadded.getElements(values); + } + + public Array withValues(List values) { + return getPadding().withValues(TomlRightPadded.withElements(this.values, values)); + } + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitArray(this, p); + } + + public Padding getPadding() { + Padding p; + if (this.padding == null) { + p = new Padding(this); + this.padding = new WeakReference<>(p); + } else { + p = this.padding.get(); + if (p == null || p.t != this) { + p = new Padding(this); + this.padding = new WeakReference<>(p); + } + } + return p; + } + + @RequiredArgsConstructor + public static class Padding { + private final Array t; + + public List> getValues() { + return t.values; + } + + public Array withValues(List> values) { + return t.values == values ? t : new Array(t.id, t.prefix, t.markers, values); + } + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @With + class Document implements Toml, SourceFile { + @EqualsAndHashCode.Include + UUID id; + + Path sourcePath; + Space prefix; + Markers markers; + + @With(AccessLevel.PRIVATE) + String charsetName; + + boolean charsetBomMarked; + Checksum checksum; + FileAttributes fileAttributes; + + @Override + public Charset getCharset() { + return Charset.forName(charsetName); + } + + @Override + public SourceFile withCharset(Charset charset) { + return withCharsetName(charset.name()); + } + + List values; + Space eof; + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitDocument(this, p); + } + + @Override + public

TreeVisitor> printer(Cursor cursor) { + return new TomlPrinter<>(); + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @With + class Empty implements Toml { + @EqualsAndHashCode.Include + UUID id; + + Space prefix; + Markers markers; + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitEmpty(this, p); + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @With + class Identifier implements TomlKey { + @EqualsAndHashCode.Include + UUID id; + + Space prefix; + Markers markers; + String source; + String name; + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitIdentifier(this, p); + } + + @Override + public String toString() { + return "Identifier{prefix=" + prefix + ", name=" + name + "}"; + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @RequiredArgsConstructor + @AllArgsConstructor(access = AccessLevel.PRIVATE) + @With + class KeyValue implements TomlValue { + @Nullable + @NonFinal + transient WeakReference padding; + + @EqualsAndHashCode.Include + UUID id; + + Space prefix; + + Markers markers; + + TomlRightPadded key; + + public TomlKey getKey() { + return key.getElement(); + } + + public KeyValue withKey(TomlKey key) { + return getPadding().withKey(TomlRightPadded.withElement(this.key, key)); + } + + Toml value; + + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitKeyValue(this, p); + } + + public Padding getPadding() { + Padding p; + if (this.padding == null) { + p = new Padding(this); + this.padding = new WeakReference<>(p); + } else { + p = this.padding.get(); + if (p == null || p.t != this) { + p = new Padding(this); + this.padding = new WeakReference<>(p); + } + } + return p; + } + + @RequiredArgsConstructor + public static class Padding { + private final KeyValue t; + + public TomlRightPadded getKey() { + return t.key; + } + + public KeyValue withKey(TomlRightPadded key) { + return t.key == key ? t : new KeyValue(t.id, t.prefix, t.markers, key, t.value); + } + } + + @Override + public String toString() { + return "KeyValue{prefix=" + prefix + ", key=" + key.getElement() + '}'; + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @With + class Literal implements Toml { + @EqualsAndHashCode.Include + UUID id; + + Space prefix; + + Markers markers; + + TomlType.Primitive type; + + String source; + + Object value; + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitLiteral(this, p); + } + + @Override + public String toString() { + return "Literal{prefix=" + prefix + ", source=" + source + "}"; + } + } + + @Value + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @RequiredArgsConstructor + @AllArgsConstructor(access = AccessLevel.PRIVATE) + class Table implements TomlValue { + @Nullable + @NonFinal + transient WeakReference padding; + + @EqualsAndHashCode.Include + @With + UUID id; + + @With + Space prefix; + + @With + Markers markers; + + @With + TomlRightPadded name; + + List> values; + + public List getValues() { + return TomlRightPadded.getElements(values); + } + + public Table withValues(List values) { + return getPadding().withValues(TomlRightPadded.withElements(this.values, values)); + } + + @Override + public

Toml acceptToml(TomlVisitor

v, P p) { + return v.visitTable(this, p); + } + + public Table.Padding getPadding() { + Table.Padding p; + if (this.padding == null) { + p = new Table.Padding(this); + this.padding = new WeakReference<>(p); + } else { + p = this.padding.get(); + if (p == null || p.t != this) { + p = new Table.Padding(this); + this.padding = new WeakReference<>(p); + } + } + return p; + } + + @RequiredArgsConstructor + public static class Padding { + private final Table t; + + public List> getValues() { + return t.values; + } + + public Table withValues(List> values) { + return t.values == values ? t : new Table(t.id, t.prefix, t.markers, t.name, values); + } + } + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlKey.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlKey.java new file mode 100644 index 00000000000..bdf63eb1f0e --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlKey.java @@ -0,0 +1,19 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +public interface TomlKey extends Toml { +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java new file mode 100644 index 00000000000..41b1004c9f7 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java @@ -0,0 +1,118 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +import lombok.AccessLevel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.With; +import lombok.experimental.FieldDefaults; +import org.openrewrite.internal.lang.Nullable; +import org.openrewrite.marker.Markers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.function.Function; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; + +/** + * A Toml element that could have trailing space. + * + * @param + */ +@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) +@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) +@Data +public class TomlRightPadded { + @With + T element; + + @With + Space after; + + @With + Markers markers; + + public TomlRightPadded map(UnaryOperator map) { + return withElement(map.apply(element)); + } + + public static List getElements(List> ls) { + List list = new ArrayList<>(); + for (TomlRightPadded l : ls) { + T elem = l.getElement(); + list.add(elem); + } + return list; + } + + public static

List> withElements(List> before, List

elements) { + // a cheaper check for the most common case when there are no changes + if (elements.size() == before.size()) { + boolean hasChanges = false; + for (int i = 0; i < before.size(); i++) { + if (before.get(i).getElement() != elements.get(i)) { + hasChanges = true; + break; + } + } + if (!hasChanges) { + return before; + } + } + + List> after = new ArrayList<>(elements.size()); + Map> beforeById = before.stream().collect(Collectors + .toMap(j -> j.getElement().getId(), Function.identity())); + + for (P t : elements) { + if (beforeById.get(t.getId()) != null) { + TomlRightPadded

found = beforeById.get(t.getId()); + after.add(found.withElement(t)); + } else { + after.add(new TomlRightPadded<>(t, Space.EMPTY, Markers.EMPTY)); + } + } + + return after; + } + + public static TomlRightPadded build(T element) { + return new TomlRightPadded<>(element, Space.EMPTY, Markers.EMPTY); + } + + @Nullable + public static TomlRightPadded withElement(@Nullable TomlRightPadded before, @Nullable T elements) { + if (before == null) { + if (elements == null) { + return null; + } + return new TomlRightPadded<>(elements, Space.EMPTY, Markers.EMPTY); + } + if (elements == null) { + return null; + } + return before.withElement(elements); + } + + @Override + public String toString() { + return "TomlRightPadded(element=" + element.getClass().getSimpleName() + ", after=" + after + ')'; + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlType.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlType.java new file mode 100644 index 00000000000..abe678a6c1d --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlType.java @@ -0,0 +1,29 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +public interface TomlType { + enum Primitive implements TomlType { + Boolean, + Float, + Integer, + LocalDate, + LocalDateTime, + LocalTime, + OffsetDateTime, + String + } +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlValue.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlValue.java new file mode 100644 index 00000000000..767d3d382a4 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlValue.java @@ -0,0 +1,19 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml.tree; + +public interface TomlValue extends Toml { +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/package-info.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/package-info.java new file mode 100644 index 00000000000..2a3f1d8f923 --- /dev/null +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +@NonNullFields +package org.openrewrite.toml.tree; + +import org.jspecify.annotations.NullMarked; +import org.openrewrite.internal.lang.NonNullFields; diff --git a/rewrite-toml/src/test/java/org/openrewrite/toml/TomlParserTest.java b/rewrite-toml/src/test/java/org/openrewrite/toml/TomlParserTest.java new file mode 100644 index 00000000000..ecde113dc0e --- /dev/null +++ b/rewrite-toml/src/test/java/org/openrewrite/toml/TomlParserTest.java @@ -0,0 +1,341 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.toml; + +import org.junit.jupiter.api.Test; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.toml.Assertions.toml; + +class TomlParserTest implements RewriteTest { + @Test + void keyValueString() { + rewriteRun( + toml( + """ + str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." + """ + ) + ); + } + + @Test + void keyValueInteger() { + rewriteRun( + toml( + """ + int1 = +99 + int2 = 42 + int3 = 0 + int4 = -17 + int5 = 1_000 + + # hexadecimal with prefix `0x` + hex1 = 0xDEADBEEF + hex2 = 0xdeadbeef + hex3 = 0xdead_beef + # octal with prefix `0o` + oct1 = 0o01234567 + oct2 = 0o755 # useful for Unix file permissions + + # binary with prefix `0b` + bin1 = 0b11010110 + """ + ) + ); + } + + @Test + void keyValueFloat() { + rewriteRun( + toml( + """ + # fractional + flt1 = +1.0 + flt2 = 3.1415 + flt3 = -0.01 + + # exponent + flt4 = 5e+22 + flt5 = 1e06 + flt6 = -2E-2 + + # both + flt7 = 6.626e-34 + + flt8 = 224_617.445_991_228 + + # infinity + sf1 = inf # positive infinity + sf2 = +inf # positive infinity + sf3 = -inf # negative infinity + + # not a number + sf4 = nan # actual sNaN/qNaN encoding is implementation-specific + sf5 = +nan # sa + sf6 = -nan # valid, actual encoding is implementation-specific + """ + ) + ); + } + + @Test + void keyValueBool() { + rewriteRun( + toml( + """ + bool1 = true + bool2 = false + """ + ) + ); + } + + @Test + void keyValueOffsetDateTime() { + rewriteRun( + toml( + """ + odt1 = 1979-05-27T07:32:00Z + odt2 = 1979-05-27T00:32:00-07:00 + odt3 = 1979-05-27T00:32:00.999999-07:00 + odt4 = 1979-05-27 07:32:00Z + """ + ) + ); + } + + @Test + void keyValueLocalDateTime() { + rewriteRun( + toml( + """ + ldt1 = 1979-05-27T07:32:00 + ldt2 = 1979-05-27T00:32:00.999999 + """ + ) + ); + } + + @Test + void keyValueLocalDate() { + rewriteRun( + toml( + """ + ld1 = 1979-05-27 + """ + ) + ); + } + + @Test + void keyValueLocalTime() { + rewriteRun( + toml( + """ + lt1 = 07:32:00 + lt2 = 00:32:00.999999 + """ + ) + ); + } + + @Test + void keyValueArray() { + rewriteRun( + toml( + """ + integers = [ 1, 2, 3 ] + colors = [ "red", "yellow", "green" ] + nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] + nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] + string_array = [ "all", 'strings', ""\"are the same""\", '''type''' ] + + # Mixed-type arrays are allowed + numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] + contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } + ] + integers2 = [ + 1, 2, 3 + ] + + integers3 = [ + 1, + 2, # this is ok + ] + """ + ) + ); + } + + @Test + void table() { + rewriteRun( + toml( + """ + [table-1] + key1 = "some string" + key2 = 123 + + [table-2] + key1 = "another string" + key2 = 456 + + [dog."tater.man"] + type.name = "pug" + """ + ) + ); + } + + @Test + void arrayTable() { + rewriteRun( + toml( + """ + [[products]] + name = "Hammer" + sku = 738594937 + + [[products]] # empty table within the array + + [[products]] + name = "Nail" + sku = 284758393 + + color = "gray" + """ + ) + ); + } + + @Test + void bareKeys() { + rewriteRun( + toml( + """ + key = "value" + bare_key = "value" + bare-key = "value" + 1234 = "value" + """ + ) + ); + } + + @Test + void quotedKeys() { + rewriteRun( + toml( + """ + "127.0.0.1" = "value" + "character encoding" = "value" + "ʎǝʞ" = "value" + 'key2' = "value" + 'quoted "value"' = "value" + """ + ) + ); + } + + @Test + void dottedKeys() { + rewriteRun( + toml( + """ + physical.color = "orange" + physical.shape = "round" + site."google.com" = true + """ + ) + ); + } + + @Test + void extraWhitespaceDottedKeys() { + rewriteRun( + toml( + """ + fruit.name = "banana" # this is best practice + fruit. color = "yellow" # same as fruit.color + fruit . flavor = "banana" # same as fruit.flavor + """ + ) + ); + } + + @Test + void extraWhitespaceTable() { + rewriteRun( + toml( + """ + [a.b.c] # this is best practice + [ d.e.f ] # same as [d.e.f] + [ g . h . i ] # same as [g.h.i] + [ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'] + """ + ) + ); + } + + @Test + void extraWhitespaceArrayTable() { + rewriteRun( + toml( + """ + [[a.b.c]] # this is best practice + [[ d.e.f ]] # same as [[d.e.f]] + [[ g . h . i ]] # same as [[g.h.i]] + [[ j . "ʞ" . 'l' ]] # same as [[j."ʞ".'l']] + """ + ) + ); + } + + @Test + void empty() { + rewriteRun( + toml( + "" + ) + ); + } + + @Test + void trailingComment() { + rewriteRun( + toml( + """ + str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." + # trailing comment + """ + ) + ); + } + + @Test + void multiBytesUnicode() { + rewriteRun( + toml( + """ + robot.name = "r2d2" # 🤖 + """ + ) + ); + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index f280b567997..1cc35fdf9ba 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,6 +27,7 @@ val allProjects = listOf( "rewrite-properties", "rewrite-protobuf", "rewrite-test", + "rewrite-toml", "rewrite-xml", "rewrite-yaml", ) From 316790e39173fab5274f0b2adf38552cadb6f9e8 Mon Sep 17 00:00:00 2001 From: Shannon Pamperl Date: Fri, 3 Jan 2025 12:30:31 -0600 Subject: [PATCH 2/4] Polish and address bot review comments --- rewrite-toml/src/main/antlr/TomlLexer.g4 | 6 +----- .../java/org/openrewrite/toml/internal/TomlPrinter.java | 6 ++++++ .../src/main/java/org/openrewrite/toml/tree/Toml.java | 6 +++--- .../java/org/openrewrite/toml/tree/TomlRightPadded.java | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/rewrite-toml/src/main/antlr/TomlLexer.g4 b/rewrite-toml/src/main/antlr/TomlLexer.g4 index acebee19662..2c698f64e75 100644 --- a/rewrite-toml/src/main/antlr/TomlLexer.g4 +++ b/rewrite-toml/src/main/antlr/TomlLexer.g4 @@ -23,13 +23,9 @@ with the License. You may obtain a copy of the License at lexer grammar TomlLexer; -channels { - COMMENTS_CHANNEL -} - WS : [ \t]+ -> skip; NL : ('\r'? '\n')+; -COMMENT : '#' (~[\r\n])* -> channel(COMMENTS_CHANNEL); +COMMENT : '#' (~[\r\n])*; L_BRACKET : '['; DOUBLE_L_BRACKET : '[['; R_BRACKET : ']'; diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java index 88de816e9ef..af61c294a17 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/TomlPrinter.java @@ -32,6 +32,7 @@ public class TomlPrinter

extends TomlVisitor> { + @Override public Toml visitArray(Toml.Array array, PrintOutputCapture

p) { beforeSyntax(array, p); p.append("["); @@ -41,6 +42,7 @@ public Toml visitArray(Toml.Array array, PrintOutputCapture

p) { return array; } + @Override public Toml visitDocument(Toml.Document document, PrintOutputCapture

p) { beforeSyntax(document, p); visit(document.getValues(), p); @@ -49,12 +51,14 @@ public Toml visitDocument(Toml.Document document, PrintOutputCapture

p) { return document; } + @Override public Toml visitEmpty(Toml.Empty empty, PrintOutputCapture

p) { beforeSyntax(empty, p); afterSyntax(empty, p); return empty; } + @Override public Toml visitIdentifier(Toml.Identifier identifier, PrintOutputCapture

p) { beforeSyntax(identifier, p); p.append(identifier.getSource()); @@ -62,6 +66,7 @@ public Toml visitIdentifier(Toml.Identifier identifier, PrintOutputCapture

p) return identifier; } + @Override public Toml visitKeyValue(Toml.KeyValue keyValue, PrintOutputCapture

p) { beforeSyntax(keyValue, p); visitRightPadded(keyValue.getPadding().getKey(), p); @@ -71,6 +76,7 @@ public Toml visitKeyValue(Toml.KeyValue keyValue, PrintOutputCapture

p) { return keyValue; } + @Override public Toml visitLiteral(Toml.Literal literal, PrintOutputCapture

p) { beforeSyntax(literal, p); p.append(literal.getSource()); diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java index b2852ad40b0..8d6037316fe 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/Toml.java @@ -17,8 +17,8 @@ import lombok.*; import lombok.experimental.NonFinal; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.marker.Markers; import org.openrewrite.toml.TomlVisitor; import org.openrewrite.toml.internal.TomlPrinter; @@ -37,8 +37,7 @@ default R accept(TreeVisitor v, P p) { return (R) acceptToml(v.adapt(TomlVisitor.class), p); } - @Nullable - default

Toml acceptToml(TomlVisitor

v, P p) { + default

@Nullable Toml acceptToml(TomlVisitor

v, P p) { return v.defaultValue(this, p); } @@ -224,6 +223,7 @@ public KeyValue withKey(TomlKey key) { Toml value; + @Override public

Toml acceptToml(TomlVisitor

v, P p) { return v.visitKeyValue(this, p); } diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java index 41b1004c9f7..911bd8adf7a 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/tree/TomlRightPadded.java @@ -97,8 +97,7 @@ public static TomlRightPadded build(T element) { return new TomlRightPadded<>(element, Space.EMPTY, Markers.EMPTY); } - @Nullable - public static TomlRightPadded withElement(@Nullable TomlRightPadded before, @Nullable T elements) { + public static @Nullable TomlRightPadded withElement(@Nullable TomlRightPadded before, @Nullable T elements) { if (before == null) { if (elements == null) { return null; From 1a92d15689eb570862cb8b9ad20466d3a69ffee3 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 3 Jan 2025 20:33:43 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../java/org/openrewrite/toml/internal/grammar/TomlLexer.java | 2 +- .../java/org/openrewrite/toml/internal/grammar/TomlParser.java | 2 +- .../toml/internal/grammar/TomlParserBaseListener.java | 2 +- .../toml/internal/grammar/TomlParserBaseVisitor.java | 2 +- .../openrewrite/toml/internal/grammar/TomlParserListener.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java index f8c5585f801..2a739910ab1 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlLexer.java @@ -582,4 +582,4 @@ public TomlLexer(CharStream input) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} \ No newline at end of file +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java index 13ba230fc50..36f1d699925 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParser.java @@ -1883,4 +1883,4 @@ public final ArrayTableContext arrayTable() throws RecognitionException { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} \ No newline at end of file +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java index ca57f4cc77c..e0944694241 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseListener.java @@ -304,4 +304,4 @@ public class TomlParserBaseListener implements TomlParserListener { *

The default implementation does nothing.

*/ @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java index 92405461133..f4cfa1ebb80 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserBaseVisitor.java @@ -174,4 +174,4 @@ public class TomlParserBaseVisitor extends AbstractParseTreeVisitor implem * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitArrayTable(TomlParser.ArrayTableContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file +} diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java index 06e33c2eb68..5b428a22f42 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserListener.java @@ -232,4 +232,4 @@ public interface TomlParserListener extends ParseTreeListener { * @param ctx the parse tree */ void exitArrayTable(TomlParser.ArrayTableContext ctx); -} \ No newline at end of file +} From fda0826a0628f7a064f8da9f79b777e869d9a245 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 3 Jan 2025 20:34:05 +0100 Subject: [PATCH 4/4] Update rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../openrewrite/toml/internal/grammar/TomlParserVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java index 1c6547fa80b..acbe51681b2 100644 --- a/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java +++ b/rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java @@ -151,4 +151,4 @@ public interface TomlParserVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitArrayTable(TomlParser.ArrayTableContext ctx); -} \ No newline at end of file +}