├── runtime ├── JavaScript │ ├── .eslintignore │ ├── .gitignore │ ├── src │ │ └── antlr4 │ │ │ ├── dfa │ │ │ ├── index.d.ts │ │ │ ├── DFA.d.ts │ │ │ ├── index.js │ │ │ └── LexerDFASerializer.js │ │ │ ├── tree │ │ │ ├── Tree.d.ts │ │ │ ├── SyntaxTree.d.ts │ │ │ ├── ErrorNode.d.ts │ │ │ ├── RuleNode.d.ts │ │ │ ├── ParseTree.d.ts │ │ │ ├── index.d.ts │ │ │ ├── TerminalNode.d.ts │ │ │ ├── ParseTreeWalker.d.ts │ │ │ ├── SyntaxTree.js │ │ │ ├── ParseTree.js │ │ │ ├── ErrorNode.js │ │ │ ├── TerminalNode.js │ │ │ ├── ParseTreeListener.d.ts │ │ │ ├── Tree.js │ │ │ ├── RuleNode.js │ │ │ ├── ParseTreeVisitor.d.ts │ │ │ └── ParseTreeListener.js │ │ │ ├── TokenSource.d.ts │ │ │ ├── atn │ │ │ ├── ATNSimulator.d.ts │ │ │ ├── PredictionContextCache.d.ts │ │ │ ├── ATNConfig.d.ts │ │ │ ├── ATNConfigSet.d.ts │ │ │ ├── PredictionMode.d.ts │ │ │ ├── ATNDeserializationOptions.d.ts │ │ │ ├── ATNDeserializer.d.ts │ │ │ ├── index.d.ts │ │ │ ├── ATNType.js │ │ │ ├── AbstractPredicateTransition.js │ │ │ └── OrderedATNConfigSet.js │ │ │ ├── misc │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── Interval.d.ts │ │ │ └── IntervalSet.d.ts │ │ │ ├── utils │ │ │ ├── arrayToString.d.ts │ │ │ ├── stringToCharArray.d.ts │ │ │ ├── index.d.ts │ │ │ ├── Printer.d.ts │ │ │ ├── stringToCharArray.js │ │ │ ├── valueToString.js │ │ │ ├── standardEqualsFunction.js │ │ │ ├── index.js │ │ │ ├── titleCase.js │ │ │ ├── arrayToString.js │ │ │ ├── standardHashCodeFunction.js │ │ │ └── escapeWhitespace.js │ │ │ ├── context │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ └── RuleContext.d.ts │ │ │ ├── state │ │ │ ├── RuleStopState.d.ts │ │ │ ├── ATNState.d.ts │ │ │ ├── index.d.ts │ │ │ ├── DecisionState.d.ts │ │ │ ├── RuleStartState.d.ts │ │ │ ├── BasicState.js │ │ │ ├── StarLoopbackState.js │ │ │ └── DecisionState.js │ │ │ ├── InputStream.d.ts │ │ │ ├── error │ │ │ ├── BailErrorStrategy.d.ts │ │ │ ├── InputMismatchException.d.ts │ │ │ ├── FailedPredicateException.d.ts │ │ │ ├── ErrorListener.d.ts │ │ │ ├── index.d.ts │ │ │ ├── NoViableAltException.d.ts │ │ │ ├── ParseCancellationException.js │ │ │ ├── DiagnosticErrorListener.d.ts │ │ │ └── ErrorStrategy.d.ts │ │ │ ├── BufferedTokenStream.d.ts │ │ │ ├── Recognizer.d.ts │ │ │ ├── FileStream.d.ts │ │ │ ├── TokenSource.js │ │ │ ├── TokenStream.js │ │ │ ├── CommonTokenStream.d.ts │ │ │ ├── CommonToken.d.ts │ │ │ ├── Token.d.ts │ │ │ └── InputStream.js │ ├── spec │ │ ├── rewriter │ │ │ ├── abc.g4 │ │ │ └── calc.g4 │ │ ├── imports │ │ │ ├── NodeEsmImportSpec.mjs │ │ │ └── NodeCommonJSImportSpec.cjs │ │ ├── support │ │ │ └── jasmine.json │ │ └── helpers │ │ │ └── Reporter.js │ ├── .babelrc │ └── .c8rc.json ├── Java │ ├── lib │ │ └── org.abego.treelayout.core.jar │ └── src │ │ └── main │ │ └── dot │ │ └── org │ │ └── antlr │ │ └── v4 │ │ └── runtime │ │ └── atn │ │ └── images │ │ └── Rule.dot └── Core │ └── src │ └── main │ └── kotlin │ └── org │ └── antlr │ └── v5 │ └── runtime │ └── core │ ├── IPrintStream.kt │ ├── atn │ └── ATNType.kt │ ├── tree │ ├── ErrorNode.kt │ ├── TerminalNode.kt │ └── RuleNode.kt │ ├── jvm │ ├── BitSet.kt │ ├── CopyOnWriteArrayList.kt │ ├── Synchronized.kt │ ├── WeakHashMap.kt │ ├── IdentityHashMap.kt │ └── Environment.kt │ ├── misc │ └── Predicate.kt │ ├── state │ ├── DecisionState.kt │ ├── BasicState.kt │ ├── BasicBlockStartState.kt │ ├── BlockStartState.kt │ ├── StarBlockStartState.kt │ ├── LoopEndState.kt │ ├── TokensStartState.kt │ └── RuleStartState.kt │ ├── ast │ └── Node.kt │ ├── error │ └── EmptyStackException.kt │ └── transition │ ├── WildcardTransition.kt │ └── AbstractPredicateTransition.kt ├── antlr5-maven-plugin └── src │ ├── site │ └── apt │ │ ├── faq.apt.vm │ │ └── examples │ │ └── import.apt │ └── test │ └── projects │ ├── importTokens │ └── src │ │ └── main │ │ └── antlr4 │ │ ├── imports │ │ └── SimpleLexer.tokens │ │ └── test │ │ └── SimpleParser.g4 │ ├── importsCustom │ └── src │ │ └── main │ │ └── antlr4 │ │ ├── Hello.g4 │ │ ├── TestParser.g4 │ │ ├── TestLexer.g4 │ │ └── imports │ │ └── TestBaseLexer.g4 │ ├── importsStandard │ └── src │ │ └── main │ │ └── antlr4 │ │ ├── test │ │ ├── Hello.g4 │ │ ├── TestParser.g4 │ │ └── TestLexer.g4 │ │ └── imports │ │ ├── TestBaseLexer2.g4 │ │ └── TestBaseLexer.g4 │ └── dependencyRemoved │ └── src │ └── main │ └── antlr4 │ ├── test │ └── Hello.g4 │ └── imports │ └── HelloBase.g4 ├── doc ├── images │ ├── tpdsl.png │ ├── xyz.png │ ├── foreign.png │ ├── nested.png │ ├── process.png │ ├── tertalk.png │ ├── xyz_opt.png │ ├── PR-on-dev.png │ ├── combined.png │ ├── dragfile.png │ ├── idea-prefs.png │ ├── nonascii.png │ ├── teronbook.png │ ├── testrigs.png │ ├── tpantlr2.png │ ├── xcodedep.png │ ├── xcodenav.png │ ├── xyz_plus.png │ ├── xyz_star.png │ ├── hello-parrt.png │ ├── nested-fuzzy.png │ ├── gen_spm_module.png │ ├── intellij-maven.png │ ├── nonnested-fuzzy.png │ ├── python3-tests.png │ ├── targetselection.png │ ├── ACE-Architecture.001.png │ ├── new-antlr-branches.png │ └── idea-prefs-after-install.png ├── faq │ ├── error-handling.md │ └── actions-preds.md └── IDEs.md ├── runtime-testsuite ├── resources │ ├── org │ │ └── antlr │ │ │ └── v5 │ │ │ └── test │ │ │ └── runtime │ │ │ ├── helpers │ │ │ ├── package_js.json │ │ │ ├── package_ts.json │ │ │ └── tsconfig.json │ │ │ └── descriptors │ │ │ ├── Sets │ │ │ ├── NotChar.txt │ │ │ ├── ParserSet.txt │ │ │ ├── ParserNotSet.txt │ │ │ ├── ParserNotToken.txt │ │ │ ├── NotCharSet.txt │ │ │ ├── OptionalSet.txt │ │ │ ├── ParserNotTokenWithLabel.txt │ │ │ ├── PlusSet.txt │ │ │ ├── RuleAsSet.txt │ │ │ ├── StarSet.txt │ │ │ ├── LexerOptionalSet.txt │ │ │ ├── OptionalSingleElement.txt │ │ │ ├── StarLexerSingleElement_2.txt │ │ │ ├── LexerPlusSet.txt │ │ │ ├── LexerStarSet.txt │ │ │ ├── OptionalLexerSingleElement.txt │ │ │ ├── PlusLexerSingleElement.txt │ │ │ ├── StarLexerSingleElement_1.txt │ │ │ ├── CharSetLiteral.txt │ │ │ ├── ComplementSet.txt │ │ │ ├── SeqDoesNotBecomeSet.txt │ │ │ ├── UnicodeNegatedBMPSetIncludesSMPCodePoints.txt │ │ │ ├── UnicodeNegatedSMPSetIncludesBMPCodePoints.txt │ │ │ ├── NotCharSetWithRuleRef3.txt │ │ │ ├── UnicodeUnescapedBMPSet.txt │ │ │ ├── UnicodeEscapedBMPRangeSet.txt │ │ │ ├── UnicodeEscapedBMPSet.txt │ │ │ ├── UnicodeEscapedSMPRangeSet.txt │ │ │ ├── UnicodeUnescapedBMPRangeSet.txt │ │ │ ├── UnicodeEscapedSMPSet.txt │ │ │ └── UnicodeEscapedSMPRangeSetMismatch.txt │ │ │ ├── LexerExec │ │ │ ├── EOFByItself.txt │ │ │ ├── EOFSuffixInFirstRule_1.txt │ │ │ ├── TokenType0xFFFF.txt │ │ │ ├── QuoteTranslation.txt │ │ │ ├── EOFSuffixInFirstRule_2.txt │ │ │ ├── NonGreedyTermination2.txt │ │ │ ├── EscapedCharacters.txt │ │ │ ├── CharSetWithQuote1.txt │ │ │ ├── NonGreedyTermination1.txt │ │ │ ├── CharSetNot.txt │ │ │ ├── CharSetWithQuote2.txt │ │ │ ├── GreedyClosure.txt │ │ │ ├── GreedyOptional.txt │ │ │ ├── CharSetWithMissingEscapeChar.txt │ │ │ ├── GreedyConfigs.txt │ │ │ ├── GreedyPositiveClosure.txt │ │ │ ├── NonGreedyClosure.txt │ │ │ ├── NonGreedyOptional.txt │ │ │ ├── StackoverflowDueToNotEscapedHyphen.txt │ │ │ ├── CharSet.txt │ │ │ ├── CharSetInSet.txt │ │ │ ├── NonGreedyPositiveClosure.txt │ │ │ ├── CharSetPlus.txt │ │ │ ├── ReservedWordsEscaping_NULL.txt │ │ │ ├── UnicodeCharSet.txt │ │ │ ├── CharSetWithEscapedChar.txt │ │ │ ├── NonGreedyConfigs.txt │ │ │ ├── RefToRuleDoesNotSetTokenNorEmitAnother.txt │ │ │ ├── Slashes.txt │ │ │ ├── EscapeTargetStringLiteral.txt │ │ │ ├── ReservedWordsEscaping.txt │ │ │ ├── RecursiveLexerRuleRefWithWildcardPlus_1.txt │ │ │ ├── RecursiveLexerRuleRefWithWildcardStar_1.txt │ │ │ ├── KeywordID.txt │ │ │ ├── CharSetRange.txt │ │ │ └── ActionPlacement.txt │ │ │ ├── ParserErrors │ │ │ ├── DuplicatedLeftRecursiveCall_1.txt │ │ │ ├── DuplicatedLeftRecursiveCall_2.txt │ │ │ ├── DuplicatedLeftRecursiveCall_3.txt │ │ │ ├── DuplicatedLeftRecursiveCall_4.txt │ │ │ ├── SingleTokenInsertion.txt │ │ │ ├── TokenMismatch.txt │ │ │ ├── SingleSetInsertion.txt │ │ │ ├── SingleTokenDeletion.txt │ │ │ ├── LL2.txt │ │ │ ├── MultiTokenDeletionBeforeLoop.txt │ │ │ ├── SingleTokenDeletionDuringLoop.txt │ │ │ ├── SingleTokenDeletionExpectingSet.txt │ │ │ ├── LL3.txt │ │ │ ├── LLStar.txt │ │ │ ├── SingleTokenDeletionBeforeAlt.txt │ │ │ ├── MultiTokenDeletionBeforeLoop2.txt │ │ │ ├── SingleTokenDeletionDuringLoop2.txt │ │ │ ├── SingleTokenDeletionBeforePredict.txt │ │ │ ├── SingleTokenDeletionBeforeLoop.txt │ │ │ ├── MultiTokenDeletionDuringLoop.txt │ │ │ ├── NoViableAltAvoidance.txt │ │ │ ├── SingleTokenDeletionBeforeLoop2.txt │ │ │ ├── MultiTokenDeletionDuringLoop2.txt │ │ │ ├── ConjuringUpToken.txt │ │ │ ├── ConjuringUpTokenFromSet.txt │ │ │ ├── InvalidEmptyInput.txt │ │ │ ├── SingleSetInsertionConsumption.txt │ │ │ ├── ExtraneousInput.txt │ │ │ ├── SingleTokenDeletionConsumption.txt │ │ │ ├── TokenMismatch2.txt │ │ │ ├── ContextListGetters.txt │ │ │ └── LL1ErrorInfo.txt │ │ │ ├── ParserExec │ │ │ ├── AStar_1.txt │ │ │ ├── Labels.txt │ │ │ ├── APlus.txt │ │ │ ├── AStar_2.txt │ │ │ ├── AorAStar_1.txt │ │ │ ├── AorAPlus.txt │ │ │ ├── AorAStar_2.txt │ │ │ ├── Basic.txt │ │ │ ├── AorBStar_1.txt │ │ │ ├── LL1OptionalBlock_1.txt │ │ │ ├── LL1OptionalBlock_2.txt │ │ │ ├── AorBPlus.txt │ │ │ ├── AorBStar_2.txt │ │ │ ├── uStartingCharDoesNotCauseIllegalUnicodeEscape.txt │ │ │ ├── AorB.txt │ │ │ ├── Optional_1.txt │ │ │ ├── Optional_2.txt │ │ │ ├── Optional_3.txt │ │ │ ├── Optional_4.txt │ │ │ ├── BuildParseTree_TRUE.txt │ │ │ ├── MultipleEOFHandling.txt │ │ │ ├── BuildParseTree_FALSE.txt │ │ │ ├── Wildcard.txt │ │ │ ├── PredictionMode_LL.txt │ │ │ ├── IfIfElseNonGreedyBinding1.txt │ │ │ ├── IfIfElseNonGreedyBinding2.txt │ │ │ ├── IfIfElseGreedyBinding1.txt │ │ │ ├── IfIfElseGreedyBinding2.txt │ │ │ ├── ListLabelsOnSet.txt │ │ │ ├── ReferenceToATN_1.txt │ │ │ ├── OrderingPredicates.txt │ │ │ ├── ReferenceToATN_2.txt │ │ │ ├── PredictionMode_SLL.txt │ │ │ ├── ParserProperty.txt │ │ │ └── PredicatedIfIfElse.txt │ │ │ ├── LexerErrors │ │ │ ├── ErrorInMiddle.txt │ │ │ ├── InvalidCharAtStart.txt │ │ │ ├── InvalidCharInToken.txt │ │ │ ├── EnforcedGreedyNestedBraces_1.txt │ │ │ ├── InvalidCharAtStartAfterDFACache.txt │ │ │ ├── InvalidCharInTokenAfterDFACache.txt │ │ │ ├── StringsEmbeddedInActions_1.txt │ │ │ ├── DFAToATNThatFailsBackToDFA.txt │ │ │ ├── EnforcedGreedyNestedBraces_2.txt │ │ │ ├── DFAToATNThatMatchesThenFailsInATN.txt │ │ │ └── StringsEmbeddedInActions_2.txt │ │ │ ├── CompositeParsers │ │ │ ├── ImportedGrammarWithEmptyOptions.txt │ │ │ ├── BringInLiteralsFromDelegate.txt │ │ │ ├── DelegatorRuleOverridesDelegate.txt │ │ │ ├── ImportedRuleWithAction.txt │ │ │ ├── CombinedImportsCombined.txt │ │ │ ├── DelegatorInvokesDelegateRule.txt │ │ │ ├── KeywordVSIDOrder.txt │ │ │ ├── DelegatorInvokesDelegateRuleWithReturnStruct.txt │ │ │ ├── DelegatorAccessesDelegateMembers.txt │ │ │ ├── DelegatorInvokesDelegateRuleWithArgs.txt │ │ │ ├── DelegatorRuleOverridesDelegates.txt │ │ │ └── DelegatorInvokesFirstVersionOfDelegateRule.txt │ │ │ ├── LeftRecursion │ │ │ ├── Simple_1.txt │ │ │ ├── Simple_2.txt │ │ │ ├── Simple_3.txt │ │ │ ├── SemPred.txt │ │ │ ├── LabelsOnOpSubrule_1.txt │ │ │ ├── LabelsOnOpSubrule_2.txt │ │ │ ├── LabelsOnOpSubrule_3.txt │ │ │ ├── SemPredFailOption.txt │ │ │ ├── PrefixAndOtherAlt_1.txt │ │ │ ├── ReturnValueAndActions_1.txt │ │ │ ├── ReturnValueAndActions_2.txt │ │ │ ├── ReturnValueAndActions_3.txt │ │ │ ├── DirectCallToLeftRecursiveRule_1.txt │ │ │ ├── ReturnValueAndActions_4.txt │ │ │ ├── TernaryExpr_1.txt │ │ │ ├── DirectCallToLeftRecursiveRule_2.txt │ │ │ ├── Expressions_1.txt │ │ │ ├── Expressions_2.txt │ │ │ ├── Expressions_6.txt │ │ │ ├── DirectCallToLeftRecursiveRule_3.txt │ │ │ ├── Expressions_4.txt │ │ │ ├── PrefixAndOtherAlt_2.txt │ │ │ ├── TernaryExpr_2.txt │ │ │ ├── TernaryExpr_3.txt │ │ │ ├── Expressions_3.txt │ │ │ ├── Expressions_5.txt │ │ │ ├── Expressions_7.txt │ │ │ ├── TernaryExpr_4.txt │ │ │ ├── TernaryExpr_5.txt │ │ │ ├── TernaryExpr_6.txt │ │ │ ├── TernaryExpr_7.txt │ │ │ ├── TernaryExpr_8.txt │ │ │ └── TernaryExpr_9.txt │ │ │ ├── ParseTrees │ │ │ ├── Token2.txt │ │ │ ├── TwoAlts.txt │ │ │ ├── RuleRef.txt │ │ │ ├── TwoAltLoop.txt │ │ │ ├── TokenAndRuleContextString.txt │ │ │ ├── ExtraToken.txt │ │ │ ├── NoViableAlt.txt │ │ │ ├── Sync.txt │ │ │ └── AltNum.txt │ │ │ ├── SemPredEvalLexer │ │ │ ├── RuleSempredFunction.txt │ │ │ ├── IDnotEnum.txt │ │ │ ├── EnumNotID.txt │ │ │ ├── PredicatedKeywords.txt │ │ │ └── IDvsEnum.txt │ │ │ ├── SemPredEvalParser │ │ │ ├── ToLeft.txt │ │ │ ├── SimpleValidate.txt │ │ │ ├── RewindBeforePredEval.txt │ │ │ ├── UnpredicatedPathsInAlt.txt │ │ │ ├── DisabledAlternative.txt │ │ │ ├── AtomWithClosureInTranslatedLRRule.txt │ │ │ ├── IndependentPredNotPassedOuterCtxToAvoidCastException.txt │ │ │ ├── NoTruePredsThrowsNoViableAlt.txt │ │ │ ├── SimpleValidate2.txt │ │ │ ├── Simple.txt │ │ │ ├── PredTestedEvenWhenUnAmbig_1.txt │ │ │ ├── Order.txt │ │ │ ├── ActionHidesPreds.txt │ │ │ └── PredTestedEvenWhenUnAmbig_2.txt │ │ │ ├── CompositeLexers │ │ │ ├── LexerDelegatorInvokesDelegateRule.txt │ │ │ └── LexerDelegatorRuleOverridesDelegate.txt │ │ │ ├── FullContextParsing │ │ │ ├── AmbigYieldsCtxSensitiveDFA.txt │ │ │ └── FullContextIF_THEN_ELSEParse_1.txt │ │ │ └── Listeners │ │ │ ├── Basic.txt │ │ │ └── TokenGetters_1.txt │ └── junit-platform.properties └── test │ └── org │ └── antlr │ └── v5 │ └── test │ └── runtime │ ├── java │ ├── api │ │ ├── VisitorBasic.g4 │ │ ├── perf │ │ │ └── emoji.txt │ │ └── VisitorCalc.g4 │ └── helpers │ │ ├── RuntimeTestLexer.java │ │ └── RuntimeTestParser.java │ ├── PredictionMode.java │ ├── README.md │ ├── kotlin │ ├── helpers │ │ ├── RuntimeTestLexer.kt │ │ ├── RuntimeTestParser.kt │ │ └── RuntimeTestPrintStream.kt │ └── KotlinRuntimeTests.java │ ├── Stage.java │ ├── OSType.java │ ├── states │ └── jvm │ │ ├── JavaExecutedState.java │ │ └── KotlinExecutedState.java │ └── GeneratedFile.java ├── .gitattributes ├── docker └── .dockerignore ├── antlr-kotlin-runtime-remnants ├── README.md └── src │ ├── nativeMain │ └── kotlin │ │ ├── org │ │ └── antlr │ │ │ └── v4 │ │ │ └── kotlinruntime │ │ │ └── CharStreams.kt │ │ └── com │ │ └── strumenta │ │ └── antlrkotlin │ │ └── runtime │ │ ├── BitSet.kt │ │ ├── CopyOnWriteArrayList.kt │ │ └── IdentityHashMap.kt │ ├── wasmJsMain │ └── kotlin │ │ └── com │ │ └── strumenta │ │ └── antlrkotlin │ │ └── runtime │ │ └── BitSet.kt │ ├── wasmWasiMain │ └── kotlin │ │ ├── com │ │ └── strumenta │ │ │ └── antlrkotlin │ │ │ └── runtime │ │ │ ├── BitSet.kt │ │ │ ├── WeakHashMap.kt │ │ │ ├── IdentityHashMap.kt │ │ │ └── CopyOnWriteArrayList.kt │ │ └── org │ │ └── antlr │ │ └── v4 │ │ └── kotlinruntime │ │ └── CharStreams.kt │ └── jsAndWasmSharedMain │ └── kotlin │ ├── org │ └── antlr │ │ └── v5 │ │ └── kotlinruntime │ │ └── CharStreams.kt │ └── com │ └── strumenta │ └── antlrkotlin │ └── runtime │ ├── CopyOnWriteArrayList.kt │ ├── WeakHashMap.kt │ └── IdentityHashMap.kt ├── tool-testsuite └── resources │ └── junit-platform.properties ├── tool └── src │ └── org │ └── antlr │ └── v5 │ ├── analysis │ ├── AssocType.java │ └── AltType.java │ ├── codegen │ ├── model │ │ ├── dbg.java │ │ ├── TokenInfo.java │ │ ├── chunk │ │ │ ├── SymbolRefChunk.java │ │ │ ├── ListLabelRef.java │ │ │ ├── ArgRef.java │ │ │ ├── LabelRef.java │ │ │ └── LocalRef.java │ │ ├── DispatchMethod.java │ │ ├── VisitorDispatchMethod.java │ │ ├── BaseVisitorFile.java │ │ ├── decl │ │ │ ├── ElementListDecl.java │ │ │ ├── TokenTypeDecl.java │ │ │ └── TokenListDecl.java │ │ ├── BaseListenerFile.java │ │ └── LabeledOp.java │ └── LexerFactory.java │ ├── automata │ └── CharactersDataCheckStatus.java │ ├── tool │ ├── ast │ │ ├── RuleElementAST.java │ │ └── QuantifierAST.java │ └── LabelType.java │ ├── gui │ └── TreeTextProvider.java │ └── parse │ └── ResyncToEndOfRuleBlock.java ├── .editorconfig └── scripts └── parse-extended-pictographic └── README.md /runtime/JavaScript/.eslintignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/site/apt/faq.apt.vm: -------------------------------------------------------------------------------- 1 | FAQ 2 | -------------------------------------------------------------------------------- /runtime/JavaScript/.gitignore: -------------------------------------------------------------------------------- 1 | /dist/ 2 | /node_modules 3 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/dfa/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './DFA'; 2 | 3 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/Tree.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Tree {} 2 | -------------------------------------------------------------------------------- /doc/images/tpdsl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/tpdsl.png -------------------------------------------------------------------------------- /doc/images/xyz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xyz.png -------------------------------------------------------------------------------- /doc/images/foreign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/foreign.png -------------------------------------------------------------------------------- /doc/images/nested.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/nested.png -------------------------------------------------------------------------------- /doc/images/process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/process.png -------------------------------------------------------------------------------- /doc/images/tertalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/tertalk.png -------------------------------------------------------------------------------- /doc/images/xyz_opt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xyz_opt.png -------------------------------------------------------------------------------- /runtime/JavaScript/spec/rewriter/abc.g4: -------------------------------------------------------------------------------- 1 | lexer grammar abc; 2 | A: 'a'; 3 | B: 'b'; 4 | C: 'c'; -------------------------------------------------------------------------------- /doc/images/PR-on-dev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/PR-on-dev.png -------------------------------------------------------------------------------- /doc/images/combined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/combined.png -------------------------------------------------------------------------------- /doc/images/dragfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/dragfile.png -------------------------------------------------------------------------------- /doc/images/idea-prefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/idea-prefs.png -------------------------------------------------------------------------------- /doc/images/nonascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/nonascii.png -------------------------------------------------------------------------------- /doc/images/teronbook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/teronbook.png -------------------------------------------------------------------------------- /doc/images/testrigs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/testrigs.png -------------------------------------------------------------------------------- /doc/images/tpantlr2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/tpantlr2.png -------------------------------------------------------------------------------- /doc/images/xcodedep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xcodedep.png -------------------------------------------------------------------------------- /doc/images/xcodenav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xcodenav.png -------------------------------------------------------------------------------- /doc/images/xyz_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xyz_plus.png -------------------------------------------------------------------------------- /doc/images/xyz_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/xyz_star.png -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/helpers/package_js.json: -------------------------------------------------------------------------------- 1 | {"type": "module"} -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/TokenSource.d.ts: -------------------------------------------------------------------------------- 1 | export declare class TokenSource { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # This rule applies to all files which don't match another line below 2 | * text=auto -------------------------------------------------------------------------------- /doc/images/hello-parrt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/hello-parrt.png -------------------------------------------------------------------------------- /doc/images/nested-fuzzy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/nested-fuzzy.png -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNSimulator.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ATNSimulator { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /doc/images/gen_spm_module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/gen_spm_module.png -------------------------------------------------------------------------------- /doc/images/intellij-maven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/intellij-maven.png -------------------------------------------------------------------------------- /doc/images/nonnested-fuzzy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/nonnested-fuzzy.png -------------------------------------------------------------------------------- /doc/images/python3-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/python3-tests.png -------------------------------------------------------------------------------- /doc/images/targetselection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/targetselection.png -------------------------------------------------------------------------------- /runtime/JavaScript/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "targets": "defaults" 4 | } 5 | -------------------------------------------------------------------------------- /doc/images/ACE-Architecture.001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/ACE-Architecture.001.png -------------------------------------------------------------------------------- /doc/images/new-antlr-branches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/new-antlr-branches.png -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/misc/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './Interval' 2 | export * from './IntervalSet'; 3 | 4 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens: -------------------------------------------------------------------------------- 1 | ID=1 2 | INT=2 3 | SEMI=3 4 | -------------------------------------------------------------------------------- /docker/.dockerignore: -------------------------------------------------------------------------------- 1 | tool-testsuite 2 | runtime-testsuite 3 | .git* 4 | README.adoc 5 | README.md 6 | cache 7 | tests 8 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/PredictionContextCache.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PredictionContextCache { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/arrayToString.d.ts: -------------------------------------------------------------------------------- 1 | export declare function arrayToString(value: any[]) : string; 2 | -------------------------------------------------------------------------------- /doc/images/idea-prefs-after-install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/doc/images/idea-prefs-after-install.png -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/context/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './RuleContext'; 2 | export * from './ParserRuleContext'; 3 | 4 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/stringToCharArray.d.ts: -------------------------------------------------------------------------------- 1 | export declare function stringToCharArray(str: string) : Uint16Array; 2 | -------------------------------------------------------------------------------- /runtime/Java/lib/org.abego.treelayout.core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/antlr5/HEAD/runtime/Java/lib/org.abego.treelayout.core.jar -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/SyntaxTree.d.ts: -------------------------------------------------------------------------------- 1 | import {Tree} from "./Tree"; 2 | 3 | export declare class SyntaxTree extends Tree {} 4 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/java/api/VisitorBasic.g4: -------------------------------------------------------------------------------- 1 | grammar VisitorBasic; 2 | 3 | s 4 | : 'A' EOF 5 | ; 6 | 7 | A : 'A'; 8 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4: -------------------------------------------------------------------------------- 1 | grammar Hello; 2 | r : 'hello' ID ; 3 | ID : [a-z]+ ; 4 | WS : [ \r\t\n]+ -> skip ; -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNConfig.d.ts: -------------------------------------------------------------------------------- 1 | import { ATNState } from "../state"; 2 | 3 | export declare class ATNConfig { 4 | state: ATNState; 5 | } 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/dfa/DFA.d.ts: -------------------------------------------------------------------------------- 1 | export declare class DFA { 2 | constructor(ds: any, index: number); 3 | toLexerString(): string; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./stringToCharArray"; 2 | export * from "./arrayToString"; 3 | export * from "./Printer"; 4 | 5 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4: -------------------------------------------------------------------------------- 1 | grammar Hello; 2 | r : 'hello' ID ; 3 | ID : [a-z]+ ; 4 | WS : [ \r\t\n]+ -> skip ; -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/RuleStopState.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNState} from "./index"; 2 | 3 | export declare class RuleStopState extends ATNState { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/Printer.d.ts: -------------------------------------------------------------------------------- 1 | export declare abstract class Printer { 2 | print(s: string) : void; 3 | println(s: string) : void; 4 | } 5 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ErrorNode.d.ts: -------------------------------------------------------------------------------- 1 | import {TerminalNode} from "./TerminalNode"; 2 | 3 | export declare class ErrorNode extends TerminalNode { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/RuleNode.d.ts: -------------------------------------------------------------------------------- 1 | import {ParseTree} from "./ParseTree"; 2 | 3 | export declare abstract class RuleNode extends ParseTree { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer2.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestBaseLexer2; 2 | 3 | fragment 4 | Digit : [0-9] ; 5 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNConfigSet.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNConfig} from "./ATNConfig"; 2 | 3 | export declare class ATNConfigSet { 4 | configs: ATNConfig[]; 5 | } 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/ATNState.d.ts: -------------------------------------------------------------------------------- 1 | import {ATN} from "../atn"; 2 | 3 | export declare class ATNState { 4 | atn: ATN; 5 | stateNumber: number; 6 | } 7 | -------------------------------------------------------------------------------- /runtime/JavaScript/spec/rewriter/calc.g4: -------------------------------------------------------------------------------- 1 | lexer grammar calc; 2 | ID: 'a' ..'z'+; 3 | INT: '0' ..'9'+; 4 | SEMI: ';'; 5 | PLUS: '+'; 6 | MUL: '*'; 7 | ASSIGN: '='; 8 | WS: ' '+; 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/misc/index.js: -------------------------------------------------------------------------------- 1 | import Interval from './Interval.js'; 2 | import IntervalSet from './IntervalSet.js'; 3 | 4 | export default { Interval, IntervalSet } 5 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTree.d.ts: -------------------------------------------------------------------------------- 1 | import {SyntaxTree} from "./SyntaxTree"; 2 | 3 | export declare class ParseTree extends SyntaxTree { 4 | getText(): string; 5 | } 6 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar TestParser; 2 | 3 | options { tokenVocab=TestLexer; } 4 | 5 | document : (Comment | Name) EOF ; -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/InputStream.d.ts: -------------------------------------------------------------------------------- 1 | export declare class InputStream { 2 | constructor(data: string); 3 | constructor(data: string, decodeToUnicodeCodePoints: boolean); 4 | } 5 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './ATNState'; 2 | export * from './DecisionState'; 3 | export * from './RuleStartState'; 4 | export * from './RuleStopState'; 5 | 6 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar TestParser; 2 | 3 | options { tokenVocab=TestLexer; } 4 | 5 | document : (Comment | Name) EOF ; -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/PredictionMode.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime; 2 | 3 | public enum PredictionMode { 4 | SLL, 5 | LL, 6 | LL_EXACT_AMBIG_DETECTION 7 | } 8 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4: -------------------------------------------------------------------------------- 1 | grammar Hello; 2 | 3 | import HelloBase; 4 | 5 | r : 'hello' ID ; 6 | ID : [a-z]+ ; 7 | WS : [ \r\t\n]+ -> skip ; 8 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/PredictionMode.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PredictionMode { 2 | static SLL: number; 3 | static LL: number; 4 | static LL_EXACT_AMBIG_DETECTION: number; 5 | } 6 | -------------------------------------------------------------------------------- /runtime/JavaScript/.c8rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "all": true, 3 | "include": [ 4 | "src/antlr4/**/*.js" 5 | ], 6 | "reporter": [ 7 | "text", 8 | "lcov" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/DecisionState.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNState} from "./index"; 2 | 3 | export declare class DecisionState extends ATNState { 4 | decision: number; 5 | nonGreedy: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/README.md: -------------------------------------------------------------------------------- 1 | These files are inherited from the Kotlin target for ANTLR 4, which is multi-platform. They are currently unused but kept around to make it possible to implement other Kotlin targets later). -------------------------------------------------------------------------------- /tool-testsuite/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled = true 2 | junit.jupiter.execution.parallel.mode.default = concurrent 3 | junit.jupiter.execution.parallel.mode.classes.default = concurrent -------------------------------------------------------------------------------- /runtime-testsuite/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled = true 2 | junit.jupiter.execution.parallel.mode.default = concurrent 3 | junit.jupiter.execution.parallel.mode.classes.default = concurrent -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNDeserializationOptions.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ATNDeserializationOptions { 2 | readOnly?: boolean; 3 | verifyATN?: boolean; 4 | generateRuleBypassTransitions?: boolean; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/BailErrorStrategy.d.ts: -------------------------------------------------------------------------------- 1 | import {DefaultErrorStrategy} from "./DefaultErrorStrategy"; 2 | 3 | export declare class BailErrorStrategy extends DefaultErrorStrategy { 4 | 5 | constructor(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/java/api/perf/emoji.txt: -------------------------------------------------------------------------------- 1 | 😀🖖💩 2 | 👴🏽🖖🏿👦🏼 3 | 👮‍♀️👷‍♀️👯‍♂️ 4 | 🙇🏻‍♀️👼🏽🎅🏿 5 | 01234 6 | 0️⃣1️⃣2️⃣3️⃣4️⃣ 7 | ™©® 8 | ™️©️®️ 9 | 🇨🇨🇧🇬🇯🇲 10 | 🏳️‍🌈 11 | 🏴‍☠️ 12 | 13 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/IPrintStream.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.runtime.core 2 | 3 | public interface IPrintStream { 4 | 5 | public fun print(value: String) 6 | public fun printLine(value: String?) 7 | 8 | } -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestLexer; 2 | 3 | import TestBaseLexer; 4 | 5 | WS : Whitespace+ -> skip; 6 | TEXT : ~[<&]+ ; // match any 16 bit char other than < and & -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/RuleStartState.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNState, RuleStopState} from "./index"; 2 | 3 | export declare class RuleStartState extends ATNState { 4 | stopState: RuleStopState; 5 | isLeftRecursiveRule: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/helpers/package_ts.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "devDependencies": { 4 | "@types/node": "^18.0.5" 5 | }, 6 | "dependencies": { 7 | "antlr4": "^4.13.1" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/BufferedTokenStream.d.ts: -------------------------------------------------------------------------------- 1 | import { TokenStream } from './TokenStream'; 2 | import { Lexer } from "./Lexer"; 3 | 4 | export declare class BufferedTokenStream extends TokenStream { 5 | 6 | tokenSource: Lexer; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/NotChar.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ~'b' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | x 11 | 12 | [output] 13 | """x 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/ParserSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : t=('x'|'y') {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | x 10 | 11 | [output] 12 | """x 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /doc/faq/error-handling.md: -------------------------------------------------------------------------------- 1 | # Error handling 2 | 3 | ## How do I perform semantic checking with ANTLR? 4 | 5 | See [How to implement error handling in ANTLR4](http://stackoverflow.com/questions/21613421/how-to-implement-error-handling-in-antlr4/21615751#21615751). 6 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/ParserNotSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : t=~('x'|'y') 'z' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | zz 10 | 11 | [output] 12 | """z 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/ParserNotToken.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ~'x' 'z' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | zz 10 | 11 | [output] 12 | """zz 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/NotCharSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ~('b'|'c') ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | x 11 | 12 | [output] 13 | """x 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/OptionalSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ('a'|'b')? 'c' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ac 10 | 11 | [output] 12 | """ac 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/ParserNotTokenWithLabel.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : t=~'x' 'z' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | zz 10 | 11 | [output] 12 | """z 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/PlusSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ('a'|'b')+ 'c' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | abaac 10 | 11 | [output] 12 | """abaac 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/RuleAsSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a @after {} : 'a' | 'b' |'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | b 10 | 11 | [output] 12 | """b 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/StarSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ('a'|'b')* 'c' {} ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | abaac 10 | 11 | [output] 12 | """abaac 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime/JavaScript/spec/imports/NodeEsmImportSpec.mjs: -------------------------------------------------------------------------------- 1 | import * as antlr4 from 'antlr4' 2 | 3 | describe('Antlr4 Node Esm', () => { 4 | it('should use the Esm module on Node.js', () => { 5 | expect(antlr4).toBeDefined(); 6 | }); 7 | }); 8 | export {}; 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/EOFByItself.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | DONE : EOF ; 4 | A : 'a'; 5 | 6 | [input] 7 | 8 | 9 | [output] 10 | [@0,0:-1='',<1>,1:0] 11 | [@1,0:-1='',<-1>,1:0] 12 | 13 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestLexer; 2 | 3 | import TestBaseLexer, TestBaseLexer2; 4 | 5 | WS : Whitespace+ -> skip; 6 | TEXT : ~[<&]+ ; // match any 16 bit char other than < and & 7 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/EOFSuffixInFirstRule_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' EOF ; 4 | B : 'a'; 5 | C : 'c'; 6 | 7 | [input] 8 | 9 | 10 | [output] 11 | """[@0,0:-1='',<-1>,1:0] 12 | """ 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/TokenType0xFFFF.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | T_FFFF: 'FFFF' -> type(65535); 4 | 5 | [input] 6 | FFFF 7 | 8 | [output] 9 | [@0,0:3='FFFF',<65535>,1:0] 10 | [@1,4:3='',<-1>,1:4] 11 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/DuplicatedLeftRecursiveCall_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : expr EOF; 4 | expr : 'x' 5 | | expr expr 6 | ; 7 | 8 | [start] 9 | start 10 | 11 | [input] 12 | x 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/DuplicatedLeftRecursiveCall_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : expr EOF; 4 | expr : 'x' 5 | | expr expr 6 | ; 7 | 8 | [start] 9 | start 10 | 11 | [input] 12 | xx 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/DuplicatedLeftRecursiveCall_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : expr EOF; 4 | expr : 'x' 5 | | expr expr 6 | ; 7 | 8 | [start] 9 | start 10 | 11 | [input] 12 | xxx 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/DuplicatedLeftRecursiveCall_4.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : expr EOF; 4 | expr : 'x' 5 | | expr expr 6 | ; 7 | 8 | [start] 9 | start 10 | 11 | [input] 12 | xxxx 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenInsertion.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b' 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ac 10 | 11 | [errors] 12 | """line 1:1 missing 'b' at 'c' 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime/JavaScript/spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": [ 4 | "**/*Spec.[c|m]*js", 5 | "**/*Spec.js" 6 | ], 7 | "helpers": [ 8 | "helpers/**/*.js" 9 | ], 10 | "env": { 11 | "random": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/TokenMismatch.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aa 10 | 11 | [errors] 12 | """line 1:1 mismatched input 'a' expecting 'b' 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/LexerOptionalSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ('a'|'b')? 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | ac 11 | 12 | [output] 13 | """ac 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/OptionalSingleElement.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A? 'c' {} ; 4 | A : 'b' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | bc 11 | 12 | [output] 13 | """bc 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/StarLexerSingleElement_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : 'b'* 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | c 11 | 12 | [output] 13 | """c 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/stringToCharArray.js: -------------------------------------------------------------------------------- 1 | export default function stringToCharArray(str) { 2 | let result = new Uint16Array(str.length); 3 | for (let i = 0; i < str.length; i++) { 4 | result[i] = str.charCodeAt(i); 5 | } 6 | return result; 7 | } 8 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/QuoteTranslation.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | QUOTE : '"' ; // make sure this compiles 4 | 5 | [input] 6 | " 7 | 8 | [output] 9 | [@0,0:0='"',<1>,1:0] 10 | [@1,1:0='',<-1>,1:1] 11 | 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleSetInsertion.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'c') 'd' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ad 10 | 11 | [errors] 12 | """line 1:1 missing {'b', 'c'} at 'd' 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/LexerPlusSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ('a'|'b')+ 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | abaac 11 | 12 | [output] 13 | """abaac 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/LexerStarSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ('a'|'b')* 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | abaac 11 | 12 | [output] 13 | """abaac 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/OptionalLexerSingleElement.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : 'b'? 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | bc 11 | 12 | [output] 13 | """bc 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/PlusLexerSingleElement.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : 'b'+ 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | bbbbc 11 | 12 | [output] 13 | """bbbbc 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/spec/helpers/Reporter.js: -------------------------------------------------------------------------------- 1 | import { SpecReporter } from 'jasmine-spec-reporter'; 2 | 3 | jasmine.getEnv().clearReporters(); 4 | jasmine.getEnv().addReporter( 5 | new SpecReporter({ 6 | spec: { 7 | displayPending: true, 8 | }, 9 | }) 10 | ); 11 | -------------------------------------------------------------------------------- /runtime/JavaScript/spec/imports/NodeCommonJSImportSpec.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const antlr4 = require("antlr4"); 4 | describe('Antlr4 Node CommonJs', () => { 5 | it('should use the CommonJS module on Node.js', () => { 6 | expect(antlr4).toBeDefined(); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/Recognizer.d.ts: -------------------------------------------------------------------------------- 1 | import {ErrorListener} from "./error"; 2 | 3 | export declare class Recognizer { 4 | 5 | state: number; 6 | 7 | removeErrorListeners(): void; 8 | addErrorListener(listener: ErrorListener): void; 9 | } 10 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/InputMismatchException.d.ts: -------------------------------------------------------------------------------- 1 | import {RecognitionException} from "./RecognitionException"; 2 | import {Parser} from "../Parser"; 3 | 4 | export declare class InputMismatchException extends RecognitionException { 5 | constructor(recognizer: Parser); 6 | } -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/EOFSuffixInFirstRule_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' EOF ; 4 | B : 'a'; 5 | C : 'c'; 6 | 7 | [input] 8 | a 9 | 10 | [output] 11 | [@0,0:0='a',<1>,1:0] 12 | [@1,1:0='',<-1>,1:1] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyTermination2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | STRING : '!' ('!!' | .)+? '!'; 4 | 5 | [input] 6 | !!!mom! 7 | 8 | [output] 9 | [@0,0:6='!!!mom!',<1>,1:0] 10 | [@1,7:6='',<-1>,1:7] 11 | 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletion.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aab 10 | 11 | [errors] 12 | """line 1:1 extraneous input 'a' expecting 'b' 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/StarLexerSingleElement_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : 'b'* 'c' ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | bbbbc 11 | 12 | [output] 13 | """bbbbc 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/helpers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2020", 4 | "moduleResolution": "node", 5 | "target": "ES6", 6 | "noImplicitAny": true, 7 | }, 8 | "ts-node": { 9 | "esm": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/FileStream.d.ts: -------------------------------------------------------------------------------- 1 | import {CharStream} from "./CharStream"; 2 | 3 | export declare class FileStream extends CharStream { 4 | 5 | fileName: string; 6 | 7 | constructor(fileName: string, encoding?: string, decodeToUnicodeCodePoints?: boolean); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/misc/Interval.d.ts: -------------------------------------------------------------------------------- 1 | import {Token} from "../Token"; 2 | 3 | export declare class Interval { 4 | 5 | start: number; 6 | stop: number; 7 | 8 | constructor(start: number, stop: number); 9 | constructor(start: Token, stop: Token | undefined); 10 | } 11 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './RuleNode'; 2 | export * from './ErrorNode'; 3 | export * from './TerminalNode'; 4 | export * from './ParseTree'; 5 | export * from './ParseTreeListener'; 6 | export * from './ParseTreeVisitor'; 7 | export * from './ParseTreeWalker'; 8 | 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/EscapedCharacters.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | LF : '\\u000A'; 4 | X : 'x'; 5 | 6 | [input] 7 | """x 8 | """ 9 | 10 | [output] 11 | [@0,0:0='x',<2>,1:0] 12 | [@1,1:1='\n',<1>,1:1] 13 | [@2,2:1='',<-1>,2:0] 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AStar_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ID* { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | 14 | 15 | [output] 16 | """ 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/TerminalNode.d.ts: -------------------------------------------------------------------------------- 1 | import {ParserRuleContext} from "../context"; 2 | import {ParseTree} from "./ParseTree"; 3 | import {Token} from "../Token"; 4 | 5 | export declare class TerminalNode extends ParseTree { 6 | symbol: Token; 7 | parentCtx: ParserRuleContext; 8 | } 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/LL2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b' 4 | | 'a' 'c' 5 | ; 6 | q : 'e' ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | ae 13 | 14 | [errors] 15 | """line 1:1 no viable alternative at input 'ae' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/MultiTokenDeletionBeforeLoop.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b'* 'c'; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aacabc 10 | 11 | [errors] 12 | """line 1:1 extraneous input 'a' expecting {'b', 'c'} 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Labels.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : b1=b b2+=b* b3+=';' ; 4 | b : id_=ID val+=INT*; 5 | ID : 'a'..'z'+ ; 6 | INT : '0'..'9'+; 7 | WS : (' '|'\n') -> skip ; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | abc 34; 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/README.md: -------------------------------------------------------------------------------- 1 | # Runtime test mechanism 2 | 3 | The files in the various target subdirectories were automatically generated 4 | and exist as a convenience so that we can test individual targets and also 5 | groups of tests using the development environments like Intellij. -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNDeserializer.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNDeserializationOptions} from "./ATNDeserializationOptions"; 2 | import {ATN} from "./ATN"; 3 | 4 | export declare class ATNDeserializer { 5 | constructor(options?: ATNDeserializationOptions); 6 | deserialize(data: number[]) : ATN; 7 | } 8 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar SimpleParser; 2 | options { 3 | // get token types from SimpleLexer.tokens; don't name it 4 | // SimpleParser.tokens as ANTLR will overwrite! 5 | tokenVocab=SimpleLexer; 6 | } 7 | 8 | s : ( ID | INT )* SEMI ; 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionDuringLoop.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b'* 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ababbc 10 | 11 | [errors] 12 | """line 1:2 extraneous input 'a' expecting {'b', 'c'} 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionExpectingSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'c') ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aab 10 | 11 | [errors] 12 | """line 1:1 extraneous input 'a' expecting {'b', 'c'} 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/APlus.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ID+ { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | a b c 14 | 15 | [output] 16 | """abc 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AStar_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ID* { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | a b c 14 | 15 | [output] 16 | """abc 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorAStar_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|ID)* { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | 14 | 15 | [output] 16 | """ 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/CharSetLiteral.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (A {})+ ; 4 | A : [AaBb] ; 5 | WS : (' '|'\n')+ -> skip ; 6 | 7 | [start] 8 | a 9 | 10 | [input] 11 | A a B b 12 | 13 | [output] 14 | A 15 | a 16 | B 17 | b 18 | 19 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/TokenSource.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default class TokenSource {} 6 | 7 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/ErrorInMiddle.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'abc' ; 4 | 5 | [input] 6 | abx 7 | 8 | [output] 9 | """[@0,3:2='',<-1>,1:3] 10 | """ 11 | 12 | [errors] 13 | """line 1:0 token recognition error at: 'abx' 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetWithQuote1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : ["a-z]+ {} ; 4 | WS : [ \n\t]+ -> skip ; 5 | 6 | [input] 7 | b"a 8 | 9 | [output] 10 | A 11 | [@0,0:2='b"a',<1>,1:0] 12 | [@1,3:2='',<-1>,1:3] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyTermination1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | STRING : '!' ('!!' | .)*? '!'; 4 | 5 | [input] 6 | !hi!!mom! 7 | 8 | [output] 9 | [@0,0:3='!hi!',<1>,1:0] 10 | [@1,4:8='!mom!',<1>,1:4] 11 | [@2,9:8='',<-1>,1:9] 12 | 13 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/LL3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b'* 'c' 4 | | 'a' 'b' 'd' 5 | ; 6 | q : 'e' ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | abe 13 | 14 | [errors] 15 | """line 1:2 no viable alternative at input 'abe' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/LLStar.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a'+ 'b' 4 | | 'a'+ 'c' 5 | ; 6 | q : 'e' ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | aaae 13 | 14 | [errors] 15 | """line 1:3 no viable alternative at input 'aaae' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorAPlus.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|ID)+ { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | a b c 14 | 15 | [output] 16 | """abc 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/InvalidCharAtStart.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' 'b' ; 4 | 5 | [input] 6 | x 7 | 8 | [output] 9 | """[@0,1:0='',<-1>,1:1] 10 | """ 11 | 12 | [errors] 13 | """line 1:0 token recognition error at: 'x' 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/InvalidCharInToken.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' 'b' ; 4 | 5 | [input] 6 | ax 7 | 8 | [output] 9 | """[@0,2:1='',<-1>,1:2] 10 | """ 11 | 12 | [errors] 13 | """line 1:0 token recognition error at: 'ax' 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetNot.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : ~[ab \n] ~[ \ncd]* {} ; 4 | WS : [ \n\\u000D]+ -> skip ; 5 | 6 | [input] 7 | xaf 8 | 9 | [output] 10 | I 11 | [@0,0:2='xaf',<1>,1:0] 12 | [@1,3:2='',<-1>,1:3] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetWithQuote2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : ["\\\\ab]+ {} ; 4 | WS : [ \n\t]+ -> skip ; 5 | 6 | [input] 7 | b"\a 8 | 9 | [output] 10 | A 11 | [@0,0:3='b"\a',<1>,1:0] 12 | [@1,4:3='',<-1>,1:4] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/GreedyClosure.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '//' .*? '\n' CMT*; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:13='//blah\n//blah\n',<1>,1:0] 12 | [@1,14:13='',<-1>,3:0] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/GreedyOptional.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '//' .*? '\n' CMT?; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:13='//blah\n//blah\n',<1>,1:0] 12 | [@1,14:13='',<-1>,3:0] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorAStar_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|ID)* { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | WS : (' '|'\n') -> skip; 8 | 9 | [start] 10 | a 11 | 12 | [input] 13 | a b c 14 | 15 | [output] 16 | """abc 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTreeWalker.d.ts: -------------------------------------------------------------------------------- 1 | import {ParseTreeListener} from "./ParseTreeListener"; 2 | import {ParseTree} from "./ParseTree"; 3 | 4 | export declare class ParseTreeWalker { 5 | static DEFAULT: ParseTreeWalker; 6 | 7 | walk(listener: T, t: ParseTree): void; 8 | } 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetWithMissingEscapeChar.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : [0-9]+ {} ; 4 | WS : [ \n]+ -> skip ; 5 | 6 | [input] 7 | """34 """ 8 | 9 | [output] 10 | I 11 | [@0,0:1='34',<1>,1:0] 12 | [@1,3:2='',<-1>,1:3] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/GreedyConfigs.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : ('a' | 'ab') {} ; 4 | WS : (' '|'\n') -> skip ; 5 | J : .; 6 | 7 | [input] 8 | ab 9 | 10 | [output] 11 | ab 12 | [@0,0:1='ab',<1>,1:0] 13 | [@1,2:1='',<-1>,1:2] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/GreedyPositiveClosure.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : ('//' .*? '\n')+; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:13='//blah\n//blah\n',<1>,1:0] 12 | [@1,14:13='',<-1>,3:0] 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionBeforeAlt.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ('b' | 'c') 4 | ; 5 | q : 'a' 6 | ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | ac 13 | 14 | [errors] 15 | """line 1:0 extraneous input 'a' expecting {'b', 'c'} 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/ComplementSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | parse : ~NEW_LINE; 4 | NEW_LINE: '\\r'? '\\n'; 5 | 6 | [start] 7 | parse 8 | 9 | [input] 10 | a 11 | 12 | [errors] 13 | line 1:0 token recognition error at: 'a' 14 | line 1:1 missing {} at '' 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/SeqDoesNotBecomeSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : C {} ; 4 | fragment A : '1' | '2'; 5 | fragment B : '3' '4'; 6 | C : A | B; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | 34 13 | 14 | [output] 15 | """34 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/EnforcedGreedyNestedBraces_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ACTION : '{' (ACTION | ~[{}])* '}'; 4 | WS : [ \r\n\t]+ -> skip; 5 | 6 | [input] 7 | { { } } 8 | 9 | [output] 10 | [@0,0:6='{ { } }',<1>,1:0] 11 | [@1,7:6='',<-1>,1:7] 12 | 13 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/MultiTokenDeletionBeforeLoop2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'z'{})* 'c'; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aacabc 10 | 11 | [errors] 12 | """line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'} 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionDuringLoop2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'z'{})* 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ababbc 10 | 11 | [errors] 12 | """line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'} 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeNegatedBMPSetIncludesSMPCodePoints.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS {} ; 4 | LETTERS : 'a' ~('b')+ 'c'; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | a😳😡😝🤓c 11 | 12 | [output] 13 | """a😳😡😝🤓c 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionBeforePredict.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a'+ 'b' 4 | | 'a'+ 'c' 5 | ; 6 | q : 'e' ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | caaab 13 | 14 | [errors] 15 | """line 1:0 extraneous input 'c' expecting 'a' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Basic.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ID INT { 4 | 5 | }; 6 | ID : 'a'..'z'+ ; 7 | INT : '0'..'9'+; 8 | WS : (' '|'\n') -> skip; 9 | 10 | [start] 11 | a 12 | 13 | [input] 14 | abc 34 15 | 16 | [output] 17 | """abc34 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionBeforeLoop.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b'* EOF ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aabc 10 | 11 | [errors] 12 | line 1:1 extraneous input 'a' expecting {, 'b'} 13 | line 1:3 token recognition error at: 'c' 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeNegatedSMPSetIncludesBMPCodePoints.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS {} ; 4 | LETTERS : 'a' ~('\\u{1F600}'..'\\u{1F943}')+ 'c'; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | abc 11 | 12 | [output] 13 | """abc 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyClosure.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '//' .*? '\n' CMT*?; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:6='//blah\n',<1>,1:0] 12 | [@1,7:13='//blah\n',<1>,2:0] 13 | [@2,14:13='',<-1>,3:0] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorBStar_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|INT{ 4 | })* { 5 | 6 | }; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\\n') -> skip ; 10 | 11 | [start] 12 | a 13 | 14 | [input] 15 | 16 | 17 | [output] 18 | """ 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/LL1OptionalBlock_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|{}INT)? { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | INT : '0'..'9'+ ; 8 | WS : (' '|'\n') -> skip; 9 | 10 | [start] 11 | a 12 | 13 | [input] 14 | 15 | 16 | [output] 17 | """ 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/LL1OptionalBlock_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|{}INT)? { 4 | 5 | }; 6 | ID : 'a'..'z'+; 7 | INT : '0'..'9'+ ; 8 | WS : (' '|'\n') -> skip; 9 | 10 | [start] 11 | a 12 | 13 | [input] 14 | a 15 | 16 | [output] 17 | """a 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/ImportedGrammarWithEmptyOptions.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : a ; 5 | B : 'b' ; 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar S; 10 | options {} 11 | a : B ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | b 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/InvalidCharAtStartAfterDFACache.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' 'b' ; 4 | 5 | [input] 6 | abx 7 | 8 | [output] 9 | [@0,0:1='ab',<1>,1:0] 10 | [@1,3:2='',<-1>,1:3] 11 | 12 | [errors] 13 | """line 1:2 token recognition error at: 'x' 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/InvalidCharInTokenAfterDFACache.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'a' 'b' ; 4 | 5 | [input] 6 | abax 7 | 8 | [output] 9 | [@0,0:1='ab',<1>,1:0] 10 | [@1,4:3='',<-1>,1:4] 11 | 12 | [errors] 13 | """line 1:2 token recognition error at: 'ax' 14 | """ 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyOptional.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '//' .*? '\n' CMT??; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:6='//blah\n',<1>,1:0] 12 | [@1,7:13='//blah\n',<1>,2:0] 13 | [@2,14:13='',<-1>,3:0] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/StackoverflowDueToNotEscapedHyphen.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | https://github.com/antlr/antlr4/issues/1943 3 | 4 | [grammar] 5 | lexer grammar L; 6 | WORD : [a-z-+]+; 7 | 8 | [input] 9 | word 10 | 11 | [output] 12 | [@0,0:3='word',<1>,1:0] 13 | [@1,4:3='',<-1>,1:4] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorBPlus.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|INT{ 4 | })+ { 5 | 6 | }; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\\n') -> skip ; 10 | 11 | [start] 12 | a 13 | 14 | [input] 15 | a 34 c 16 | 17 | [output] 18 | """a34c 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/NotCharSetWithRuleRef3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : A {} ; 4 | A : ('a'|B) ; // this doesn't collapse to set but works 5 | fragment 6 | B : ~('a'|'c') ; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | x 13 | 14 | [output] 15 | """x 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './ATN'; 2 | export * from './ATNConfig'; 3 | export * from './ATNConfigSet'; 4 | export * from './ATNDeserializer'; 5 | export * from './LexerATNSimulator'; 6 | export * from './ParserATNSimulator'; 7 | export * from './PredictionMode'; 8 | export * from './PredictionContextCache'; 9 | 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : '0'..'9'+ {} ; 4 | WS : [ \n\\u000D] -> skip ; 5 | 6 | [input] 7 | """34 8 | 34""" 9 | 10 | [output] 11 | I 12 | I 13 | [@0,0:1='34',<1>,1:0] 14 | [@1,4:5='34',<1>,2:1] 15 | [@2,6:5='',<-1>,2:3] 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetInSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : (~[ab \\n]|'a') {} ; 4 | WS : [ \n\\u000D]+ -> skip ; 5 | 6 | [input] 7 | a x 8 | 9 | [output] 10 | I 11 | I 12 | [@0,0:0='a',<1>,1:0] 13 | [@1,2:2='x',<1>,1:2] 14 | [@2,3:2='',<-1>,1:3] 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyPositiveClosure.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : ('//' .*? '\n')+?; 4 | WS : (' '|'\t')+; 5 | 6 | [input] 7 | //blah 8 | //blah 9 | 10 | [output] 11 | [@0,0:6='//blah\n',<1>,1:0] 12 | [@1,7:13='//blah\n',<1>,2:0] 13 | [@2,14:13='',<-1>,3:0] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/MultiTokenDeletionDuringLoop.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' 'b'* 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | abaaababc 10 | 11 | [errors] 12 | line 1:2 extraneous input 'a' expecting {'b', 'c'} 13 | line 1:6 extraneous input 'a' expecting {'b', 'c'} 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorBStar_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : (ID|INT{ 4 | })* { 5 | 6 | }; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\\n') -> skip ; 10 | 11 | [start] 12 | a 13 | 14 | [input] 15 | a 34 c 16 | 17 | [output] 18 | """a34c 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/uStartingCharDoesNotCauseIllegalUnicodeEscape.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | Test for https://github.com/antlr/antlr4/issues/4128 3 | 4 | [grammar] 5 | grammar u; 6 | u : 'u' {}; 7 | 8 | [start] 9 | u 10 | 11 | [input] 12 | u 13 | 14 | [output] 15 | """u 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/context/index.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import PredictionContext from './PredictionContext.js'; 6 | 7 | export default { PredictionContext } 8 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/FailedPredicateException.d.ts: -------------------------------------------------------------------------------- 1 | import {RecognitionException} from "./RecognitionException"; 2 | import {Parser} from "../Parser"; 3 | 4 | export declare class FailedPredicateException extends RecognitionException { 5 | 6 | constructor(recognizer: Parser, predicate: string | undefined, message: string | undefined); 7 | } 8 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Simple_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : a ; 4 | a : a ID 5 | | ID 6 | ; 7 | ID : 'a'..'z'+ ; 8 | WS : (' '|'\n') -> skip ; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | x 15 | 16 | [output] 17 | """(s (a x)) 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetPlus.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : '0'..'9'+ {} ; 4 | WS : [ \n\\u000D]+ -> skip ; 5 | 6 | [input] 7 | """34 8 | 34""" 9 | 10 | [output] 11 | I 12 | I 13 | [@0,0:1='34',<1>,1:0] 14 | [@1,4:5='34',<1>,2:1] 15 | [@2,6:5='',<-1>,2:3] 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/BringInLiteralsFromDelegate.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : a ; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | parser grammar S; 9 | a : '=' 'a' {}; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | =a 16 | 17 | [output] 18 | """S.a""" -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/Token2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : 'x' 'y' 12 | ; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | xy 19 | 20 | [output] 21 | """(a x y) 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/TwoAlts.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : 'x' | 'y' 12 | ; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | y 19 | 20 | [output] 21 | """(a y) 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/NoViableAltAvoidance.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : e '!' ; 4 | e : 'a' 'b' 5 | | 'a' 6 | ; 7 | DOT : '.' ; 8 | WS : [ \t\r\n]+ -> skip; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | a. 15 | 16 | [errors] 17 | """line 1:1 mismatched input '.' expecting '!' 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionBeforeLoop2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'z'{})* EOF ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | aabc 10 | 11 | [errors] 12 | line 1:1 extraneous input 'a' expecting {, 'b', 'z'} 13 | line 1:3 token recognition error at: 'c' 14 | 15 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/SyntaxTree.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import Tree from "./Tree.js"; 6 | 7 | export default class SyntaxTree extends Tree { 8 | } 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/valueToString.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default function valueToString(v) { 6 | return v === null ? "null" : v; 7 | } 8 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Simple_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : a ; 4 | a : a ID 5 | | ID 6 | ; 7 | ID : 'a'..'z'+ ; 8 | WS : (' '|'\n') -> skip ; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | x y 15 | 16 | [output] 17 | """(s (a (a x) y)) 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/StringsEmbeddedInActions_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ACTION2 : '[' (STRING | ~'"')*? ']'; 4 | STRING : '"' ('\\\\' '"' | .)*? '"'; 5 | WS : [ \t\r\n]+ -> skip; 6 | 7 | [input] 8 | ["foo"] 9 | 10 | [output] 11 | [@0,0:6='["foo"]',<1>,1:0] 12 | [@1,7:6='',<-1>,1:7] 13 | 14 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/analysis/AssocType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.analysis; 8 | 9 | public enum AssocType { 10 | left, 11 | right 12 | } 13 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Simple_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : a ; 4 | a : a ID 5 | | ID 6 | ; 7 | ID : 'a'..'z'+ ; 8 | WS : (' '|'\n') -> skip ; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | x y z 15 | 16 | [output] 17 | """(s (a (a (a x) y) z)) 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/ReservedWordsEscaping_NULL.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | https://github.com/antlr/antlr4/pull/3889 3 | 4 | [grammar] 5 | lexer grammar L; 6 | 7 | NULL : ('N' | 'n')('U' | 'u')('L' | 'l')('L' | 'l') ; 8 | 9 | [input] 10 | NULL 11 | 12 | [output] 13 | [@0,0:3='NULL',<1>,1:0] 14 | [@1,4:3='',<-1>,1:4] 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/AorB.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : ID { 4 | 5 | } | INT { 6 | 7 | }; 8 | ID : 'a'..'z'+ ; 9 | INT : '0'..'9'+; 10 | WS : (' '|'\\n') -> skip ; 11 | 12 | [start] 13 | a 14 | 15 | [input] 16 | 34 17 | 18 | [output] 19 | """alt 2 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/TokenStream.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | // this is just to keep meaningful parameter types to Parser 6 | export default class TokenStream {} 7 | 8 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorRuleOverridesDelegate.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | b : 'b'|'c'; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | parser grammar S; 9 | a : b {}; 10 | b : B ; 11 | 12 | [start] 13 | a 14 | 15 | [input] 16 | c 17 | 18 | [output] 19 | """S.a""" -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/ImportedRuleWithAction.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : a; 5 | B : 'b'; 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar S; 10 | a @after {} : B; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | b 17 | 18 | [skip] 19 | Go 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/UnicodeCharSet.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | regression test for antlr/antlr4#1925 3 | 4 | [grammar] 5 | lexer grammar L; 6 | ID : ([A-Z_]|'Ā'..'\uFFFC') ([A-Z_0-9]|'Ā'..'\uFFFC')*; // FFFD+ are not valid char 7 | 8 | [input] 9 | 均 10 | 11 | [output] 12 | [@0,0:0='均',<1>,1:0] 13 | [@1,1:0='',<-1>,1:1] 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/MultiTokenDeletionDuringLoop2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' ('b'|'z'{})* 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | abaaababc 10 | 11 | [errors] 12 | line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'} 13 | line 1:6 extraneous input 'a' expecting {'b', 'z', 'c'} 14 | 15 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/java/api/VisitorCalc.g4: -------------------------------------------------------------------------------- 1 | grammar VisitorCalc; 2 | 3 | s 4 | : expr EOF 5 | ; 6 | 7 | expr 8 | : INT # number 9 | | expr (MUL | DIV) expr # multiply 10 | | expr (ADD | SUB) expr # add 11 | ; 12 | 13 | INT : [0-9]+; 14 | MUL : '*'; 15 | DIV : '/'; 16 | ADD : '+'; 17 | SUB : '-'; 18 | WS : [ \t]+ -> channel(HIDDEN); 19 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/ErrorListener.d.ts: -------------------------------------------------------------------------------- 1 | import {Recognizer} from "../Recognizer"; 2 | import {RecognitionException} from "./RecognitionException"; 3 | 4 | export declare class ErrorListener { 5 | syntaxError(recognizer: Recognizer, offendingSymbol: TSymbol, line: number, column: number, msg: string, e: RecognitionException | undefined): void; 6 | } 7 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTree.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import SyntaxTree from "./SyntaxTree.js"; 6 | 7 | export default class ParseTree extends SyntaxTree { 8 | } 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/DFAToATNThatFailsBackToDFA.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'ab' ; 4 | B : 'abc' ; 5 | 6 | [input] 7 | ababx 8 | 9 | [output] 10 | [@0,0:1='ab',<1>,1:0] 11 | [@1,2:3='ab',<1>,1:2] 12 | [@2,5:4='',<-1>,1:5] 13 | 14 | [errors] 15 | """line 1:4 token recognition error at: 'x' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetWithEscapedChar.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | DASHBRACK : [\\-\]]+ {} ; 4 | WS : [ \n]+ -> skip ; 5 | 6 | [input] 7 | """- ] """ 8 | 9 | [output] 10 | DASHBRACK 11 | DASHBRACK 12 | [@0,0:0='-',<1>,1:0] 13 | [@1,2:2=']',<1>,1:2] 14 | [@2,4:3='',<-1>,1:4] 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/NonGreedyConfigs.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : .*? ('a' | 'ab') {} ; 4 | WS : (' '|'\n') -> skip ; 5 | J : . {}; 6 | 7 | [input] 8 | ab 9 | 10 | [output] 11 | a 12 | b 13 | [@0,0:0='a',<1>,1:0] 14 | [@1,1:1='b',<3>,1:1] 15 | [@2,2:1='',<-1>,1:2] 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/RefToRuleDoesNotSetTokenNorEmitAnother.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : '-' I ; 4 | I : '0'..'9'+ ; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [input] 8 | 34 -21 3 9 | 10 | [output] 11 | [@0,0:1='34',<2>,1:0] 12 | [@1,3:5='-21',<1>,1:3] 13 | [@2,7:7='3',<2>,1:7] 14 | [@3,8:7='',<-1>,1:8] 15 | 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ErrorNode.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import TerminalNode from "./TerminalNode.js"; 6 | 7 | export default class ErrorNode extends TerminalNode { 8 | } 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/TerminalNode.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ParseTree from "./ParseTree.js"; 6 | 7 | export default class TerminalNode extends ParseTree { 8 | } 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/standardEqualsFunction.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default function standardEqualsFunction(a, b) { 6 | return a ? a.equals(b) : a===b; 7 | } 8 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/dbg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model; 8 | 9 | /** */ 10 | public class dbg extends OutputModelObject { 11 | } 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/SemPred.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : a ; 4 | a : a {}? ID 5 | | ID 6 | ; 7 | ID : 'a'..'z'+ ; 8 | WS : (' '|'\n') -> skip ; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | x y z 15 | 16 | [output] 17 | """(s (a (a (a x) y) z)) 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/EnforcedGreedyNestedBraces_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ACTION : '{' (ACTION | ~[{}])* '}'; 4 | WS : [ \r\n\t]+ -> skip; 5 | 6 | [input] 7 | { { } 8 | 9 | [output] 10 | """[@0,5:4='',<-1>,1:5] 11 | """ 12 | 13 | [errors] 14 | """line 1:0 token recognition error at: '{ { }' 15 | """ 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/RuleRef.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : b 'x' 12 | ; 13 | b : 'y' 14 | ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | yx 21 | 22 | [output] 23 | """(a (b y) x) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/atn/ATNType.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.runtime.core.atn 2 | 3 | /** 4 | * Represents the type of recognizer an ATN applies to. 5 | * 6 | * @author Sam Harwell 7 | */ 8 | public enum class ATNType { 9 | /** 10 | * A lexer grammar. 11 | */ 12 | LEXER, 13 | 14 | /** 15 | * A parser grammar. 16 | */ 17 | PARSER, 18 | } -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/context/RuleContext.d.ts: -------------------------------------------------------------------------------- 1 | import {RuleNode} from "../tree"; 2 | import {Parser} from "../Parser"; 3 | 4 | export declare class RuleContext extends RuleNode { 5 | parentCtx: RuleContext | undefined; 6 | invokingState: number; 7 | 8 | get ruleContext() : RuleContext; 9 | toStringTree(ruleNames: string[] | null, recog: Parser) : string; 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | tab_width = 4 5 | 6 | [*.{java,stg}] 7 | charset = utf-8 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | indent_style = tab 11 | ij_java_else_on_new_line = true 12 | 13 | [*.{h,cpp}] 14 | charset = utf-8 15 | insert_final_newline = true 16 | trim_trailing_whitespace = true 17 | indent_style = space 18 | indent_size = 2 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/TwoAltLoop.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : ('x' | 'y')* 'z' 12 | ; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | xyyxyxz 19 | 20 | [output] 21 | """(a x y y x y x z) 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/ConjuringUpToken.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' x='b' {} 'c' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ac 10 | 11 | [output] 12 | """conjured=[@-1,-1:-1='',<2>,1:1] 13 | """ 14 | 15 | [errors] 16 | """line 1:1 missing 'b' at 'c' 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/kotlin/helpers/RuntimeTestLexer.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.kotlin.helpers 2 | 3 | import org.antlr.v5.runtime.core.CharStream 4 | import org.antlr.v5.runtime.core.Lexer 5 | import java.io.PrintStream 6 | 7 | abstract class RuntimeTestLexer(input: CharStream) : Lexer(input) { 8 | var outStream: PrintStream = System.out 9 | } 10 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/kotlin/helpers/RuntimeTestParser.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.kotlin.helpers 2 | 3 | import org.antlr.v5.runtime.core.TokenStream 4 | import org.antlr.v5.runtime.core.Parser 5 | 6 | abstract class RuntimeTestParser(input: TokenStream) : Parser(input) { 7 | var outStream: RuntimeTestPrintStream = RuntimeTestPrintStream(System.out) 8 | } 9 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/tree/ErrorNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.tree 8 | 9 | public interface ErrorNode : TerminalNode 10 | -------------------------------------------------------------------------------- /scripts/parse-extended-pictographic/README.md: -------------------------------------------------------------------------------- 1 | README for scripts/extended-pictographic 2 | =========== 3 | 4 | This directory contains the Unicode UTS #35 `ExtendedPictographic.txt` data file, 5 | intended to be parsed by the script `parse.py` to produce `ExtendedPictographic-Parsed.txt`. 6 | 7 | This produces a series of `IntervalSet` entries to be consumed by 8 | `UnicodeDataTemplateController`. 9 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestBaseLexer; 2 | 3 | tokens { Name } 4 | 5 | // Default "mode": Everything OUTSIDE of a tag 6 | Comment : '' ; 7 | CDSect : '' ; 8 | 9 | fragment 10 | Whitespace : ' ' | '\n' | '\t' | '\r' ; 11 | 12 | fragment 13 | Hexdigit : [a-fA-F0-9] ; -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalLexer/RuleSempredFunction.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | Test for https://github.com/antlr/antlr4/issues/958 3 | 4 | [grammar] 5 | lexer grammar L; 6 | T : 'a' {}? ; 7 | 8 | [input] 9 | aaa 10 | 11 | [output] 12 | [@0,0:0='a',<1>,1:0] 13 | [@1,1:1='a',<1>,1:1] 14 | [@2,2:2='a',<1>,1:2] 15 | [@3,3:2='',<-1>,1:3] 16 | 17 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/analysis/AltType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.analysis; 8 | 9 | public enum AltType { 10 | other, 11 | binaryLR, 12 | suffixLR, 13 | prefix, 14 | } 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Optional_1.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test is meant to detect regressions of bug antlr/antlr4#41. 3 | https://github.com/antlr/antlr4/issues/41 4 | 5 | [grammar] 6 | grammar T; 7 | stat : ifstat | 'x'; 8 | ifstat : 'if' stat ('else' stat)?; 9 | WS : [ \n\t]+ -> skip ; 10 | 11 | [start] 12 | stat 13 | 14 | [input] 15 | x 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Optional_2.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test is meant to detect regressions of bug antlr/antlr4#41. 3 | https://github.com/antlr/antlr4/issues/41 4 | 5 | [grammar] 6 | grammar T; 7 | stat : ifstat | 'x'; 8 | ifstat : 'if' stat ('else' stat)?; 9 | WS : [ \n\t]+ -> skip ; 10 | 11 | [start] 12 | stat 13 | 14 | [input] 15 | if x 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/Stage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.test.runtime; 8 | 9 | public enum Stage { 10 | Generate, 11 | Compile, 12 | Execute 13 | } 14 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/nativeMain/kotlin/org/antlr/v4/kotlinruntime/CharStreams.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.kotlinruntime 7 | 8 | public actual object CharStreams : AbstractCharStreams() 9 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmJsMain/kotlin/com/strumenta/antlrkotlin/runtime/BitSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | public actual typealias BitSet = SimpleBitSet 9 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmWasiMain/kotlin/com/strumenta/antlrkotlin/runtime/BitSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | public actual typealias BitSet = SimpleBitSet 9 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmWasiMain/kotlin/org/antlr/v4/kotlinruntime/CharStreams.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.kotlinruntime 7 | 8 | public actual object CharStreams : AbstractCharStreams() 9 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/kotlin/KotlinRuntimeTests.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.kotlin; 2 | 3 | import org.antlr.v5.test.runtime.RuntimeRunner; 4 | import org.antlr.v5.test.runtime.RuntimeTests; 5 | 6 | public class KotlinRuntimeTests extends RuntimeTests { 7 | @Override 8 | protected RuntimeRunner createRuntimeRunner() { 9 | return new KotlinRunner(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/ATNType.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | /** 7 | * Represents the type of recognizer an ATN applies to 8 | */ 9 | export default { 10 | LEXER: 0, 11 | PARSER: 1 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/DFAToATNThatMatchesThenFailsInATN.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | A : 'ab' ; 4 | B : 'abc' ; 5 | C : 'abcd' ; 6 | 7 | [input] 8 | ababcx 9 | 10 | [output] 11 | [@0,0:1='ab',<1>,1:0] 12 | [@1,2:4='abc',<2>,1:2] 13 | [@2,6:5='',<-1>,1:6] 14 | 15 | [errors] 16 | """line 1:5 token recognition error at: 'x' 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/ConjuringUpTokenFromSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : 'a' x=('b'|'c') {} 'd' ; 4 | 5 | [start] 6 | a 7 | 8 | [input] 9 | ad 10 | 11 | [output] 12 | """conjured=[@-1,-1:-1='',<2>,1:1] 13 | """ 14 | 15 | [errors] 16 | """line 1:1 missing {'b', 'c'} at 'd' 17 | """ 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Optional_3.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test is meant to detect regressions of bug antlr/antlr4#41. 3 | https://github.com/antlr/antlr4/issues/41 4 | 5 | [grammar] 6 | grammar T; 7 | stat : ifstat | 'x'; 8 | ifstat : 'if' stat ('else' stat)?; 9 | WS : [ \n\t]+ -> skip ; 10 | 11 | [start] 12 | stat 13 | 14 | [input] 15 | if x else x 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Optional_4.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test is meant to detect regressions of bug antlr/antlr4#41. 3 | https://github.com/antlr/antlr4/issues/41 4 | 5 | [grammar] 6 | grammar T; 7 | stat : ifstat | 'x'; 8 | ifstat : 'if' stat ('else' stat)?; 9 | WS : [ \n\t]+ -> skip ; 10 | 11 | [start] 12 | stat 13 | 14 | [input] 15 | if if x else x 16 | 17 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/OSType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.test.runtime; 8 | 9 | public enum OSType { 10 | Windows, 11 | Linux, 12 | Mac, 13 | Unknown 14 | } 15 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/jsAndWasmSharedMain/kotlin/org/antlr/v5/kotlinruntime/CharStreams.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.kotlinruntime 7 | 8 | public actual object CharStreams : AbstractCharStreams() 9 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/LabelsOnOpSubrule_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e; 4 | e : a=e op=('*'|'/') b=e {} 5 | | INT {} 6 | | '(' x=e ')' {} 7 | ; 8 | INT : '0'..'9'+ ; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | 4 16 | 17 | [output] 18 | """(s (e 4)) 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/Slashes.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | Backslash : '\\\\'; 4 | Slash : '/'; 5 | Vee : '\\\\/'; 6 | Wedge : '/\\\\'; 7 | WS : [ \t] -> skip; 8 | 9 | [input] 10 | \ / \/ /\ 11 | 12 | [output] 13 | [@0,0:0='\',<1>,1:0] 14 | [@1,2:2='/',<2>,1:2] 15 | [@2,4:5='\/',<3>,1:4] 16 | [@3,7:8='/\',<4>,1:7] 17 | [@4,9:8='',<-1>,1:9] 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/BuildParseTree_TRUE.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | r 5 | : a b {} 6 | ; 7 | a 8 | : A 9 | ; 10 | b 11 | : B 12 | ; 13 | A : 'A'; 14 | B : 'B'; 15 | WS : [ \r\n\t]+ -> skip ; 16 | 17 | [start] 18 | r 19 | 20 | [input] 21 | A B 22 | 23 | [output] 24 | """(r (a A) (b B)) 25 | """ 26 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/nativeMain/kotlin/com/strumenta/antlrkotlin/runtime/BitSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package com.strumenta.antlrkotlin.runtime 8 | 9 | public actual typealias BitSet = SimpleBitSet 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/MultipleEOFHandling.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test ensures that {@link ParserATNSimulator} produces a correct 3 | result when the grammar contains multiple explicit references to 4 | {@code EOF} inside of parser rules. 5 | 6 | [grammar] 7 | grammar T; 8 | prog : ('x' | 'x' 'y') EOF EOF; 9 | 10 | [start] 11 | prog 12 | 13 | [input] 14 | x 15 | 16 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeUnescapedBMPSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS {} ; 4 | // These are actually not escaped -- Java passes the 5 | // raw unescaped Unicode values to the grammar compiler. 6 | LETTERS : ('a'|'ä'|'亜'|'あ')* 'c'; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | aäあ亜c 13 | 14 | [output] 15 | """aäあ亜c 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerErrors/StringsEmbeddedInActions_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ACTION2 : '[' (STRING | ~'"')*? ']'; 4 | STRING : '"' ('\\\\' '"' | .)*? '"'; 5 | WS : [ \t\r\n]+ -> skip; 6 | 7 | [input] 8 | ["foo] 9 | 10 | [output] 11 | """[@0,6:5='',<-1>,1:6] 12 | """ 13 | 14 | [errors] 15 | """line 1:0 token recognition error at: '["foo]' 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/ToLeft.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a+ ; 4 | a : {}? ID {} 5 | | {}? ID {} 6 | ; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | x x y 16 | 17 | [output] 18 | alt 2 19 | alt 2 20 | alt 2 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeEscapedBMPRangeSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS* 'd' {} ; 4 | // Note the double-backslash to avoid Java passing 5 | // unescaped values as part of the grammar. 6 | LETTERS : ('a'|'\\u00E0'..'\\u00E5'); 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | aáäáâåd 13 | 14 | [output] 15 | """aáäáâåd 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeEscapedBMPSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS {} ; 4 | // Note the double-backslash to avoid Java passing 5 | // unescaped values as part of the grammar. 6 | LETTERS : ('a'|'\\u00E4'|'\\u4E9C'|'\\u3042')* 'c'; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | aäあ亜c 13 | 14 | [output] 15 | """aäあ亜c 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/kotlin/helpers/RuntimeTestPrintStream.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.kotlin.helpers 2 | 3 | import org.antlr.v5.runtime.core.IPrintStream 4 | 5 | class RuntimeTestPrintStream(outStream: java.io.OutputStream) : 6 | java.io.PrintStream(outStream), 7 | IPrintStream { 8 | override fun printLine(value: String?) { 9 | super.println(value) 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/BitSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.jvm 8 | 9 | import java.util.BitSet as JavaBitSet 10 | 11 | public typealias BitSet = JavaBitSet 12 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/misc/Predicate.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.misc 8 | 9 | public interface Predicate { 10 | public fun test(t: T): Boolean 11 | } 12 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/automata/CharactersDataCheckStatus.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.automata; 2 | 3 | public class CharactersDataCheckStatus { 4 | public final boolean collision; 5 | public final boolean notImpliedCharacters; 6 | 7 | public CharactersDataCheckStatus(boolean collision, boolean notImpliedCharacters) { 8 | this.collision = collision; 9 | this.notImpliedCharacters = notImpliedCharacters; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/CombinedImportsCombined.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : x INT; 5 | 6 | [slaveGrammar] 7 | parser grammar S; 8 | tokens { A, B, C } 9 | x : 'x' INT {}; 10 | INT : '0'..'9'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | x 34 9 18 | 19 | [output] 20 | """S.x 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorInvokesDelegateRule.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : a ; 5 | B : 'b' ; // defines B from inherited token space 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar S; 10 | a : B {}; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | b 17 | 18 | [output] 19 | """S.a 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeEscapedSMPRangeSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS* 'd' {} ; 4 | // Note the double-backslash to avoid Java passing 5 | // unescaped values as part of the grammar. 6 | LETTERS : ('a'|'\\u{1F600}'..'\\u{1F943}'); 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | a😉🥂🜀d 13 | 14 | [output] 15 | """a😉🥂🜀d 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeUnescapedBMPRangeSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS* 'd' {} ; 4 | // These are actually not escaped -- Java passes the 5 | // raw unescaped Unicode values to the grammar compiler. 6 | LETTERS : ('a'|'à'..'å'); 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | aáäáâåd 13 | 14 | [output] 15 | """aáäáâåd 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/CopyOnWriteArrayList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.runtime.core.jvm 7 | 8 | public typealias CopyOnWriteArrayList = java.util.concurrent.CopyOnWriteArrayList 9 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './RecognitionException'; 2 | export * from './NoViableAltException'; 3 | export * from './FailedPredicateException'; 4 | export * from './InputMismatchException'; 5 | export * from './ErrorStrategy'; 6 | export * from './BailErrorStrategy'; 7 | export * from './DefaultErrorStrategy'; 8 | export * from './ErrorListener'; 9 | export * from './DiagnosticErrorListener'; 10 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/misc/IntervalSet.d.ts: -------------------------------------------------------------------------------- 1 | import {Interval} from "./Interval"; 2 | 3 | export declare class IntervalSet { 4 | 5 | isNil: boolean; 6 | size: number; 7 | minElement: number; 8 | maxElement: number; 9 | intervals: Interval[]; 10 | 11 | contains(i: number): boolean; 12 | toString(literalNames?: (string | null)[], symbolicNames?: string[], elemsAreChar?: boolean): string; 13 | } 14 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/index.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import arrayToString from "./arrayToString.js"; 6 | import stringToCharArray from "./stringToCharArray.js"; 7 | 8 | export default { arrayToString, stringToCharArray }; 9 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/tool/ast/RuleElementAST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.tool.ast; 8 | 9 | /** Tag indicated AST node is a rule element like token or rule ref. */ 10 | public interface RuleElementAST { 11 | } 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalLexer/IDnotEnum.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ENUM : [a-z]+ { }? ; 4 | ID : [a-z]+ ; 5 | WS : (' '|'\n') -> skip; 6 | 7 | [input] 8 | enum abc enum 9 | 10 | [output] 11 | [@0,0:3='enum',<2>,1:0] 12 | [@1,5:7='abc',<2>,1:5] 13 | [@2,9:12='enum',<2>,1:9] 14 | [@3,13:12='',<-1>,1:13] 15 | s0-' '->:s2=>3 16 | 17 | [flags] 18 | showDFA 19 | 20 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/CommonTokenStream.d.ts: -------------------------------------------------------------------------------- 1 | import {Lexer} from "./Lexer"; 2 | import {BufferedTokenStream} from "./BufferedTokenStream"; 3 | import {Token} from "./Token"; 4 | 5 | export declare class CommonTokenStream extends BufferedTokenStream { 6 | // properties 7 | tokens: Token[]; 8 | // methods 9 | constructor(lexer: Lexer); 10 | constructor(lexer: Lexer, channel: number); 11 | fill(): void; 12 | } 13 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/gui/TreeTextProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.gui; 8 | 9 | import org.antlr.v5.runtime.core.tree.Tree; 10 | 11 | public interface TreeTextProvider { 12 | String getText(Tree node); 13 | } 14 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/KeywordVSIDOrder.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | a : A {}; 5 | A : 'abc' {}; 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | lexer grammar S; 10 | ID : 'a'..'z'+; 11 | 12 | [start] 13 | a 14 | 15 | [input] 16 | abc 17 | 18 | [output] 19 | M.A 20 | M.a: [@0,0:2='abc',<1>,1:0] 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/LabelsOnOpSubrule_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e; 4 | e : a=e op=('*'|'/') b=e {} 5 | | INT {} 6 | | '(' x=e ')' {} 7 | ; 8 | INT : '0'..'9'+ ; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | 1*2/3 16 | 17 | [output] 18 | """(s (e (e (e 1) * (e 2)) / (e 3))) 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/EscapeTargetStringLiteral.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#2709 "PHP target generates 3 | invalid output when $ is used as part of the literal in lexer rule" 4 | https://github.com/antlr/antlr4/issues/2709 5 | 6 | [grammar] 7 | lexer grammar L; 8 | ACTION_WITH_DOLLAR: '$ACTION'; 9 | 10 | [output] 11 | """[@0,0:-1='',<-1>,1:0] 12 | """ 13 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/ReservedWordsEscaping.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | https://github.com/antlr/antlr4/issues/1070 3 | 4 | [grammar] 5 | lexer grammar L; 6 | 7 | channels { break } 8 | 9 | A: 'a' -> mode(for); 10 | 11 | mode for; 12 | B: 'b' -> channel(break); 13 | 14 | [input] 15 | ab 16 | 17 | [output] 18 | [@0,0:0='a',<1>,1:0] 19 | [@1,1:1='b',<2>,channel=2,1:1] 20 | [@2,2:1='',<-1>,1:2] 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/InvalidEmptyInput.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for #6 "NullPointerException in getMissingSymbol". 3 | https://github.com/antlr/antlr4/issues/6 4 | 5 | [grammar] 6 | grammar T; 7 | start : ID+; 8 | ID : [a-z]+; 9 | 10 | [start] 11 | start 12 | 13 | [input] 14 | 15 | 16 | [errors] 17 | """line 1:0 mismatched input '' expecting ID 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/BuildParseTree_FALSE.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | r 5 | : a b {} 6 | ; 7 | a 8 | : A 9 | ; 10 | b 11 | : B 12 | ; 13 | A : 'A'; 14 | B : 'B'; 15 | WS : [ \r\n\t]+ -> skip ; 16 | 17 | [start] 18 | r 19 | 20 | [input] 21 | A B 22 | 23 | [output] 24 | """r 25 | """ 26 | 27 | [flags] 28 | notBuildParseTree 29 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/tool/ast/QuantifierAST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.tool.ast; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public interface QuantifierAST { 14 | 15 | boolean isGreedy(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestBaseLexer; 2 | 3 | tokens { Name } 4 | 5 | // Default "mode": Everything OUTSIDE of a tag 6 | Comment : '' ; 7 | CDSect : '' ; 8 | 9 | fragment 10 | Whitespace : ' ' | '\n' | '\t' | '\r' ; 11 | 12 | fragment 13 | Hexdigit : [a-fA-F0-9] ; 14 | 15 | fragment 16 | Digit : [0-9] ; 17 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar TestBaseLexer; 2 | 3 | tokens { Name } 4 | 5 | // Default "mode": Everything OUTSIDE of a tag 6 | Comment : '' ; 7 | CDSect : '' ; 8 | 9 | fragment 10 | Whitespace : ' ' | '\n' | '\t' | '\r' ; 11 | 12 | fragment 13 | Hexdigit : [a-fA-F0-9] ; 14 | 15 | fragment 16 | Digit : [0-9] ; 17 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/Synchronized.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.runtime.core.jvm 7 | 8 | public inline fun synchronized(lock: Any, block: () -> R): R = 9 | kotlin.synchronized(lock, block) 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/LabelsOnOpSubrule_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e; 4 | e : a=e op=('*'|'/') b=e {} 5 | | INT {} 6 | | '(' x=e ')' {} 7 | ; 8 | INT : '0'..'9'+ ; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | (1/2)*3 16 | 17 | [output] 18 | """(s (e (e ( (e (e 1) / (e 2)) )) * (e 3))) 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/TokenAndRuleContextString.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | 5 | s 6 | @init { 7 | 8 | } 9 | @after { 10 | 11 | } 12 | : r=a ; 13 | a : 'x' { 14 | 15 | } ; 16 | 17 | [start] 18 | s 19 | 20 | [input] 21 | x 22 | 23 | [output] 24 | [a, s] 25 | (a x) 26 | 27 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalLexer/EnumNotID.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ENUM : [a-z]+ { }? ; 4 | ID : [a-z]+ ; 5 | WS : (' '|'\n') -> skip; 6 | 7 | [input] 8 | enum abc enum 9 | 10 | [output] 11 | [@0,0:3='enum',<1>,1:0] 12 | [@1,5:7='abc',<2>,1:5] 13 | [@2,9:12='enum',<1>,1:9] 14 | [@3,13:12='',<-1>,1:13] 15 | s0-' '->:s3=>3 16 | 17 | [flags] 18 | showDFA 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/SimpleValidate.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a ; 4 | a : {}? ID {} 5 | | {}? INT {} 6 | ; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | x 16 | 17 | [errors] 18 | """line 1:0 no viable alternative at input 'x' 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/titleCase.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default function titleCase(str) { 6 | return str.replace(/\w\S*/g, function (txt) { 7 | return txt.charAt(0).toUpperCase() + txt.substr(1); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/LexerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen; 8 | 9 | /** */ 10 | public class LexerFactory extends DefaultOutputModelFactory { 11 | public LexerFactory(CodeGenerator gen) { super(gen); } 12 | } 13 | -------------------------------------------------------------------------------- /doc/faq/actions-preds.md: -------------------------------------------------------------------------------- 1 | # Actions and semantic predicates 2 | 3 | ## How do I test if an optional rule was matched? 4 | 5 | For optional rule references such as the initialization clause in the following 6 | 7 | ``` 8 | decl : 'var' ID (EQUALS expr)? ; 9 | ``` 10 | 11 | testing to see if that clause was matched can be done using `$EQUALS!=null` or `$expr.ctx!=null` where `$expr.ctx` points to the context or parse tree created for that reference to rule expr. -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorInvokesDelegateRuleWithReturnStruct.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : a {} ; 5 | B : 'b' ; // defines B from inherited token space 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar S; 10 | a : B {} ; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | b 17 | 18 | [output] 19 | """S.ab""" 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleSetInsertionConsumption.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | myset: ('b'|'c') ; 4 | a: 'a' myset 'd' {} ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | ad 11 | 12 | [output] 13 | """[@0,0:0='a',<3>,1:0] 14 | """ 15 | 16 | [errors] 17 | """line 1:1 missing {'b', 'c'} at 'd' 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/TokenInfo.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.codegen.model; 2 | 3 | public class TokenInfo { 4 | public final int type; 5 | public final String name; 6 | 7 | public TokenInfo(int type, String name) { 8 | this.type = type; 9 | this.name = name; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "TokenInfo{" + 15 | "type=" + type + 16 | ", name='" + name + '\'' + 17 | '}'; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/ExtraneousInput.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | member : 'a'; 5 | body : member*; 6 | file : body EOF; 7 | B : 'b'; 8 | 9 | [start] 10 | file 11 | 12 | [input] 13 | baa 14 | 15 | [output] 16 | 17 | [errors] 18 | """line 1:0 mismatched input 'b' expecting {, 'a'} 19 | """ 20 | 21 | [skip] 22 | Cpp 23 | CSharp 24 | Go 25 | JavaScript 26 | TypeScript 27 | PHP 28 | Python3 29 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/Wildcard.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | Match assignments, ignore other tokens with wildcard. 3 | 4 | [grammar] 5 | grammar T; 6 | a : (assign|.)+ EOF ; 7 | assign : ID '=' INT ';' { 8 | 9 | } ; 10 | ID : 'a'..'z'+ ; 11 | INT : '0'..'9'+; 12 | WS : (' '|'\n') -> skip; 13 | 14 | [start] 15 | a 16 | 17 | [input] 18 | x=10; abc;;;; y=99; 19 | 20 | [output] 21 | x=10; 22 | y=99; 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/RewindBeforePredEval.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a a; 4 | a : {}? ID INT {} 5 | | {}? ID INT {} 6 | ; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | y 3 x 4 16 | 17 | [output] 18 | alt 2 19 | alt 1 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/UnpredicatedPathsInAlt.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a {} 4 | | b {} 5 | ; 6 | a : {}? ID INT 7 | | ID INT 8 | ; 9 | b : ID ID 10 | ; 11 | ID : 'a'..'z'+ ; 12 | INT : '0'..'9'+; 13 | WS : (' '|'\n') -> skip ; 14 | 15 | [start] 16 | s 17 | 18 | [input] 19 | x 4 20 | 21 | [output] 22 | """alt 1 23 | """ 24 | 25 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeEscapedSMPSet.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS {} ; 4 | // Note the double-backslash to avoid Java passing 5 | // unescaped values as part of the grammar. 6 | LETTERS : ('a'|'\\u{1D5BA}'|'\\u{1D5BE}'|'\\u{1D5C2}'|'\\u{1D5C8}'|'\\u{1D5CE}')* 'c'; 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | a𝗂𝗎𝖺c 13 | 14 | [output] 15 | """a𝗂𝗎𝖺c 16 | """ 17 | 18 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/WeakHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.jvm 8 | 9 | import java.util.WeakHashMap as JavaWeakHashMap 10 | 11 | public typealias WeakHashMap = JavaWeakHashMap 12 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/CommonToken.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from "./Token"; 2 | import {InputStream} from "./InputStream"; 3 | import {TokenSource} from "./TokenSource"; 4 | 5 | export declare class CommonToken extends Token { 6 | constructor(source: [ TokenSource, InputStream ], type: number, channel: number, start: number, stop: number); 7 | clone(): CommonToken; 8 | cloneWithType(type: number): CommonToken; 9 | toString(): string; 10 | } 11 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/NoViableAltException.d.ts: -------------------------------------------------------------------------------- 1 | import {ATNConfigSet} from "../atn"; 2 | import {Recognizer} from "../Recognizer"; 3 | import { Token } from "../Token"; 4 | import {RecognitionException} from "./RecognitionException"; 5 | 6 | export declare class NoViableAltException extends RecognitionException { 7 | 8 | deadEndConfigs: ATNConfigSet; 9 | 10 | constructor(recognizer: Recognizer); 11 | 12 | startToken: Token; 13 | } 14 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTreeListener.d.ts: -------------------------------------------------------------------------------- 1 | import {ParserRuleContext} from "../context"; 2 | import {ErrorNode} from "./ErrorNode"; 3 | import {TerminalNode} from "./TerminalNode"; 4 | 5 | export declare abstract class ParseTreeListener { 6 | visitTerminal(node: TerminalNode) : void; 7 | visitErrorNode(node: ErrorNode) : void; 8 | enterEveryRule(ctx: ParserRuleContext) : void; 9 | exitEveryRule(ctx: ParserRuleContext) : void; 10 | } 11 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/ExtraToken.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : 'x' 'y' 12 | ; 13 | Z : 'z' 14 | ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | xzy 21 | 22 | [output] 23 | """(a x z y) 24 | """ 25 | 26 | [errors] 27 | """line 1:1 extraneous input 'z' expecting 'y' 28 | """ 29 | 30 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/PredictionMode_LL.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | r 5 | : (a b | a) EOF {} 6 | ; 7 | a 8 | : X Y? 9 | ; 10 | b 11 | : Y 12 | ; 13 | X: 'X'; 14 | Y: 'Y'; 15 | WS : [ \r\n\t]+ -> skip ; 16 | 17 | [start] 18 | r 19 | 20 | [input] 21 | X Y 22 | 23 | [output] 24 | """(r (a X) (b Y) ) 25 | """ 26 | 27 | [flags] 28 | predictionMode=LL 29 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/Token.d.ts: -------------------------------------------------------------------------------- 1 | import {CharStream} from "./CharStream"; 2 | 3 | export declare class Token { 4 | 5 | static EOF: number; 6 | 7 | tokenIndex: number; 8 | line: number; 9 | column: number; 10 | channel: number; 11 | text: string; 12 | type: number; 13 | start : number; 14 | stop: number; 15 | 16 | clone(): Token; 17 | cloneWithType(type: number): Token; 18 | getInputStream(): CharStream; 19 | } 20 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/Tree.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | /** 7 | * The basic notion of a tree has a parent, a payload, and a list of children. 8 | * It is the most abstract interface for all the trees used by ANTLR. 9 | */ 10 | export default class Tree {} 11 | 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeLexers/LexerDelegatorInvokesDelegateRule.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar M; 3 | import S; 4 | B : 'b'; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | lexer grammar S; 9 | A : 'a' {}; 10 | C : 'c' ; 11 | 12 | [input] 13 | abc 14 | 15 | [output] 16 | S.A 17 | [@0,0:0='a',<3>,1:0] 18 | [@1,1:1='b',<1>,1:1] 19 | [@2,2:2='c',<4>,1:2] 20 | [@3,3:2='',<-1>,1:3] 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeLexers/LexerDelegatorRuleOverridesDelegate.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar M; 3 | import S; 4 | A : 'a' B {} ; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | lexer grammar S; 9 | A : 'a' {} ; 10 | B : 'b' {} ; 11 | 12 | [input] 13 | ab 14 | 15 | [output] 16 | M.A 17 | [@0,0:1='ab',<1>,1:0] 18 | [@1,2:1='',<-1>,1:2] 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/RecursiveLexerRuleRefWithWildcardPlus_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '/*' (CMT | .)+? '*' '/' ; 4 | WS : (' '|'\n')+; 5 | 6 | [input] 7 | /* ick */ 8 | /* /* */ 9 | /* /*nested*/ */ 10 | 11 | [output] 12 | [@0,0:8='/* ick */',<1>,1:0] 13 | [@1,9:9='\n',<2>,1:9] 14 | [@2,10:34='/* /* */\n/* /*nested*/ */',<1>,2:0] 15 | [@3,35:35='\n',<2>,3:16] 16 | [@4,36:35='',<-1>,4:0] 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/RecursiveLexerRuleRefWithWildcardStar_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | CMT : '/*' (CMT | .)*? '*' '/' ; 4 | WS : (' '|'\n')+; 5 | 6 | [input] 7 | /* ick */ 8 | /* /* */ 9 | /* /*nested*/ */ 10 | 11 | [output] 12 | [@0,0:8='/* ick */',<1>,1:0] 13 | [@1,9:9='\n',<2>,1:9] 14 | [@2,10:34='/* /* */\n/* /*nested*/ */',<1>,2:0] 15 | [@3,35:35='\n',<2>,3:16] 16 | [@4,36:35='',<-1>,4:0] 17 | 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/NoViableAlt.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : 'x' | 'y' 12 | ; 13 | Z : 'z' 14 | ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | z 21 | 22 | [output] 23 | """(a z) 24 | """ 25 | 26 | [errors] 27 | """line 1:0 mismatched input 'z' expecting {'x', 'y'} 28 | """ 29 | 30 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/IfIfElseNonGreedyBinding1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : statement+ ; 4 | statement : 'x' | ifStatement; 5 | ifStatement : 'if' 'y' statement ('else' statement)?? { 6 | 7 | }; 8 | ID : 'a'..'z'+ ; 9 | WS : (' '|'\n') -> channel(HIDDEN); 10 | 11 | [start] 12 | start 13 | 14 | [input] 15 | if y if y x else x 16 | 17 | [output] 18 | if y x 19 | if y if y x else x 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/IfIfElseNonGreedyBinding2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : statement+ ; 4 | statement : 'x' | ifStatement; 5 | ifStatement : 'if' 'y' statement (|'else' statement) { 6 | 7 | }; 8 | ID : 'a'..'z'+ ; 9 | WS : (' '|'\n') -> channel(HIDDEN); 10 | 11 | [start] 12 | start 13 | 14 | [input] 15 | if y if y x else x 16 | 17 | [output] 18 | if y x 19 | if y if y x else x 20 | 21 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmWasiMain/kotlin/com/strumenta/antlrkotlin/runtime/WeakHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | // TODO(Edoardo): implement real weak keys 9 | public actual typealias WeakHashMap = HashMap 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorAccessesDelegateMembers.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; // uses no rules from the import 3 | import S; 4 | s : 'b' {} ; // gS is import pointer 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | parser grammar S; 9 | @parser::members { 10 | 11 | } 12 | a : B; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | b 19 | 20 | [output] 21 | """foo 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/SemPredFailOption.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : a ; 4 | a : a ID {}?\ 5 | | ID 6 | ; 7 | ID : 'a'..'z'+ ; 8 | WS : (' '|'\n') -> skip ; 9 | 10 | [start] 11 | s 12 | 13 | [input] 14 | x y z 15 | 16 | [output] 17 | """(s (a (a x) y z)) 18 | """ 19 | 20 | [errors] 21 | """line 1:4 rule a custom message 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/SingleTokenDeletionConsumption.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | myset: ('b'|'c') ; 4 | a: 'a' myset 'd' {} ; 5 | 6 | [start] 7 | a 8 | 9 | [input] 10 | aabd 11 | 12 | [output] 13 | """[@2,2:2='b',<1>,1:2] 14 | """ 15 | 16 | [errors] 17 | """line 1:1 extraneous input 'a' expecting {'b', 'c'} 18 | """ 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/IfIfElseGreedyBinding1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : statement+ ; 4 | statement : 'x' | ifStatement; 5 | ifStatement : 'if' 'y' statement ('else' statement)? { 6 | 7 | }; 8 | ID : 'a'..'z'+ ; 9 | WS : (' '|'\n') -> channel(HIDDEN); 10 | 11 | [start] 12 | start 13 | 14 | [input] 15 | if y if y x else x 16 | 17 | [output] 18 | if y x else x 19 | if y if y x else x 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/IfIfElseGreedyBinding2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : statement+ ; 4 | statement : 'x' | ifStatement; 5 | ifStatement : 'if' 'y' statement ('else' statement|) { 6 | 7 | }; 8 | ID : 'a'..'z'+ ; 9 | WS : (' '|'\n') -> channel(HIDDEN); 10 | 11 | [start] 12 | start 13 | 14 | [input] 15 | if y if y x else x 16 | 17 | [output] 18 | if y x else x 19 | if y if y x else x 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/DisabledAlternative.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#218 "ANTLR4 EOF Related Bug". 3 | https://github.com/antlr/antlr4/issues/218 4 | 5 | [grammar] 6 | grammar T; 7 | cppCompilationUnit : content+ EOF; 8 | content: anything | {}? .; 9 | anything: ANY_CHAR; 10 | ANY_CHAR: [_a-zA-Z0-9]; 11 | 12 | [start] 13 | cppCompilationUnit 14 | 15 | [input] 16 | hello 17 | 18 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/tree/TerminalNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.tree 8 | 9 | import org.antlr.v5.runtime.core.Token 10 | 11 | public interface TerminalNode : ParseTree { 12 | public val symbol: Token 13 | } 14 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/arrayToString.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import valueToString from "./valueToString.js"; 6 | 7 | export default function arrayToString(a) { 8 | return Array.isArray(a) ? ("[" + a.map(valueToString).join(", ") + "]") : "null"; 9 | } 10 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/chunk/SymbolRefChunk.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.codegen.model.chunk; 2 | 3 | import org.antlr.v5.codegen.model.decl.StructDecl; 4 | 5 | public abstract class SymbolRefChunk extends ActionChunk { 6 | public final String name; 7 | public final String escapedName; 8 | 9 | public SymbolRefChunk(StructDecl ctx, String name, String escapedName) { 10 | super(ctx); 11 | this.name = name; 12 | this.escapedName = escapedName; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/Sync.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init { 5 | 6 | } 7 | @after { 8 | 9 | } 10 | : r=a ; 11 | a : 'x' 'y'* '!' 12 | ; 13 | Z : 'z' 14 | ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | xzyy! 21 | 22 | [output] 23 | """(a x z y y !) 24 | """ 25 | 26 | [errors] 27 | """line 1:1 extraneous input 'z' expecting {'y', '!'} 28 | """ 29 | 30 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/AtomWithClosureInTranslatedLRRule.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#196 3 | "element+ in expression grammar doesn't parse properly" 4 | https://github.com/antlr/antlr4/issues/196 5 | 6 | [grammar] 7 | grammar T; 8 | start : e[0] EOF; 9 | e[int _p] 10 | : ( 'a' | 'b'+ ) ( {3 >= $_p}? '+' e[4] )* 11 | ; 12 | 13 | [start] 14 | start 15 | 16 | [input] 17 | a+b+a 18 | 19 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/IndependentPredNotPassedOuterCtxToAvoidCastException.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : b ';' | b '.' ; 4 | b : a ; 5 | a 6 | : {}? ID {} 7 | | {}? ID {} 8 | ; 9 | ID : 'a'..'z'+ ; 10 | INT : '0'..'9'+; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a; 18 | 19 | [output] 20 | """alt 2 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/NoTruePredsThrowsNoViableAlt.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a a; 4 | a : {}? ID INT {} 5 | | {}? ID INT {} 6 | ; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | y 3 x 4 16 | 17 | [errors] 18 | """line 1:0 no viable alternative at input 'y' 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/IdentityHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.jvm 8 | 9 | import java.util.IdentityHashMap as JavaIdentityHashMap 10 | 11 | public typealias IdentityHashMap = JavaIdentityHashMap 12 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/BasicState.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ATNState from "./ATNState.js"; 6 | 7 | export default class BasicState extends ATNState { 8 | constructor() { 9 | super(); 10 | this.stateType = ATNState.BASIC; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/PrefixAndOtherAlt_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : expr EOF ; 4 | expr : literal 5 | | op expr 6 | | expr op expr 7 | ; 8 | literal : '-'? Integer ; 9 | op : '+' | '-' ; 10 | Integer : [0-9]+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | -1 18 | 19 | [output] 20 | """(s (expr (literal - 1)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/TokenMismatch2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | stat: ( '(' expr? ')' )? EOF ; 5 | expr: ID '=' STR ; 6 | 7 | ERR : '~FORCE_ERROR~' ; 8 | ID : [a-zA-Z]+ ; 9 | STR : '"' ~["]* '"' ; 10 | WS : [ \t\r\n]+ -> skip ; 11 | 12 | [start] 13 | stat 14 | 15 | [input] 16 | """( ~FORCE_ERROR~ """ 17 | 18 | [errors] 19 | """line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID} 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/ListLabelsOnSet.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for #270 "Fix operator += applied to a set of 3 | tokens". https://github.com/antlr/antlr4/issues/270 4 | 5 | [grammar] 6 | grammar T; 7 | a : b b* ';' ; 8 | b : ID val+=(INT | FLOAT)*; 9 | ID : 'a'..'z'+ ; 10 | INT : '0'..'9'+; 11 | FLOAT : [0-9]+ '.' [0-9]+; 12 | WS : (' '|'\n') -> skip ; 13 | 14 | [start] 15 | a 16 | 17 | [input] 18 | abc 34; 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/ReferenceToATN_1.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#561 "Issue with parser 3 | generation in 4.2.2" https://github.com/antlr/antlr4/issues/561 4 | 5 | [grammar] 6 | grammar T; 7 | a : (ID|ATN)* ATN? {} ; 8 | ID : 'a'..'z'+ ; 9 | ATN : '0'..'9'+; 10 | WS : (' '|'\n') -> skip ; 11 | 12 | [start] 13 | a 14 | 15 | [input] 16 | 17 | 18 | [output] 19 | """ 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalLexer/PredicatedKeywords.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ENUM : [a-z]+ { }? { } ; 4 | ID : [a-z]+ { } ; 5 | WS : [ \n] -> skip ; 6 | 7 | [input] 8 | enum enu a 9 | 10 | [output] 11 | enum! 12 | ID enu 13 | ID a 14 | [@0,0:3='enum',<1>,1:0] 15 | [@1,5:7='enu',<2>,1:5] 16 | [@2,9:9='a',<2>,1:9] 17 | [@3,10:9='',<-1>,1:10] 18 | 19 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/DecisionState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | public abstract class DecisionState : ATNState() { 10 | public var decision: Int = -1 11 | public var nonGreedy: Boolean = false 12 | } 13 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/ParseCancellationException.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default class ParseCancellationException extends Error { 6 | constructor() { 7 | super() 8 | Error.captureStackTrace(this, ParseCancellationException); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/RuleNode.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ParseTree from "./ParseTree.js"; 6 | 7 | export default class RuleNode extends ParseTree { 8 | 9 | get ruleContext() { 10 | throw new Error("missing interface implementation") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/nativeMain/kotlin/com/strumenta/antlrkotlin/runtime/CopyOnWriteArrayList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | // TODO(Edoardo): make thread safe at some point 9 | public actual typealias CopyOnWriteArrayList = ArrayList 10 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmWasiMain/kotlin/com/strumenta/antlrkotlin/runtime/IdentityHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | // TODO(Edoardo): implement real identity comparison 9 | public actual typealias IdentityHashMap = HashMap 10 | -------------------------------------------------------------------------------- /antlr5-maven-plugin/src/site/apt/examples/import.apt: -------------------------------------------------------------------------------- 1 | Imported Grammar Files 2 | 3 | In order to have the ANTLR plugin automatically locate and use grammars used 4 | as imports in your main <<<.g4>>> files, you need to place the imported grammar 5 | files in the <<>> directory beneath the root directory of your grammar 6 | files (which is <<>> by default of course). 7 | 8 | For a default layout, place your import grammars in the directory: <<>> 9 | -------------------------------------------------------------------------------- /doc/IDEs.md: -------------------------------------------------------------------------------- 1 | # Integrating ANTLR into Development Systems 2 | 3 | The Java target is the reference implementation mirrored by other targets. The following pages help you integrate ANTLR into development environments and build systems appropriate for your target language. As of December 2016, we have Java, C#, Python 3, JavaScript, Go, C++, and Swift targets. 4 | 5 | The easiest thing is probably just to use an [ANTLR plug-in](http://www.antlr.org/tools.html) for your favorite development environment. 6 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/FullContextParsing/AmbigYieldsCtxSensitiveDFA.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} 4 | : ID | ID {} ; 5 | ID : 'a'..'z'+; 6 | WS : (' '|'\t'|'\n')+ -> skip ; 7 | 8 | [start] 9 | s 10 | 11 | [input] 12 | abc 13 | 14 | [output] 15 | Decision 0: 16 | s0-ID->:s1^=>1 17 | 18 | [errors] 19 | """line 1:0 reportAttemptingFullContext d=0 (s), input='abc' 20 | """ 21 | 22 | [flags] 23 | showDiagnosticErrors 24 | 25 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/KeywordID.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | KEND : 'end' ; // has priority 4 | ID : 'a'..'z'+ ; 5 | WS : (' '|'\n')+; 6 | 7 | [input] 8 | end eend ending a 9 | 10 | [output] 11 | [@0,0:2='end',<1>,1:0] 12 | [@1,3:3=' ',<3>,1:3] 13 | [@2,4:7='eend',<2>,1:4] 14 | [@3,8:8=' ',<3>,1:8] 15 | [@4,9:14='ending',<2>,1:9] 16 | [@5,15:15=' ',<3>,1:15] 17 | [@6,16:16='a',<2>,1:16] 18 | [@7,17:16='',<-1>,1:17] 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/OrderingPredicates.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#2301. 3 | 4 | [grammar] 5 | grammar Issue2301; 6 | 7 | SPACES: [ \t\r\n]+ -> skip; 8 | 9 | AT: 'AT'; 10 | X : 'X'; 11 | Y : 'Y'; 12 | 13 | ID: [A-Z]+; 14 | 15 | constant 16 | : 'DUMMY' 17 | ; 18 | 19 | expr 20 | : ID constant? 21 | | expr AT X 22 | | expr AT Y 23 | ; 24 | 25 | [start] 26 | expr 27 | 28 | [input] 29 | POINT AT X 30 | 31 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/states/jvm/JavaExecutedState.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.states.jvm; 2 | 3 | import org.antlr.v5.runtime.core.tree.ParseTree; 4 | 5 | public class JavaExecutedState extends JvmExecutedState { 6 | public JavaExecutedState(JavaCompiledState previousState, String output, String errors, ParseTree parseTree, Exception exception) { 7 | super(previousState, output, errors, parseTree, exception); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/BasicState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * @author Sam Harwell 11 | */ 12 | public class BasicState : ATNState() { 13 | override val stateType: Int = 14 | BASIC 15 | } 16 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/nativeMain/kotlin/com/strumenta/antlrkotlin/runtime/IdentityHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package com.strumenta.antlrkotlin.runtime 8 | 9 | // TODO(Edoardo): implement real identity comparison 10 | public actual typealias IdentityHashMap = HashMap 11 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/ReferenceToATN_2.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#561 "Issue with parser 3 | generation in 4.2.2" https://github.com/antlr/antlr4/issues/561 4 | 5 | [grammar] 6 | grammar T; 7 | a : (ID|ATN)* ATN? {} ; 8 | ID : 'a'..'z'+ ; 9 | ATN : '0'..'9'+; 10 | WS : (' '|'\n') -> skip ; 11 | 12 | [start] 13 | a 14 | 15 | [input] 16 | a 34 c 17 | 18 | [output] 19 | """a34c 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/tree/RuleNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.tree 8 | 9 | import org.antlr.v5.runtime.core.context.RuleContext 10 | 11 | public interface RuleNode : ParseTree { 12 | public val ruleContext: RuleContext 13 | } 14 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/AbstractPredicateTransition.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import Transition from "../transition/Transition.js"; 6 | 7 | export default class AbstractPredicateTransition extends Transition { 8 | constructor(target) { 9 | super(target); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/DiagnosticErrorListener.d.ts: -------------------------------------------------------------------------------- 1 | import {ErrorListener} from "./ErrorListener"; 2 | import {Recognizer} from "../Recognizer"; 3 | import {RecognitionException} from "./RecognitionException"; 4 | 5 | export declare class DiagnosticErrorListener implements ErrorListener { 6 | 7 | syntaxError(recognizer: Recognizer, offendingSymbol: TSymbol, line: number, column: number, msg: string, e: RecognitionException | undefined): void; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/standardHashCodeFunction.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import { stringHashCode } from "./stringHashCode.js"; 6 | 7 | export default function standardHashCodeFunction(a) { 8 | return a ? typeof a === 'string' ? stringHashCode(a) : a.hashCode() : -1; 9 | } 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorInvokesDelegateRuleWithArgs.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S; 4 | s : label=a[3] {} ; 5 | B : 'b' ; // defines B from inherited token space 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar S; 10 | a[int x] returns [int y] : B {} {$y=1000;} ; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | b 17 | 18 | [output] 19 | """S.a1000 20 | """ 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/CharSetRange.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : [0-9]+ {} ; 4 | ID : [a-zA-Z] [a-zA-Z0-9]* {} ; 5 | WS : [ \n\\u0009\r]+ -> skip ; 6 | 7 | [input] 8 | """34 9 | 34 a2 abc 10 | """ 11 | 12 | [output] 13 | I 14 | I 15 | ID 16 | ID 17 | [@0,0:1='34',<1>,1:0] 18 | [@1,4:5='34',<1>,2:1] 19 | [@2,7:8='a2',<2>,2:4] 20 | [@3,10:12='abc',<2>,2:7] 21 | [@4,17:16='',<-1>,3:3] 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/ContextListGetters.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | Regression test for "Getter for context is not a list when it should be". 3 | https://github.com/antlr/antlr4/issues/19 4 | 5 | [grammar] 6 | grammar T; 7 | @parser::members{ 8 | 9 | } 10 | s : (a | b)+; 11 | a : 'a' {}; 12 | b : 'b' {}; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | abab 19 | 20 | [output] 21 | """abab""" -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/SimpleValidate2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a a a; 4 | a : {}? ID {} 5 | | {}? INT {} 6 | ; 7 | ID : 'a'..'z'+ ; 8 | INT : '0'..'9'+; 9 | WS : (' '|'\n') -> skip ; 10 | 11 | [start] 12 | s 13 | 14 | [input] 15 | 3 4 x 16 | 17 | [output] 18 | alt 2 19 | alt 2 20 | 21 | [errors] 22 | """line 1:4 no viable alternative at input 'x' 23 | """ 24 | 25 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/GeneratedFile.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime; 2 | 3 | public class GeneratedFile { 4 | public final String name; 5 | public final Type type; 6 | 7 | public enum Type { 8 | Lexer, 9 | Parser, 10 | Other 11 | } 12 | 13 | public GeneratedFile(String name, Type type) { 14 | this.name = name; 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return name + "; FileType:" + type; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/ReturnValueAndActions_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : e {}; 4 | e returns [int v, ignored] 5 | : a=e '*' b=e {$v = $a.v * $b.v;} 6 | | a=e '+' b=e {$v = $a.v + $b.v;} 7 | | INT {$v = $INT.int;} 8 | | '(' x=e ')' {$v = $x.v;} 9 | ; 10 | INT : '0'..'9'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | 4 18 | 19 | [output] 20 | """4 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/ReturnValueAndActions_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : e {}; 4 | e returns [int v, ignored] 5 | : a=e '*' b=e {$v = $a.v * $b.v;} 6 | | a=e '+' b=e {$v = $a.v + $b.v;} 7 | | INT {$v = $INT.int;} 8 | | '(' x=e ')' {$v = $x.v;} 9 | ; 10 | INT : '0'..'9'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | 1+2 18 | 19 | [output] 20 | """3 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/ReturnValueAndActions_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : e {}; 4 | e returns [int v, ignored] 5 | : a=e '*' b=e {$v = $a.v * $b.v;} 6 | | a=e '+' b=e {$v = $a.v + $b.v;} 7 | | INT {$v = $INT.int;} 8 | | '(' x=e ')' {$v = $x.v;} 9 | ; 10 | INT : '0'..'9'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | 1+2*3 18 | 19 | [output] 20 | """7 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/PredictionMode_SLL.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | r 5 | : (a b | a) EOF {} 6 | ; 7 | a 8 | : X Y? 9 | ; 10 | b 11 | : Y 12 | ; 13 | X: 'X'; 14 | Y: 'Y'; 15 | WS : [ \r\n\t]+ -> skip ; 16 | 17 | [start] 18 | r 19 | 20 | [input] 21 | X Y 22 | 23 | [output] 24 | """XY 25 | """ 26 | 27 | [errors] 28 | """line 1:3 missing 'Y' at '' 29 | """ 30 | 31 | [flags] 32 | predictionMode=SLL 33 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTreeVisitor.d.ts: -------------------------------------------------------------------------------- 1 | import {RuleNode} from "./RuleNode"; 2 | import {ErrorNode} from "./ErrorNode"; 3 | import {TerminalNode} from "./TerminalNode"; 4 | import {ParseTree} from "./ParseTree"; 5 | 6 | export declare class ParseTreeVisitor { 7 | 8 | visit(tree: ParseTree): Result; 9 | 10 | visitChildren(node: RuleNode): Result; 11 | 12 | visitTerminal(node: TerminalNode): Result; 13 | 14 | visitErrorNode(node: ErrorNode): Result; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/DirectCallToLeftRecursiveRule_1.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for "Support direct calls to left-recursive 3 | rules". https://github.com/antlr/antlr4/issues/161 4 | 5 | [grammar] 6 | grammar T; 7 | a @after {} : a ID 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | a 15 | 16 | [input] 17 | x 18 | 19 | [output] 20 | """(a x) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/ReturnValueAndActions_4.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : e {}; 4 | e returns [int v, ignored] 5 | : a=e '*' b=e {$v = $a.v * $b.v;} 6 | | a=e '+' b=e {$v = $a.v + $b.v;} 7 | | INT {$v = $INT.int;} 8 | | '(' x=e ')' {$v = $x.v;} 9 | ; 10 | INT : '0'..'9'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | (1+2)*3 18 | 19 | [output] 20 | """9 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a 18 | 19 | [output] 20 | """(s (e a) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/Simple.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a a a; // do 3x: once in ATN, next in DFA then INT in ATN 4 | a : {}? ID {} 5 | | {}? ID {} 6 | | INT{} 7 | ; 8 | ID : 'a'..'z'+ ; 9 | INT : '0'..'9'+; 10 | WS : (' '|'\n') -> skip ; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | x y 3 17 | 18 | [output] 19 | alt 2 20 | alt 2 21 | alt 3 22 | 23 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/jvm/Environment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.runtime.core.jvm 7 | 8 | import java.lang.System as JavaSystem 9 | 10 | @Suppress("NOTHING_TO_INLINE") 11 | internal inline fun platformGetEnv(name: String): String? = 12 | JavaSystem.getenv(name) 13 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/tree/ParseTreeListener.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default class ParseTreeListener { 6 | visitTerminal(node) { 7 | } 8 | 9 | visitErrorNode(node) { 10 | } 11 | 12 | enterEveryRule(node) { 13 | } 14 | 15 | exitEveryRule(node) { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/DirectCallToLeftRecursiveRule_2.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for "Support direct calls to left-recursive 3 | rules". https://github.com/antlr/antlr4/issues/161 4 | 5 | [grammar] 6 | grammar T; 7 | a @after {} : a ID 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | a 15 | 16 | [input] 17 | x y 18 | 19 | [output] 20 | """(a (a x) y) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | a 21 | 22 | [output] 23 | """(s (e a) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | 1 21 | 22 | [output] 23 | """(s (e 1) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/states/jvm/KotlinExecutedState.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.states.jvm; 2 | 3 | import org.antlr.v5.runtime.core.tree.ParseTree; 4 | 5 | public class KotlinExecutedState extends JvmExecutedState { 6 | public KotlinExecutedState(KotlinCompiledState previousState, String output, String errors, ParseTree parseTree, 7 | Exception exception) { 8 | super(previousState, output, errors, parseTree, exception); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorRuleOverridesDelegates.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S, T; 4 | b : 'b'|'c' {}|B|A; 5 | WS : (' '|'\n') -> skip ; 6 | 7 | [slaveGrammar] 8 | parser grammar T; 9 | tokens { A } 10 | b : 'b' {}; 11 | 12 | [slaveGrammar] 13 | parser grammar S; 14 | a : b {}; 15 | b : 'b' ; 16 | 17 | [start] 18 | a 19 | 20 | [input] 21 | c 22 | 23 | [output] 24 | M.b 25 | S.a 26 | 27 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_6.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | -a 21 | 22 | [output] 23 | """(s (e - (e a)) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/PredTestedEvenWhenUnAmbig_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | @parser::members {} 4 | primary 5 | : ID {} 6 | | {}? 'enum' {} 7 | ; 8 | ID : [a-z]+ ; 9 | WS : [ \t\n\r]+ -> skip ; 10 | 11 | [start] 12 | primary 13 | 14 | [input] 15 | abc 16 | 17 | [output] 18 | """ID abc 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/java/helpers/RuntimeTestLexer.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.java.helpers; 2 | 3 | import org.antlr.v5.runtime.core.CharStream; 4 | import org.antlr.v5.runtime.core.Lexer; 5 | 6 | public abstract class RuntimeTestLexer extends Lexer { 7 | protected java.io.PrintStream outStream = System.out; 8 | 9 | public RuntimeTestLexer(CharStream input) { super(input); } 10 | 11 | public void setOutStream(java.io.PrintStream outStream) { this.outStream = outStream; } 12 | } 13 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/BasicBlockStartState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * @author Sam Harwell 11 | */ 12 | public class BasicBlockStartState : BlockStartState() { 13 | override val stateType: Int = 14 | BLOCK_START 15 | } 16 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/jsAndWasmSharedMain/kotlin/com/strumenta/antlrkotlin/runtime/CopyOnWriteArrayList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | // Note(Edoardo): JS is single threaded, so a normal list is good enough 9 | public actual typealias CopyOnWriteArrayList = ArrayList 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/DirectCallToLeftRecursiveRule_3.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for "Support direct calls to left-recursive 3 | rules". https://github.com/antlr/antlr4/issues/161 4 | 5 | [grammar] 6 | grammar T; 7 | a @after {} : a ID 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | a 15 | 16 | [input] 17 | x y z 18 | 19 | [output] 20 | """(a (a (a x) y) z) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_4.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | a.b 21 | 22 | [output] 23 | """(s (e (e a) . b) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/PrefixAndOtherAlt_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : expr EOF ; 4 | expr : literal 5 | | op expr 6 | | expr op expr 7 | ; 8 | literal : '-'? Integer ; 9 | op : '+' | '-' ; 10 | Integer : [0-9]+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | -1 + -1 18 | 19 | [output] 20 | """(s (expr (expr (literal - 1)) (op +) (expr (literal - 1))) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a+b 18 | 19 | [output] 20 | """(s (e (e a) + (e b)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a*b 18 | 19 | [output] 20 | """(s (e (e a) * (e b)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/ast/Node.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.runtime.core.ast 7 | 8 | /** 9 | * The Abstract Syntax Tree will be constituted by instances of [Node]. 10 | */ 11 | public interface Node { 12 | public val parent: Node? 13 | public val position: Position? 14 | } 15 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/DispatchMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.codegen.model; 7 | 8 | import org.antlr.v5.codegen.OutputModelFactory; 9 | 10 | public class DispatchMethod extends OutputModelObject { 11 | public DispatchMethod(OutputModelFactory factory) { 12 | super(factory); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_3.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | a-1 21 | 22 | [output] 23 | """(s (e (e a) - (e 1)) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_5.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | a.this 21 | 22 | [output] 23 | """(s (e (e a) . this) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/BlockStartState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * The start of a regular `(...)` block. 11 | */ 12 | public abstract class BlockStartState : DecisionState() { 13 | public var endState: BlockEndState? = null 14 | } 15 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/StarLoopbackState.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ATNState from "./ATNState.js"; 6 | 7 | export default class StarLoopbackState extends ATNState { 8 | constructor() { 9 | super(); 10 | this.stateType = ATNState.STAR_LOOP_BACK; 11 | return this; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/parse/ResyncToEndOfRuleBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.parse; 8 | 9 | /** Used to throw us out of deeply nested element back to end of a rule's 10 | * alt list. Note it's not under RecognitionException. 11 | */ 12 | public class ResyncToEndOfRuleBlock extends RuntimeException { 13 | } 14 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/wasmWasiMain/kotlin/com/strumenta/antlrkotlin/runtime/CopyOnWriteArrayList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package com.strumenta.antlrkotlin.runtime 7 | 8 | // Note(Edoardo): WASI is single threaded at the moment, so a normal list is good enough 9 | public actual typealias CopyOnWriteArrayList = ArrayList 10 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/Expressions_7.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow 4 | e : e '.' ID 5 | | e '.' 'this' 6 | | '-' e 7 | | e '*' e 8 | | e ('+'|'-') e 9 | | INT 10 | | ID 11 | ; 12 | ID : 'a'..'z'+ ; 13 | INT : '0'..'9'+ ; 14 | WS : (' '|'\n') -> skip ; 15 | 16 | [start] 17 | s 18 | 19 | [input] 20 | -a+b 21 | 22 | [output] 23 | """(s (e (e - (e a)) + (e b)) ) 24 | """ 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_4.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a?b:c 18 | 19 | [output] 20 | """(s (e (e a) ? (e b) : (e c)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/error/EmptyStackException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.runtime.core.error 7 | 8 | /** 9 | * Thrown to indicate that a stack is empty. 10 | */ 11 | public class EmptyStackException(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) 12 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/transition/WildcardTransition.kt: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.runtime.core.transition 2 | 3 | import org.antlr.v5.runtime.core.state.ATNState 4 | 5 | public class WildcardTransition(target: ATNState) : Transition(target) { 6 | override val serializationType: Int = 7 | WILDCARD 8 | 9 | override fun matches(symbol: Int, minVocabSymbol: Int, maxVocabSymbol: Int): Boolean = 10 | symbol in minVocabSymbol..maxVocabSymbol 11 | 12 | override fun toString(): String = 13 | "." 14 | } -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/InputStream.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | import CharStream from './CharStream.js'; 7 | 8 | /** 9 | * @deprecated Use CharStream instead 10 | */ 11 | export default class InputStream extends CharStream { 12 | constructor(data, decodeToUnicodeCodePoints) { 13 | super(data, decodeToUnicodeCodePoints); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/state/DecisionState.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ATNState from "./ATNState.js"; 6 | 7 | export default class DecisionState extends ATNState { 8 | constructor() { 9 | super(); 10 | this.decision = -1; 11 | this.nonGreedy = false; 12 | return this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_5.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a=b=c 18 | 19 | [output] 20 | """(s (e (e a) = (e (e b) = (e c))) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Sets/UnicodeEscapedSMPRangeSetMismatch.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | a : LETTERS* 'd' {} ; 4 | // Note the double-backslash to avoid Java passing 5 | // unescaped values as part of the grammar. 6 | LETTERS : ('a'|'\\u{1F600}'..'\\u{1F943}'); 7 | 8 | [start] 9 | a 10 | 11 | [input] 12 | a🗿🥄d 13 | 14 | [output] 15 | """ad 16 | """ 17 | 18 | [errors] 19 | line 1:1 token recognition error at: '🗿' 20 | line 1:2 token recognition error at: '🥄' 21 | 22 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/StarBlockStartState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * The block that begins a closure loop. 11 | */ 12 | public class StarBlockStartState : BlockStartState() { 13 | override val stateType: Int = 14 | STAR_BLOCK_START 15 | } 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/dfa/index.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | import DFA from './DFA.js'; 7 | import DFASerializer from './DFASerializer.js'; 8 | import LexerDFASerializer from './LexerDFASerializer.js'; 9 | import PredPrediction from './PredPrediction.js'; 10 | 11 | export default { DFA, DFASerializer, LexerDFASerializer, PredPrediction }; 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/ParserProperty.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This is a regression test for antlr/antlr4#561 "Issue with parser 3 | generation in 4.2.2" https://github.com/antlr/antlr4/issues/561 4 | 5 | [grammar] 6 | grammar T; 7 | 8 | a : {}? ID {} 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | a 15 | 16 | [input] 17 | abc 18 | 19 | [output] 20 | """valid 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserExec/PredicatedIfIfElse.txt: -------------------------------------------------------------------------------- 1 | [notes] 2 | This test is meant to test the expected solution to antlr/antlr4#42. 3 | https://github.com/antlr/antlr4/issues/42 4 | 5 | [grammar] 6 | grammar T; 7 | s : stmt EOF ; 8 | stmt : ifStmt | ID; 9 | ifStmt : 'if' ID stmt ('else' stmt | { })> }?); 10 | ELSE : 'else'; 11 | ID : [a-zA-Z]+; 12 | WS : [ \\n\\t]+ -> skip; 13 | 14 | [start] 15 | s 16 | 17 | [input] 18 | if x if x a else b 19 | 20 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/Order.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s : a {} a; // do 2x: once in ATN, next in DFA; 4 | // action blocks lookahead from falling off of 'a' 5 | // and looking into 2nd 'a' ref. !ctx dependent pred 6 | a : ID {} 7 | | {}? ID {} 8 | ; 9 | ID : 'a'..'z'+ ; 10 | INT : '0'..'9'+; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | x y 18 | 19 | [output] 20 | alt 1 21 | alt 1 22 | 23 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/VisitorDispatchMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.codegen.model; 7 | 8 | import org.antlr.v5.codegen.OutputModelFactory; 9 | 10 | public class VisitorDispatchMethod extends DispatchMethod { 11 | public VisitorDispatchMethod(OutputModelFactory factory) { 12 | super(factory); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/jsAndWasmSharedMain/kotlin/com/strumenta/antlrkotlin/runtime/WeakHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package com.strumenta.antlrkotlin.runtime 8 | 9 | // Note(Edoardo): this is implemented as an HashMap in the JS target, 10 | // so let's keep it as it is 11 | public actual typealias WeakHashMap = HashMap 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/FullContextParsing/FullContextIF_THEN_ELSEParse_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s 4 | @init {} 5 | @after {} 6 | : '{' stat* '}' ; 7 | stat: 'if' ID 'then' stat ('else' ID)? 8 | | 'return' 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\t'|'\n')+ -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | { if x then return } 18 | 19 | [output] 20 | Decision 1: 21 | s0-'}'->:s1=>2 22 | 23 | [flags] 24 | showDiagnosticErrors 25 | 26 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_6.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a?b+c:d 18 | 19 | [output] 20 | """(s (e (e a) ? (e (e b) + (e c)) : (e d)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_7.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a?b=c:d 18 | 19 | [output] 20 | """(s (e (e a) ? (e (e b) = (e c)) : (e d)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LexerExec/ActionPlacement.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | I : ({} 'a' 4 | | {} 5 | 'a' {} 6 | 'b' {}) 7 | {} ; 8 | WS : (' '|'\n') -> skip ; 9 | J : .; 10 | 11 | [input] 12 | ab 13 | 14 | [output] 15 | stuff0: 16 | stuff1: a 17 | stuff2: ab 18 | ab 19 | [@0,0:1='ab',<1>,1:0] 20 | [@1,2:1='',<-1>,1:2] 21 | 22 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/ActionHidesPreds.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | @parser::members {} 4 | s : a+ ; 5 | a : {} ID {}? {} 6 | | {} ID {}? {} 7 | ; 8 | ID : 'a'..'z'+ ; 9 | INT : '0'..'9'+; 10 | WS : (' '|'\n') -> skip ; 11 | 12 | [start] 13 | s 14 | 15 | [input] 16 | x x y 17 | 18 | [output] 19 | alt 1 20 | alt 1 21 | alt 1 22 | 23 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/BaseVisitorFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.codegen.model; 7 | 8 | import org.antlr.v5.codegen.OutputModelFactory; 9 | 10 | public class BaseVisitorFile extends VisitorFile { 11 | public BaseVisitorFile(OutputModelFactory factory, String fileName) { 12 | super(factory, fileName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/decl/ElementListDecl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.decl; 8 | 9 | import org.antlr.v5.codegen.OutputModelFactory; 10 | 11 | public class ElementListDecl extends Decl { 12 | public ElementListDecl(OutputModelFactory factory, String name) { 13 | super(factory, name); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /antlr-kotlin-runtime-remnants/src/jsAndWasmSharedMain/kotlin/com/strumenta/antlrkotlin/runtime/IdentityHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package com.strumenta.antlrkotlin.runtime 8 | 9 | // Note(Edoardo): this is implemented as an HashMap in the JS target, 10 | // so let's keep it as it is 11 | public actual typealias IdentityHashMap = HashMap 12 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/CompositeParsers/DelegatorInvokesFirstVersionOfDelegateRule.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar M; 3 | import S,T; 4 | s : a ; 5 | B : 'b' ; // defines B from inherited token space 6 | WS : (' '|'\n') -> skip ; 7 | 8 | [slaveGrammar] 9 | parser grammar T; 10 | a : B {}; 11 | 12 | [slaveGrammar] 13 | parser grammar S; 14 | a : b {}; 15 | b : B; 16 | 17 | [start] 18 | s 19 | 20 | [input] 21 | b 22 | 23 | [output] 24 | """S.a 25 | """ 26 | 27 | -------------------------------------------------------------------------------- /runtime-testsuite/test/org/antlr/v5/test/runtime/java/helpers/RuntimeTestParser.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v5.test.runtime.java.helpers; 2 | 3 | import org.antlr.v5.runtime.core.Parser; 4 | import org.antlr.v5.runtime.core.TokenStream; 5 | 6 | public abstract class RuntimeTestParser extends Parser { 7 | protected java.io.PrintStream outStream = System.out; 8 | 9 | public RuntimeTestParser(TokenStream input) { 10 | super(input); 11 | } 12 | 13 | public void setOutStream(java.io.PrintStream outStream) { 14 | this.outStream = outStream; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/error/ErrorStrategy.d.ts: -------------------------------------------------------------------------------- 1 | import {RecognitionException} from "./RecognitionException"; 2 | import {Parser} from "../Parser"; 3 | import {Token} from "../Token"; 4 | 5 | export declare class ErrorStrategy { 6 | reset(recognizer: Parser): void; 7 | sync(recognizer: Parser): void; 8 | recover(recognizer: Parser, e: RecognitionException): void; 9 | recoverInline(recognizer: Parser): Token; 10 | reportMatch(recognizer: Parser): void; 11 | reportError(recognizer: Parser, e: RecognitionException): void; 12 | } 13 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/utils/escapeWhitespace.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | export default function escapeWhitespace(s, escapeSpaces) { 6 | s = s.replace(/\t/g, "\\t") 7 | .replace(/\n/g, "\\n") 8 | .replace(/\r/g, "\\r"); 9 | if (escapeSpaces) { 10 | s = s.replace(/ /g, "\u00B7"); 11 | } 12 | return s; 13 | } 14 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/BaseListenerFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v5.codegen.model; 7 | 8 | import org.antlr.v5.codegen.OutputModelFactory; 9 | 10 | public class BaseListenerFile extends ListenerFile { 11 | public BaseListenerFile(OutputModelFactory factory, String fileName) { 12 | super(factory, fileName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/chunk/ListLabelRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.chunk; 8 | 9 | import org.antlr.v5.codegen.model.decl.StructDecl; 10 | 11 | public class ListLabelRef extends LabelRef { 12 | public ListLabelRef(StructDecl ctx, String name, String escapedName) { super(ctx, name, escapedName); } 13 | } 14 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/decl/TokenTypeDecl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.decl; 8 | 9 | import org.antlr.v5.codegen.OutputModelFactory; 10 | 11 | /** */ 12 | public class TokenTypeDecl extends Decl { 13 | public TokenTypeDecl(OutputModelFactory factory, String name) { 14 | super(factory, name); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_8.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a? b?c:d : e 18 | 19 | [output] 20 | """(s (e (e a) ? (e (e b) ? (e c) : (e d)) : (e e)) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/LeftRecursion/TernaryExpr_9.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | s @after {} : e EOF ; // must indicate EOF can follow or 'a\' won't match 4 | e : e '*' e 5 | | e '+' e 6 | |\ e '?' e ':' e 7 | |\ e '=' e 8 | | ID 9 | ; 10 | ID : 'a'..'z'+ ; 11 | WS : (' '|'\n') -> skip ; 12 | 13 | [start] 14 | s 15 | 16 | [input] 17 | a?b: c?d:e 18 | 19 | [output] 20 | """(s (e (e a) ? (e b) : (e (e c) ? (e d) : (e e))) ) 21 | """ 22 | 23 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Listeners/Basic.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | 5 | 6 | 7 | s 8 | @after { 9 | 10 | 11 | } 12 | : r=a ; 13 | a : INT INT 14 | | ID 15 | ; 16 | MULT: '*' ; 17 | ADD : '+' ; 18 | INT : [0-9]+ ; 19 | ID : [a-z]+ ; 20 | WS : [ \t\n]+ -> skip ; 21 | 22 | [start] 23 | s 24 | 25 | [input] 26 | 1 2 27 | 28 | [output] 29 | (a 1 2) 30 | 1 31 | 2 32 | 33 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParseTrees/AltNum.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | options { contextSuperClass=MyRuleNode; } 5 | 6 | 7 | 8 | 9 | s 10 | @init { 11 | 12 | } 13 | @after { 14 | 15 | } 16 | : r=a ; 17 | 18 | a : 'f' 19 | | 'g' 20 | | 'x' b 'z' 21 | ; 22 | b : 'e' {} | 'y' 23 | ; 24 | 25 | [start] 26 | s 27 | 28 | [input] 29 | xyz 30 | 31 | [output] 32 | """(a:3 x (b:2 y) z) 33 | """ 34 | 35 | [skip] 36 | Go 37 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalParser/PredTestedEvenWhenUnAmbig_2.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | @parser::members {} 4 | primary 5 | : ID {} 6 | | {}? 'enum' {} 7 | ; 8 | ID : [a-z]+ ; 9 | WS : [ \t\n\r]+ -> skip ; 10 | 11 | [start] 12 | primary 13 | 14 | [input] 15 | enum 16 | 17 | [errors] 18 | """line 1:0 no viable alternative at input 'enum' 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/LoopEndState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * Mark the end of a * or + loop. 11 | */ 12 | public class LoopEndState : ATNState() { 13 | public var loopBackState: ATNState? = null 14 | 15 | override val stateType: Int = 16 | LOOP_END 17 | } 18 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/TokensStartState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | /** 10 | * The Tokens rule start state linking to each lexer rule start state. 11 | */ 12 | public class TokensStartState : DecisionState() { 13 | override val stateType: Int = 14 | TOKEN_START 15 | } 16 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/atn/OrderedATNConfigSet.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import ATNConfigSet from "./ATNConfigSet.js"; 6 | import HashSet from "../misc/HashSet.js"; 7 | 8 | export default class OrderedATNConfigSet extends ATNConfigSet { 9 | constructor() { 10 | super(); 11 | this.configLookup = new HashSet(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/LabeledOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model; 8 | 9 | import org.antlr.v5.codegen.model.decl.Decl; 10 | 11 | import java.util.List; 12 | 13 | /** All the rule elements we can label like tokens, rules, sets, wildcard. */ 14 | public interface LabeledOp { 15 | public List getLabels(); 16 | } 17 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/chunk/ArgRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.chunk; 8 | 9 | import org.antlr.v5.codegen.model.decl.StructDecl; 10 | 11 | /** */ 12 | public class ArgRef extends LocalRef { 13 | public ArgRef(StructDecl ctx, String name, String escapedName) { 14 | super(ctx, name, escapedName); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/chunk/LabelRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.chunk; 8 | 9 | import org.antlr.v5.codegen.model.decl.StructDecl; 10 | 11 | public class LabelRef extends SymbolRefChunk { 12 | public LabelRef(StructDecl ctx, String name, String escapedName) { 13 | super(ctx, name, escapedName); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/chunk/LocalRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.chunk; 8 | 9 | import org.antlr.v5.codegen.model.decl.StructDecl; 10 | 11 | public class LocalRef extends SymbolRefChunk { 12 | public LocalRef(StructDecl ctx, String name, String escapedName) { 13 | super(ctx, name, escapedName); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/state/RuleStartState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.state 8 | 9 | public class RuleStartState : ATNState() { 10 | public var stopState: RuleStopState? = null 11 | public var isLeftRecursiveRule: Boolean = false 12 | 13 | override val stateType: Int = 14 | RULE_START 15 | } 16 | -------------------------------------------------------------------------------- /runtime/Core/src/main/kotlin/org/antlr/v5/runtime/core/transition/AbstractPredicateTransition.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.runtime.core.transition 8 | 9 | import org.antlr.v5.runtime.core.state.ATNState 10 | 11 | /** 12 | * @author Sam Harwell 13 | */ 14 | public abstract class AbstractPredicateTransition(target: ATNState) : Transition(target) 15 | -------------------------------------------------------------------------------- /runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/Rule.dot: -------------------------------------------------------------------------------- 1 | digraph "" { 2 | graph[fontname="CourierNew";rankdir="LR";pad="0.25"]; 3 | node[fontname="CourierNew";target="_parent"]; 4 | edge[fontname="CourierNew"]; 5 | { node[shape="box"]; 6 | RuleStartState[URL="../RuleStartState.html"]; 7 | RuleStopState[URL="../RuleStopState.html"]; 8 | } 9 | { node[style="dashed"]; 10 | content; 11 | } 12 | 13 | RuleStartState -> content[label="ε"]; 14 | content -> RuleStopState[style="dashed"]; 15 | } 16 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/tool/LabelType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.tool; 8 | 9 | /** the various kinds of labels. t=type, id=ID, types+=type ids+=ID */ 10 | public enum LabelType { 11 | RULE_LABEL, 12 | TOKEN_LABEL, 13 | RULE_LIST_LABEL, 14 | TOKEN_LIST_LABEL, 15 | LEXER_STRING_LABEL; // used in lexer for x='a' 16 | } 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/ParserErrors/LL1ErrorInfo.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | start : animal (AND acClass)? service EOF; 4 | animal : (DOG | CAT ); 5 | service : (HARDWARE | SOFTWARE) ; 6 | AND : 'and'; 7 | DOG : 'dog'; 8 | CAT : 'cat'; 9 | HARDWARE: 'hardware'; 10 | SOFTWARE: 'software'; 11 | WS : ' ' -> skip ; 12 | acClass 13 | @init 14 | {} 15 | : ; 16 | 17 | [start] 18 | start 19 | 20 | [input] 21 | dog and software 22 | 23 | [output] 24 | """{'hardware', 'software'} 25 | """ 26 | 27 | -------------------------------------------------------------------------------- /tool/src/org/antlr/v5/codegen/model/decl/TokenListDecl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-present The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v5.codegen.model.decl; 8 | 9 | import org.antlr.v5.codegen.OutputModelFactory; 10 | 11 | /** */ 12 | public class TokenListDecl extends TokenDecl { 13 | public TokenListDecl(OutputModelFactory factory, String varName) { 14 | super(factory, varName); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/Listeners/TokenGetters_1.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | grammar T; 3 | 4 | 5 | 6 | 7 | s 8 | @after { 9 | 10 | 11 | } 12 | : r=a ; 13 | a : INT INT 14 | | ID 15 | ; 16 | MULT: '*' ; 17 | ADD : '+' ; 18 | INT : [0-9]+ ; 19 | ID : [a-z]+ ; 20 | WS : [ \t\n]+ -> skip ; 21 | 22 | [start] 23 | s 24 | 25 | [input] 26 | 1 2 27 | 28 | [output] 29 | (a 1 2) 30 | 1 2 [1, 2] 31 | 32 | -------------------------------------------------------------------------------- /runtime-testsuite/resources/org/antlr/v5/test/runtime/descriptors/SemPredEvalLexer/IDvsEnum.txt: -------------------------------------------------------------------------------- 1 | [grammar] 2 | lexer grammar L; 3 | ENUM : 'enum' { }? ; 4 | ID : 'a'..'z'+ ; 5 | WS : (' '|'\n') -> skip; 6 | 7 | [input] 8 | enum abc enum 9 | 10 | [output] 11 | [@0,0:3='enum',<2>,1:0] 12 | [@1,5:7='abc',<2>,1:5] 13 | [@2,9:12='enum',<2>,1:9] 14 | [@3,13:12='',<-1>,1:13] 15 | s0-' '->:s5=>3 16 | s0-'a'->:s4=>2 17 | s0-'e'->:s1=>2 18 | :s1=>2-'n'->:s2=>2 19 | :s2=>2-'u'->:s3=>2 20 | :s4=>2-'b'->:s4=>2 21 | :s4=>2-'c'->:s4=>2 22 | 23 | [flags] 24 | showDFA 25 | 26 | -------------------------------------------------------------------------------- /runtime/JavaScript/src/antlr4/dfa/LexerDFASerializer.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-present The ANTLR Project Contributors. All rights reserved. 2 | * Use is of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | import DFASerializer from "./DFASerializer.js"; 6 | 7 | export default class LexerDFASerializer extends DFASerializer { 8 | constructor(dfa) { 9 | super(dfa, null); 10 | } 11 | 12 | getEdgeLabel(i) { 13 | return "'" + String.fromCharCode(i) + "'"; 14 | } 15 | } 16 | --------------------------------------------------------------------------------