summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Bourg <ebourg@apache.org>2018-07-19 10:02:03 +0200
committerEmmanuel Bourg <ebourg@apache.org>2018-07-19 10:02:03 +0200
commit85142a98ead0e61e2d2e147e441a100433a1c7e8 (patch)
tree2b4eb1fa322ce8d7b83f43e4775d3878f8707e1b
parent1781c15a732a0f3d2efbacf88f9a1486f0bd1582 (diff)
parent1d0464db4ec5e5c20b2ae62bb3c4eceaa6840bde (diff)
Merge tag 'upstream/4.6'
Upstream version 4.6
-rw-r--r--.github/ISSUE_TEMPLATE.md8
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md5
-rw-r--r--LICENSE.txt10
-rw-r--r--README.md30
-rw-r--r--antlr4-maven-plugin/pom.xml121
-rw-r--r--antlr4-maven-plugin/resources/META-INF/m2e/lifecycle-mapping-metadata.xml6
-rw-r--r--antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java31
-rw-r--r--antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java182
-rw-r--r--antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java314
-rw-r--r--antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java79
-rw-r--r--antlr4-maven-plugin/src/site/site.xml8
-rw-r--r--antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java361
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g47
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens3
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g48
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml48
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g44
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g46
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g45
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g44
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g46
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g45
-rw-r--r--appveyor.yml8
-rw-r--r--contributors.txt37
-rw-r--r--doc/IDEs.md5
-rw-r--r--doc/ace-javascript-target.md247
-rw-r--r--doc/actions.md204
-rw-r--r--doc/antlr-project-testing.md285
-rw-r--r--doc/building-antlr.md109
-rw-r--r--doc/cpp-target.md182
-rw-r--r--doc/creating-a-language-target.md22
-rw-r--r--doc/csharp-target.md94
-rw-r--r--doc/faq/actions-preds.md11
-rw-r--r--doc/faq/error-handling.md5
-rw-r--r--doc/faq/general.md100
-rw-r--r--doc/faq/getting-started.md11
-rw-r--r--doc/faq/index.md50
-rw-r--r--doc/faq/installation.md60
-rw-r--r--doc/faq/lexical.md63
-rw-r--r--doc/faq/parse-trees.md73
-rw-r--r--doc/faq/translation.md9
-rw-r--r--doc/getting-started.md131
-rw-r--r--doc/go-target.md115
-rw-r--r--doc/grammars.md184
-rw-r--r--doc/images/ACE-Architecture.001.pngbin0 -> 89206 bytes
-rw-r--r--doc/images/combined.pngbin0 -> 3469 bytes
-rw-r--r--doc/images/dragfile.pngbin0 -> 85143 bytes
-rw-r--r--doc/images/foreign.pngbin0 -> 719 bytes
-rw-r--r--doc/images/hello-parrt.pngbin0 -> 11130 bytes
-rw-r--r--doc/images/idea-prefs-after-install.pngbin0 -> 20537 bytes
-rw-r--r--doc/images/idea-prefs.pngbin0 -> 17237 bytes
-rw-r--r--doc/images/intellij-maven.pngbin0 -> 80990 bytes
-rw-r--r--doc/images/nested-fuzzy.pngbin0 -> 94555 bytes
-rw-r--r--doc/images/nested.pngbin0 -> 4246 bytes
-rw-r--r--doc/images/nonascii.pngbin0 -> 499 bytes
-rw-r--r--doc/images/nonnested-fuzzy.pngbin0 -> 63132 bytes
-rw-r--r--doc/images/process.pngbin0 -> 48742 bytes
-rw-r--r--doc/images/python3-tests.pngbin0 -> 233156 bytes
-rw-r--r--doc/images/targetselection.pngbin0 -> 124911 bytes
-rw-r--r--doc/images/teronbook.pngbin0 -> 74302 bytes
-rw-r--r--doc/images/tertalk.pngbin0 -> 73738 bytes
-rw-r--r--doc/images/testrigs.pngbin0 -> 142650 bytes
-rw-r--r--doc/images/tpantlr2.pngbin0 -> 48787 bytes
-rw-r--r--doc/images/tpdsl.pngbin0 -> 87674 bytes
-rw-r--r--doc/images/xcodedep.pngbin0 -> 449534 bytes
-rw-r--r--doc/images/xcodenav.pngbin0 -> 87208 bytes
-rw-r--r--doc/images/xyz.pngbin0 -> 1077 bytes
-rw-r--r--doc/images/xyz_opt.pngbin0 -> 1132 bytes
-rw-r--r--doc/images/xyz_plus.pngbin0 -> 1226 bytes
-rw-r--r--doc/images/xyz_star.pngbin0 -> 1384 bytes
-rw-r--r--doc/index.md68
-rw-r--r--doc/interpreters.md79
-rw-r--r--doc/java-target.md244
-rw-r--r--doc/javascript-target.md157
-rw-r--r--doc/left-recursion.md50
-rw-r--r--doc/lexer-rules.md283
-rw-r--r--doc/lexicon.md110
-rw-r--r--doc/listeners.md38
-rw-r--r--doc/options.md101
-rw-r--r--doc/parser-rules.md489
-rw-r--r--doc/parsing-binary-files.md182
-rw-r--r--doc/predicates.md164
-rw-r--r--doc/python-target.md129
-rw-r--r--doc/releasing-antlr.md434
-rw-r--r--doc/resources.md33
-rw-r--r--doc/resources/worker-base.js1079
-rw-r--r--doc/runtimetests-overview.md41
-rw-r--r--doc/swift-target.md99
-rw-r--r--doc/targets.md20
-rw-r--r--doc/tool-options.md161
-rw-r--r--doc/tree-matching.md156
-rw-r--r--doc/wildcard.md228
-rw-r--r--pom.xml30
-rw-r--r--runtime-testsuite/README.md9
-rw-r--r--runtime-testsuite/annotations/pom.xml51
-rw-r--r--runtime-testsuite/annotations/src/org/antlr/v4/test/runtime/CommentHasStringValue.java20
-rw-r--r--runtime-testsuite/pom.xml268
-rw-r--r--runtime-testsuite/processors/pom.xml56
-rw-r--r--runtime-testsuite/processors/resources/META-INF/services/javax.annotation.processing.Processor1
-rw-r--r--runtime-testsuite/processors/src/org/antlr/v4/test/runtime/CommentHasStringValueProcessor.java80
-rw-r--r--runtime/Java/pom.xml181
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ANTLRFileStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ANTLRInputStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/BailErrorStrategy.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/BaseErrorListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java41
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/CharStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/CommonToken.java41
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/CommonTokenFactory.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java34
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ConsoleErrorListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/FailedPredicateException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/InputMismatchException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/IntStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/InterpreterRuleContext.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/Lexer.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/LexerInterpreter.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/LexerNoViableAltException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ListTokenSource.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/Parser.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ParserInterpreter.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ParserRuleContext.java50
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/ProxyErrorListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/RecognitionException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/Recognizer.java32
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/RuleContext.java32
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/RuleContextWithAltNum.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java32
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/Token.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/TokenFactory.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/TokenSource.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/TokenStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/TokenStreamRewriter.java75
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/UnbufferedTokenStream.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/Vocabulary.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/VocabularyImpl.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/WritableToken.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java49
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java30
-rwxr-xr-xruntime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java61
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java49
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ATNType.java32
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ActionTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/AmbiguityInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/AtomTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/BasicBlockStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/BasicState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/BlockEndState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/BlockStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/DecisionEventInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/DecisionInfo.java32
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/DecisionState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/EpsilonTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ErrorInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LL1Analyzer.java57
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionExecutor.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionType.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerChannelAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerCustomAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerIndexedCustomAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerModeAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerMoreAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerPopModeAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerPushModeAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerSkipAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LexerTypeAction.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LookaheadEventInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/LoopEndState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/NotSetTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ParseInfo.java30
-rwxr-xr-xruntime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java203
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PlusBlockStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PlusLoopbackState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PredicateEvalInfo.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PredicateTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java33
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/PredictionMode.java36
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/ProfilingATNSimulator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/RangeTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/RuleStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/RuleStopState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/RuleTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/SetTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/StarBlockStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopEntryState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopbackState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/TokensStartState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/Transition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/atn/WildcardTransition.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/dfa/DFA.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/dfa/DFASerializer.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/dfa/LexerDFASerializer.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java33
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/DoubleKeyMap.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/EqualityComparator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java31
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/IntegerStack.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Interval.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/LogManager.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/MultiMap.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/MurmurHash.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/NotNull.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Pair.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/ParseCancellationException.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Predicate.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Triple.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/misc/Utils.java84
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/AbstractParseTreeVisitor.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNode.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNodeImpl.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/IterativeParseTreeWalker.java79
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeListener.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeProperty.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeWalker.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/RuleNode.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNode.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/Chunk.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreeMatch.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePattern.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TagChunk.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TextChunk.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TokenTagToken.java30
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java7
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java6
-rw-r--r--runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java6
-rw-r--r--tool-testsuite/pom.xml53
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/BaseJavaToolTest.java51
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/InterpreterTreeTextProvider.java6
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/JavaUnicodeInputStream.java30
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/ParserInterpreterForTesting.java30
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/PositionAdjustingLexer.g44
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestASTStructure.java30
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNConstruction.java423
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNDeserialization.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java48
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNLexerInterpreter.java44
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java54
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNSerialization.java41
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestActionSplitter.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestActionTranslation.java150
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestAmbigParseTrees.java8
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestAttributeChecks.java48
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestBasicSemanticErrors.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestBufferedTokenStream.java39
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestCodeGeneration.java42
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestCommonTokenStream.java36
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java185
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestDollarParser.java18
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestErrorSets.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestFastQueue.java30
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestGrammarParserInterpreter.java34
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestGraphNodes.java106
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestIntervalSet.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestLeftRecursionToolIssues.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestLexerActions.java17
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestLookaheadTrees.java8
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java16
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestParserExec.java55
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java41
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestParserProfiler.java41
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java50
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java134
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestSymbolIssues.java174
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestTokenPositionOptions.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestTokenStreamRewriter.java909
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestTokenTypeAssignment.java33
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestToolSyntaxErrors.java132
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestTopologicalSort.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedCharStream.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedTokenStream.java40
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestVocabulary.java39
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java16
-rw-r--r--tool/pom.xml192
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/LeftRecursiveRules.stg4
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg65
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg1112
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Files.stg344
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg1498
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg28
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg34
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg26
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg26
-rwxr-xr-xtool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg1026
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/depend.stg4
-rw-r--r--tool/resources/org/antlr/v4/tool/templates/dot/graphs.stg4
-rw-r--r--tool/src/org/antlr/v4/Tool.java45
-rw-r--r--tool/src/org/antlr/v4/analysis/AnalysisPipeline.java33
-rw-r--r--tool/src/org/antlr/v4/analysis/LeftRecursionDetector.java30
-rw-r--r--tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAltInfo.java30
-rw-r--r--tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java30
-rw-r--r--tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java30
-rw-r--r--tool/src/org/antlr/v4/automata/ATNFactory.java30
-rw-r--r--tool/src/org/antlr/v4/automata/ATNOptimizer.java53
-rw-r--r--tool/src/org/antlr/v4/automata/ATNPrinter.java30
-rw-r--r--tool/src/org/antlr/v4/automata/ATNVisitor.java30
-rw-r--r--tool/src/org/antlr/v4/automata/LexerATNFactory.java296
-rw-r--r--tool/src/org/antlr/v4/automata/ParserATNFactory.java35
-rw-r--r--tool/src/org/antlr/v4/automata/TailEpsilonRemover.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/ActionTranslator.java57
-rw-r--r--tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/CodeGenPipeline.java107
-rw-r--r--tool/src/org/antlr/v4/codegen/CodeGenerator.java145
-rw-r--r--tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/LexerFactory.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/OutputModelController.java61
-rw-r--r--tool/src/org/antlr/v4/codegen/OutputModelFactory.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/OutputModelWalker.java41
-rw-r--r--tool/src/org/antlr/v4/codegen/ParserFactory.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/SourceGenTriggers.g4
-rw-r--r--tool/src/org/antlr/v4/codegen/Target.java103
-rw-r--r--tool/src/org/antlr/v4/codegen/Wildcard.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Action.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/AddToLabelList.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/AltBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ArgAction.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/BaseListenerFile.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/BaseVisitorFile.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/CaptureNextToken.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/CaptureNextTokenType.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Choice.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/CodeBlockForAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/CodeBlockForOuterMostAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/DispatchMethod.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java8
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ExceptionClause.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/InvokeRule.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1Choice.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1Loop.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LabeledOp.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LeftRecursiveRuleFunction.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Lexer.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/LexerFile.java46
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ListenerDispatchMethod.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ListenerFile.java34
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Loop.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/MatchNotSet.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/MatchSet.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/MatchToken.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ModelElement.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/OptionalBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/OutputFile.java43
-rw-r--r--tool/src/org/antlr/v4/codegen/model/OutputModelObject.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Parser.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ParserFile.java46
-rw-r--r--tool/src/org/antlr/v4/codegen/model/PlusBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Recognizer.java41
-rw-r--r--tool/src/org/antlr/v4/codegen/model/RuleActionFunction.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/RuleElement.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/RuleFunction.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/RuleSempredFunction.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/SemPred.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/SerializedATN.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/SrcOp.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/StarBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/Sync.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/TestSetInline.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/VisitorDispatchMethod.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/VisitorFile.java34
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ActionChunk.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ActionTemplate.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ActionText.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ArgRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/LabelRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ListLabelRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/LocalRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/NonLocalAttrRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/QRetValueRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RetValueRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_ctx.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_parser.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_start.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_stop.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_text.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/SetAttr.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/SetNonLocalAttr.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_ctx.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_parser.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_start.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_stop.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_text.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_channel.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_index.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_int.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_line.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_pos.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_text.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_type.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/chunk/TokenRef.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/dbg.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/CodeBlock.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextRuleGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListIndexedGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextTokenGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListIndexedGetterDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/Decl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/ElementListDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java61
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/target/CSharpTarget.java32
-rw-r--r--tool/src/org/antlr/v4/codegen/target/CppTarget.java235
-rw-r--r--tool/src/org/antlr/v4/codegen/target/GoTarget.java218
-rw-r--r--tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java35
-rw-r--r--tool/src/org/antlr/v4/codegen/target/JavaTarget.java30
-rw-r--r--tool/src/org/antlr/v4/codegen/target/Python2Target.java32
-rw-r--r--tool/src/org/antlr/v4/codegen/target/Python3Target.java32
-rw-r--r--tool/src/org/antlr/v4/codegen/target/SwiftTarget.java553
-rw-r--r--tool/src/org/antlr/v4/gui/BasicFontMetrics.java30
-rw-r--r--tool/src/org/antlr/v4/gui/GraphicsSupport.java30
-rw-r--r--tool/src/org/antlr/v4/gui/JFileChooserConfirmOverwrite.java30
-rw-r--r--tool/src/org/antlr/v4/gui/PostScriptDocument.java30
-rw-r--r--tool/src/org/antlr/v4/gui/SystemFontMetrics.java30
-rw-r--r--tool/src/org/antlr/v4/gui/TestRig.java41
-rw-r--r--tool/src/org/antlr/v4/gui/TreeLayoutAdaptor.java30
-rw-r--r--tool/src/org/antlr/v4/gui/TreePostScriptGenerator.java30
-rw-r--r--tool/src/org/antlr/v4/gui/TreeTextProvider.java30
-rw-r--r--tool/src/org/antlr/v4/gui/TreeViewer.java47
-rw-r--r--tool/src/org/antlr/v4/gui/Trees.java10
-rw-r--r--tool/src/org/antlr/v4/misc/CharSupport.java99
-rw-r--r--tool/src/org/antlr/v4/misc/FrequencySet.java30
-rw-r--r--tool/src/org/antlr/v4/misc/Graph.java41
-rw-r--r--tool/src/org/antlr/v4/misc/MutableInt.java30
-rw-r--r--tool/src/org/antlr/v4/misc/OrderedHashMap.java30
-rw-r--r--tool/src/org/antlr/v4/misc/Utils.java32
-rw-r--r--tool/src/org/antlr/v4/parse/ANTLRLexer.g4
-rw-r--r--tool/src/org/antlr/v4/parse/ANTLRParser.g4
-rw-r--r--tool/src/org/antlr/v4/parse/ATNBuilder.g4
-rw-r--r--tool/src/org/antlr/v4/parse/ActionSplitter.g4
-rw-r--r--tool/src/org/antlr/v4/parse/ActionSplitterListener.java30
-rw-r--r--tool/src/org/antlr/v4/parse/BlockSetTransformer.g4
-rw-r--r--tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java30
-rw-r--r--tool/src/org/antlr/v4/parse/GrammarToken.java30
-rw-r--r--tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g4
-rw-r--r--tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g6
-rw-r--r--tool/src/org/antlr/v4/parse/ResyncToEndOfRuleBlock.java30
-rw-r--r--tool/src/org/antlr/v4/parse/ScopeParser.java501
-rw-r--r--tool/src/org/antlr/v4/parse/TokenVocabParser.java30
-rw-r--r--tool/src/org/antlr/v4/parse/ToolANTLRLexer.java30
-rw-r--r--tool/src/org/antlr/v4/parse/ToolANTLRParser.java30
-rw-r--r--tool/src/org/antlr/v4/parse/v3TreeGrammarException.java30
-rw-r--r--tool/src/org/antlr/v4/parse/v4ParserException.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/ActionSniffer.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/AttributeChecks.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java32
-rw-r--r--tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/RuleCollector.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/SemanticPipeline.java34
-rw-r--r--tool/src/org/antlr/v4/semantics/SymbolChecks.java154
-rw-r--r--tool/src/org/antlr/v4/semantics/SymbolCollector.java30
-rw-r--r--tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ANTLRMessage.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ANTLRToolListener.java30
-rw-r--r--tool/src/org/antlr/v4/tool/Alternative.java30
-rw-r--r--tool/src/org/antlr/v4/tool/Attribute.java43
-rw-r--r--tool/src/org/antlr/v4/tool/AttributeDict.java32
-rw-r--r--tool/src/org/antlr/v4/tool/AttributeResolver.java30
-rw-r--r--tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java58
-rw-r--r--tool/src/org/antlr/v4/tool/DOTGenerator.java30
-rw-r--r--tool/src/org/antlr/v4/tool/DefaultToolListener.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ErrorManager.java32
-rw-r--r--tool/src/org/antlr/v4/tool/ErrorSeverity.java32
-rw-r--r--tool/src/org/antlr/v4/tool/ErrorType.java99
-rw-r--r--tool/src/org/antlr/v4/tool/Grammar.java45
-rw-r--r--tool/src/org/antlr/v4/tool/GrammarInterpreterRuleContext.java30
-rw-r--r--tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java91
-rw-r--r--tool/src/org/antlr/v4/tool/GrammarSemanticsMessage.java30
-rw-r--r--tool/src/org/antlr/v4/tool/GrammarSyntaxMessage.java30
-rw-r--r--tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java30
-rw-r--r--tool/src/org/antlr/v4/tool/LabelElementPair.java30
-rw-r--r--tool/src/org/antlr/v4/tool/LabelType.java37
-rw-r--r--tool/src/org/antlr/v4/tool/LeftRecursionCyclesMessage.java30
-rw-r--r--tool/src/org/antlr/v4/tool/LeftRecursiveRule.java30
-rw-r--r--tool/src/org/antlr/v4/tool/LexerGrammar.java30
-rw-r--r--tool/src/org/antlr/v4/tool/Rule.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ToolMessage.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/ActionAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/AltAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/BlockAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/GrammarAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java35
-rw-r--r--tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/NotAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/OptionalBlockAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/PlusBlockAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/PredAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/QuantifierAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/RangeAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/RuleAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/RuleElementAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/RuleRefAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/SetAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/StarBlockAST.java30
-rw-r--r--tool/src/org/antlr/v4/tool/ast/TerminalAST.java30
564 files changed, 17105 insertions, 13697 deletions
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..61171f1
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,8 @@
+Before submitting an issue to ANTLR, please check off these boxes:
+
+- [ ] I am not submitting a question on how to use ANTLR; instead, go to [antlr4-discussion google group](https://groups.google.com/forum/#!forum/antlr-discussion) or ask at [stackoverflow](http://stackoverflow.com/questions/tagged/antlr4)
+- [ ] I have done a search of the existing issues to make sure I'm not sending in a duplicate
+
+[cut]
+Please include information about the expected behavior, actual behavior, and the smallest grammar or code that reproduces the behavior. If appropriate, please indicate the code generation targets such as Java, C#, ... Pointers into offending code regions are also very welcome.
+[/cut]
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..e2af226
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,5 @@
+[cut]
+Thank you for proposing a contribution to the ANTLR project. In order to accept changes from the outside world, all contributors must "sign" the [contributors.txt](https://github.com/antlr/antlr4/blob/master/contributors.txt) contributors certificate of origin. It's an unfortunate reality of today's fuzzy and bizarre world of open-source ownership.
+
+Make sure you are already in the contributors.txt file or add a commit to this pull request with the appropriate change. Thanks!
+[/cut]
diff --git a/LICENSE.txt b/LICENSE.txt
index 95d0a25..5496b67 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,5 @@
-[The "BSD license"]
-Copyright (c) 2015 Terence Parr, Sam Harwell
-All rights reserved.
+[The "BSD 3-clause license"]
+Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -11,8 +10,9 @@ are met:
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
diff --git a/README.md b/README.md
index c1d6902..d26d18a 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,13 @@
# ANTLR v4
+[![Build Travis-CI Status](https://travis-ci.org/antlr/antlr4.png?branch=master)](https://travis-ci.org/antlr/antlr4) [![Build AppVeyor Status](https://ci.appveyor.com/api/projects/status/5acpbx1pg7bhgh8v/branch/master?svg=true)](https://ci.appveyor.com/project/parrt/antlr4) [![Java 7+](https://img.shields.io/badge/java-7+-4c7e9f.svg)](http://java.oracle.com) [![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/antlr/antlr4/master/LICENSE.txt)
+
**ANTLR** (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build parse trees and also generates a listener interface (or visitor) that makes it easy to respond to the recognition of phrases of interest.
*Given day-job constraints, my time working on this project is limited so I'll have to focus first on fixing bugs rather than changing/improving the feature set. Likely I'll do it in bursts every few months. Please do not be offended if your bug or pull request does not yield a response! --parrt*
+[![Donate](https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BF92STRXT8F8Q)
+
## Authors and major contributors
* [Terence Parr](http://www.cs.usfca.edu/~parrt/), parrt@cs.usfca.edu
@@ -11,22 +15,29 @@ ANTLR project lead and supreme dictator for life
[University of San Francisco](http://www.usfca.edu/)
* [Sam Harwell](http://tunnelvisionlabs.com/) (Tool co-author, Java and C# target)
* Eric Vergnaud (Javascript, Python2, Python3 targets and significant work on C# target)
+* [Peter Boyer](https://github.com/pboyer) (Go target)
+* [Mike Lischke](http://www.soft-gems.net/) (C++ completed target)
+* Dan McLaughlin (C++ initial target)
+* David Sisson (C++ initial target and test)
+* [Janyou](https://github.com/janyou) (Swift target)
+* [Ewan Mellor](https://github.com/ewanmellor), [Hanzhou Shi](https://github.com/hanjoes) (Swift target merging)
## Useful information
* [Release notes](https://github.com/antlr/antlr4/releases)
-* [Getting started with v4](https://raw.githubusercontent.com/antlr/antlr4/master/doc/getting-started.md)
+* [Getting started with v4](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md)
* [Official site](http://www.antlr.org/)
-* [Documentation](https://raw.githubusercontent.com/antlr/antlr4/master/doc/index.md)
-* [FAQ](https://raw.githubusercontent.com/antlr/antlr4/master/doc/faq/index.md)
-* [API](http://www.antlr.org/api/Java/index.html)
+* [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md)
+* [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md)
+* [ANTLR code generation targets](https://github.com/antlr/antlr4/blob/master/doc/targets.md)<br>(Currently: Java, C#, Python2|3, JavaScript, Go, C++, Swift)
+* [Java API](http://www.antlr.org/api/Java/index.html)
* [ANTLR v3](http://www.antlr3.org/)
-* [v3 to v4 Migration, differences](https://raw.githubusercontent.com/antlr/antlr4/master/doc/faq/general.md)
+* [v3 to v4 Migration, differences](https://github.com/antlr/antlr4/blob/master/doc/faq/general.md)
You might also find the following pages useful, particularly if you want to mess around with the various target languages.
-* [How to build ANTLR itself](https://raw.githubusercontent.com/antlr/antlr4/master/doc/building-antlr.md)
-* [How we create and deploy an ANTLR release](https://raw.githubusercontent.com/antlr/antlr4/master/doc/releasing-antlr.md)
+* [How to build ANTLR itself](https://github.com/antlr/antlr4/blob/master/doc/building-antlr.md)
+* [How we create and deploy an ANTLR release](https://github.com/antlr/antlr4/blob/master/doc/releasing-antlr.md)
## The Definitive ANTLR 4 Reference
@@ -40,8 +51,3 @@ You will find the [Book source code](http://pragprog.com/titles/tpantlr2/source_
[This repository](https://github.com/antlr/grammars-v4) is a collection of grammars without actions where the
root directory name is the all-lowercase name of the language parsed
by the grammar. For example, java, cpp, csharp, c, etc...
-
-Travis Status
----------
-
-<a href="https://travis-ci.org/antlr/antlr4"><img src="https://api.travis-ci.org/antlr/antlr4.png"></a>
diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml
index b9e144d..319418a 100644
--- a/antlr4-maven-plugin/pom.xml
+++ b/antlr4-maven-plugin/pom.xml
@@ -1,40 +1,14 @@
<!--
-
-[The "BSD license"]
- ANTLR - Copyright (c) Terence Parr, Sam Harwell
- Maven Plugin - Copyright (c) Jim Idle
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
+ <version>4.6</version>
</parent>
<artifactId>antlr4-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
@@ -48,11 +22,16 @@
<!-- Ancilliary information for completeness -->
<inceptionYear>2009</inceptionYear>
+ <properties>
+ <mavenVersion>3.3.9</mavenVersion>
+ <takariLifecycleVersion>1.11.12</takariLifecycleVersion>
+ </properties>
+
<!-- ============================================================================= -->
- <!-- What are we depedent on for the Mojos to execute? We need the plugin
- API itself and of course we need the ANTLR Tool and runtime and any of their
- dependencies, which we inherit. The Tool itself provides us with all the
+ <!-- What are we depedent on for the Mojos to execute? We need the plugin
+ API itself and of course we need the ANTLR Tool and runtime and any of their
+ dependencies, which we inherit. The Tool itself provides us with all the
dependencies, so we need only name it here. -->
<dependencies>
@@ -64,11 +43,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.2</version>
@@ -78,8 +52,8 @@
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
- <!-- The version of ANTLR tool that this version of the plugin controls.
- We have decided that this should be in lockstep with ANTLR itself, other
+ <!-- The version of ANTLR tool that this version of the plugin controls.
+ We have decided that this should be in lockstep with ANTLR itself, other
than -1 -2 -3 etc patch releases. -->
<dependency>
<groupId>org.antlr</groupId>
@@ -90,13 +64,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -105,9 +73,49 @@
<version>3.2</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-plugin-testing</artifactId>
+ <version>2.9.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${mavenVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>${mavenVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.2.1</version>
+ </dependency>
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -132,6 +140,21 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-lifecycle-plugin</artifactId>
+ <version>${takariLifecycleVersion}</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>testProperties</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testProperties</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
@@ -145,7 +168,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9</version>
+ <version>2.10.4</version>
<configuration>
<quiet>true</quiet>
</configuration>
@@ -153,7 +176,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
+ <version>2.5</version>
</plugin>
</plugins>
</reporting>
diff --git a/antlr4-maven-plugin/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/antlr4-maven-plugin/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
index de806ee..84a4919 100644
--- a/antlr4-maven-plugin/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ b/antlr4-maven-plugin/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java
index b251878..92d2377 100644
--- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java
+++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java
@@ -1,31 +1,8 @@
/*
- [The "BSD license"]
- Copyright (c) 2012 Terence Parr
- Copyright (c) 2012 Sam Harwell
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
package org.antlr.mojo.antlr4;
import org.antlr.v4.Tool;
diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java
index d8712ee..0afe54f 100644
--- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java
+++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java
@@ -1,31 +1,8 @@
/*
- [The "BSD license"]
- Copyright (c) 2012 Terence Parr
- Copyright (c) 2012 Sam Harwell
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
package org.antlr.mojo.antlr4;
@@ -59,6 +36,7 @@ import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -95,7 +73,13 @@ public class Antlr4Mojo extends AbstractMojo {
* specify grammar file encoding; e.g., euc-jp
*/
@Parameter(property = "project.build.sourceEncoding")
- protected String encoding;
+ protected String inputEncoding;
+
+ /**
+ * specify output file encoding; defaults to source encoding
+ */
+ @Parameter(property = "project.build.sourceEncoding")
+ protected String outputEncoding;
/**
* Generate parse tree listener interface and base class.
@@ -184,6 +168,12 @@ public class Antlr4Mojo extends AbstractMojo {
@Parameter(defaultValue = "${basedir}/src/main/antlr4/imports")
private File libDirectory;
+ /**
+ * The directory where build status information is located.
+ */
+ @Parameter(defaultValue = "${project.build.directory}/maven-status/antlr4", readonly=true)
+ private File statusDirectory;
+
@Component
private BuildContext buildContext;
@@ -222,6 +212,8 @@ public class Antlr4Mojo extends AbstractMojo {
Log log = getLog();
+ outputEncoding = validateEncoding(outputEncoding);
+
if (log.isDebugEnabled()) {
for (String e : excludes) {
log.debug("ANTLR: Exclude: " + e);
@@ -249,16 +241,22 @@ public class Antlr4Mojo extends AbstractMojo {
outputDir.mkdirs();
}
+ GrammarDependencies dependencies = new GrammarDependencies(sourceDirectory, libDirectory, arguments, getDependenciesStatusFile(), getLog());
+
// Now pick up all the files and process them with the Tool
//
List<List<String>> argumentSets;
+ Set<File> grammarFiles;
+ Set<File> importGrammarFiles;
try {
List<String> args = getCommandArguments();
- argumentSets = processGrammarFiles(args, sourceDirectory);
- } catch (InclusionScanException ie) {
- log.error(ie);
- throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze", ie);
+ grammarFiles = getGrammarFiles(sourceDirectory);
+ importGrammarFiles = getImportFiles(sourceDirectory);
+ argumentSets = processGrammarFiles(args, grammarFiles, dependencies, sourceDirectory);
+ } catch (Exception e) {
+ log.error(e);
+ throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze", e);
}
log.debug("Output directory base will be " + outputDirectory.getAbsolutePath());
@@ -272,6 +270,14 @@ public class Antlr4Mojo extends AbstractMojo {
throw new MojoFailureException("Error creating an instanceof the ANTLR tool.", e);
}
+ try {
+ dependencies.analyze(grammarFiles, importGrammarFiles, tool);
+ } catch (Exception e) {
+ log.error("Dependency analysis failed, see exception report for details",
+ e);
+ throw new MojoFailureException("Dependency analysis failed.", e);
+ }
+
// Set working directory for ANTLR to be the base source directory
tool.inputDirectory = sourceDirectory;
@@ -288,6 +294,12 @@ public class Antlr4Mojo extends AbstractMojo {
// Tell Maven that there are some new source files underneath the output directory.
addSourceRoot(this.getOutputDirectory());
}
+
+ try {
+ dependencies.save();
+ } catch (IOException ex) {
+ log.warn("Could not save grammar dependency status", ex);
+ }
}
private List<String> getCommandArguments() {
@@ -310,9 +322,10 @@ public class Antlr4Mojo extends AbstractMojo {
args.add("-atn");
}
- if (encoding != null && !encoding.isEmpty()) {
+ if ( inputEncoding!=null && !inputEncoding.isEmpty()) {
args.add("-encoding");
- args.add(encoding);
+ outputEncoding = inputEncoding;
+ args.add(inputEncoding);
}
if (listener) {
@@ -355,22 +368,11 @@ public class Antlr4Mojo extends AbstractMojo {
* @param sourceDirectory
* @exception InclusionScanException
*/
-
- private List<List<String>> processGrammarFiles(List<String> args, File sourceDirectory) throws InclusionScanException {
- // Which files under the source set should we be looking for as grammar files
- SourceMapping mapping = new SuffixMapping("g4", Collections.<String>emptySet());
-
- // What are the sets of includes (defaulted or otherwise).
- Set<String> includes = getIncludesPatterns();
-
- // Now, to the excludes, we need to add the imports directory
- // as this is autoscanned for imported grammars and so is auto-excluded from the
- // set of grammar fields we should be analyzing.
- excludes.add("imports/**");
-
- SourceInclusionScanner scan = new SimpleSourceInclusionScanner(includes, excludes);
- scan.addSourceMapping(mapping);
- Set<File> grammarFiles = scan.getIncludedSources(sourceDirectory, null);
+ private List<List<String>> processGrammarFiles(
+ List<String> args,
+ Set<File> grammarFiles,
+ GrammarDependencies dependencies,
+ File sourceDirectory) throws InclusionScanException, IOException {
// We don't want the plugin to run for every grammar, regardless of whether
// it's changed since the last compilation. Check the mtime of the tokens vs
@@ -381,7 +383,8 @@ public class Antlr4Mojo extends AbstractMojo {
String tokensFileName = grammarFile.getName().split("\\.")[0] + ".tokens";
File outputFile = new File(outputDirectory, tokensFileName);
if ( (! outputFile.exists()) ||
- outputFile.lastModified() < grammarFile.lastModified() ) {
+ outputFile.lastModified() < grammarFile.lastModified() ||
+ dependencies.isDependencyChanged(grammarFile)) {
grammarFilesToProcess.add(grammarFile);
}
}
@@ -405,7 +408,7 @@ public class Antlr4Mojo extends AbstractMojo {
getLog().debug("Grammar file '" + grammarFile.getPath() + "' detected.");
- String relPathBase = findSourceSubdir(sourceDirectory, grammarFile.getPath());
+ String relPathBase = MojoUtils.findSourceSubdir(sourceDirectory, grammarFile);
String relPath = relPathBase + grammarFile.getName();
getLog().debug(" ... relative path is: " + relPath);
@@ -430,6 +433,39 @@ public class Antlr4Mojo extends AbstractMojo {
return result;
}
+ private Set<File> getImportFiles(File sourceDirectory) throws InclusionScanException {
+ if (!libDirectory.exists()) return Collections.emptySet();
+
+ Set<String> includes = new HashSet<String>();
+ includes.add("*.g4");
+ includes.add("*.tokens");
+
+ SourceInclusionScanner scan = new SimpleSourceInclusionScanner(includes,
+ Collections.<String>emptySet());
+ scan.addSourceMapping(new SuffixMapping("G4", "g4"));
+
+ return scan.getIncludedSources(libDirectory, null);
+ }
+
+ private Set<File> getGrammarFiles(File sourceDirectory) throws InclusionScanException
+ {
+ // Which files under the source set should we be looking for as grammar files
+ SourceMapping mapping = new SuffixMapping("g4", Collections.<String>emptySet());
+
+ // What are the sets of includes (defaulted or otherwise).
+ Set<String> includes = getIncludesPatterns();
+
+ // Now, to the excludes, we need to add the imports directory
+ // as this is autoscanned for imported grammars and so is auto-excluded from the
+ // set of grammar fields we should be analyzing.
+ excludes.add("imports/**");
+
+ SourceInclusionScanner scan = new SimpleSourceInclusionScanner(includes, excludes);
+ scan.addSourceMapping(mapping);
+
+ return scan.getIncludedSources(sourceDirectory, null);
+ }
+
private static String getPackageName(String relativeFolderPath) {
if (relativeFolderPath.contains("..")) {
throw new UnsupportedOperationException("Cannot handle relative paths containing '..'");
@@ -450,30 +486,14 @@ public class Antlr4Mojo extends AbstractMojo {
return includes;
}
- /**
- * Given the source directory File object and the full PATH to a grammar,
- * produce the path to the named grammar file in relative terms to the
- * {@code sourceDirectory}. This will then allow ANTLR to produce output
- * relative to the base of the output directory and reflect the input
- * organization of the grammar files.
- *
- * @param sourceDirectory The source directory {@link File} object
- * @param grammarFileName The full path to the input grammar file
- * @return The path to the grammar file relative to the source directory
- */
- private String findSourceSubdir(File sourceDirectory, String grammarFileName) {
- String srcPath = sourceDirectory.getPath() + File.separator;
+ private File getDependenciesStatusFile() {
+ File statusFile = new File(statusDirectory, "dependencies.ser");
- if (!grammarFileName.startsWith(srcPath)) {
- throw new IllegalArgumentException("expected " + grammarFileName + " to be prefixed with " + sourceDirectory);
+ if (!statusFile.getParentFile().exists()) {
+ statusFile.getParentFile().mkdirs();
}
- File unprefixedGrammarFileName = new File(grammarFileName.substring(srcPath.length()));
- if (unprefixedGrammarFileName.getParent() == null) {
- return "";
- }
-
- return unprefixedGrammarFileName.getParent() + File.separator;
+ return statusFile;
}
private final class CustomTool extends Tool {
@@ -515,7 +535,21 @@ public class Antlr4Mojo extends AbstractMojo {
URI relativePath = project.getBasedir().toURI().relativize(outputFile.toURI());
getLog().debug(" Writing file: " + relativePath);
OutputStream outputStream = buildContext.newFileOutputStream(outputFile);
- return new BufferedWriter(new OutputStreamWriter(outputStream));
+ if ( outputEncoding!=null && !outputEncoding.isEmpty()) {
+ return new BufferedWriter(new OutputStreamWriter(outputStream, outputEncoding));
+ }
+ else {
+ return new BufferedWriter(new OutputStreamWriter(outputStream));
+ }
}
}
+
+ /**
+ * Validates the given encoding.
+ *
+ * @return the validated encoding. If {@code null} was provided, returns the platform default encoding.
+ */
+ private String validateEncoding(String encoding) {
+ return (encoding == null) ? Charset.defaultCharset().name() : Charset.forName(encoding.trim()).name();
+ }
}
diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java
new file mode 100644
index 0000000..f8ebb1e
--- /dev/null
+++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.mojo.antlr4;
+
+import org.antlr.runtime.tree.Tree;
+import org.antlr.v4.Tool;
+import org.antlr.v4.misc.Graph;
+import org.antlr.v4.parse.ANTLRParser;
+import org.antlr.v4.tool.ast.GrammarAST;
+import org.antlr.v4.tool.ast.GrammarRootAST;
+import org.apache.maven.plugin.logging.Log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+class GrammarDependencies {
+ private final Graph<String> graph = new Graph<String>();
+ private final File sourceDirectory;
+ private final File libDirectory;
+ private final File statusFile;
+ private final String packageName;
+
+ /** Map grammars to their checksum and references. */
+ private final Map<File, Map.Entry<byte[], Collection<String>>> grammars;
+ private final Log log;
+
+ public GrammarDependencies(File sourceDirectory, File libDirectory,
+ List<String> arguments, File status, Log log) {
+ this.log = log;
+ this.sourceDirectory = sourceDirectory;
+ this.libDirectory = libDirectory;
+ this.statusFile = status;
+ this.grammars = loadStatus(status);
+ this.packageName = getPackage(arguments);
+ }
+
+ /**
+ * Determines the package to use.
+ *
+ * @param arguments the tool arguments.
+ *
+ * @return the package. Returns {@code null} to indicate that no package should be
+ * used.
+ */
+ private String getPackage(List<String> arguments) {
+ int index = (arguments != null) ? arguments.indexOf("-package") : -1;
+
+ return (index > -1)
+ ? (arguments.get(index + 1).replace('.', File.separatorChar) +
+ File.separatorChar)
+ : null;
+ }
+
+ public void save() throws IOException {
+ if (!grammars.isEmpty()) {
+ log.debug("Persisting grammars dependency status: " + statusFile);
+
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(
+ statusFile));
+
+ try {
+ out.writeObject(grammars);
+ } finally {
+ out.close();
+ }
+ }
+ }
+
+ /**
+ * Performs dependency analysis for the given grammar files.
+ *
+ * @param grammarFiles the grammar files.
+ * @param importGrammarFiles the import grammar files.
+ * @param tool the tool to use.
+ *
+ * @return self-reference.
+ */
+ public GrammarDependencies analyze(Set<File> grammarFiles,
+ Set<File> importGrammarFiles, Tool tool) throws IOException {
+ log.debug("Analysing grammar dependencies " + sourceDirectory);
+
+ // for dependency analysis we require all grammars
+ Collection<File> grammarsAndTokens = new HashSet<File>();
+ grammarsAndTokens.addAll(importGrammarFiles);
+ grammarsAndTokens.addAll(grammarFiles);
+
+ for (File grammarFile : grammarsAndTokens) {
+ // .tokens files must not be parsed, they can just be referenced
+ if (!grammarFile.getName().endsWith(".tokens"))
+ analyse(grammarFile, grammarsAndTokens, tool);
+ }
+
+ for (File grammarFile : grammarFiles) {
+ Collection<String> usages = findUsages(getRelativePath(grammarFile));
+
+ if (!usages.isEmpty()) {
+ grammars.put(grammarFile,
+ new AbstractMap.SimpleImmutableEntry<byte[], Collection<String>>(
+ MojoUtils.checksum(grammarFile), usages));
+
+ log.debug(" " + getRelativePath(grammarFile) + " used by " + usages);
+ }
+ }
+
+ for (File grammarFile : importGrammarFiles) {
+ // imported files are not allowed to be qualified
+ Collection<String> usages = findUsages(grammarFile.getName());
+
+ if (!usages.isEmpty()) {
+ grammars.put(grammarFile,
+ new AbstractMap.SimpleImmutableEntry<byte[], Collection<String>>(
+ MojoUtils.checksum(grammarFile), usages));
+
+ log.debug(" " + grammarFile.getName() + " imported by " + usages);
+ }
+ }
+
+ return this;
+ }
+
+
+ /**
+ * Determines whether a grammar used by the given grammar was modified since the last
+ * build.
+ *
+ * @param grammarFile the grammar.
+ *
+ * @return {@code true} if a grammar used by the given grammar has been modified.
+ */
+ public boolean isDependencyChanged(File grammarFile) throws IOException {
+ String grammarPath = getRelativePath(grammarFile);
+
+ for (Map.Entry<File, Map.Entry<byte[], Collection<String>>> e : grammars.entrySet()) {
+ File depGrammarFile = e.getKey();
+ byte[] checksum = e.getValue().getKey();
+ Collection<String> usages = e.getValue().getValue();
+
+ if (usages.contains(grammarPath)) {
+ if (!depGrammarFile.exists() || !Arrays.equals(MojoUtils.checksum(depGrammarFile), checksum)) {
+ log.debug(" " + grammarPath + ": dependency " +
+ depGrammarFile.getName() + " changed");
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Determines the relative target path of the given grammar file.
+ *
+ * @param grammarFile the grammar file.
+ *
+ * @return the relative path.
+ */
+ private String getRelativePath(File grammarFile) {
+ // the library directory does not allow sub-directories
+ if (grammarFile.getPath().startsWith(libDirectory.getPath()))
+ return grammarFile.getName();
+
+ // if a package is given, we have to use it
+ if (packageName != null)
+ return packageName + grammarFile.getName();
+
+ // otherwise resolve the path relative to the source directory
+ String path = MojoUtils.findSourceSubdir(sourceDirectory, grammarFile);
+
+ return path + grammarFile.getName();
+ }
+
+ /**
+ * Returns the grammar file names that directly or indirectly use the given grammar.
+ *
+ * @param grammarFileName the grammar file name.
+ *
+ * @return the grammar file names that use the given grammar file.
+ */
+ private Collection<String> findUsages(String grammarFileName) {
+ Collection<String> result = new ArrayList<String>();
+ explore(grammarFileName, result);
+
+ return result;
+ }
+
+ private void explore(String grammarName, Collection<String> result) {
+ for (Graph.Node<String> node : graph.getNode(grammarName).edges) {
+ result.add(node.payload);
+ explore(node.payload, result);
+ }
+ }
+
+ private void analyse(File grammarFile, Collection<File> grammarFiles, Tool tool) {
+ GrammarRootAST grammar = tool.parseGrammar(grammarFile.getAbsolutePath());
+
+ if (grammar == null)
+ return;
+
+ for (GrammarAST importDecl : grammar.getAllChildrenWithType(ANTLRParser.IMPORT)) {
+ Tree id = importDecl.getFirstChildWithType(ANTLRParser.ID);
+
+ // missing id is not valid, but we don't want to prevent the root cause from
+ // being reported by the ANTLR tool
+ if (id != null) {
+ String grammarPath = getRelativePath(grammarFile);
+
+ graph.addEdge(id.getText() + ".g4", grammarPath);
+ }
+ }
+
+ for (GrammarAST options : grammar.getAllChildrenWithType(ANTLRParser.OPTIONS)) {
+ for (int i = 0, count = options.getChildCount(); i < count; i++) {
+ Tree option = options.getChild(i);
+
+ if (option.getType() == ANTLRParser.ASSIGN) {
+ String key = option.getChild(0).getText();
+ String value = option.getChild(1).getText();
+
+ if ("tokenVocab".equals(key)) {
+ String name = stripQuotes(value);
+ // the grammar name may be qualified, but we resolve the path anyway
+ String grammarName = stripPath(name);
+ String grammarPath = MojoUtils.findSourceSubdir(sourceDirectory,
+ grammarFile);
+ File depGrammarFile = resolve(grammarName, grammarPath);
+
+ // if a package has been given, we use it instead of the file directory path
+ // (files probably reside in the root directory anyway with such a configuration )
+ if (packageName != null)
+ grammarPath = packageName;
+
+ graph.addEdge(getRelativePath(depGrammarFile),
+ grammarPath + grammarFile.getName());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Resolves the given grammar name.
+ *
+ * @param name the name.
+ * @param path the relative path.
+ *
+ * @return the grammar file.
+ */
+ private File resolve(String name, String path) {
+ File file = new File(sourceDirectory, path + name + ".g4");
+
+ if (file.exists())
+ return file;
+
+ file = new File(libDirectory, name + ".g4");
+
+ if (file.exists())
+ return file;
+
+ return new File(libDirectory, name + ".tokens");
+ }
+
+ private Map<File, Map.Entry<byte[], Collection<String>>> loadStatus(File statusFile) {
+ if (statusFile.exists()) {
+ log.debug("Load grammars dependency status: " + statusFile);
+
+ try {
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(
+ statusFile));
+
+ try {
+ @SuppressWarnings("unchecked")
+ Map<File, Map.Entry<byte[], Collection<String>>> data =
+ (Map<File, Map.Entry<byte[], Collection<String>>>)
+ in.readObject();
+
+ return data;
+ } finally {
+ in.close();
+ }
+ } catch (Exception ex) {
+ log.warn("Could not load grammar dependency status information", ex);
+ }
+ }
+
+ return new HashMap<File, Map.Entry<byte[], Collection<String>>>();
+ }
+
+ private String stripPath(String str) {
+ return str.replaceAll("^.*[/\\\\]", "");
+ }
+
+ private String stripQuotes(String str) {
+ return str.replaceAll("\\A'|'\\Z", "");
+ }
+}
diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java
new file mode 100644
index 0000000..56da59b
--- /dev/null
+++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.mojo.antlr4;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+
+class MojoUtils {
+ /**
+ * Creates the MD5 checksum for the given file.
+ *
+ * @param file the file.
+ *
+ * @return the checksum.
+ */
+ public static byte[] checksum(File file) throws IOException {
+ try {
+ InputStream in = new FileInputStream(file);
+ byte[] buffer = new byte[2048];
+ MessageDigest complete = MessageDigest.getInstance("MD5");
+
+ try {
+ int n;
+
+ do {
+ n = in.read(buffer);
+
+ if (n > 0) {
+ complete.update(buffer, 0, n);
+ }
+ } while (n != -1);
+ } finally {
+ in.close();
+ }
+
+ return complete.digest();
+ } catch (NoSuchAlgorithmException ex) {
+ throw new IOException("Could not create checksum " + file, ex);
+ }
+ }
+
+ /**
+ * Given the source directory File object and the full PATH to a grammar, produce the
+ * path to the named grammar file in relative terms to the {@code sourceDirectory}.
+ * This will then allow ANTLR to produce output relative to the base of the output
+ * directory and reflect the input organization of the grammar files.
+ *
+ * @param sourceDirectory The source directory {@link File} object
+ * @param grammarFileName The full path to the input grammar file
+ *
+ * @return The path to the grammar file relative to the source directory
+ */
+ public static String findSourceSubdir(File sourceDirectory, File grammarFile) {
+ String srcPath = sourceDirectory.getPath() + File.separator;
+ String path = grammarFile.getPath();
+
+ if (!path.startsWith(srcPath)) {
+ throw new IllegalArgumentException("expected " + path +
+ " to be prefixed with " + sourceDirectory);
+ }
+
+ File unprefixedGrammarFileName = new File(path.substring(srcPath.length()));
+
+ if (unprefixedGrammarFileName.getParent() == null) {
+ return "";
+ }
+
+ return unprefixedGrammarFileName.getParent() + File.separator;
+ }
+}
diff --git a/antlr4-maven-plugin/src/site/site.xml b/antlr4-maven-plugin/src/site/site.xml
index 0cf1aa2..23cd29c 100644
--- a/antlr4-maven-plugin/src/site/site.xml
+++ b/antlr4-maven-plugin/src/site/site.xml
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project name="ANTLR v4 Maven plugin">
<publishDate position="left"/>
@@ -7,7 +13,7 @@
<poweredBy>
<logo name="ANTLR Web Site" href="http://antlr.org/"
- img="http://www.antlr.org/wiki/download/attachments/292/ANTLR4"/>
+ img="http://www.antlr.org/images/antlr-logo.png"/>
</poweredBy>
<body>
diff --git a/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java b/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java
new file mode 100644
index 0000000..12c45cd
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.mojo.antlr4;
+
+import io.takari.maven.testing.TestMavenRuntime;
+import io.takari.maven.testing.TestResources;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class Antlr4MojoTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public final TestResources resources = new TestResources();
+
+ @Rule
+ public final TestMavenRuntime maven = new TestMavenRuntime();
+
+ @Test
+ public void importTokens() throws Exception {
+ Path baseDir = resources.getBasedir("importTokens").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("target/generated-sources/antlr4");
+
+ Path genParser = generatedSources.resolve("test/SimpleParser.java");
+ Path tokens = antlrDir.resolve("imports/SimpleLexer.tokens");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genParser));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genParser));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] sum = checksum(genParser);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(sum, checksum(genParser)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ try(Change change = Change.of(tokens, "DOT=4")) {
+ byte[] sum = checksum(genParser);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(sum, checksum(genParser)));
+ }
+ }
+
+ @Test
+ public void importsCustomLayout() throws Exception {
+ Path baseDir = resources.getBasedir("importsCustom").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("src/main/java");
+
+ Path genTestLexer = generatedSources.resolve("foo/TestLexer.java");
+ Path genTestParser = generatedSources.resolve("foo/TestParser.java");
+ Path genHello = generatedSources.resolve("foo/HelloParser.java");
+
+ Path baseGrammar = antlrDir.resolve("imports/TestBaseLexer.g4");
+ Path lexerGrammar = antlrDir.resolve("TestLexer.g4");
+ Path parserGrammar = antlrDir.resolve("TestParser.g4");
+
+ Xpp3Dom outputDirectory = TestMavenRuntime.newParameter("outputDirectory",
+ "src/main/java/foo");
+ Xpp3Dom arguments = new Xpp3Dom("arguments");
+ arguments.addChild(TestMavenRuntime.newParameter("argument", "-package"));
+ arguments.addChild(TestMavenRuntime.newParameter("argument", "foo"));
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4", outputDirectory, arguments);
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genHello));
+ assertFalse(Files.exists(genTestParser));
+ assertFalse(Files.exists(genTestLexer));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genHello));
+ assertTrue(Files.exists(genTestParser));
+ assertTrue(Files.exists(genTestLexer));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertTrue(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(baseGrammar, "DOT: '.' ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 4th - the lexer grammar changed, the parser grammar has to be processed as well
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(lexerGrammar, "fragment DOT : '.';")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 5th - the parser grammar changed, no other grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(parserGrammar, " t : WS* ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+ }
+
+ @Test
+ public void importsStandardLayout() throws Exception {
+ Path baseDir = resources.getBasedir("importsStandard").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("target/generated-sources/antlr4");
+
+ Path genTestLexer = generatedSources.resolve("test/TestLexer.java");
+ Path genTestParser = generatedSources.resolve("test/TestParser.java");
+ Path genHello = generatedSources.resolve("test/HelloParser.java");
+
+ Path baseGrammar = antlrDir.resolve("imports/TestBaseLexer.g4");
+ Path lexerGrammar = antlrDir.resolve("test/TestLexer.g4");
+ Path parserGrammar = antlrDir.resolve("test/TestParser.g4");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genHello));
+ assertFalse(Files.exists(genTestParser));
+ assertFalse(Files.exists(genTestLexer));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genHello));
+ assertTrue(Files.exists(genTestParser));
+ assertTrue(Files.exists(genTestLexer));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertTrue(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(baseGrammar, "DOT: '.' ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 4th - the lexer grammar changed, the parser grammar has to be processed as well
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(lexerGrammar)) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 5th - the parser grammar changed, no other grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(parserGrammar, " t : WS* ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+ }
+
+ @Test
+ public void processWhenDependencyRemoved() throws Exception {
+ Path baseDir = resources.getBasedir("dependencyRemoved").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+
+ Path baseGrammar = antlrDir.resolve("imports/HelloBase.g4");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ maven.executeMojo(session, project, exec);
+
+ try(Change temp = Change.of(baseGrammar)) {
+ // if the base grammar no longer exists, processing must be performed
+ Files.delete(baseGrammar);
+
+ thrown.expect(MojoExecutionException.class);
+ thrown.expectMessage("ANTLR 4 caught 1 build errors.");
+
+ maven.executeMojo(session, project, exec);
+ }
+ }
+
+ private byte[] checksum(Path path) throws IOException {
+ return MojoUtils.checksum(path.toFile());
+ }
+
+ private static class Change implements AutoCloseable {
+ final Path file;
+ final byte[] original;
+
+ public Change(Path file, String change) {
+ this.file = file;
+
+ try {
+ original = Files.readAllBytes(file);
+ } catch (IOException ex) {
+ throw new RuntimeException("Could not read file " + file);
+ }
+
+ String text = new String(original, StandardCharsets.UTF_8) + change;
+
+ write(file, text.getBytes(StandardCharsets.UTF_8));
+ }
+
+ private void write(Path file, byte[] data) {
+ try {
+ Files.write(file, data);
+ } catch (IOException ex) {
+ throw new RuntimeException("Could not write file " + file);
+ }
+ }
+
+ public static Change of(Path file, String change) {
+ return new Change(file, change);
+ }
+
+ public static Change of(Path file) {
+ return new Change(file, "\n");
+ }
+
+ @Override
+ public void close() {
+ write(file, original);
+ }
+ }
+}
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml
new file mode 100644
index 0000000..3163b81
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>deps.removed</groupId>
+ <artifactId>depRemoved</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test processing after dependency removed</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4 b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4 b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4
new file mode 100644
index 0000000..54f998c
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4
@@ -0,0 +1,7 @@
+grammar Hello;
+
+import HelloBase;
+
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ;
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml
new file mode 100644
index 0000000..478b517
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>import.tokens</groupId>
+ <artifactId>importTokens</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing tokens file</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens
new file mode 100644
index 0000000..4637d6e
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens
@@ -0,0 +1,3 @@
+ID=1
+INT=2
+SEMI=3
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4 b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4
new file mode 100644
index 0000000..bbd8274
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4
@@ -0,0 +1,8 @@
+parser grammar SimpleParser;
+options {
+ // get token types from SimpleLexer.tokens; don't name it
+ // SimpleParser.tokens as ANTLR will overwrite!
+ tokenVocab=SimpleLexer;
+}
+
+s : ( ID | INT )* SEMI ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml
new file mode 100644
index 0000000..a5826bc
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml
@@ -0,0 +1,48 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>imports.custom</groupId>
+ <artifactId>importsCustom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing, custom layout</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${basedir}/src/main/java/com/foo</outputDirectory>
+ <arguments>
+ <argument>-visitor</argument>
+ <argument>-no-listener</argument>
+ <argument>-Xlog</argument>
+ <argument>-package</argument>
+ <argument>com.foo</argument>
+ </arguments>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4
new file mode 100644
index 0000000..e38ac87
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4
@@ -0,0 +1,4 @@
+grammar Hello;
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4
new file mode 100644
index 0000000..668b764
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4
@@ -0,0 +1,6 @@
+lexer grammar TestLexer;
+
+import TestBaseLexer;
+
+WS : Whitespace+ -> skip;
+TEXT : ~[<&]+ ; // match any 16 bit char other than < and & \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4
new file mode 100644
index 0000000..5c25961
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4
@@ -0,0 +1,5 @@
+parser grammar TestParser;
+
+options { tokenVocab=TestLexer; }
+
+document : (Comment | Name) EOF ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml
new file mode 100644
index 0000000..77f63a2
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>imports.standard</groupId>
+ <artifactId>importsStandard</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing, standard layout</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4
new file mode 100644
index 0000000..e38ac87
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4
@@ -0,0 +1,4 @@
+grammar Hello;
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4
new file mode 100644
index 0000000..668b764
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4
@@ -0,0 +1,6 @@
+lexer grammar TestLexer;
+
+import TestBaseLexer;
+
+WS : Whitespace+ -> skip;
+TEXT : ~[<&]+ ; // match any 16 bit char other than < and & \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4
new file mode 100644
index 0000000..5c25961
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4
@@ -0,0 +1,5 @@
+parser grammar TestParser;
+
+options { tokenVocab=TestLexer; }
+
+document : (Comment | Name) EOF ; \ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..5718455
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,8 @@
+version: '4.6-SNAPSHOT+AppVeyor.{build}'
+os: Windows Server 2012
+build_script:
+ - mvn -DskipTests install -q --batch-mode
+test_script:
+ - mvn install -q -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" -Dantlr-javascript-nodejs="C:\Program Files (x86)\nodejs\node.exe" --batch-mode
+build:
+ verbosity: minimal
diff --git a/contributors.txt b/contributors.txt
index 687eeaf..db7d4df 100644
--- a/contributors.txt
+++ b/contributors.txt
@@ -1,4 +1,4 @@
-ANTLR Project Contributors Certification of Origin and Rights
+ANTLR Project Contributors Certification of Origin and Rights
All contributors to ANTLR v4 must formally agree to abide by this
certificate of origin by signing on the bottom with their github
@@ -58,6 +58,7 @@ YYYY/MM/DD, github id, Full name, email
2014/03/18, aphyr, Kyle Kingsbury, aphyr@aphyr.com
2014/06/07, ericvergnaud, Eric Vergnaud, eric.vergnaud@wanadoo.fr
2014/07/04, jimidle, Jim Idle, jimi@Idle.ws
+2014/01/01, danmclaughlin, Dan McLaughlin, dan.mclaughlin@gmail.com
2014/09/04. jeduden, Jan-Eric Duden, jeduden@gmail.com
2014/09/27, petrbel, Petr Bělohlávek, antlr@petrbel.cz
2014/10/18, sergiusignacius, Sérgio Silva, serge.a.silva@gmail.com
@@ -89,6 +90,40 @@ YYYY/MM/DD, github id, Full name, email
2015/12/23, pboyer, Peter Boyer, peter.b.boyer@gmail.com
2015/12/24, dtymon, David Tymon, david.tymon@gmail.com
2016/02/18, reitzig, Raphael Reitzig, reitzig[at]cs.uni-kl.de
+2016/03/10, mike-lischke, Mike Lischke, mike@lischke-online.de
2016/03/27, beardlybread, Bradley Steinbacher, bradley.j.steinbacher@gmail.com
2016/03/29, msteiger, Martin Steiger, antlr@martin-steiger.de
2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de
+2016/07/10, twz123, Tom Wieczorek, tom.wieczorek@zalando.de
+2016/07/20, chrisheller, Chris Heller, chris.heller.greyheller@gmail.com
+2016/07/20, nburles, Nathan Burles, nburles@gmail.com
+2016/07/20, kosl90, Li Liqiang, kos1990l@gmail.com
+2016/07/27, timoc, Tim O'Callaghan, timo@linux.com
+2016/07/26, nic30, Michal Orsák, michal.o.socials@gmail.com
+2016/07/18, willfaught, Will Faught, will.faught@gmail.com
+2016/08/08, wjkohnen, Wolfgang Johannes Kohnen, wjkohnen-go-antlr@ko-sys.com
+2016/08/11, BurtHarris, Ralph "Burt" Harris, Burt_Harris_antlr4@azxs.33mail.com
+2016/08/19, andjo403, Andreas Jonson, andjo403@hotmail.com
+2016/09/27, harriman, Kurt Harriman, harriman@acm.org
+2016/10/13, cgudrian, Christian Gudrian, christian.gudrian@gmx.de
+2016/10/13, nielsbasjes, Niels Basjes, niels@basjes.nl
+2016/10/21, FloorGoddijn, Floor Goddijn, floor.goddijn[at]aimms.com
+2016/11/01, RYDB3RG, Kai Stammerjohann, RYDB3RG@users.noreply.github.com
+2016/11/05, runner-mei, meifakun, runner.mei@gmail.com
+2016/11/15, hanjoes, Hanzhou Shi, hanzhou87@gmail.com
+2016/11/16, sridharxp, Sridharan S, aurosridhar@gmail.com
+2016/11/06, NoodleOfDeath, Thom Morgan, github@bytemeapp.com
+2016/11/01, sebkur, Sebastian Kürten, sebastian@topobyte.de
+2016/04/13, renatahodovan, Renata Hodovan, reni@inf.u-szeged.hu
+2016/11/05, ewanmellor, Ewan Mellor, github@ewanmellor.org
+2016/11/06, janyou, Janyou, janyou.antlr@outlook.com
+2016/11/20, marcohu, Marco Hunsicker, antlr@hunsicker.de
+2016/09/02, lygav, Vladimir (Vladi) Lyga, lyvladi@gmail.com
+2016/09/23, ghosthope, Dmitry Shakhtanov, sudstrike@gmail.com
+2016/11/25, MrSampson, Oliver Sampson, olsam@quickaudio.com
+2016/11/29, millergarym, Gary Miller, miller.garym@gmail.com
+2016/11/29, wxio, Gary Miller, gm@wx.io
+2016/11/29, Naios, Denis Blank, naios@users.noreply.github.com
+2016/12/01, samtatasurya, Samuel Tatasurya, xemradiant@gmail.com
+2016/12/03, redxdev, Samuel Bloomberg, sam@redxdev.com
+2016/12/11, Gaulouis, Gaulouis, gaulouis.com@gmail.com
diff --git a/doc/IDEs.md b/doc/IDEs.md
new file mode 100644
index 0000000..7c21e8a
--- /dev/null
+++ b/doc/IDEs.md
@@ -0,0 +1,5 @@
+# Integrating ANTLR into Development Systems
+
+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 2, Python 3, JavaScript, Go, C++, and Swift targets.
+
+The easiest thing is probably just to use an [ANTLR plug-in](http://www.antlr.org/tools.html) for your favorite development environment.
diff --git a/doc/ace-javascript-target.md b/doc/ace-javascript-target.md
new file mode 100644
index 0000000..fbba9e9
--- /dev/null
+++ b/doc/ace-javascript-target.md
@@ -0,0 +1,247 @@
+# Integrating ANTLR JavaScript parsers with ACE editor
+
+Having the ability to parse code other than JavaScript is great, but nowadays users expect to be able to edit code with nice edit features such as keyword highlighting, indentation and brace matching, and advanced ones such as syntax checking.
+
+I have been through the process of integrating an ANTLR parser with ACE, the dominant code editor for web based code editing. Information about ACE can be found on their web site.
+
+This page describes my experience, and humbly aims to help you get started. It is not however a reference guide, and no support is provided.
+
+## Architecture
+
+The ACE editor is organized as follows
+
+1. The editor itself is a <div> which once initialized comprises a number of elements. This UI element is responsible for the display, and the generation of edit events.
+1. The editor relies on a Session, which manages events and configuration.
+1. The code itself is stored in a Document. Any insertion or deletion of text is reflected in the Document.
+1. Keyword highlighting, indentation and brace matching are delegated to a mode. There is no direct equivalent of an ACE mode in ANTLR. While keywords are the equivalent of ANTLR lexer tokens, indentation and brace matching are edit tasks, not parsing ones. A given ACE editor can only have one mode, which corresponds to the language being edited. There is no need for ANTLR integration to support keyword highlighting, indentation and brace matching.
+1. Syntax checking is delegated to a worker. This is where ANTLR integration is needed. If syntax checking is enabled, ACE asks the mode to create a worker. In JavaScript, workers run in complete isolation i.e. they don't share code or variables with other workers, or with the HTML page itself.
+1. The below diagram describes how the whole system works. In green are the components *you* need to provide. You'll notice that there is no need to load ANTLR in the HTML page itself. You'll also notice that ACE maintains a document in each thread. This is done through low level events sent by the ACE session to the worker which describe the delta. Once applied to the worker document, a high level event is triggered, which is easy to handle since at this point the worker document is a perfect copy of the UI document.
+
+<img src=images/ACE-Architecture.001.png>
+
+## Step-by-step guide
+
+The first thing to do is to create an editor in your html page. This is thoroughly described in the ACE documentation, so we'll just sum it up here:
+
+```xml
+<script src="../js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
+<script>
+ var editor = ace.edit("editor");
+</script>
+```
+
+This should give you a working editor. You may want to control its sizing using CSS. I personally load the editor in an iframe and set its style to position: absolute, top: 0, left: 0 etc... but I'm sure you know better than me how to achieve results.
+
+The second thing to do is to configure the ACE editor to use your mode i.e. language configuration. A good place to start is to inherit from the built-in TextMode. The following is a very simple example, which only caters for comments, literals, and a limited subset of separators and keywords :
+
+```javascript
+ace.define('ace/mode/my-mode',["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules", "ace/worker/worker_client" ], function(require, exports, module) {
+ var oop = require("ace/lib/oop");
+ var TextMode = require("ace/mode/text").Mode;
+ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
+
+ var MyHighlightRules = function() {
+ var keywordMapper = this.createKeywordMapper({
+ "keyword.control": "if|then|else",
+ "keyword.operator": "and|or|not",
+ "keyword.other": "class",
+ "storage.type": "int|float|text",
+ "storage.modifier": "private|public",
+ "support.function": "print|sort",
+ "constant.language": "true|false"
+ }, "identifier");
+ this.$rules = {
+ "start": [
+ { token : "comment", regex : "//" },
+ { token : "string", regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' },
+ { token : "constant.numeric", regex : "0[xX][0-9a-fA-F]+\\b" },
+ { token : "constant.numeric", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" },
+ { token : "keyword.operator", regex : "!|%|\\\\|/|\\*|\\-|\\+|~=|==|<>|!=|<=|>=|=|<|>|&&|\\|\\|" },
+ { token : "punctuation.operator", regex : "\\?|\\:|\\,|\\;|\\." },
+ { token : "paren.lparen", regex : "[[({]" },
+ { token : "paren.rparen", regex : "[\\])}]" },
+ { token : "text", regex : "\\s+" },
+ { token: keywordMapper, regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }
+ ]
+ };
+ };
+ oop.inherits(MyHighlightRules, TextHighlightRules);
+
+ var MyMode = function() {
+ this.HighlightRules = MyHighlightRules;
+ };
+ oop.inherits(MyMode, TextMode);
+
+ (function() {
+
+ this.$id = "ace/mode/my-mode";
+
+ }).call(MyMode.prototype);
+
+ exports.Mode = MyMode;
+});
+```
+
+Now if you store the above in a file called "my-mode.js", setting the ACE Editor becomes straightforward:
+
+```xml
+<script src="../js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
+<script src="../js/my-mode.js" type="text/javascript" charset="utf-8"></script>
+<script>
+ var editor = ace.edit("editor");
+ editor.getSession().setMode("ace/mode/my-mode");
+</script>
+```
+
+At this point you should have a working editor, able to highlight keywords. You may wonder why you need to set the tokens when you have already done so in your ANTLR lexer grammar. First, ACE expects a classification (control, operator, type...) which does not exist in ANTLR. Second, there is no need for ANTLR to achieve this, since ACE comes with its own lexer.
+
+Ok, now that we have a working editor comes the time where we need syntax validation. This is where the worker comes in the picture.
+
+Creating the worker is the responsibility of the mode you provide. So you need to enhance it with something like the following:
+
+```javascript
+var WorkerClient = require("ace/worker/worker_client").WorkerClient;
+this.createWorker = function(session) {
+ this.$worker = new WorkerClient(["ace"], "ace/worker/my-worker", "MyWorker", "../js/my-worker.js");
+ this.$worker.attachToDocument(session.getDocument());
+
+ this.$worker.on("errors", function(e) {
+ session.setAnnotations(e.data);
+ });
+
+ this.$worker.on("annotate", function(e) {
+ session.setAnnotations(e.data);
+ });
+
+ this.$worker.on("terminate", function() {
+ session.clearAnnotations();
+ });
+
+ return this.$worker;
+
+};
+```
+
+The above code needs to be placed in the existing worker, after:
+
+```javascript
+this.$id = "ace/mode/my-mode";
+```
+
+Please note that the mode code runs on the UI side, not the worker side. The event handlers here are for events sent by the worker, not to the worker.
+
+Obviously the above won't work out of the box, because you need to provide the "my-worker.js" file.
+
+Creating a worker from scratch is not something I've tried. Simply put, your worker needs to handle all messages sent by ACE using the WorkerClient created by the mode. This is not a simple task, and is better delegated to existing ACE code, so we can focus on tasks specific to our language.
+
+What I did is I started from "mode-json.js", a rather simple worker which comes with ACE, stripped out all JSON validation related stuff out of it, and saved the remaining code in a file name "worker-base.js" which you can find [here](resources/worker-base.js). Once this done, I was able to create a simple worker, as follows:
+
+```javascript
+importScripts("worker-base.js");
+ace.define('ace/worker/my-worker',["require","exports","module","ace/lib/oop","ace/worker/mirror"], function(require, exports, module) {
+ "use strict";
+
+ var oop = require("ace/lib/oop");
+ var Mirror = require("ace/worker/mirror").Mirror;
+
+ var MyWorker = function(sender) {
+ Mirror.call(this, sender);
+ this.setTimeout(200);
+ this.$dialect = null;
+ };
+
+ oop.inherits(MyWorker, Mirror);
+
+ (function() {
+
+ this.onUpdate = function() {
+ var value = this.doc.getValue();
+ var annotations = validate(value);
+ this.sender.emit("annotate", annotations);
+ };
+
+ }).call(MyWorker.prototype);
+
+ exports.MyWorker = MyWorker;
+});
+
+var validate = function(input) {
+ return [ { row: 0, column: 0, text: "MyMode says Hello!", type: "error" } ];
+};
+```
+
+At this point, you should have an editor which displays an error icon next to the first line. When you hover over the error icon, it should display: MyMode says Hello!. Is that not a friendly worker? Yum.
+
+What remains to be done is have our validate function actually validate the input. Finally ANTLR comes in the picture!
+
+To start with, let's load ANTLR and your parser, listener etc.. Easy, since you could write:
+
+```js
+var antlr4 = require('antlr4/index');
+```
+
+This may work, but it's actually unreliable. The reason is that the require function used by ANTLR, which exactly mimics the NodeJS require function, uses a different syntax than the require function that comes with ACE. So we need to bring in a require function that conforms to the NodeJS syntax. I personally use one that comes from Torben Haase's Honey project, which you can find here. But hey, now we're going to have 2 'require' functions not compatible with each other! Indeed, this is why you need to take special care, as follows:
+
+```js
+// load nodejs compatible require
+var ace_require = require;
+require = undefined;
+var Honey = { 'requirePath': ['..'] }; // walk up to js folder, see Honey docs
+importScripts("../lib/require.js");
+var antlr4_require = require;
+require = ace_require;
+```
+Now it's safe to load antlr, and the parsers generated for your language. Assuming that your language files (generated or hand-built) are in a folder with an index.js file that calls require for each file, your parser loading code can be as simple as follows:
+```js
+// load antlr4 and myLanguage
+var antlr4, mylanguage;
+try {
+ require = antlr4_require;
+ antlr4 = require('antlr4/index');
+ mylanguage = require('mylanguage/index');
+} finally {
+ require = ace_require;
+}
+```
+Please note the try-finally construct. ANTLR uses 'require' synchronously so it's perfectly safe to ignore the ACE 'require' while running ANTLR code. ACE itself does not guarantee synchronous execution, so you are much safer always switching 'require' back to 'ace_require'.
+Now detecting deep syntax errors in your code is a task for your ANTLR listener or visitor or whatever piece of code you've delegated this to. We're not going to describe this here, since it would require some knowledge of your language. However, detecting grammar syntax errors is something ANTLR does beautifully (isn't that why you went for ANTLR in the first place?). So what we will illustrate here is how to report grammar syntax errors. I have no doubt that from there, you will be able to extend the validator to suit your specific needs.
+Whenever ANTLR encounters an unexpected token, it fires an error. By default, the error is routed to an error listener which simply writes to the console.
+What we need to do is replace this listener by our own listener, se we can route errors to the ACE editor. First, let's create such a listener:
+```js
+// class for gathering errors and posting them to ACE editor
+var AnnotatingErrorListener = function(annotations) {
+ antlr4.error.ErrorListener.call(this);
+ this.annotations = annotations;
+ return this;
+};
+
+AnnotatingErrorListener.prototype = Object.create(antlr4.error.ErrorListener.prototype);
+AnnotatingErrorListener.prototype.constructor = AnnotatingErrorListener;
+
+AnnotatingErrorListener.prototype.syntaxError = function(recognizer, offendingSymbol, line, column, msg, e) {
+ this.annotations.push({
+ row: line - 1,
+ column: column,
+ text: msg,
+ type: "error"
+ });
+};
+```
+With this, all that remains to be done is plug the listener in when we parse the code. Here is how I do it:
+```js
+var validate = function(input) {
+ var stream = new antlr4.InputStream(input);
+ var lexer = new mylanguage.MyLexer(stream);
+ var tokens = new antlr4.CommonTokenStream(lexer);
+ var parser = new mylanguage.MyParser(tokens);
+ var annotations = [];
+ var listener = new AnnotatingErrorListener(annotations)
+ parser.removeErrorListeners();
+ parser.addErrorListener(listener);
+ parser.parseMyRule();
+ return annotations;
+};
+```
+You know what? That's it! You now have an ACE editor that does syntax validation using ANTLR! I hope you find this useful, and simple enough to get started.
+What I did not address here is packaging, not something I'm an expert at. The good news is that it makes development simple, since I don't have to run any compilation process. I just edit my code, reload my editor page, and check how it goes.
+Now wait, hey! How do you debug this? Well, as usual, using Chrome, since neither Firefox or Safari are able to debug worker code. What a shame...
diff --git a/doc/actions.md b/doc/actions.md
new file mode 100644
index 0000000..ef51c8f
--- /dev/null
+++ b/doc/actions.md
@@ -0,0 +1,204 @@
+# Actions and Attributes
+
+In Chapter 10, Attributes and Actions, we learned how to embed actions within grammars and looked at the most common token and rule attributes. This section summarizes the important syntax and semantics from that chapter and provides a complete list of all available attributes. (You can learn more about actions in the grammar from the free excerpt on listeners and actions.)
+
+Actions are blocks of text written in the target language and enclosed in curly braces. The recognizer triggers them according to their locations within the grammar. For example, the following rule emits "found a decl" after the parser has seen a valid declaration:
+
+```
+decl: type ID ';' {System.out.println("found a decl");} ;
+type: 'int' | 'float' ;
+```
+
+Most often, actions access the attributes of tokens and rule references:
+
+```
+decl: type ID ';'
+ {System.out.println("var "+$ID.text+":"+$type.text+";");}
+ | t=ID id=ID ';'
+ {System.out.println("var "+$id.text+":"+$t.text+";");}
+ ;
+```
+
+## Token Attributes
+
+All tokens have a collection of predefined, read-only attributes. The attributes include useful token properties such as the token type and text matched for a token. Actions can access these attributes via `$label.attribute` where label labels a particular instance of a token reference (`a` and `b` in the example below are used in the action code as `$a` and `$b`). Often, a particular token is only referenced once in the rule, in which case the token name itself can be used unambiguously in the action code (token `INT` can be used as `$INT` in the action). The following example illustrates token attribute expression syntax:
+
+```
+r : INT {int x = $INT.line;}
+ ( ID {if ($INT.line == $ID.line) ...;} )?
+ a=FLOAT b=FLOAT {if ($a.line == $b.line) ...;}
+ ;
+```
+
+The action within the `(...)?` subrule can see the `INT` token matched before it in the outer level.
+
+Because there are two references to the `FLOAT` token, a reference to `$FLOAT` in an action is not unique; you must use labels to specify which token reference you’re interested in.
+
+Token references within different alternatives are unique because only one of them can be matched for any invocation of the rule. For example, in the following rule, actions in both alternatives can reference `$ID` directly without using a label:
+
+```
+ r : ... ID {System.out.println($ID.text);}
+ | ... ID {System.out.println($ID.text);}
+ ;
+```
+
+To access the tokens matched for literals, you must use a label:
+
+```
+ stat: r='return' expr ';' {System.out.println("line="+$r.line);} ;
+```
+
+Most of the time you access the attributes of the token, but sometimes it is useful to access the Token object itself because it aggregates all the attributes. Further, you can use it to test whether an optional subrule matched a token:
+
+```
+ stat: 'if' expr 'then' stat (el='else' stat)?
+ {if ( $el!=null ) System.out.println("found an else");}
+ | ...
+ ;
+```
+
+`$T` and `$L` evaluate to `Token` objects for token name `T` and token label `L`. `$ll` evaluates to `List<Token>` for list label `ll`. `$T.attr` evaluates to the type and value specified in the following table for attribute `attr`:
+
+
+|Attribute|Type|Description|
+|---------|----|-----------|
+|text|String|The text matched for the token; translates to a call to getText. Example: $ID.text.|
+|type|int|The token type (nonzero positive integer) of the token such as INT; translates to a call to getType. Example: $ID.type.|
+|line|int|The line number on which the token occurs, counting from 1; translates to a call to getLine. Example: $ID.line.|
+|pos|int|The character position within the line at which the token’s first character occurs counting from zero; translates to a call togetCharPositionInLine. Example: $ID.pos.|
+|index|int|The overall index of this token in the token stream, counting from zero; translates to a call to getTokenIndex. Example: $ID.index.|
+|channel|int|The token’s channel number. The parser tunes to only one channel, effectively ignoring off-channel tokens. The default channel is 0 (Token.DEFAULT_CHANNEL), and the default hidden channel is Token.HIDDEN_CHANNEL. Translates to a call to getChannel. Example: $ID.channel.|
+|int|int|The integer value of the text held by this token; it assumes that the text is a valid numeric string. Handy for building calculators and so on. Translates to Integer.valueOf(text-of-token). Example: $INT.int.|
+
+## Parser Rule Attributes
+
+ANTLR predefines a number of read-only attributes associated with parser rule references that are available to actions. Actions can access rule attributes only for references that precede the action. The syntax is `$r.attr` for rule name `r` or a label assigned to a rule reference. For example, `$expr.text` returns the complete text matched by a preceding invocation of rule `expr`:
+
+```
+returnStat : 'return' expr {System.out.println("matched "+$expr.text);} ;
+```
+
+Using a rule label looks like this:
+
+```
+returnStat : 'return' e=expr {System.out.println("matched "+e.text);} ;
+```
+
+You can also use `$ followed by the name of the attribute to access the value associated with the currently executing rule. For example, `$start` is the starting token of the current rule.
+
+```
+returnStat : 'return' expr {System.out.println("first token "+$start.getText());} ;
+```
+
+`$r` and `$rl` evaluate to `ParserRuleContext` objects of type `RContext` for rule name `r` and rule label `rl`. `$rll` evaluates to `List<RContext>` for rule list label `rll`. `$r.attr` evaluates to the type and value specified in the following table for attribute `attr`:
+
+|Attribute|Type|Description|
+|---------|----|-----------|
+|text|String|The text matched for a rule or the text matched from the start of the rule up until the point of the `$text` expression evaluation. Note that this includes the text for all tokens including those on hidden channels, which is what you want because usually that has all the whitespace and comments. When referring to the current rule, this attribute is available in any action including any exception actions.|
+|start|Token|The first token to be potentially matched by the rule that is on the main token channel; in other words, this attribute is never a hidden token. For rules that end up matching no tokens, this attribute points at the first token that could have been matched by this rule. When referring to the current rule, this attribute is available to any action within the rule.|
+|stop|Token|The last nonhidden channel token to be matched by the rule. When referring to the current rule, this attribute is available only to the after and finally actions.|
+|ctx|ParserRuleContext|The rule context object associated with a rule invocation. All of the other attributes are available through this attribute. For example, `$ctx.start` accesses the start field within the current rules context object. It’s the same as `$start`.|
+
+## Dynamically-Scoped Attributes
+
+You can pass information to and from rules using parameters and return values, just like functions in a general-purpose programming language. Programming languages don’t allow functions to access the local variables or parameters of invoking functions, however. For example, the following reference to local variable `x` form a nested method call is illegal in Java:
+
+```java
+void f() {
+ int x = 0;
+ g();
+}
+void g() {
+ h();
+}
+void h() {
+ int y = x; // INVALID reference to f's local variable x
+}
+```
+
+Variable `x` is available only within the scope of `f`, which is the text lexically delimited by curly brackets. For this reason, Java is said to use lexical scoping. Lexical scoping is the norm for most programming languages. Languages that allow methods further down in the call chain to access local variables defined earlier are said to use dynamic scoping. The term dynamic refers to the fact that a compiler cannot statically determine the set of visible variables. This is because the set of variables visible to a method changes depending on who calls that method.
+
+It turns out that, in the grammar realm, distant rules sometimes need to communicate with each other, mostly to provide context information to rules matched below in the rule invocation chain. (Naturally, this assumes that you are using actions directly in the grammar instead of the parse-tree listener event mechanism.) ANTLR allows dynamic scoping in that actions can access attributes from invoking rules using syntax `$r::x` where `r` is a rule name and `x` is an attribute within that rule. It is up to the programmer to ensure that `r` is in fact an invoking rule of the current rule. A runtime exception occurs if `r` is not in the current call chain when you access `$r::x`.
+
+To illustrate the use of dynamic scoping, consider the real problem of defining variables and ensuring that variables in expressions are defined. The following grammar defines the symbols attribute where it belongs in the block rule but adds variable names to it in rule `decl`. Rule `stat` then consults the list to see whether variables have been defined.
+
+```
+grammar DynScope;
+
+prog: block ;
+
+block
+ /* List of symbols defined within this block */
+ locals [
+ List<String> symbols = new ArrayList<String>()
+ ]
+ : '{' decl* stat+ '}'
+ // print out all symbols found in block
+ // $block::symbols evaluates to a List as defined in scope
+ {System.out.println("symbols="+$symbols);}
+ ;
+
+/** Match a declaration and add identifier name to list of symbols */
+decl: 'int' ID {$block::symbols.add($ID.text);} ';' ;
+
+/** Match an assignment then test list of symbols to verify
+ * that it contains the variable on the left side of the assignment.
+ * Method contains() is List.contains() because $block::symbols
+ * is a List.
+ */
+stat: ID '=' INT ';'
+ {
+ if ( !$block::symbols.contains($ID.text) ) {
+ System.err.println("undefined variable: "+$ID.text);
+ }
+ }
+ | block
+ ;
+
+ID : [a-z]+ ;
+INT : [0-9]+ ;
+WS : [ \t\r\n]+ -> skip ;
+```
+
+Here’s a simple build and test sequence:
+
+```bash
+$ antlr4 DynScope.g4
+$ javac DynScope*.java
+$ grun DynScope prog
+=> {
+=> int i;
+=> i = 0;
+=> j = 3;
+=> }
+=> EOF
+<= undefined variable: j
+ symbols=[i]
+```
+
+There’s an important difference between a simple field declaration in a `@members` action and dynamic scoping. symbols is a local variable and so there is a copy for each invocation of rule `block`. That’s exactly what we want for nested blocks so that we can reuse the same input variable name in an inner block. For example, the following nested code block redefines `i` in the inner scope. This new definition must hide the definition in the outer scope.
+
+```
+{
+ int i;
+ int j;
+ i = 0;
+ {
+ int i;
+ int x;
+ x = 5;
+ }
+ x = 3;
+}
+```
+
+Here’s the output generated for that input by DynScope:
+
+```bash
+$ grun DynScope prog nested-input
+symbols=[i, x]
+undefined variable: x
+symbols=[i, j]
+```
+
+Referencing `$block::symbols` accesses the `symbols` field of the most recently invoked `block`’s rule context object. If you need access to a symbols instance from a rule invocation farther up the call chain, you can walk backwards starting at the current context, `$ctx`. Use `getParent` to walk up the chain.
diff --git a/doc/antlr-project-testing.md b/doc/antlr-project-testing.md
new file mode 100644
index 0000000..e29b00c
--- /dev/null
+++ b/doc/antlr-project-testing.md
@@ -0,0 +1,285 @@
+# ANTLR project unit tests
+
+## Introduction
+
+Because ANTLR supports multiple target languages, the unit tests are broken into two groups: the unit tests that test the tool itself (in `tool-testsuite`) and the unit tests that test the parser runtimes (in `antlr4/runtime-testsuite`). The tool tests are straightforward because they are Java code testing Java code; see the section at the bottom of this file.
+
+The runtime tests must be specified in a generic fashion to work across language targets. Furthermore, we must test the various targets from Java. This usually means Java launching processes to compile, say, C++ and run parsers.
+
+As of 4.6, we use [a Java descriptor object](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/RuntimeTestDescriptor.java) to describe each runtime test. Unit tests are grouped together into categories such as [ParserExecDescriptors](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java), which has multiple nested descriptor objects, one per test. For example, here is the start of that file:
+
+```java
+public class ParserExecDescriptors {
+ public static class APlus extends BaseParserTestDescriptor {
+ public String input = "a b c";
+ public String output = "abc\n";
+ public String errors = "";
+ public String startRule = "a";
+ public String grammarName = "T";
+
+ /**
+ grammar T;
+ a : ID+ {
+ <writeln("$text")>
+ };
+ ID : 'a'..'z'+;
+ WS : (' '|'\n') -> skip;
+ */
+ @CommentHasStringValue
+ public String grammar;
+ }
+```
+
+The mysterious `@CommentHasStringValue` annotation is a bit of a hack that allows multi-line strings in Java. This kung fu is required so that we can use Java classes rather than StringTemplate group files to specify runtime tests (the legacy system used those and it was hard to get them right). Here are all the [Runtime test descriptors](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors) organized into groups.
+
+The grammars are strings representing StringTemplates (`ST` objects) so `<writeln("$text")>` will get replace when the unit test file is generated (`Test.java`, `Test.cs`, ...). The `writeln` template must be defined per target. Here are all of the
+[Target templates for runtime tests](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates).
+
+## Requirements
+
+In order to perform the tests on all target languages, you need to have the following languages installed:
+
+* `mono` (e.g., `brew install mono`) on non-Windows boxes (on Windows it uses the Microsoft .net stack). Also must [`xbuild` the runtime](https://github.com/antlr/antlr4/blob/master/doc/releasing-antlr.md) before tests will run; see below
+* `nodejs`
+* Python 2.7
+* Python 3.5
+* Go
+* Swift 3 (via XCode 8.x) tested currently only osx
+* clang (for C++ target)
+*
+To **install into local repository** `~/.m2/repository/org/antlr`, do this:
+
+```bash
+$ export MAVEN_OPTS="-Xmx1G" # don't forget this on linux
+$ mvn install -DskipTests=true # make sure all artifacts are visible on this machine
+```
+
+Now, make sure C# runtime is built and installed locally.
+
+```bash
+cd ~/antlr/code/antlr4/runtime/CSharp/runtime/CSharp
+# kill previous ones manually as "xbuild /t:Clean" didn't seem to do it
+rm Antlr4.Runtime/bin/net20/Release/Antlr4.Runtime.dll
+rm Antlr4.Runtime/obj/net20/Release/Antlr4.Runtime.dll
+# build
+xbuild /p:Configuration=Release Antlr4.Runtime/Antlr4.Runtime.mono.csproj
+```
+
+C++ test rig automatically builds C++ runtime during tests. Others don't need a prebuilt lib.
+
+
+## Running the runtime tests
+
+A single test rig is sufficient to test all targets against all descriptors using the [junit parameterized tests](https://github.com/junit-team/junit4/wiki/parameterized-tests) mechanism. But, that is inconvenient because we often want to test just a single target or perhaps even just a single test within a single group of a single target. I have automatically generated a bunch of
+[Target runtime test rigs](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime) that allow developers such flexibility. For example, here are the Python3 test rigs in intellij:
+
+<img src=images/testrigs.png width=300>
+
+And the result of testing the entire subdirectory:
+
+<img src=images/python3-tests.png width=400>
+
+From `mvn`, on the commandline, you will see:
+
+```bash
+$ cd antlr4
+$ mvn test
+...
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.antlr.v4.test.runtime.csharp.TestCompositeLexers
+dir /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeLexers-1446068612451
+Starting build /usr/bin/xbuild /p:Configuration=Release /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeLexers-1446068612451/Antlr4.Test.mono.csproj
+dir /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeLexers-1446068615081
+Starting build /usr/bin/xbuild /p:Configuration=Release /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeLexers-1446068615081/Antlr4.Test.mono.csproj
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.451 sec
+Running org.antlr.v4.test.runtime.csharp.TestCompositeParsers
+dir /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeParsers-1446068615864
+antlr reports warnings from [-visitor, -Dlanguage=CSharp, -o, /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeParsers-1446068615864, -lib, /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeParsers-1446068615864, -encoding, UTF-8, /var/folders/s1/h3qgww1x0ks3pb30l8t1wgd80000gn/T/TestCompositeParsers-1446068615864/M.g4]
+...
+[INFO] ------------------------------------------------------------------------
+[INFO] Reactor Summary:
+[INFO]
+[INFO] ANTLR 4 ............................................ SUCCESS [ 0.445 s]
+[INFO] ANTLR 4 Runtime .................................... SUCCESS [ 3.392 s]
+[INFO] ANTLR 4 Tool ....................................... SUCCESS [ 1.373 s]
+[INFO] ANTLR 4 Maven plugin ............................... SUCCESS [ 1.519 s]
+[INFO] ANTLR 4 Runtime Test Annotations ................... SUCCESS [ 0.086 s]
+[INFO] ANTLR 4 Runtime Test Processors .................... SUCCESS [ 0.014 s]
+[INFO] ANTLR 4 Runtime Tests (2nd generation) ............. SUCCESS [06:39 min]
+[INFO] ANTLR 4 Tool Tests ................................. SUCCESS [ 6.922 s]
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 06:53 min
+[INFO] Finished at: 2016-11-16T15:36:56-08:00
+[INFO] Final Memory: 44M/458M
+[INFO] ------------------------------------------------------------------------
+```
+
+Note: That is actually result of running the much faster:
+
+```bash
+mvn -Dparallel=methods -DthreadCount=4 install
+```
+
+## Running test subsets
+
+*From the `runtime-testsuite` dir*
+
+### Run one test group across targets
+
+```bash
+$ cd runtime-testsuite
+$ export MAVEN_OPTS="-Xmx1G" # don't forget this on linux
+$ mvn -Dtest=TestParserExec test
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.antlr.v4.test.runtime.cpp.TestParserExec
+...
+Tests run: 32, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 114.283 sec
+Running org.antlr.v4.test.runtime.csharp.TestParserExec
+...
+```
+
+Or run all lexer related tests:
+
+```
+$ cd runtime-testsuite
+$ mvn -Dtest=Test*Lexer* test
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.antlr.v4.test.runtime.cpp.TestCompositeLexers
+...
+```
+
+### Run all tests for a single target
+
+```bash
+$ cd runtime-testsuite
+$ mvn -Dtest=java.* test
+...
+```
+
+Or run all lexer related tests in Java target only:
+
+```bash
+$ cd runtime-testsuite
+$ mvn -Dtest=java.*Lexer* test
+...
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.antlr.v4.test.runtime.java.TestCompositeLexers
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.277 sec
+Running org.antlr.v4.test.runtime.java.TestLexerErrors
+Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.376 sec
+Running org.antlr.v4.test.runtime.java.TestLexerExec
+Tests run: 38, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.07 sec
+Running org.antlr.v4.test.runtime.java.TestSemPredEvalLexer
+Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.255 sec
+
+Results :
+
+Tests run: 59, Failures: 0, Errors: 0, Skipped: 0
+```
+
+## Testing in parallel
+
+Use this to run tests in parallel:
+
+```bash
+$ export MAVEN_OPTS="-Xmx1G"
+$ mvn -Dparallel=methods -DthreadCount=4 test
+...
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Concurrency config is parallel='methods', perCoreThreadCount=true, threadCount=4, useUnlimitedThreads=false
+...
+```
+
+This can be combined with other `-D` above.
+
+## Adding a runtime test
+
+To add a new runtime test, first determine which [group of tests](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors) it belongs to. Then, add a new [RuntimeTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/RuntimeTestDescriptor.java) implementation by subclassing one of:
+
+* [BaseParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseParserTestDescriptor.java); see example [APlus](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java#L7).
+* [BaseDiagnosticParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseDiagnosticParserTestDescriptor) if you want to test parser diagnostic output; see [example output](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/FullContextParsingDescriptors.java#L16).
+* [BaseCompositeParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseCompositeParserTestDescriptor.java); see example [BringInLiteralsFromDelegate](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/CompositeParsersDescriptors.java#L11)
+* [BaseLexerTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseLexerTestDescriptor.java); see example [ActionPlacement](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/LexerExecDescriptors.java#L12).
+* [BaseCompositeLexerTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseCompositeLexerTestDescriptor.java); see example [LexerDelegatorInvokesDelegateRule](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/CompositeLexersDescriptors.java#L11)
+
+
+Each descriptor object describes the following mandatory elements for the test:
+
+ * the test type
+ * the grammar
+ * the start rule
+ * the input text to parse or lex
+ * the expected output
+ * the expected errors
+
+Your best bet is to find a similar test in the appropriate group and then copy and paste the descriptor object, creating a new nested class within the test group class. Modify the field definitions to suit your new problem.
+
+If you need to create a whole new group of tests, it requires a new descriptor class; call it `XDescriptors`. Then, in each [target subdirectory](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime), you need to create a new test rig `TestX.java` file:
+
+```java
+package org.antlr.v4.test.runtime.java;
+
+import org.antlr.v4.test.runtime.BaseRuntimeTest;
+import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
+import org.antlr.v4.test.runtime.descriptors.ListenersDescriptors;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class TestX extends BaseRuntimeTest {
+ public TestX(RuntimeTestDescriptor descriptor) {
+ super(descriptor,new Base<TARGET>Test());
+ }
+
+ @Parameterized.Parameters(name="{0}")
+ public static RuntimeTestDescriptor[] getAllTestDescriptors() {
+ return BaseRuntimeTest.getRuntimeTestDescriptors(XDescriptors.class, "<TARGET>");
+ }
+}
+```
+
+where `<TARGET>` is replaced with Java, Cpp, CSharp, Python2, ... in the various subdirectories.
+
+### Ignoring tests
+
+In order to turn off a test for a particular target, we need to use the `ignore` method. Given a target name, a descriptor object can decide whether to ignore the test. This is not always convenient but it is fully general and works well for the one case we have now where we have to ignore `Visitor` tests in all targets except JavaScript.
+
+### Cross-language actions embedded within grammars
+
+To get:
+
+```
+System.out.println($set.stop);
+```
+
+Use instead the language-neutral:
+
+```
+<writeln("$set.stop")>
+```
+
+Template file [runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Java.test.stg](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Java.test.stg) has templates like:
+
+```
+writeln(s) ::= <<System.out.println(<s>);>>
+```
+
+that translate generic operations to target-specific language statements or expressions.
+
+## Adding an ANTLR tool unit test
+
+Just go into the appropriate Java test class in dir [antlr4/tool-testsuite/test/org/antlr/v4/test/tool](https://github.com/antlr/antlr4/tree/master/tool-testsuite/test/org/antlr/v4/test/tool) and add your unit test.
+
+
diff --git a/doc/building-antlr.md b/doc/building-antlr.md
new file mode 100644
index 0000000..ac220bc
--- /dev/null
+++ b/doc/building-antlr.md
@@ -0,0 +1,109 @@
+# Building ANTLR
+
+Most programmers do not need the information on this page because they will simply download the appropriate jar(s) or use ANTLR through maven (via ANTLR's antlr4-maven-plugin). If you would like to fork the project and fix bugs or tweak the runtime code generation, then you will almost certainly need to build ANTLR itself. There are two components:
+
+ 1. the tool that compiles grammars down into parsers and lexers in one of the target languages
+ 1. the runtime used by those generated parsers and lexers.
+
+I will assume that the root directory is `/tmp` for the purposes of explaining how to build ANTLR in this document.
+
+*As of 4.6, ANTLR tool and Java-target runtime requires Java 7.*
+
+# Get the source
+
+The first step is to get the Java source code from the ANTLR 4 repository at github. You can download the repository from github, but the easiest thing to do is simply clone the repository on your local disk:
+
+```bash
+$ cd /tmp
+/tmp $ git clone https://github.com/antlr/antlr4.git
+Cloning into 'antlr4'...
+remote: Counting objects: 61480, done.
+remote: Total 61480 (delta 0), reused 0 (delta 0), pack-reused 61480
+Receiving objects: 100% (61480/61480), 31.24 MiB | 7.18 MiB/s, done.
+Resolving deltas: 100% (32970/32970), done.
+Checking connectivity... done.
+Checking out files: 100% (1427/1427), done.
+```
+
+# Compile
+
+```bash
+$ cd /tmp
+$ git clone git@github.com:antlr/antlr4.git
+Cloning into 'antlr4'...
+remote: Counting objects: 59858, done.
+remote: Compressing objects: 100% (57/57), done.
+remote: Total 59858 (delta 28), reused 9 (delta 9), pack-reused 59786
+Receiving objects: 100% (59858/59858), 31.10 MiB | 819.00 KiB/s, done.
+Resolving deltas: 100% (31898/31898), done.
+Checking connectivity... done.
+$ cd antlr4
+$ export MAVEN_OPTS="-Xmx1G" # don't forget this on linux
+$ mvn -DskipTests install
+...
+[INFO] ------------------------------------------------------------------------
+[INFO] Reactor Summary:
+[INFO]
+[INFO] ANTLR 4 ............................................ SUCCESS [ 0.287 s]
+[INFO] ANTLR 4 Runtime .................................... SUCCESS [ 4.915 s]
+[INFO] ANTLR 4 Tool ....................................... SUCCESS [ 1.315 s]
+[INFO] ANTLR 4 Maven plugin ............................... SUCCESS [ 2.393 s]
+[INFO] ANTLR 4 Runtime Test Annotations ................... SUCCESS [ 0.078 s]
+[INFO] ANTLR 4 Runtime Test Processors .................... SUCCESS [ 0.019 s]
+[INFO] ANTLR 4 Runtime Tests (2nd generation) ............. SUCCESS [ 1.986 s]
+[INFO] ANTLR 4 Tool Tests ................................. SUCCESS [ 0.513 s]
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 12.005 s
+[INFO] Finished at: 2016-11-21T11:42:42-08:00
+[INFO] Final Memory: 52M/434M
+[INFO] ------------------------------------------------------------------------
+```
+
+We do `install` not `compile` as tool tests and such refer to modules that must be pulled from the maven install local cache.
+
+# Installing libs to mvn cache locally
+
+To skip the tests (which require all the target languages be installed) and **install into local repository** `~/.m2/repository/org/antlr`, do this:
+
+```bash
+$ export MAVEN_OPTS="-Xmx1G" # don't forget this on linux
+$ mvn install -DskipTests=true # make sure all artifacts are visible on this machine
+```
+
+You should see these jars (when building 4.6-SNAPSHOT):
+
+```bash
+/Users/parrt/.m2/repository/org/antlr $ find antlr4* -name '*.jar'
+antlr4-maven-plugin/4.6-SNAPSHOT/antlr4-maven-plugin-4.6-SNAPSHOT.jar
+antlr4-runtime-test-annotation-processors/4.6-SNAPSHOT/antlr4-runtime-test-annotation-processors-4.6-SNAPSHOT.jar
+antlr4-runtime-test-annotations/4.6-SNAPSHOT/antlr4-runtime-test-annotations-4.6-SNAPSHOT.jar
+antlr4-runtime-testsuite/4.6-SNAPSHOT/antlr4-runtime-testsuite-4.6-SNAPSHOT-tests.jar
+antlr4-runtime-testsuite/4.6-SNAPSHOT/antlr4-runtime-testsuite-4.6-SNAPSHOT.jar
+antlr4-runtime/4.6-SNAPSHOT/antlr4-runtime-4.6-SNAPSHOT.jar
+antlr4-tool-testsuite/4.6-SNAPSHOT/antlr4-tool-testsuite-4.6-SNAPSHOT.jar
+antlr4/4.6-SNAPSHOT/antlr4-4.6-SNAPSHOT-tests.jar
+antlr4/4.6-SNAPSHOT/antlr4-4.6-SNAPSHOT.jar
+```
+
+Note that ANTLR is written in itself, which is why maven downloads antlr4-4.5.jar for boostrapping 4.6-SNAPSHOT purposes.
+
+# Testing tool and targets
+
+See [ANTLR project unit tests](antlr-project-testing.md).
+
+
+# Building without testing
+
+To build without running the tests (saves a lot of time), do this:
+
+```bash
+$ mvn -DskipTests install
+```
+
+## Building ANTLR in Intellij IDE
+
+After download ANTLR source, just "import project from existing sources" and click on the "Maven Projects" tab in right gutter of IDE. It should build stuff in the background automatically and look like:
+
+<img src=images/intellij-maven.png width=200>
diff --git a/doc/cpp-target.md b/doc/cpp-target.md
new file mode 100644
index 0000000..31283e8
--- /dev/null
+++ b/doc/cpp-target.md
@@ -0,0 +1,182 @@
+# C++
+
+The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library.
+
+## How to create a C++ lexer or parser?
+This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
+
+```
+$ antlr4 -Dlanguage=Cpp MyGrammar.g4
+```
+
+You will see that there are a whole bunch of files generated by this call. If visitor or listener are not suppressed (which is the default) you'll get:
+
+* MyGrammarLexer.h + MyGrammarLexer.cpp
+* MyGrammarParser.h + MyGrammarParser.cpp
+* MyGrammarVisitor.h + MyGrammarVisitor.cpp
+* MyGrammarBaseVisitor.h + MyGrammarBaseVisitor.cpp
+* MyGrammarListener.h + MyGrammarListener.cpp
+* MyGrammarBaseListener.h + MyGrammarBaseListener.cpp
+
+## Where can I get the runtime?
+
+Once you've generated the lexer and/or parser code, you need to download or build the runtime. Prebuilt C++ runtime binaries for Windows (Visual Studio 2013/2015), OSX/macOS and iOS are available on the ANTLR web site:
+
+* http://www.antlr.org
+
+Use CMake to build a Linux library (works also on OSX, however not for the iOS library).
+
+Instead of downloading a prebuilt binary you can also easily build your own library on OSX or Windows. Just use the provided projects for XCode or Visual Studio and build it. Should work out of the box without any additional dependency.
+
+
+## How do I run the generated lexer and/or parser?
+
+Putting it all together to get a working parser is really easy. Look in the [runtime/Cpp/demo](../runtime/Cpp/demo) folder for a simple example. The [README](../runtime/Cpp/demo/README.md) there describes shortly how to build and run the demo on OSX, Windows or Linux.
+
+## How do I create and run a custom listener?
+
+The generation step above created a listener and base listener class for you. The listener class is an abstract interface, which declares enter and exit methods for each of your parser rules. The base listener implements all those abstract methods with an empty body, so you don't have to do it yourself if you just want to implement a single function. Hence use this base listener as the base class for your custom listener:
+
+```c++
+#include <iostream>
+
+#include "antlr4-runtime.h"
+#include "MyGrammarLexer.h"
+#include "MyGrammarParser.h"
+#include "MyGrammarBaseListener.h"
+
+using namespace org::antlr::v4::runtime;
+
+class TreeShapeListener : public MyGrammarBaseListener {
+public:
+ void enterKey(Ref<ParserRuleContext> ctx) {
+ // Do something when entering the key rule.
+ }
+};
+
+
+int main(int argc, const char* argv[]) {
+ std::ifstream stream;
+ stream.open(argv[1]);
+ ANTLRInputStream input(stream);
+ MyGrammarLexer lexer(&input);
+ CommonTokenStream tokens(&lexer);
+ MyGrammarParser parser(&tokens);
+
+ Ref<tree::ParseTree> tree = parser.key();
+ Ref<TreeShapeListener> listener(new TreeShapeListener());
+ tree::ParseTreeWalker::DEFAULT->walk(listener, tree);
+
+ return 0;
+}
+
+```
+
+This example assumes your grammar contains a parser rule named `key` for which the enterKey function was generated. The `Ref<>` template is an alias for `std::shared_ptr<>` to simplify the runtime source code which often makes use of smart pointers.
+
+## Specialities of this ANTLR target
+
+There are a couple of things that only the C++ ANTLR target has to deal with. They are described here.
+
+### Build Aspects
+
+The code generation (by running the ANTLR4 jar) allows to specify 2 values you
+might find useful for better integration of the generated files into your
+application (both are optional):
+
+* A **namespace**: use the **`-package`** parameter to specify the namespace you want.
+* An **export macro**: especially in VC++ extra work is required to export your classes from a DLL.
+This is usually accomplished by a macro that has different values depending on whether
+you are creating the DLL or import it. The ANTLR4 runtime itself also uses one for its classes:
+
+```c++
+ #ifdef ANTLR4CPP_EXPORTS
+ #define ANTLR4CPP_PUBLIC __declspec(dllexport)
+ #else
+ #ifdef ANTLR4CPP_STATIC
+ #define ANTLR4CPP_PUBLIC
+ #else
+ #define ANTLR4CPP_PUBLIC __declspec(dllimport)
+ #endif
+ #endif
+```
+
+Just like the `ANTLR4CPP_PUBLIC` macro here you can specify your own one for
+the generated classes using the **`-DexportMacro=...`** command-line parameter or
+grammar option `options {exportMacro='...';}` in your grammar file.
+
+In order to create a static lib in Visual Studio define the `ANTLR4CPP_STATIC` macro
+in addition to the project settings that must be set for a static library
+(if you compile the runtime yourself).
+
+For gcc and clang it is possible to use the `-fvisibility=hidden` setting to
+hide all symbols except those that are made default-visible (which has been
+defined for all public classes in the runtime).
+
+### Memory Management
+
+Since C++ has no built-in memory management we need to take extra care.
+For that we rely mostly on smart pointers, which however might cause time
+penalties or memory side effects (like cyclic references) if not used with care.
+Currently however the memory household looks very stable. Generally, when you
+see a raw pointer in code consider this as being managed elsewehere. You
+should never try to manage such a pointer (delete, assign to smart pointer etc.).
+
+### Unicode Support
+
+Encoding is mostly an input issue, i.e. when the lexer converts text input into lexer tokens. The parser is completely encoding unaware. However, lexer input in the grammar is defined by character ranges with either a single member (e.g. 'a' or [a] or [abc]), an explicit range (e.g. 'a'..'z' or [a-z]), the full Unicode range (for a wildcard) and the full Unicode range minus a sub range (for negated ranges, e.g. ~[a]). The explicit ranges (including single member ranges) are encoded in the serialized ATN by 16bit numbers, hence cannot reach beyond 0xFFFF (the Unicode BMP), while the implicit ranges can include any value (and hence support the full Unicode set, up to 0x10FFFF).
+
+> An interesting side note here is that the Java target fully supports Unicode as well, despite the inherent limitations from the serialized ATN. That's possible because the Java String class represents characters beyond the BMP as surrogate pairs (two 16bit values) and even reads them as 2 separate input characters. To make this work a character range for an identifier in a grammar must include the surrogate pairs area (for a Java parser).
+
+The C++ target however always expects UTF-8 input (either in a string or via a wide stream) which is then converted to UTF-32 (a char32_t array) and fed to the lexer. ANTLR, when parsing your grammar, limits character ranges explicitly to the BMP currently. So, in order to allow specifying the full Unicode set the C++ target uses a little trick: whenever an explicit character range includes the (unused) codepoint 0xFFFF in a grammar it is silently extended to the full Unicode range. It's clear that this is an all-or-nothing solution. You cannot define a subset of Unicode codepoints > 0xFFFF that way. This can only be solved if ANTLR supports larger character intervals.
+
+The differences in handling characters beyond the BMP leads to a difference between Java and C++ lexers: the character offsets may not concur. This is because Java reads two 16bit values per Unicode char (if that falls into the surrogate area) while a C++ parser only reads one 32bit value. That usually doesn't have practical consequences, but might confuse people when comparing token positions.
+
+### Named Actions
+
+In order to help customizing the generated files there are a number of additional socalled **named actions**. These actions are tight to specific areas in the generated code and allow to add custom (target specific) code. All targets support these actions
+
+* @parser::header
+* @parser::members
+* @lexer::header
+* @lexer::members
+
+(and their scopeless alternatives `@header` and `@members`) where header doesn't mean a C/C++ header file, but the top of a code file. The content of the header action appears in all generated files at the first line. So it's good for things like license/copyright information.
+
+The content of a *members* action is placed in the public section of lexer or parser class declarations. Hence it can be used for public variables or predicate functions used in a grammar predicate. Since all targets support *header* + *members* they are the best place for stuff that should be available also in generated files for other languages.
+
+In addition to that the C++ target supports many more such named actions. Unfortunately, it's not possible to define new scopes (e.g. *listener* in addition to *parser*) so they had to be defined as part of the existing scopes (*lexer* or *parser*). The grammar in the demo application contains all of the named actions as well for reference. Here's the list:
+
+* **@lexer::preinclude** - Placed right before the first #include (e.g. good for headers that must appear first, for system headers etc.). Appears in both lexer h and cpp file.
+* **@lexer::postinclude** - Placed right after the last #include, but before any class code (e.g. for additional namespaces). Appears in both lexer h and cpp file.
+* **@lexer::context** - Placed right before the lexer class declaration. Use for e.g. additional types, aliases, forward declarations and the like. Appears in the lexer h file.
+* **@lexer::declarations** - Placed in the private section of the lexer declaration (generated sections in all classes strictly follow the pattern: public, protected, privat, from top to bottom). Use this for private vars etc.
+* **@lexer::definitions** - Placed before other implementations in the cpp file (but after *@postinclude*). Use this to implement e.g. private types.
+
+For the parser there are the same actions as shown above for the lexer. In addition to that there are even more actions for visitor and listener classes:
+
+* **@parser::listenerpreinclude**
+* **@parser::listenerpostinclude**
+* **@parser::listenerdeclarations**
+* **@parser::listenermembers**
+* **@parser::listenerdefinitions**
+*
+* **@parser::baselistenerpreinclude**
+* **@parser::baselistenerpostinclude**
+* **@parser::baselistenerdeclarations**
+* **@parser::baselistenermembers**
+* **@parser::baselistenerdefinitions**
+*
+* **@parser::visitorpreinclude**
+* **@parser::visitorpostinclude**
+* **@parser::visitordeclarations**
+* **@parser::visitormembers**
+* **@parser::visitordefinitions**
+*
+* **@parser::basevisitorpreinclude**
+* **@parser::basevisitorpostinclude**
+* **@parser::basevisitordeclarations**
+* **@parser::basevisitormembers**
+* **@parser::basevisitordefinitions**
+
+and should be self explanatory now. Note: there is no *context* action for listeners or visitors, simply because they would be even less used than the other actions and there are so many already.
diff --git a/doc/creating-a-language-target.md b/doc/creating-a-language-target.md
new file mode 100644
index 0000000..ff7db29
--- /dev/null
+++ b/doc/creating-a-language-target.md
@@ -0,0 +1,22 @@
+# Creating an ANTLR Language Target
+
+This document describes how to make ANTLR generate parsers in a new language, *X*.
+
+## Overview
+
+Creating a new target involves the following key elements:
+
+1. For the tool, create class *X*Target as a subclass of class `Target` in package `org.antlr.v4.codegen.target`. This class describes language specific details about escape characters and strings and so on. There is very little to do here typically.
+1. Create *X*.stg in directory tool/resources/org/antlr/v4/tool/templates/codegen/*X*/*X*.stg. This is a [StringTemplate](http://www.stringtemplate.org/) group file (`.stg`) that tells ANTLR how to express all of the parsing elements needed to generate code. You will see templates called `ParserFile`, `Parser`, `Lexer`, `CodeBlockForAlt`, `AltBlock`, etc... Each of these must be described how to build the indicated chunk of code. Your best bet is to find the closest existing target, copy that template file, and tweak to suit.
+1. Create a runtime library to support the parsers generated by ANTLR. Under directory runtime/*X*, you are in complete control of the directory structure as dictated by common usage of that target language. For example, Java has: `runtime/Java/lib` and `runtime/Java/src` directories. Under `src`, you will find a directory structure for package `org.antlr.v4.runtime` and below.
+1. Create a template file for runtime tests. All you have to do is provide a few templates that indicate how to print values and declare variables. Our runtime test mechanism in dir `runtime-testsuite` will automatically generate code using these templates for each target and check the test results. It needs to know how to define various class fields, compare members and so on. You must create a *X*.test.stg file underneath [runtime-testsuite/resources/org/antlr/v4/test/runtime](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime). Again, your best bet is to copy the templates from the closest language to your target and tweak it to suit.
+
+## Getting started
+
+1. Fork the `antlr/antlr4` repository at github to your own user so that you have repository `username/antlr4`.
+2. Clone `username/antlr4`, the forked repository, to your local disk. Your remote `origin` will be the forked repository on GitHub. Add a remote `upstream` to the original `antlr/antlr4` repository (URL `https://github.com/antlr/antlr4.git`). Changes that you would like to contribute back to the project are done with [pull requests](https://help.github.com/articles/using-pull-requests/).
+3. Try to build it before doing anything
+```bash
+$ mvn compile
+```
+That should proceed with success. See [Building ANTLR](building-antlr.md) for more details.
diff --git a/doc/csharp-target.md b/doc/csharp-target.md
new file mode 100644
index 0000000..18e6075
--- /dev/null
+++ b/doc/csharp-target.md
@@ -0,0 +1,94 @@
+# C&sharp;
+
+## Which frameworks are supported?
+
+The C# runtime is CLS compliant, and only requires a corresponding 3.5 .Net framework.
+
+In practice, the runtime has been extensively tested against:
+
+* Microsoft .Net 3.5 framework
+* Mono .Net 3.5 framework
+
+No issue was found, so you should find that the runtime works pretty much against any recent .Net framework.
+
+## How do I get started?
+
+You will find full instructions on the [Git repo page for ANTLR C# runtime](https://github.com/antlr/antlr4/tree/master/runtime/CSharp).
+
+## How do I use the runtime from my project?
+
+(i.e., How do I run the generated lexer and/or parser?)
+
+Let's suppose that your grammar is named `MyGrammar`. The tool will generate for you the following files:
+
+* MyGrammarLexer.cs
+* MyGrammarParser.cs
+* MyGrammarListener.cs (if you have not activated the -no-listener option)
+* MyGrammarBaseListener.js (if you have not activated the -no-listener option)
+* MyGrammarVisitor.js (if you have activated the -visitor option)
+* MyGrammarBaseVisitor.js (if you have activated the -visitor option)
+
+Now a fully functioning code might look like the following for start rule `StartRule`:
+
+```
+using Antlr4.Runtime;
+
+public void MyParseMethod() {
+ String input = "your text to parse here";
+ AntlrInputStream stream = new InputStream(input);
+ ITokenSource lexer = new MyGrammarLexer(stream);
+ ITokenStream tokens = new CommonTokenStream(lexer);
+ MyGrammarParser parser = new MyGrammarParser(tokens);
+ parser.buildParseTrees = true;
+ IParseTree tree = parser.StartRule();
+}
+```
+
+This program will work. But it won't be useful unless you do one of the following:
+
+* you visit the parse tree using a custom listener
+* you visit the parse tree using a custom visitor
+* your grammar comprises production code (like AntLR3)
+
+(please note that production code is target specific, so you can't have multi target grammars that include production code)
+
+## How do I create and run a custom listener?
+
+Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value".
+
+The antlr4 tool will have generated the following listener (only partial code shown here):
+
+```
+interface IMyGrammarParserListener : IParseTreeListener {
+ void EnterKey (MyGrammarParser.KeyContext context);
+ void ExitKey (MyGrammarParser.KeyContext context);
+ void EnterValue (MyGrammarParser.ValueContext context);
+ void ExitValue (MyGrammarParser.ValueContext context);
+}
+```
+
+In order to provide custom behavior, you might want to create the following class:
+
+```
+class KeyPrinter : MyGrammarBaseListener {
+ // override default listener behavior
+ void ExitKey (MyGrammarParser.KeyContext context) {
+ Console.WriteLine("Oh, a key!");
+ }
+}
+```
+
+In order to execute this listener, you would simply add the following lines to the above code:
+
+
+```
+...
+IParseTree tree = parser.StartRule() - only repeated here for reference
+KeyPrinter printer = new KeyPrinter();
+ParseTreeWalker.DEFAULT.walk(printer, tree);
+```
+
+Further information can be found from The Definitive ANTLR Reference book.
+
+The C# implementation of ANTLR is as close as possible to the Java one, so you shouldn't find it difficult to adapt the examples for C#. See also [Sam Harwell's alternative C# target](https://github.com/tunnelvisionlabs/antlr4cs)
+
diff --git a/doc/faq/actions-preds.md b/doc/faq/actions-preds.md
new file mode 100644
index 0000000..46fe975
--- /dev/null
+++ b/doc/faq/actions-preds.md
@@ -0,0 +1,11 @@
+# Actions and semantic predicates
+
+## How do I test if an optional rule was matched?
+
+For optional rule references such as the initialization clause in the following
+
+```
+decl : 'var' ID (EQUALS expr)? ;
+```
+
+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. \ No newline at end of file
diff --git a/doc/faq/error-handling.md b/doc/faq/error-handling.md
new file mode 100644
index 0000000..ebc3299
--- /dev/null
+++ b/doc/faq/error-handling.md
@@ -0,0 +1,5 @@
+# Error handling
+
+## How do I perform semantic checking with ANTLR?
+
+See [How to implement error handling in ANTLR4](http://stackoverflow.com/questions/21613421/how-to-implement-error-handling-in-antlr4/21615751#21615751).
diff --git a/doc/faq/general.md b/doc/faq/general.md
new file mode 100644
index 0000000..9189ac9
--- /dev/null
+++ b/doc/faq/general.md
@@ -0,0 +1,100 @@
+# General
+
+## Why do we need ANTLR v4?
+
+*Oliver Zeigermann asked me some questions about v4. Here is our conversation.*
+
+*See the [preface from the book](http://media.pragprog.com/titles/tpantlr2/preface.pdf)*
+
+**Q: Why is the new version of ANTLR also called “honey badger”?**
+
+ANTLR v4 is called the honey badger release after the fearless hero of the YouTube sensation, The Crazy Nastyass Honey Badger.
+
+**Q: Why did you create a new version of ANTLR?**
+
+Well, I start creating a new version because v3 had gotten very messy on the inside and also relied on grammars written in ANTLR v2. Unfortunately, v2's open-source license was unclear and so projects such as Eclipse could not include v3 because of its dependency on v2. In the end, Sam Harwell converted all of the v2 grammars into v3 so that v3 was written in itself. Because v3 has a very clean BSD license, the Eclipse project okayed for inclusion in that project in the summer of 2011.
+
+As I was rewriting ANTLR, I wanted to experiment with a new variation of the LL(\*) parsing algorithm. As luck would have it, I came up with a cool new version called adaptive LL(\*) that pushes all of the grammar analysis effort to runtime. The parser warms up like Java does with its JIT on-the-fly compiler; the code gets faster and faster the longer it runs. The benefit is that the adaptive algorithm is much stronger than the static LL(\*) grammar analysis algorithm in v3. Honey Badger takes any grammar that you give it; it just doesn't give a damn. (v4 accepts even left recursive grammars, except for indirectly left recursive grammars where x calls y which calls x).
+
+v4 is the culmination of 25 years of research into parsers and parser generators. I think I finally know what I want to build. :)
+
+**Q: What makes you excited about ANTLR4?**
+
+The biggest thing is the new adaptive parsing strategy, which lets us accept any grammar we care to write. That gives us a huge productivity boost because we can now write much more natural expression rules (which occur in almost every grammar). For example, bottom-up parser generators such as yacc let you write very natural grammars like this:
+
+```
+e : e '*' e
+ | e '+' e
+ | INT
+ ;
+```
+
+ANTLR v4 will also take that grammar now, translating it secretly to a non-left recursive version.
+
+Another big thing with v4 is that my goal has shifted from performance to ease-of-use. For example, ANTLR automatically can build parse trees for you and generate listeners and visitors. This is not only a huge productivity win, but also an important step forward in building grammars that don't depend on embedded actions. Those embedded actions (raw Java code or whatever) locked the grammar into use with only one language. If we keep all of the actions out of the grammar and put them into external visitors, we can reuse the same grammar to generate code in any language for which we have an ANTLR target.
+
+**Q: What do you think are the things people had problems with in ANTLR3?**
+
+The biggest problem was figuring out why ANTLR did not like their grammar. The static analysis often could not figure out how to generate a parser for the grammar. This problem totally goes away with the honey badger because it will take just about anything you give it without a whimper.
+
+**Q: And what with other compiler generator tools?**
+
+The biggest problem for the average practitioner is that most parser generators do not produce code you can load into a debugger and step through. This immediately removes bottom-up parser generators and the really powerful GLR parser generators from consideration by the average programmer. There are a few other tools that generate source code like ANTLR does, but they don't have v4's adaptive LL(\*) parsers. You will be stuck with contorting your grammar to fit the needs of the tool's weaker, say, LL(k) parsing strategy. PEG-based tools have a number of weaknesses, but to mention one, they have essentially no error recovery because they cannot report an error and until they have parsed the entire input.
+
+**Q: What are the main design decisions in ANTLR4?**
+
+Ease-of-use over performance. I will worry about performance later. Simplicity over complexity. For example, I have taken out explicit/manual AST construction facilities and the tree grammar facilities. For 20 years I've been trying to get people to go that direction, but I've since decided that it was a mistake. It's much better to give people a parser generator that can automatically build trees and then let them use pure code to do whatever tree walking they want. People are extremely familiar and comfortable with visitors, for example.
+
+**Q: What do you think people will like most on ANTLR4?**
+
+The lack of errors when you run your grammar through ANTLR. The automatic tree construction and listener/visitor generation.
+
+**What do you think are the problems people will try to solve with ANTLR4?**
+
+In my experience, almost no one uses parser generators to build commercial compilers. So, people are using ANTLR for their everyday work, building everything from configuration files to little scripting languages.
+
+In response to a question about this entry from stackoverflow.com: I believe that compiler developers are very concerned with parsing speed, error reporting, and error recovery. For that, they want absolute control over their parser. Also, some languages are so complicated, such as C++, that parser generators might build parsers slower than compiler developers want. The compiler developers also like the control of a recursive-descent parser for predicating the parse to handle context-sensitive constructs such as `T(i)` in C++.
+
+There is also likely a sense that parsing is the easy part of building a compiler so they don't immediately jump automatically to parser generators. I think this is also a function of previous generation parser generators. McPeak's Elkhound GLR-based parser generator is powerful enough and fast enough, in the hands of someone that knows what they're doing, to be suitable for compilers. I can also attest to the fact that ANTLR v4 is now powerful enough and fast enough to compete well with handbuilt parsers. E.g., after warm-up, it's now taking just 1s to parse the entire JDK java/\* library.
+
+## What is the difference between ANTLR 3 and 4?
+
+The biggest difference between ANTLR 3 and 4 is that ANTLR 4 takes any grammar you give it unless the grammar had indirect left recursion. That means we don't need syntactic predicates or backtracking so ANTLR 4 does not support that syntax; you will get a warning for using it. ANTLR 4 allows direct left recursion so that expressing things like arithmetic expression syntax is very easy and natural:
+
+```
+expr : expr '*' expr
+ | expr '+' expr
+ | INT
+ ;
+```
+
+ANTLR 4 automatically constructs parse trees for you and abstract syntax tree (AST) construction is no longer an option. See also [What if I need ASTs not parse trees for a compiler, for example?](https://github.com/antlr/antlr4/blob/master/doc/faq/parse-trees.md#what-if-i-need-asts-not-parse-trees-for-a-compiler-for-example).
+
+Another big difference is that we discourage the use of actions directly within the grammar because ANTLR 4 automatically generates [listeners and visitors](https://github.com/antlr/antlr4/blob/master/doc/listeners.md) for you to use that trigger method calls when some phrases of interest are recognized during a tree walk after parsing. See also [Parse Tree Matching and XPath](https://github.com/antlr/antlr4/blob/master/doc/tree-matching.md).
+
+Semantic predicates are still allowed in both the parser and lexer rules as our actions. For efficiency sake keep semantic predicates to the right edge of lexical rules.
+
+There are no tree grammars because we use listeners and visitors instead.
+
+## Why is my expression parser slow?
+
+Make sure to use two-stage parsing. See example in [bug report](https://github.com/antlr/antlr4/issues/374).
+
+```Java
+
+CharStream input = new ANTLRFileStream(args[0]);
+ExprLexer lexer = new ExprLexer(input);
+CommonTokenStream tokens = new CommonTokenStream(lexer);
+ExprParser parser = new ExprParser(tokens);
+parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
+try {
+ parser.stat(); // STAGE 1
+}
+catch (Exception ex) {
+ tokens.reset(); // rewind input stream
+ parser.reset();
+ parser.getInterpreter().setPredictionMode(PredictionMode.LL);
+ parser.stat(); // STAGE 2
+ // if we parse ok, it's LL not SLL
+}
+```
diff --git a/doc/faq/getting-started.md b/doc/faq/getting-started.md
new file mode 100644
index 0000000..bd0d4ff
--- /dev/null
+++ b/doc/faq/getting-started.md
@@ -0,0 +1,11 @@
+# Getting started
+
+## How to I install and run a simple grammar?
+
+See [Getting Started with ANTLR v4](https://raw.githubusercontent.com/antlr/antlr4/master/doc/getting-started.md).
+
+## Why does my parser test program hang?
+
+Your test program is likely not hanging but simply waiting for you to type some input for standard input. Don't forget that you need to type the end of file character, generally on a line by itself, at the end of the input. On a Mac or Linux machine it is ctrl-D, as gawd intended, or ctrl-Z on a Windows machine.
+
+See [Getting Started with ANTLR v4](https://raw.githubusercontent.com/antlr/antlr4/master/doc/getting-started.md). \ No newline at end of file
diff --git a/doc/faq/index.md b/doc/faq/index.md
new file mode 100644
index 0000000..734fc6c
--- /dev/null
+++ b/doc/faq/index.md
@@ -0,0 +1,50 @@
+# Frequently-Asked Questions (FAQ)
+
+This is the main landing page for the ANTLR 4 FAQ. The links below will take you to the appropriate file containing all answers for that subcategory.
+
+*To add to or improve this FAQ, [fork](https://help.github.com/articles/fork-a-repo/) the [antlr/antlr4 repo](https://github.com/antlr/antlr4) then update this `doc/faq/index.md` or file(s) in that directory. Submit a [pull request](https://help.github.com/articles/creating-a-pull-request/) to get your changes incorporated into the main repository. Do not mix code and FAQ updates in the sample pull request.* **You must sign the contributors.txt certificate of origin with your pull request if you've not done so before.**
+
+## Getting Started
+
+* [How to I install and run a simple grammar?](getting-started.md)
+* [Why does my parser test program hang?](getting-started.md)
+
+## Installation
+
+* [Why can't ANTLR (grun) find my lexer or parser?](installation.md)
+* [Why can't I run the ANTLR tool?](installation.md)
+* [Why doesn't my parser compile?](installation.md)
+
+## General
+
+* [Why do we need ANTLR v4?](general.md)
+* [What is the difference between ANTLR 3 and 4?](general.md)
+* [Why is my expression parser slow?](general.md)
+
+## Grammar syntax
+
+## Lexical analysis
+
+* [How can I parse non-ASCII text and use characters in token rules?](lexical.md)
+* [How do I replace escape characters in string tokens?](lexical.md)
+* [Why are my keywords treated as identifiers?](lexical.md)
+* [Why are there no whitespace tokens in the token stream?](lexical.md)
+
+## Parse Trees
+
+* [How do I get the input text for a parse-tree subtree?](parse-trees.md)
+* [What if I need ASTs not parse trees for a compiler, for example?](parse-trees.md)
+* [When do I use listener/visitor vs XPath vs Tree pattern matching?](parse-trees.md)
+
+## Translation
+
+* [ASTs vs parse trees](parse-trees.md)
+* [Decoupling input walking from output generation](parse-trees.md)
+
+## Actions and semantic predicates
+
+* [How do I test if an optional rule was matched?](actions-preds.md)
+
+## Error handling
+
+* [How do I perform semantic checking with ANTLR?](error-handling.md)
diff --git a/doc/faq/installation.md b/doc/faq/installation.md
new file mode 100644
index 0000000..fb945da
--- /dev/null
+++ b/doc/faq/installation.md
@@ -0,0 +1,60 @@
+# Installation
+
+Please read carefully: [Getting Started with ANTLR v4](https://raw.githubusercontent.com/antlr/antlr4/master/doc/getting-started.md).
+
+## Why can't ANTLR (grun) find my lexer or parser?
+
+If you see "Can't load Hello as lexer or parser", it's because you don't have '.' (current directory) in your CLASSPATH.
+
+```bash
+$ alias antlr4='java -jar /usr/local/lib/antlr-4.2.2-complete.jar'
+$ alias grun='java org.antlr.v4.runtime.misc.TestRig'
+$ export CLASSPATH="/usr/local/lib/antlr-4.2.2-complete.jar"
+$ antlr4 Hello.g4
+$ javac Hello*.java
+$ grun Hello r -tree
+Can't load Hello as lexer or parser
+$
+```
+
+For mac/linux, use:
+
+```bash
+export CLASSPATH=".:/usr/local/lib/antlr-4.2.2-complete.jar:$CLASSPATH"
+```
+
+or for Windows:
+
+```
+SET CLASSPATH=.;C:\Javalib\antlr4-complete.jar;%CLASSPATH%
+```
+
+**See the dot at the beginning?** It's critical.
+
+## Why can't I run the ANTLR tool?
+
+If you get a no class definition found error, you are missing the ANTLR jar in your `CLASSPATH` (or you might only have the runtime jar):
+
+```bash
+/tmp $ java org.antlr.v4.Tool Hello.g4
+Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/v4/Tool
+Caused by: java.lang.ClassNotFoundException: org.antlr.v4.Tool
+ at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
+ at java.security.AccessController.doPrivileged(Native Method)
+ at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
+ at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
+```
+
+## Why doesn't my parser compile?
+
+If you see these kinds of errors, it's because you don't have the runtime or complete ANTLR library in your CLASSPATH.
+
+```bash
+/tmp $ javac Hello*.java
+HelloBaseListener.java:3: package org.antlr.v4.runtime does not exist
+import org.antlr.v4.runtime.ParserRuleContext;
+ ^
+...
+```
diff --git a/doc/faq/lexical.md b/doc/faq/lexical.md
new file mode 100644
index 0000000..371d1f9
--- /dev/null
+++ b/doc/faq/lexical.md
@@ -0,0 +1,63 @@
+# Lexical analysis
+
+## How can I parse non-ASCII text and use characters in token rules?
+
+See [Using non-ASCII characters in token rules](http://stackoverflow.com/questions/28126507/antlr4-using-non-ascii-characters-in-token-rules/28129510#28129510).
+
+## How do I replace escape characters in string tokens?
+
+Unfortunately, manipulating the text of the token matched by a lexical rule is cumbersome (as of 4.2). You have to build up a buffer and then set the text at the end. Actions in the lexer execute at the associated position in the input just like they do in the parser. Here's an example that does escape character replacement in strings. It's not pretty but it works.
+
+```
+grammar Foo;
+
+@members {
+StringBuilder buf = new StringBuilder(); // can't make locals in lexer rules
+}
+
+STR : '"'
+ ( '\\'
+ ( 'r' {buf.append('\r');}
+ | 'n' {buf.append('\n');}
+ | 't' {buf.append('\t');}
+ | '\\' {buf.append('\\');}
+ | '\"' {buf.append('"');}
+ )
+ | ~('\\'|'"') {buf.append((char)_input.LA(-1));}
+ )*
+ '"'
+ {setText(buf.toString()); buf.setLength(0); System.out.println(getText());}
+ ;
+```
+
+It's easier and more efficient to return original input string and then use a small function to rewrite the string later during a parse tree walk or whatever. But, here's how to do it from within the lexer.
+
+Lexer actions don't work in the interpreter, which includes xpath and tree patterns.
+
+For more on the argument against doing complicated things in the lexer, see the [related lexer-action issue at github](https://github.com/antlr/antlr4/issues/483#issuecomment-37326067).
+
+## Why are my keywords treated as identifiers?
+
+Keywords such as `begin` are also valid identifiers lexically and so that input is ambiguous. To resolve ambiguities, ANTLR gives precedence to the lexical rules specified first. That implies that you must put the identifier rule after all of your keywords:
+
+```
+grammar T;
+
+decl : DEF 'int' ID ';'
+
+DEF : 'def' ; // ambiguous with ID as is 'int'
+ID : [a-z]+ ;
+```
+
+Notice that literal `'int'` is also physically before the ID rule and will also get precedence.
+
+## Why are there no whitespace tokens in the token stream?
+
+The lexer is not sending white space to the parser, which means that the rewrite stream doesn't have access to the tokens either. It is because of the skip lexer command:
+
+```
+WS : [ \t\r\n\u000C]+ -> skip
+ ;
+```
+
+You have to change all those to `-> channel(HIDDEN)` which will send them to the parser on a different channel, making them available in the token stream, but invisible to the parser. \ No newline at end of file
diff --git a/doc/faq/parse-trees.md b/doc/faq/parse-trees.md
new file mode 100644
index 0000000..5a243ce
--- /dev/null
+++ b/doc/faq/parse-trees.md
@@ -0,0 +1,73 @@
+# Parse Trees
+
+## How do I get the input text for a parse-tree subtree?
+
+In ParseTree, you have this method:
+
+```java
+/** Return the combined text of all leaf nodes. Does not get any
+ * off-channel tokens (if any) so won't return whitespace and
+ * comments if they are sent to parser on hidden channel.
+ */
+String getText();
+```
+
+But, you probably want this method from TokenStream:
+
+```java
+/**
+ * Return the text of all tokens in the source interval of the specified
+ * context. This method behaves like the following code, including potential
+ * exceptions from the call to {@link #getText(Interval)}, but may be
+ * optimized by the specific implementation.
+ *
+ * <p>If {@code ctx.getSourceInterval()} does not return a valid interval of
+ * tokens provided by this stream, the behavior is unspecified.</p>
+ *
+ * <pre>
+ * TokenStream stream = ...;
+ * String text = stream.getText(ctx.getSourceInterval());
+ * </pre>
+ *
+ * @param ctx The context providing the source interval of tokens to get
+ * text for.
+ * @return The text of all tokens within the source interval of {@code ctx}.
+ */
+public String getText(RuleContext ctx);
+```
+
+That is, do this:
+
+```
+mytokens.getText(mySubTree);
+```
+
+## What if I need ASTs not parse trees for a compiler, for example?
+
+For writing a compiler, either generate [LLVM-type static-single-assignment](http://llvm.org/docs/LangRef.html) form or construct an AST from the parse tree using a listener or visitor. Or, use actions in grammar, turning off auto-parse-tree construction.
+
+## When do I use listener/visitor vs XPath vs Tree pattern matching?
+
+### XPath
+
+XPath works great when you need to find specific nodes, possibly in certain contexts. The context is limited to the parents on the way to the root of the tree. For example, if you want to find all ID nodes, use path `//ID`. If you want all variable declarations, you might use path `//vardecl`. If you only want fields declarations, then you can use some context information via path `/classdef/vardecl`, which would only find vardecls that our children of class definitions. You can merge the results of multiple XPath `findAll()`s simulating a set union for XPath. The only caveat is that the order from the original tree is not preserved when you union multiple `findAll()` sets.
+
+### Tree pattern matching
+
+Use tree pattern matching when you want to find specific subtree structures such as all assignments to 0 using pattern `x = 0;`. (Recall that these are very convenient because you specify the tree structure in the concrete syntax of the language described by the grammar.) If you want to find all assignments of any kind, you can use pattern `x = <expr>;` where `<expr>` will find any expression. This works great for matching particular substructures and therefore gives you a bit more ability to specify context. I.e., instead of just finding all identifiers, you can find all identifiers on the left hand side of an expression.
+
+### Listeners/Visitors
+
+Using the listener or visitor interfaces give you the most power but require implementing more methods. It might be more challenging to discover the emergent behavior of the listener than a simple tree pattern matcher that says *go find me X under node Y*.
+
+Listeners are great when you want to visit many nodes in a tree.
+
+Listeners allow you to compute and save context information necessary for processing at various nodes. For example, when building a symbol table manager for a compiler or translator, you need to compute symbol scopes such as globals, class, function, and code block. When you enter a class or function, you push a new scope and then pop it when you exit that class or function. When you see a symbol, you need to define it or look it up in the proper scope. By having enter/exit listener functions push and pop scopes, listener functions for defining variables simply say something like:
+
+```java
+scopeStack.peek().define(new VariableSymbol("foo"))
+```
+
+That way each listener function does not have to compute its appropriate scope.
+
+Examples: [DefScopesAndSymbols.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/DefScopesAndSymbols.java) and [SetScopeListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/SetScopeListener.java) and [VerifyListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/VerifyListener.java) \ No newline at end of file
diff --git a/doc/faq/translation.md b/doc/faq/translation.md
new file mode 100644
index 0000000..3f45212
--- /dev/null
+++ b/doc/faq/translation.md
@@ -0,0 +1,9 @@
+# Translation
+
+## ASTs vs parse trees
+
+I used to do specialized AST (**abstract** syntax tree) nodes rather than (concrete) parse trees because I used to think more about compilation and generating bytecode/assembly code. When I started thinking more about translation, I started using parse trees. For v4, I realized that I did mostly translation. I guess what I'm saying is that maybe parse trees are not as good as ASTs for generating bytecodes. Personally, I would rather see `(+ 3 4)` rather than `(expr 3 + 4)` for generating byte codes, but it's not the end of the world. (*Can someone fill this in?*)
+
+## Decoupling input walking from output generation
+
+I suggest creating an intermediate model that represents your output. You walk the parse tree to collect information and create your model. Then, you could almost certainly automatically walk this internal model to generate output based upon stringtemplates that match the class names of the internal model. In other words, define a special `IFStatement` object that has all of the fields you want and then create them as you walk the parse tree. This decoupling of the input from the output is very powerful. Just because we have a parse tree listener doesn't mean that the parse tree itself is necessarily the best data structure to hold all information necessary to generate code. Imagine a situation where the output is the exact reverse of the input. In that case, you really want to walk the input just to collect data. Generating output should be driven by the internal model not the way it was represented in the input. \ No newline at end of file
diff --git a/doc/getting-started.md b/doc/getting-started.md
new file mode 100644
index 0000000..056f0fa
--- /dev/null
+++ b/doc/getting-started.md
@@ -0,0 +1,131 @@
+# Getting Started with ANTLR v4
+
+Hi and welcome to the version 4 release of ANTLR! It's named after the fearless hero of the [Crazy Nasty-Ass Honey Badger](http://www.youtube.com/watch?v=4r7wHMg5Yjg) since ANTLR v4 takes whatever you give it--it just doesn't give a crap! See [Why do we need ANTLR v4?](faq/general.md) and the [preface of the ANTLR v4 book](http://media.pragprog.com/titles/tpantlr2/preface.pdf).
+
+## Installation
+
+ANTLR is really two things: a tool that translates your grammar to a parser/lexer in Java (or other target language) and the runtime needed by the generated parsers/lexers. Even if you are using the ANTLR Intellij plug-in or ANTLRWorks to run the ANTLR tool, the generated code will still need the runtime library.
+
+The first thing you should do is probably download and install a development tool plug-in. Even if you only use such tools for editing, they are great. Then, follow the instructions below to get the runtime environment available to your system to run generated parsers/lexers. In what follows, I talk about antlr-4.5.3-complete.jar, which has the tool and the runtime and any other support libraries (e.g., ANTLR v4 is written in v3).
+
+If you are going to integrate ANTLR into your existing build system using mvn, ant, or want to get ANTLR into your IDE such as eclipse or intellij, see Integrating ANTLR into Development Systems.
+
+### UNIX
+
+0. Install Java (version 1.6 or higher)
+1. Download
+```
+$ cd /usr/local/lib
+$ curl -O http://www.antlr.org/download/antlr-4.5.3-complete.jar
+```
+Or just download in browser from website:
+ [http://www.antlr.org/download.html](http://www.antlr.org/download.html)
+and put it somewhere rational like `/usr/local/lib`.
+2. Add `antlr-4.5.3-complete.jar` to your `CLASSPATH`:
+```
+$ export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH"
+```
+It's also a good idea to put this in your `.bash_profile` or whatever your startup script is.
+3. Create aliases for the ANTLR Tool, and `TestRig`.
+```
+$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
+$ alias grun='java org.antlr.v4.gui.TestRig'
+```
+
+### WINDOWS
+
+(*Thanks to Graham Wideman*)
+
+0. Install Java (version 1.6 or higher)
+1. Download antlr-4.5.3-complete.jar (or whatever version) from [http://www.antlr.org/download/](http://www.antlr.org/download/)
+Save to your directory for 3rd party Java libraries, say `C:\Javalib`
+2. Add `antlr-4.5-complete.jar` to CLASSPATH, either:
+ * Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable
+ * Temporarily, at command line:
+```
+SET CLASSPATH=.;C:\Javalib\antlr-4.5.3-complete.jar;%CLASSPATH%
+```
+3. Create short convenient commands for the ANTLR Tool, and TestRig, using batch files or doskey commands:
+ * Batch files (in directory in system PATH) antlr4.bat and grun.bat
+```
+java org.antlr.v4.Tool %*
+```
+```
+java org.antlr.v4.gui.TestRig %*
+```
+ * Or, use doskey commands:
+```
+doskey antlr4=java org.antlr.v4.Tool $*
+doskey grun =java org.antlr.v4.gui.TestRig $*
+```
+
+### Testing the installation
+
+Either launch org.antlr.v4.Tool directly:
+
+```
+$ java org.antlr.v4.Tool
+ANTLR Parser Generator Version 4.5.3
+-o ___ specify output directory where all output is generated
+-lib ___ specify location of .tokens files
+...
+```
+
+or use -jar option on java:
+
+```
+$ java -jar /usr/local/lib/antlr-4.5.3-complete.jar
+ANTLR Parser Generator Version 4.5.3
+-o ___ specify output directory where all output is generated
+-lib ___ specify location of .tokens files
+...
+```
+
+## A First Example
+
+In a temporary directory, put the following grammar inside file Hello.g4:
+Hello.g4
+
+```
+// Define a grammar called Hello
+grammar Hello;
+r : 'hello' ID ; // match keyword hello followed by an identifier
+ID : [a-z]+ ; // match lower-case identifiers
+WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
+```
+
+Then run ANTLR the tool on it:
+
+```
+$ cd /tmp
+$ antlr4 Hello.g4
+$ javac Hello*.java
+```
+
+Now test it:
+
+```
+$ grun Hello r -tree
+hello parrt
+^D
+(r hello parrt)
+(That ^D means EOF on unix; it's ^Z in Windows.) The -tree option prints the parse tree in LISP notation.
+It's nicer to look at parse trees visually.
+$ grun Hello r -gui
+hello parrt
+^D
+```
+
+That pops up a dialog box showing that rule `r` matched keyword `hello` followed by identifier `parrt`.
+
+![](images/hello-parrt.png)
+
+## Book source code
+
+The book has lots and lots of examples that should be useful to. You can download them here for free:
+
+[http://pragprog.com/titles/tpantlr2/source_code](http://pragprog.com/titles/tpantlr2/source_code)
+
+Also, there is a large collection of grammars for v4 at github:
+
+[https://github.com/antlr/grammars-v4](https://github.com/antlr/grammars-v4)
diff --git a/doc/go-target.md b/doc/go-target.md
new file mode 100644
index 0000000..6de6db9
--- /dev/null
+++ b/doc/go-target.md
@@ -0,0 +1,115 @@
+# ANTLR4 Language Target, Runtime for Go
+
+### First steps
+
+#### 1. Install ANTLR4
+
+[The getting started guide](getting-started.md) should get you started.
+
+#### 2. Get the Go ANTLR runtime
+
+Each target language for ANTLR has a runtime package for running parser generated by ANTLR4. The runtime provides a common set of tools for using your parser.
+
+Get the runtime and install it on your GOPATH:
+
+```bash
+go get github.com/antlr/antlr4/runtime/Go/antlr
+```
+
+#### 3. Set the release tag (optional)
+
+`go get` has no native way to specify a branch or commit. So, when you run it, you'll download the latest commits. This may or may not be your preference.
+
+You'll need to use git to set the release. For example, to set the release tag for release 4.6.0:
+
+```bash
+cd $GOPATH/src/github.com/antlr/antlr4 # enter the antlr4 source directory
+git checkout tags/4.6.0 # the go runtime was added in release 4.6.0
+```
+
+A complete list of releases can be found on [the release page](https://github.com/antlr/antlr4/releases).
+
+#### 4. Generate your parser
+
+You use the ANTLR4 "tool" to generate a parser. These will reference the ANTLR runtime, installed above.
+
+Suppose you're using a UNIX system and have set up an alias for the ANTLR4 tool as described in [the getting started guide](getting-started.md). To generate your go parser, you'll need to invoke:
+
+```bash
+antlr4 -Dlanguage=Go MyGrammar.g4
+```
+
+For a full list of antlr4 tool options, please visit the [tool documentation page](tool-options.md).
+
+### Referencing the Go ANTLR runtime
+
+You can reference the go ANTLR runtime package like this:
+
+```go
+import "github.com/antlr/antlr4/runtime/Go/antlr"
+```
+
+### Complete example
+
+Suppose you're using the JSON grammar from https://github.com/antlr/grammars-v4/tree/master/json.
+
+Then, invoke `antlr4 -Dlanguage=Go JSON.g4`. The result of this is a collection of .go files in the `parser` directory including:
+```
+json_parser.go
+json_base_listener.go
+json_lexer.go
+json_listener.go
+```
+
+Another common option to the ANTLR tool is `-visitor`, which generates a parse tree visitor, but we won't be doing that here. For a full list of antlr4 tool options, please visit the [tool documentation page](tool-options.md).
+
+We'll write a small main func to call the generated parser/lexer (assuming they are separate). This one writes out the encountered `ParseTreeContext`'s. Suppose the gen'ed parser code is in the `parser` directory relative to this code:
+
+```
+package main
+
+import (
+ "github.com/antlr/antlr4/runtime/Go/antlr"
+ "./parser"
+ "os"
+ "fmt"
+)
+
+type TreeShapeListener struct {
+ *parser.BaseJSONListener
+}
+
+func NewTreeShapeListener() *TreeShapeListener {
+ return new(TreeShapeListener)
+}
+
+func (this *TreeShapeListener) EnterEveryRule(ctx antlr.ParserRuleContext) {
+ fmt.Println(ctx.GetText())
+}
+
+func main() {
+ input := antlr.NewFileStream(os.Args[1])
+ lexer := parser.NewJSONLexer(input)
+ stream := antlr.NewCommonTokenStream(lexer,0)
+ p := parser.NewJSONParser(stream)
+ p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
+ p.BuildParseTrees = true
+ tree := p.Json()
+ antlr.ParseTreeWalkerDefault.Walk(NewTreeShapeListener(), tree)
+}
+```
+
+This one expects the input to be passed on the command line:
+
+```
+go run test.go input
+```
+
+The output is:
+
+```
+{"a":1}
+{"a":1}
+"a":1
+1
+```
diff --git a/doc/grammars.md b/doc/grammars.md
new file mode 100644
index 0000000..c40d974
--- /dev/null
+++ b/doc/grammars.md
@@ -0,0 +1,184 @@
+# Grammar Structure
+
+A grammar is essentially a grammar declaration followed by a list of rules, but has the general form:
+
+```
+/** Optional javadoc style comment */
+grammar Name; ①
+options {...}
+import ... ;
+
+tokens {...}
+channels {...} // lexer only
+@actionName {...}
+
+rule1 // parser and lexer rules, possibly intermingled
+...
+ruleN
+```
+
+The file name containing grammar `X` must be called `X.g4`. You can specify options, imports, token specifications, and actions in any order. There can be at most one each of options, imports, and token specifications. All of those elements are optional except for the header ① and at least one rule. Rules take the basic form:
+
+```
+ruleName : alternative1 | ... | alternativeN ;
+```
+
+Parser rule names must start with a lowercase letter and lexer rules must start with a capital letter.
+
+Grammars defined without a prefix on the `grammar` header are combined grammars that can contain both lexical and parser rules. To make a parser grammar that only allows parser rules, use the following header.
+
+```
+parser grammar Name;
+...
+```
+
+And, naturally, a pure lexer grammar looks like this:
+
+```
+lexer grammar Name;
+...
+```
+
+Only lexer grammars can contain `mode` specifications.
+
+Only lexer grammars can contain custom channels specifications
+
+```
+channels {
+ WHITESPACE_CHANNEL,
+ COMMENTS_CHANNEL
+}
+```
+
+Those channels can then be used like enums within lexer rules:
+
+```
+WS : [ \r\t\n]+ -> channel(WHITESPACE_CHANNEL) ;
+```
+
+Sections 15.5, [Lexer Rules](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference) and Section 15.3, [Parser Rules](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference) contain details on rule syntax. Section 15.8, Options describes grammar options and Section 15.4, Actions and Attributes has information on grammar-level actions.
+
+## Grammar Imports
+
+Grammar `imports` let you break up a grammar into logical and reusable chunks, as we saw in [Importing Grammars](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference). ANTLR treats imported grammars very much like object-oriented programming languages treat superclasses. A grammar inherits all of the rules, tokens specifications, and named actions from the imported grammar. Rules in the “main grammar” override rules from imported grammars to implement inheritance.
+
+Think of `import` as more like a smart include statement (which does not include rules that are already defined). The result of all imports is a single combined grammar; the ANTLR code generator sees a complete grammar and has no idea there were imported grammars.
+
+To process a main grammar, the ANTLR tool loads all of the imported grammars into subordinate grammar objects. It then merges the rules, token types, and named actions from the imported grammars into the main grammar. In the diagram below, the grammar on the right illustrates the effect of grammar `MyELang` importing grammar `ELang`.
+
+<img src=images/combined.png width=400>
+
+`MyELang` inherits rules `stat`, `WS`, and `ID`, but overrides rule `expr` and adds `INT`. Here’s a sample build and test run that shows `MyELang` can recognize integer expressions whereas the original `ELang` can’t. The third, erroneous input statement triggers an error message that also demonstrates the parser was looking for `MyELang`’s expr not `ELang`’s.
+
+```
+$ antlr4 MyELang.g4
+$ javac MyELang*.java
+$ grun MyELang stat
+=> 34;
+=> a;
+=> ;
+=> EOF
+<= line 3:0 extraneous input ';' expecting {INT, ID}
+```
+
+If there were any `tokens` specifications, the main grammar would merge the token sets. Any named actions such as `@members` would be merged. In general, you should avoid named actions and actions within rules in imported grammars since that limits their reuse. ANTLR also ignores any options in imported grammars.
+
+Imported grammars can also import other grammars. ANTLR pursues all imported grammars in a depth-first fashion. If two or more imported grammars define rule `r`, ANTLR chooses the first version of `r` it finds. In the following diagram, ANTLR examines grammars in the following order `Nested`, `G1`, `G3`, `G2`.
+
+<img src=images/nested.png width=350>
+
+`Nested` includes the `r` rule from `G3` because it sees that version before the `r` in `G2`.
+
+Not every kind of grammar can import every other kind of grammar:
+
+* Lexer grammars can import lexers.
+* Parsers can import parsers.
+* Combined grammars can import lexers or parsers.
+
+ANTLR adds imported rules to the end of the rule list in a main lexer grammar. That means lexer rules in the main grammar get precedence over imported rules. For example, if a main grammar defines rule `IF : ’if’ ;` and an imported grammar defines rule `ID : [a-z]+ ;` (which also recognizes `if`), the imported `ID` won’t hide the main grammar’s `IF` token definition.
+
+## Tokens Section
+
+The purpose of the `tokens` section is to define token types needed by a grammar for which there is no associated lexical rule. The basic syntax is:
+
+```
+tokens { Token1, ..., TokenN }
+```
+
+Most of the time, the tokens section is used to define token types needed by actions in the grammar as shown in Section 10.3, [Recognizing Languages whose Keywords Aren’t Fixed](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference):
+
+```
+// explicitly define keyword token types to avoid implicit definition warnings
+tokens { BEGIN, END, IF, THEN, WHILE }
+
+@lexer::members { // keywords map used in lexer to assign token types
+Map<String,Integer> keywords = new HashMap<String,Integer>() {{
+ put("begin", KeywordsParser.BEGIN);
+ put("end", KeywordsParser.END);
+ ...
+}};
+}
+```
+
+The `tokens` section really just defines a set of tokens to add to the overall set.
+
+```
+$ cat Tok.g4
+grammar Tok;
+tokens { A, B, C }
+a : X ;
+$ antlr4 Tok.g4
+warning(125): Tok.g4:3:4: implicit definition of token X in parser
+$ cat Tok.tokens
+A=1
+B=2
+C=3
+X=4
+```
+
+## Actions at the Grammar Level
+
+Currently there are only two defined named actions (for the Java target) used outside of grammar rules: `header` and `members`. The former injects code into the generated recognizer class file, before the recognizer class definition, and the latter injects code into the recognizer class definition, as fields and methods.
+
+For combined grammars, ANTLR injects the actions into both the parser and the lexer. To restrict an action to the generated parser or lexer, use `@parser::name` or `@lexer::name`.
+
+Here’s an example where the grammar specifies a package for the generated code:
+
+```
+grammar Count;
+
+@header {
+package foo;
+}
+
+@members {
+int count = 0;
+}
+
+list
+@after {System.out.println(count+" ints");}
+: INT {count++;} (',' INT {count++;} )*
+;
+
+INT : [0-9]+ ;
+WS : [ \r\t\n]+ -> skip ;
+```
+
+The grammar itself then should be in directory `foo` so that ANTLR generates code in that same `foo` directory (at least when not using the `-o` ANTLR tool option):
+
+```
+$ cd foo
+$ antlr4 Count.g4 # generates code in the current directory (foo)
+$ ls
+Count.g4 CountLexer.java CountParser.java
+Count.tokens CountLexer.tokens
+CountBaseListener.java CountListener.java
+$ javac *.java
+$ cd ..
+$ grun foo.Count list
+=> 9, 10, 11
+=> EOF
+<= 3 ints
+```
+
+The Java compiler expects classes in package `foo` to be in directory `foo`.
diff --git a/doc/images/ACE-Architecture.001.png b/doc/images/ACE-Architecture.001.png
new file mode 100644
index 0000000..ef36f98
--- /dev/null
+++ b/doc/images/ACE-Architecture.001.png
Binary files differ
diff --git a/doc/images/combined.png b/doc/images/combined.png
new file mode 100644
index 0000000..8131bb3
--- /dev/null
+++ b/doc/images/combined.png
Binary files differ
diff --git a/doc/images/dragfile.png b/doc/images/dragfile.png
new file mode 100644
index 0000000..1b7e8da
--- /dev/null
+++ b/doc/images/dragfile.png
Binary files differ
diff --git a/doc/images/foreign.png b/doc/images/foreign.png
new file mode 100644
index 0000000..daaa8d8
--- /dev/null
+++ b/doc/images/foreign.png
Binary files differ
diff --git a/doc/images/hello-parrt.png b/doc/images/hello-parrt.png
new file mode 100644
index 0000000..5bc0596
--- /dev/null
+++ b/doc/images/hello-parrt.png
Binary files differ
diff --git a/doc/images/idea-prefs-after-install.png b/doc/images/idea-prefs-after-install.png
new file mode 100644
index 0000000..2d5c8bd
--- /dev/null
+++ b/doc/images/idea-prefs-after-install.png
Binary files differ
diff --git a/doc/images/idea-prefs.png b/doc/images/idea-prefs.png
new file mode 100644
index 0000000..ab375b8
--- /dev/null
+++ b/doc/images/idea-prefs.png
Binary files differ
diff --git a/doc/images/intellij-maven.png b/doc/images/intellij-maven.png
new file mode 100644
index 0000000..775e532
--- /dev/null
+++ b/doc/images/intellij-maven.png
Binary files differ
diff --git a/doc/images/nested-fuzzy.png b/doc/images/nested-fuzzy.png
new file mode 100644
index 0000000..4da816c
--- /dev/null
+++ b/doc/images/nested-fuzzy.png
Binary files differ
diff --git a/doc/images/nested.png b/doc/images/nested.png
new file mode 100644
index 0000000..9c9bb1d
--- /dev/null
+++ b/doc/images/nested.png
Binary files differ
diff --git a/doc/images/nonascii.png b/doc/images/nonascii.png
new file mode 100644
index 0000000..c431fee
--- /dev/null
+++ b/doc/images/nonascii.png
Binary files differ
diff --git a/doc/images/nonnested-fuzzy.png b/doc/images/nonnested-fuzzy.png
new file mode 100644
index 0000000..d175942
--- /dev/null
+++ b/doc/images/nonnested-fuzzy.png
Binary files differ
diff --git a/doc/images/process.png b/doc/images/process.png
new file mode 100644
index 0000000..5185aae
--- /dev/null
+++ b/doc/images/process.png
Binary files differ
diff --git a/doc/images/python3-tests.png b/doc/images/python3-tests.png
new file mode 100644
index 0000000..3f278e3
--- /dev/null
+++ b/doc/images/python3-tests.png
Binary files differ
diff --git a/doc/images/targetselection.png b/doc/images/targetselection.png
new file mode 100644
index 0000000..32e2d86
--- /dev/null
+++ b/doc/images/targetselection.png
Binary files differ
diff --git a/doc/images/teronbook.png b/doc/images/teronbook.png
new file mode 100644
index 0000000..3eb53d8
--- /dev/null
+++ b/doc/images/teronbook.png
Binary files differ
diff --git a/doc/images/tertalk.png b/doc/images/tertalk.png
new file mode 100644
index 0000000..069db0a
--- /dev/null
+++ b/doc/images/tertalk.png
Binary files differ
diff --git a/doc/images/testrigs.png b/doc/images/testrigs.png
new file mode 100644
index 0000000..00e05b7
--- /dev/null
+++ b/doc/images/testrigs.png
Binary files differ
diff --git a/doc/images/tpantlr2.png b/doc/images/tpantlr2.png
new file mode 100644
index 0000000..fb2e5c6
--- /dev/null
+++ b/doc/images/tpantlr2.png
Binary files differ
diff --git a/doc/images/tpdsl.png b/doc/images/tpdsl.png
new file mode 100644
index 0000000..05f137a
--- /dev/null
+++ b/doc/images/tpdsl.png
Binary files differ
diff --git a/doc/images/xcodedep.png b/doc/images/xcodedep.png
new file mode 100644
index 0000000..9cdce88
--- /dev/null
+++ b/doc/images/xcodedep.png
Binary files differ
diff --git a/doc/images/xcodenav.png b/doc/images/xcodenav.png
new file mode 100644
index 0000000..d708ef7
--- /dev/null
+++ b/doc/images/xcodenav.png
Binary files differ
diff --git a/doc/images/xyz.png b/doc/images/xyz.png
new file mode 100644
index 0000000..ab08138
--- /dev/null
+++ b/doc/images/xyz.png
Binary files differ
diff --git a/doc/images/xyz_opt.png b/doc/images/xyz_opt.png
new file mode 100644
index 0000000..61d9894
--- /dev/null
+++ b/doc/images/xyz_opt.png
Binary files differ
diff --git a/doc/images/xyz_plus.png b/doc/images/xyz_plus.png
new file mode 100644
index 0000000..2f6fb98
--- /dev/null
+++ b/doc/images/xyz_plus.png
Binary files differ
diff --git a/doc/images/xyz_star.png b/doc/images/xyz_star.png
new file mode 100644
index 0000000..7a7841e
--- /dev/null
+++ b/doc/images/xyz_star.png
Binary files differ
diff --git a/doc/index.md b/doc/index.md
new file mode 100644
index 0000000..d5c5551
--- /dev/null
+++ b/doc/index.md
@@ -0,0 +1,68 @@
+# ANTLR 4 Documentation
+
+Please check [Frequently asked questions (FAQ)](faq/index.md) before asking questions on stackoverflow or antlr-discussion list.
+
+Notes:
+<ul>
+<li>To add to or improve this documentation, <a href=https://help.github.com/articles/fork-a-repo>fork</a> the <a href=https://github.com/antlr/antlr4>antlr/antlr4 repo</a> then update this `doc/index.md` or file(s) in that directory. Submit a <a href=https://help.github.com/articles/creating-a-pull-request>pull request</a> to get your changes incorporated into the main repository. Do not mix code and documentation updates in the sample pull request. <b>You must sign the contributors.txt certificate of origin with your pull request if you've not done so before.</b></li>
+
+<li>Copyright © 2012, The Pragmatic Bookshelf. Pragmatic Bookshelf grants a nonexclusive, irrevocable, royalty-free, worldwide license to reproduce, distribute, prepare derivative works, and otherwise use this contribution as part of the ANTLR project and associated documentation.</li>
+
+<li>This text was copied with permission from the <a href=http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference>The Definitive ANTLR 4 Reference</a>, though it is being morphed over time as the tool changes.</li>
+</ul>
+
+Links in the documentation refer to various sections of the book but have been redirected to the general book page on the publisher's site. There are two excerpts on the publisher's website that might be useful to you without having to purchase the book: [Let's get Meta](http://media.pragprog.com/titles/tpantlr2/picture.pdf) and [Building a Translator with a Listener](http://media.pragprog.com/titles/tpantlr2/listener.pdf). You should also consider reading the following books (the vid describes the reference book):
+
+<a href=""><img src=images/tpantlr2.png width=120></a>
+<a href=""><img src=images/tpdsl.png width=120></a>
+<a href="https://www.youtube.com/watch?v=OAoA3E-cyug"><img src=images/teronbook.png width=250></a>
+
+This documentation is a reference and summarizes grammar syntax and the key semantics of ANTLR grammars. The source code for all examples in the book, not just this chapter, are free at the publisher's website. The following video is a general tour of ANTLR 4 and includes a description of how to use parse tree listeners to process Java files easily:
+
+<a href="https://vimeo.com/59285751"><img src=images/tertalk.png width=200></a>
+
+## Sections
+
+* [Getting Started with ANTLR v4](getting-started.md)
+
+* [Grammar Lexicon](lexicon.md)
+
+* [Grammar Structure](grammars.md)
+
+* [Parser Rules](parser-rules.md)
+
+* [Left-recursive rules](left-recursion.md)
+
+* [Actions and Attributes](actions.md)
+
+* [Lexer Rules](lexer-rules.md)
+
+* [Wildcard Operator and Nongreedy Subrules](wildcard.md)
+
+* [Parse Tree Listeners](listeners.md)
+
+* [Parse Tree Matching and XPath](tree-matching.md)
+
+* [Semantic Predicates](predicates.md)
+
+* [Options](options.md)
+
+* [ANTLR Tool Command Line Options](tool-options.md)
+
+* [Runtime Libraries and Code Generation Targets](targets.md)
+
+* [Parsing binary streams](parsing-binary-files.md)
+
+* [Parser and lexer interpreters](interpreters.md)
+
+* [Resources](resources.md)
+
+# Building / releasing ANTLR itself
+
+* [Building ANTLR itself](building-antlr.md)
+
+* [Cutting an ANTLR Release](releasing-antlr.md)
+
+* [ANTLR project unit tests](antlr-project-testing.md)
+
+* [Creating an ANTLR Language Target](creating-a-language-target.md)
diff --git a/doc/interpreters.md b/doc/interpreters.md
new file mode 100644
index 0000000..c99e6d5
--- /dev/null
+++ b/doc/interpreters.md
@@ -0,0 +1,79 @@
+# Parser and lexer interpreters
+
+*Since ANTLR 4.2*
+
+For small parsing tasks it is sometimes convenient to use ANTLR in interpreted mode, rather than generating a parser in a particular target, compiling it and running it as part of your application. Here's some sample code that creates lexer and parser Grammar objects and then creates interpreters. Once we have a ParserInterpreter, we can use it to parse starting in any rule we like, given a rule index (which the Grammar can provide).
+
+```java
+LexerGrammar lg = new LexerGrammar(
+ "lexer grammar L;\n" +
+ "A : 'a' ;\n" +
+ "B : 'b' ;\n" +
+ "C : 'c' ;\n");
+Grammar g = new Grammar(
+ "parser grammar T;\n" +
+ "s : (A|B)* C ;\n",
+ lg);
+LexerInterpreter lexEngine =
+ lg.createLexerInterpreter(new ANTLRInputStream(input));
+CommonTokenStream tokens = new CommonTokenStream(lexEngine);
+ParserInterpreter parser = g.createParserInterpreter(tokens);
+ParseTree t = parser.parse(g.rules.get(startRule).index);
+```
+
+You can also load combined grammars from a file:
+
+```java
+public static ParseTree parse(String fileName,
+ String combinedGrammarFileName,
+ String startRule)
+ throws IOException
+{
+ final Grammar g = Grammar.load(combinedGrammarFileName);
+ LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRFileStream(fileName));
+ CommonTokenStream tokens = new CommonTokenStream(lexEngine);
+ ParserInterpreter parser = g.createParserInterpreter(tokens);
+ ParseTree t = parser.parse(g.getRule(startRule).index);
+ System.out.println("parse tree: "+t.toStringTree(parser));
+ return t;
+}
+```
+
+Then:
+
+```java
+ParseTree t = parse("T.om",
+ MantraGrammar,
+ "compilationUnit");
+```
+
+To load separate lexer/parser grammars, do this:
+
+```java
+public static ParseTree parse(String fileNameToParse,
+ String lexerGrammarFileName,
+ String parserGrammarFileName,
+ String startRule)
+ throws IOException
+{
+ final LexerGrammar lg = (LexerGrammar) Grammar.load(lexerGrammarFileName);
+ final Grammar pg = Grammar.load(parserGrammarFileName, lg);
+ ANTLRFileStream input = new ANTLRFileStream(fileNameToParse);
+ LexerInterpreter lexEngine = lg.createLexerInterpreter(input);
+ CommonTokenStream tokens = new CommonTokenStream(lexEngine);
+ ParserInterpreter parser = pg.createParserInterpreter(tokens);
+ ParseTree t = parser.parse(pg.getRule(startRule).index);
+ System.out.println("parse tree: " + t.toStringTree(parser));
+ return t;
+}
+```
+
+Then:
+
+```java
+ParseTree t = parse(fileName, XMLLexerGrammar, XMLParserGrammar, "document");
+```
+
+This is also how we will integrate instantaneous parsing into ANTLRWorks2 and development environment plug-ins.
+
+See [TestParserInterpreter.java](https://github.com/antlr/antlr4/blob/master/tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java).
diff --git a/doc/java-target.md b/doc/java-target.md
new file mode 100644
index 0000000..f6e6154
--- /dev/null
+++ b/doc/java-target.md
@@ -0,0 +1,244 @@
+# Java
+
+## Development environments
+
+### Intellij
+
+There is a very complete and useful plug-in for intellij 12-14, you can grab at the [download page](https://plugins.jetbrains.com/plugin/7358?pr=). Check the [plugin readme](https://github.com/antlr/intellij-plugin-v4) for feature set. Just go to the preferences and click on the "Install plug-in from disk..." button from this dialog box:
+
+<img src="images/idea-prefs.png">
+
+Select the intellij-plugin-1.x.zip (or whatever version) file and hit okay or apply. It will ask you to restart the IDE. If you look at the plug-ins again, you will see:
+
+<img src="images/idea-prefs-after-install.png">
+
+Also, I have prepared a [video](https://youtu.be/eW4WFgRtFeY) that will help you generate grammars and so on using ANTLR v4 in Intellij (w/o the plugin).
+
+### Eclipse
+
+Edgar Espina has created an [eclipse plugin for ANTLR v4](https://youtu.be/eW4WFgRtFeY). Features: Advanced Syntax Highlighting, Automatic Code Generation (on save), Manual Code Generation (through External Tools menu), Code Formatter (Ctrl+Shift+F), Syntax Diagrams, Advanced Rule Navigation between files (F3), Quick fixes.
+
+### NetBeans
+
+Sam Harwell's [ANTLRWorks2](http://tunnelvisionlabs.com/products/demo/antlrworks) works also as a plug-in, not just a stand-alone tool built on top of NetBeans.
+
+## Build systems
+
+### ant
+
+### mvn
+
+*Maven Plugin Reference*
+
+The reference pages for the latest version of the Maven plugin for ANTLR 4 can be found here:
+
+[http://www.antlr.org/api/maven-plugin/latest/index.html](http://www.antlr.org/api/maven-plugin/latest/index.html)
+
+*Walkthrough*
+
+This section describes how to create a simple Antlr 4 project and build it using maven. We are going to use the ArrayInit.g4 example from chapter 3 of the book, and bring it under maven. We will need to rename files and modify them. We will conclude by building a portable stand alone application.
+
+Generate the skeleton. To generate the maven skeleton, type these commands:
+
+```bash
+mkdir SimpleAntlrMavenProject
+cd SimpleAntlrMavenProject
+mvn archetype:generate -DgroupId=org.abcd.examples -DartifactId=array-example -Dpackage=org.abcd.examples.ArrayInit -Dversion=1.0
+# Accept all the default values
+cd array-example
+```
+
+Maven will ask a series of questions, simply accept the default answers by hitting enter.
+
+Move into the directory created by maven:
+
+```bash
+cd array-example
+```
+
+We can use the find command to see the files created by maven:
+
+```bash
+$ find . -type f
+./pom.xml
+./src/test/java/org/abcd/examples/ArrayInit/AppTest.java
+./src/main/java/org/abcd/examples/ArrayInit/App.java
+```
+
+We need to edit the pom.xml file extensively. The App.java will be renamed to ArrayInit.java and will contain the main ANTLR java program which we will download from the book examples. The AppTest.java file will be renamed ArrayInitTest.java but will remain the empty test as created by maven. We will also be adding the grammar file ArrayInit.g4 from the book examples in there.
+
+Get the examples for the book and put them in the Downloads folder. To obtain the ArrayInit.g4 grammar from the book, simply download it:
+
+```bash
+pushd ~/Downloads
+wget http://media.pragprog.com/titles/tpantlr2/code/tpantlr2-code.tgz
+tar xvfz tpantlr2-code.tgz
+popd
+```
+
+Copy the grammar to the maven project. The grammar file goes into a special folder under the src/ directory. The folder name must match the maven package name org.abcd.examples.ArrayInit.
+
+```bash
+mkdir -p src/main/antlr4/org/abcd/examples/ArrayInit
+cp ~/Downloads/code/starter/ArrayInit.g4 src/main/antlr4/org/abcd/examples/ArrayInit
+```
+
+Copy the main program to the maven project. We replace the maven App.java file with the main java program from the book. In the book, that main program is called Test.java, we rename it to ArrayInit.java:
+
+```bash
+# Remove the maven file
+rm ./src/main/java/org/abcd/examples/ArrayInit/App.java
+# Copy and rename the example from the book
+cp ~/Downloads/code/starter/Test.java ./src/main/java/org/abcd/examples/ArrayInit/ArrayInit.java
+```
+
+Spend a few minutes to read the main program. Notice that it reads the standard input stream. We need to remember this when we run the application.
+
+Edit the ArrayInit.java file. We need to add a package declaration and to rename the class. Edit the file ./src/main/java/org/abcd/examples/ArrayInit/ArrayInit.java in your favorite editor. The head of the file should look like this when you are done:
+
+```java
+package org.abcd.examples.ArrayInit;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.tree.*;
+
+public class ArrayInit {
+...
+```
+
+Edit the ArrayInitTest.java file. Maven creates a test file called AppTest.java, we need to rename it to match the name of our application:
+
+```bash
+pushd src/test/java/org/abcd/examples/ArrayInit
+mv AppTest.java ArrayInitTest.java
+sed 's/App/ArrayInit/g' ArrayInitTest.java >ArrayInitTest.java.tmp
+mv ArrayInitTest.java.tmp ArrayInitTest.java
+popd
+```
+
+Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The final product looks like this:
+
+```xml
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.abcd.examples</groupId>
+ <artifactId>array-init</artifactId>
+ <version>1.0</version>
+ <packaging>jar</packaging>
+ <name>array-init</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- This plugin sets up maven to use Java 7 -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ <!-- Plugin to compile the g4 files ahead of the java files
+ See https://github.com/antlr/antlr4/blob/master/antlr4-maven-plugin/src/site/apt/examples/simple.apt.vm
+ Except that the grammar does not need to contain the package declaration as stated in the documentation (I do not know why)
+ To use this plugin, type:
+ mvn antlr4:antlr4
+ In any case, Maven will invoke this plugin before the Java source is compiled
+ -->
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>4.5</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- plugin to create a self-contained portable package
+ This allows us to execute our application like this:
+ java -cp target/array-init-1.0-jar-with-dependencies.jar org.abcd.examples.ArrayInit.ArrayInit
+ -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>simple-command</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+```
+
+This concludes the changes we had to make. We can look at the list of files we have with the find command:
+
+```bash
+$ find . -type f
+./pom.xml
+./src/test/java/org/abcd/examples/ArrayInit/ArrayInitTest.java
+./src/main/antlr4/org/abcd/examples/ArrayInit/ArrayInit.g4
+./src/main/java/org/abcd/examples/ArrayInit/ArrayInit.java
+```
+
+Building a stand alone application. With all the files now in place, we can ask maven to create a standalone application. The following command does this:
+
+```bash
+mvn package
+```
+
+Maven creates a self-contained jar file called target/array-init-1.0-jar-with-dependencies.jar. We can execute the jar file, but remember that it expects some input on the command line, which means the command will hang on the command line until we feed it some input:
+
+```bash
+java -cp target/array-init-1.0-jar-with-dependencies.jar org.abcd.examples.ArrayInit.ArrayInit
+```
+
+And let's feed it the following input:
+
+```bash
+{1,2,3}
+^D
+```
+
+The ^D signals the end of the input to the standard input stream and gets the rest of the application going. You should see the following output:
+
+```bash
+(init { (value 1) , (value 2) , (value 3) })
+```
+
+You can also build a jar file without the dependencies, and execute it with a maven command instead:
+
+```bash
+mvn install
+mvn exec:java -Dexec.mainClass=org.abcd.examples.ArrayInit.ArrayInit
+{1,2,3}
+^D
+``` \ No newline at end of file
diff --git a/doc/javascript-target.md b/doc/javascript-target.md
new file mode 100644
index 0000000..e00f3b7
--- /dev/null
+++ b/doc/javascript-target.md
@@ -0,0 +1,157 @@
+# JavaScript
+
+## Which browsers are supported?
+
+In theory, all browsers supporting ECMAScript 5.1.
+
+In practice, this target has been extensively tested against:
+
+* Firefox 34.0.5
+* Safari 8.0.2
+* Chrome 39.0.2171
+* Explorer 11.0.3
+
+The tests were conducted using Selenium. No issue was found, so you should find that the runtime works pretty much against any recent JavaScript engine.
+
+## Is NodeJS supported?
+
+The runtime has also been extensively tested against Node.js 0.10.33. No issue was found.
+
+## How to create a JavaScript lexer or parser?
+
+This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
+
+```bash
+$ antlr4 -Dlanguage=JavaScript MyGrammar.g4
+```
+
+For a full list of antlr4 tool options, please visit the [tool documentation page](tool-options.md).
+
+## Where can I get the runtime?
+
+Once you've generated the lexer and/or parser code, you need to download the runtime.
+
+The JavaScript runtime is available from the ANTLR web site [download section](http://www.antlr.org/download/index.html). The runtime is provided in the form of source code, so no additional installation is required.
+
+We will not document here how to refer to the runtime from your project, since this would differ a lot depending on your project type and IDE.
+
+## How do I get the runtime in my browser?
+
+The runtime is quite big and is currently maintained in the form of around 50 scripts, which follow the same structure as the runtimes for other targets (Java, C#, Python...).
+
+This structure is key in keeping code maintainable and consistent across targets.
+
+However, it would be a bit of a problem when it comes to get it into a browser. Nobody wants to write 50 times:
+
+```
+<script src='lib/myscript.js'>
+```
+
+In order to avoid having to do this, and also to have the exact same code for browsers and Node.js, we rely on a script which provides the equivalent of the Node.js 'require' function.
+
+This script is provided by Torben Haase, and is NOT part of ANTLR JavaScript runtime, although the runtime heavily relies on it. Please note that syntax for 'require' in NodeJS is different from the one implemented by RequireJS and similar frameworks.
+
+So in short, assuming you have at the root of your web site, both the 'antlr4' directory and a 'lib' directory with 'require.js' inside it, all you need to put in your HTML header is the following:
+
+```xml
+<script src='lib/require.js'>
+<script>
+ var antlr4 = require('antlr4/index');
+ </script>
+```
+
+This will load the runtime asynchronously.
+
+## How do I get the runtime in Node.js?
+
+Right now, there is no npm package available, so you need to register a link instead. This can be done by running the following command from the antlr4 directory:
+
+```bash
+$ npm link antlr4
+```
+
+This will install antlr4 using the package.json descriptor that comes with the script.
+
+## How do I run the generated lexer and/or parser?
+
+Let's suppose that your grammar is named, as above, "MyGrammar". Let's suppose this parser comprises a rule named "StartRule". The tool will have generated for you the following files:
+
+* MyGrammarLexer.js
+* MyGrammarParser.js
+* MyGrammarListener.js (if you have not activated the -no-listener option)
+* MyGrammarVisitor.js (if you have activated the -visitor option)
+
+(Developers used to Java/C# ANTLR will notice that there is no base listener or visitor generated, this is because JavaScript having no support for interfaces, the generated listener and visitor are fully fledged classes)
+
+Now a fully functioning script might look like the following:
+
+```javascript
+ var input = "your text to parse here"
+ var chars = new antlr4.InputStream(input);
+ var lexer = new MyGrammarLexer.MyGrammarLexer(chars);
+ var tokens = new antlr4.CommonTokenStream(lexer);
+ var parser = new MyGrammarParser.MyGrammarParser(tokens);
+ parser.buildParseTrees = true;
+ var tree = parser.MyStartRule();
+```
+
+This program will work. But it won't be useful unless you do one of the following:
+
+* you visit the parse tree using a custom listener
+* you visit the parse tree using a custom visitor
+* your grammar comprises production code (like AntLR3)
+
+(please note that production code is target specific, so you can't have multi target grammars that include production code)
+
+## How do I create and run a custom listener?
+
+Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value". The antlr4 tool will have generated the following listener:
+
+```javascript
+ MyGrammarListener = function(ParseTreeListener) {
+ // some code here
+ }
+ // some code here
+ MyGrammarListener.prototype.enterKey = function(ctx) {};
+ MyGrammarListener.prototype.exitKey = function(ctx) {};
+ MyGrammarListener.prototype.enterValue = function(ctx) {};
+ MyGrammarListener.prototype.exitValue = function(ctx) {};
+```
+
+In order to provide custom behavior, you might want to create the following class:
+
+```javascript
+ KeyPrinter = function() {
+ MyGrammarListener.call(this); // inherit default listener
+ return this;
+ };
+
+// inherit default listener
+KeyPrinter.prototype = Object.create(MyGrammarListener.prototype);
+KeyPrinter.prototype.constructor = KeyPrinter;
+
+// override default listener behavior
+ KeyPrinter.prototype.exitKey = function(ctx) {
+ console.log("Oh, a key!");
+ };
+```
+
+In order to execute this listener, you would simply add the following lines to the above code:
+
+```javascript
+ ...
+ tree = parser.StartRule() - only repeated here for reference
+ var printer = new KeyPrinter();
+ antlr4.tree.ParseTreeWalker.DEFAULT.walk(printer, tree);
+```
+
+## How do I integrate my parser with ACE editor?
+
+This specific task is described in this [dedicated page](ace-javascript-target.md).
+
+## How can I learn more about ANTLR?
+
+
+Further information can be found from "The definitive ANTLR 4 reference" book.
+
+The JavaScript implementation of ANTLR is as close as possible to the Java one, so you shouldn't find it difficult to adapt the book's examples to JavaScript.
diff --git a/doc/left-recursion.md b/doc/left-recursion.md
new file mode 100644
index 0000000..3430e10
--- /dev/null
+++ b/doc/left-recursion.md
@@ -0,0 +1,50 @@
+# Left-recursive rules
+
+The most natural expression of some common language constructs is left recursive. For example C declarators and arithmetic expressions. Unfortunately, left recursive specifications of arithmetic expressions are typically ambiguous but much easier to write out than the multiple levels required in a typical top-down grammar. Here is a sample ANTLR 4 grammar with a left recursive expression rule:
+
+```
+stat: expr '=' expr ';' // e.g., x=y; or x=f(x);
+ | expr ';' // e.g., f(x); or f(g(x));
+ ;
+expr: expr '*' expr
+ | expr '+' expr
+ | expr '(' expr ')' // f(x)
+ | id
+ ;
+```
+
+In straight context free grammars, such a rule is ambiguous because `1+2*3` it can interpret either operator as occurring first, but ANTLR rewrites that to be non-left recursive and unambiguous using semantic predicates:
+
+```
+expr[int pr] : id
+ ( {4 >= $pr}? '*' expr[5]
+ | {3 >= $pr}? '+' expr[4]
+ | {2 >= $pr}? '(' expr[0] ')'
+ )*
+ ;
+```
+
+The predicates resolve ambiguities by comparing the precedence of the current operator against the precedence of the previous operator. An expansion of expr[pr] can match only those subexpressions whose precedence meets or exceeds pr.
+
+## Formal rules
+
+The formal 4.0, 4.1 ANTLR left-recursion elimination rules were changed (simplified) for 4.2 and are laid out in the [ALL(*) tech report](http://www.antlr.org/papers/allstar-techreport.pdf):
+
+* Binary expressions are expressions which contain a recursive invocation of the rule as the first and last element of the alternative.
+* Suffix expressions contain a recursive invocation of the rule as the first element of the alternative, but not as the last element.
+* Prefix expressions contain a recursive invocation of the rule as the last element of the alternative, but not as the first element.
+
+There is no such thing as a "ternary" expression--they are just binary expressions in disguise.
+
+The right associativity specifiers used to be on the individual tokens but it's done on alternative basis anyway so the option is now on the individual alternative; e.g.,
+
+```
+e : e '*' e
+ | e '+' e
+ |<assoc=right> e '?' e ':' e
+ |<assoc=right> e '=' e
+ | INT
+ ;
+```
+
+If your 4.0 or 4.1 grammar uses a right-associative ternary operator, you will need to update your grammar to include `<assoc=right>` on the alternative operator. To smooth the transition, `<assoc=right>` is still allowed on token references but it is ignored.
diff --git a/doc/lexer-rules.md b/doc/lexer-rules.md
new file mode 100644
index 0000000..adda9e8
--- /dev/null
+++ b/doc/lexer-rules.md
@@ -0,0 +1,283 @@
+# Lexer Rules
+
+A lexer grammar is composed of lexer rules, optionally broken into multiple modes. Lexical modes allow us to split a single lexer grammar into multiple sublexers. The lexer can only return tokens matched by rules from the current mode.
+
+Lexer rules specify token definitions and more or less follow the syntax of parser rules except that lexer rules cannot have arguments, return values, or local variables. Lexer rule names must begin with an uppercase letter, which distinguishes them from parser rule names:
+
+```
+/** Optional document comment */
+TokenName : alternative1 | ... | alternativeN ;
+```
+
+You can also define rules that are not tokens but rather aid in the recognition of tokens. These fragment rules do not result in tokens visible to the parser:
+
+```
+fragment
+HelperTokenRule : alternative1 | ... | alternativeN ;
+```
+
+For example, `DIGIT` is a pretty common fragment rule:
+
+```
+INT : DIGIT+ ; // references the DIGIT helper rule
+fragment DIGIT : [0-9] ; // not a token by itself
+```
+
+## Lexical Modes
+
+Modes allow you to group lexical rules by context, such as inside and outside of XML tags. It’s like having multiple sublexers, one for context. The lexer can only return tokens matched by entering a rule in the current mode. Lexers start out in the so-called default mode. All rules are considered to be within the default mode unless you specify a mode command. Modes are not allowed within combined grammars, just lexer grammars. (See grammar `XMLLexer` from [Tokenizing XML](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference).)
+
+```
+rules in default mode
+...
+mode MODE1;
+rules in MODE1
+...
+mode MODEN;
+rules in MODEN
+...
+```
+
+## Lexer Rule Elements
+
+Lexer rules allow two constructs that are unavailable to parser rules: the .. range operator and the character set notation enclosed in square brackets, [characters]. Don’t confuse character sets with arguments to parser rules. [characters] only means character set in a lexer. Here’s a summary of all lexer rule elements:
+
+<table>
+<tr>
+<th>Syntax</th><th>Description</th>
+</tr>
+<tr>
+<td>T</td><td>
+Match token T at the current input position. Tokens always begin with a capital letter.</td>
+</tr>
+
+<tr>
+<td>’literal’</td><td>
+Match that character or sequence of characters. E.g., ’while’ or ’=’.</td>
+</tr>
+
+<tr>
+<td>[char set]</td><td>
+Match one of the characters specified in the character set. Interpret x-y as set of characters between range x and y, inclusively. The following escaped characters are interpreted as single special characters: \n, \r, \b, \t, and \f. To get ], \, or - you must escape them with \. You can also use Unicode character specifications: \uXXXX. Here are a few examples:
+
+<pre>
+WS : [ \n\u000D] -> skip ; // same as [ \n\r]
+
+ID : [a-zA-Z] [a-zA-Z0-9]* ; // match usual identifier spec
+
+DASHBRACK : [\-\]]+ ; // match - or ] one or more times
+</pre>
+</td>
+</tr>
+
+<tr>
+<td>’x’..’y’</td><td>
+Match any single character between range x and y, inclusively. E.g., ’a’..’z’. ’a’..’z’ is identical to [a-z].</td>
+</tr>
+
+<tr>
+<td>T</td><td>
+Invoke lexer rule T; recursion is allowed in general, but not left recursion. T can be a regular token or fragment rule.
+
+<pre>
+ID : LETTER (LETTER|'0'..'9')* ;
+
+fragment
+LETTER : [a-zA-Z\u0080-\u00FF_] ;
+</pre>
+</td>
+</tr>
+
+<tr>
+<td>.</td><td>
+The dot is a single-character wildcard that matches any single character. Example:
+<pre>
+ESC : '\\' . ; // match any escaped \x character
+</pre>
+</td>
+</tr>
+
+<tr>
+<td>{«action»}</td><td>
+Lexer actions can appear anywhere as of 4.2, not just at the end of the outermost alternative. The lexer executes the actions at the appropriate input position, according to the placement of the action within the rule. To execute a single action for a role that has multiple alternatives, you can enclose the alts in parentheses and put the action afterwards:
+
+<pre>
+END : ('endif'|'end') {System.out.println("found an end");} ;
+</pre>
+
+<p>The action conforms to the syntax of the target language. ANTLR copies the action’s contents into the generated code verbatim; there is no translation of expressions like $x.y as there is in parser actions.</p>
+<p>
+Only actions within the outermost token rule are executed. In other words, if STRING calls ESC_CHAR and ESC_CHAR has an action, that action is not executed when the lexer starts matching in STRING.</p></td>
+</tr>
+
+<tr>
+<td>{«p»}?</td><td>
+Evaluate semantic predicate «p». If «p» evaluates to false at runtime, the surrounding rule becomes “invisible” (nonviable). Expression «p» conforms to the target language syntax. While semantic predicates can appear anywhere within a lexer rule, it is most efficient to have them at the end of the rule. The one caveat is that semantic predicates must precede lexer actions. See Predicates in Lexer Rules.</td>
+</tr>
+
+<tr>
+<td>~x</td><td>
+Match any single character not in the set described by x. Set x can be a single character literal, a range, or a subrule set like ~(’x’|’y’|’z’) or ~[xyz]. Here is a rule that uses ~ to match any character other than characters using ~[\r\n]*:
+<pre>
+COMMENT : '#' ~[\r\n]* '\r'? '\n' -> skip ;
+</pre>
+</td>
+</tr>
+</table>
+
+Just as with parser rules, lexer rules allow subrules in parentheses and EBNF operators: `?`, `*`, `+`. The `COMMENT` rule illustrates the `*` and `?` operators. A common use of `+` is `[0-9]+` to match integers. Lexer subrules can also use the nongreedy `?` suffix on those EBNF operators.
+
+## Recursive Lexer Rules
+
+ANTLR lexer rules can be recursive, unlike most lexical grammar tools. This comes in really handy when you want to match nested tokens like nested action blocks: `{...{...}...}`.
+
+```
+lexer grammar Recur;
+
+ACTION : '{' ( ACTION | ~[{}] )* '}' ;
+
+WS : [ \r\t\n]+ -> skip ;
+```
+
+## Redundant String Literals
+
+Be careful that you don’t specify the same string literal on the right-hand side of multiple lexer rules. Such literals are ambiguous and could match multiple token types. ANTLR makes this literal unavailable to the parser. The same is true for rules across modes. For example, the following lexer grammar defines two tokens with the same character sequence:
+
+```
+lexer grammar L;
+AND : '&' ;
+mode STR;
+MASK : '&' ;
+```
+
+A parser grammar cannot reference literal ’&’, but it can reference the name of the tokens:
+
+```
+parser grammar P;
+options { tokenVocab=L; }
+a : '&' // results in a tool error: no such token
+ AND // no problem
+ MASK // no problem
+ ;
+```
+
+Here’s a build and test sequence:
+
+```bash
+$ antlr4 L.g4 # yields L.tokens file needed by tokenVocab option in P.g4
+$ antlr4 P.g4
+error(126): P.g4:3:4: cannot create implicit token for string literal '&' in non-combined grammar
+```
+
+## Lexer Rule Actions
+
+An ANTLR lexer creates a Token object after matching a lexical rule. Each request for a token starts in `Lexer.nextToken`, which calls `emit` once it has identified a token. `emit` collects information from the current state of the lexer to build the token. It accesses fields `_type`, `_text`, `_channel`, `_tokenStartCharIndex`, `_tokenStartLine`, and `_tokenStartCharPositionInLine`. You can set the state of these with the various setter methods such as `setType`. For example, the following rule turns `enum` into an identifier if `enumIsKeyword` is false.
+
+```
+ENUM : 'enum' {if (!enumIsKeyword) setType(Identifier);} ;
+```
+
+ANTLR does no special `$x` attribute translations in lexer actions (unlike v3).
+
+There can be at most a single action for a lexical rule, regardless of how many alternatives there are in that rule.
+
+## Lexer Commands
+
+To avoid tying a grammar to a particular target language, ANTLR supports lexer commands. Unlike arbitrary embedded actions, these commands follow specific syntax and are limited to a few common commands. Lexer commands appear at the end of the outermost alternative of a lexer rule definition. Like arbitrary actions, there can only be one per token rule. A lexer command consists of the `->` operator followed by one or more command names that can optionally take parameters:
+
+```
+TokenName : «alternative» -> command-name
+TokenName : «alternative» -> command-name («identifier or integer»)
+```
+
+An alternative can have more than one command separated by commas. Here are the valid command names:
+
+* skip
+* more
+* popMode
+* mode( x )
+* pushMode( x )
+* type( x )
+* channel( x )
+
+See the book source code for usage, some examples of which are shown here:
+
+### skip
+
+A 'skip' command tells the lexer to get another token and throw out the current text.
+
+```
+ID : [a-zA-Z]+ ; // match identifiers
+INT : [0-9]+ ; // match integers
+NEWLINE:'\r'? '\n' ; // return newlines to parser (is end-statement signal)
+WS : [ \t]+ -> skip ; // toss out whitespace
+```
+
+### mode(), pushMode(), popMode, and more
+
+The mode commands alter the mode stack and hence the mode of the lexer. The 'more' command forces the lexer to get another token but without throwing out the current text. The token type will be that of the "final" rule matched (i.e., the one without a more or skip command).
+
+```
+// Default "mode": Everything OUTSIDE of a tag
+COMMENT : '<!--' .*? '-->' ;
+CDATA : '<![CDATA[' .*? ']]>' ;OPEN : '<' -> pushMode(INSIDE) ;
+ ...
+XMLDeclOpen : '<?xml' S -> pushMode(INSIDE) ;
+SPECIAL_OPEN: '<?' Name -> more, pushMode(PROC_INSTR) ;
+// ----------------- Everything INSIDE of a tag ---------------------
+mode INSIDE;
+CLOSE : '>' -> popMode ;
+SPECIAL_CLOSE: '?>' -> popMode ; // close <?xml...?>
+SLASH_CLOSE : '/>' -> popMode ;
+```
+
+Also check out:
+
+```
+lexer grammar Strings;
+LQUOTE : '"' -> more, mode(STR) ;
+WS : [ \r\t\n]+ -> skip ;
+mode STR;
+STRING : '"' -> mode(DEFAULT_MODE) ; // token we want parser to see
+TEXT : . -> more ; // collect more text for string
+```
+
+Popping the bottom layer of a mode stack will result in an exception. Switching modes with `mode` changes the current stack top. More than one `more` is the same as just one and the position does not matter.
+
+### type()
+
+```
+lexer grammar SetType;
+tokens { STRING }
+DOUBLE : '"' .*? '"' -> type(STRING) ;
+SINGLE : '\'' .*? '\'' -> type(STRING) ;
+WS : [ \r\t\n]+ -> skip ;
+```
+
+For multiple 'type()' commands, only the rightmost has an effect.
+
+### channel()
+
+```
+BLOCK_COMMENT
+ : '/*' .*? '*/' -> channel(HIDDEN)
+ ;
+LINE_COMMENT
+ : '//' ~[\r\n]* -> channel(HIDDEN)
+ ;
+...
+// ----------
+// Whitespace
+//
+// Characters and character constructs that are of no import
+// to the parser and are used to make the grammar easier to read
+// for humans.
+//
+WS : [ \t\r\n\f]+ -> channel(HIDDEN) ;
+```
+
+As of 4.5, you can also define channel names like enumerations with the following construct above the lexer rules:
+
+```
+channels { WSCHANNEL, MYHIDDEN }
+```
diff --git a/doc/lexicon.md b/doc/lexicon.md
new file mode 100644
index 0000000..804a745
--- /dev/null
+++ b/doc/lexicon.md
@@ -0,0 +1,110 @@
+# Grammar Lexicon
+
+The lexicon of ANTLR is familiar to most programmers because it follows the syntax of C and its derivatives with some extensions for grammatical descriptions.
+
+## Comments
+
+There are single-line, multiline, and Javadoc-style comments:
+
+```
+/** This grammar is an example illustrating the three kinds
+ * of comments.
+ */
+grammar T;
+/* a multi-line
+ comment
+*/
+
+/** This rule matches a declarator for my language */
+decl : ID ; // match a variable name
+```
+
+The Javadoc comments are hidden from the parser and are ignored at the moment. They are intended to be used only at the start of the grammar and any rule.
+
+## Identifiers
+
+Token names always start with a capital letter and so do lexer rules as defined by Java’s `Character.isUpperCase` method. Parser rule names always start with a lowercase letter (those that fail `Character.isUpperCase`). The initial character can be followed by uppercase and lowercase letters, digits, and underscores. Here are some sample names:
+
+```
+ID, LPAREN, RIGHT_CURLY // token names/rules
+expr, simpleDeclarator, d2, header_file // rule names
+```
+
+Like Java, ANTLR accepts Unicode characters in ANTLR names:
+
+<img src=images/nonascii.png width=100>
+
+To support Unicode parser and lexer rule names, ANTLR uses the following rule:
+
+```
+ID : a=NameStartChar NameChar*
+ {
+ if ( Character.isUpperCase(getText().charAt(0)) ) setType(TOKEN_REF);
+ else setType(RULE_REF);
+ }
+ ;
+```
+
+Rule `NameChar` identifies the valid identifier characters:
+
+```
+fragment
+NameChar
+ : NameStartChar
+ | '0'..'9'
+ | '_'
+ | '\u00B7'
+ | '\u0300'..'\u036F'
+ | '\u203F'..'\u2040'
+ ;
+fragment
+NameStartChar
+ : 'A'..'Z' | 'a'..'z'
+ | '\u00C0'..'\u00D6'
+ | '\u00D8'..'\u00F6'
+ | '\u00F8'..'\u02FF'
+ | '\u0370'..'\u037D'
+ | '\u037F'..'\u1FFF'
+ | '\u200C'..'\u200D'
+ | '\u2070'..'\u218F'
+ | '\u2C00'..'\u2FEF'
+ | '\u3001'..'\uD7FF'
+ | '\uF900'..'\uFDCF'
+ | '\uFDF0'..'\uFFFD'
+ ;
+```
+
+Rule `NameStartChar` is the list of characters that can start an identifier (rule, token, or label name):
+These more or less correspond to `isJavaIdentifierPart` and `isJavaIdentifierStart` in Java’s Character class. Make sure to use the `-encoding` option on the ANTLR tool if your grammar file is not in UTF-8 format, so that ANTLR reads characters properly.
+
+## Literals
+
+ANTLR does not distinguish between character and string literals as most languages do. All literal strings one or more characters in length are enclosed in single quotes such as `’;’`, `’if’`, `’>=’`, and `’\’'` (refers to the one-character string containing the single quote character). Literals never contain regular expressions.
+
+Literals can contain Unicode escape sequences of the form `\uXXXX`, where XXXX is the hexadecimal Unicode character value. For example, `’\u00E8’` is the French letter with a grave accent: `’è’`. ANTLR also understands the usual special escape sequences: `’\n’` (newline), `’\r’` (carriage return), `’\t’` (tab), `’\b’` (backspace), and `’\f’` (form feed). You can use Unicode characters directly within literals or use the Unicode escape sequences:
+
+```
+grammar Foreign;
+a : '外' ;
+```
+
+The recognizers that ANTLR generates assume a character vocabulary containing all Unicode characters. The input file encoding assumed by the runtime library depends on the target language. For the Java target, the runtime library assumes files are in UTF-8. Using the constructors, you can specify a different encoding. See, for example, ANTLR’s `ANTLRFileStream`.
+
+## Actions
+
+Actions are code blocks written in the target language. You can use actions in a number of places within a grammar, but the syntax is always the same: arbitrary text surrounded by curly braces. You don’t need to escape a closing curly character if it’s in a string or comment: `"}"` or `/*}*/`. If the curlies are balanced, you also don’t need to escape }: `{...}`. Otherwise, escape extra curlies with a backslash: `\{` or `\}`. The action text should conform to the target language as specified with thelanguage option.
+
+Embedded code can appear in: `@header` and `@members` named actions, parser and lexer rules, exception catching specifications, attribute sections for parser rules (return values, arguments, and locals), and some rule element options (currently predicates).
+
+The only interpretation ANTLR does inside actions relates to grammar attributes; see [Token Attributes](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference) and Chapter 10, [Attributes and Actions](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference). Actions embedded within lexer rules are emitted without any interpretation or translation into generated lexers.
+
+## Keywords
+
+Here’s a list of the reserved words in ANTLR grammars:
+
+```
+import, fragment, lexer, parser, grammar, returns,
+locals, throws, catch, finally, mode, options, tokens
+```
+
+Also, although it is not a keyword, do not use the word `rule` as a rule name. Further, do not use any keyword of the target language as a token, label, or rule name. For example, rule `if` would result in a generated function called `if`. That would not compile obviously.
diff --git a/doc/listeners.md b/doc/listeners.md
new file mode 100644
index 0000000..c3bcad9
--- /dev/null
+++ b/doc/listeners.md
@@ -0,0 +1,38 @@
+# Parse Tree Listeners
+
+*Partially taken from publically visible [excerpt from ANTLR 4 book](http://media.pragprog.com/titles/tpantlr2/picture.pdf)*
+
+By default, ANTLR-generated parsers build a data structure called a parse tree or syntax tree that records how the parser recognized the structure of the input sentence and component phrases.
+
+<img src=images/process.png>
+
+The interior nodes of the parse tree are phrase names that group and identify their children. The root node is the most abstract phrase name, in this case `stat` (short for statement). The leaves of a parse tree are always the input tokens. Parse trees sit between a language recognizer and an interpreter or translator implementation. They are extremely effective data structures because they contain all of the input and complete knowledge of how the parser grouped the symbols into phrases. Better yet, they are easy to understand and the parser generates them automatically (unless you turn them off with `parser.setBuildParseTree(false)`).
+
+Because we specify phrase structure with a set of rules, parse tree subtree roots correspond to grammar rule names. ANTLR has a ParseTreeWalker that knows how to walk these parse trees and trigger events in listener implementation objects that you can create. The ANTLR tool generates listener interfaces for you also, unless you turn that off with a commandline option. You can also have it generate visitors. For example from a Java.g4 grammar, ANTLR generates:
+
+```java
+public interface JavaListener extends ParseTreeListener<Token> {
+ void enterClassDeclaration(JavaParser.ClassDeclarationContext ctx);
+ void exitClassDeclaration(JavaParser.ClassDeclarationContext ctx);
+ void enterMethodDeclaration(JavaParser.MethodDeclarationContext ctx);
+ ...
+}
+```
+
+where there is an enter and exit method for each rule in the parser grammar. ANTLR also generates a base listener with the fall empty implementations of all listener interface methods, in this case called JavaBaseListener. You can build your listener by subclassing this base and overriding the methods of interest.
+
+Assuming you've created a listener object called `MyListener`, here is how to call the Java parser and walk the parse tree:
+
+```java
+JavaLexer lexer = new JavaLexer(input);
+CommonTokenStream tokens = new CommonTokenStream(lexer);
+JavaParser parser = new JavaParser(tokens);
+JavaParser.CompilationUnitContext tree = parser.compilationUnit(); // parse a compilationUnit
+
+MyListener extractor = new MyListener(parser);
+ParseTreeWalker.DEFAULT.walk(extractor, tree); // initiate walk of tree with listener in use of default walker
+```
+
+Listeners and visitors are great because they keep application-specific code out of grammars, making grammars easier to read and preventing them from getting entangled with a particular application.
+
+See the book for more information on listeners and to learn how to use visitors. (The biggest difference between the listener and visitor mechanisms is that listener methods are called independently by an ANTLR-provided walker object, whereas visitor methods must walk their children with explicit visit calls. Forgetting to invoke visitor methods on a node’s children, means those subtrees don’t get visited.)
diff --git a/doc/options.md b/doc/options.md
new file mode 100644
index 0000000..7ce2775
--- /dev/null
+++ b/doc/options.md
@@ -0,0 +1,101 @@
+# Options
+
+There are a number of options that you can specify at the grammar and rule element level. (There are currently no rule options.) These change how ANTLR generates code from your grammar. The general syntax is:
+
+```
+options { name1=value1; ... nameN=valueN; } // ANTLR not target language syntax
+```
+
+where a value can be an identifier, a qualified identifier (for example, a.b.c), a string, a multi-line string in curly braces `{...}`, and an integer.
+
+## Grammar Options
+
+All grammars can use the following options. In combined grammars, all options except language pertain only to the generated parser. Options may be set either within the grammar file using the options syntax (described above) or when invoking ANTLR on the command line, using the `-D` option. (see Section 15.9, [ANTLR Tool Command Line Options](tool-options.md).) The following examples demonstrate both mechanisms; note that `-D` overrides options within the grammar.
+
+* `superClass`. Set the superclass of the generated parser or lexer. For combined grammars, it sets the superclass of the parser.
+```
+$ cat Hi.g4
+grammar Hi;
+a : 'hi' ;
+$ antlr4 -DsuperClass=XX Hi.g4
+$ grep 'public class' HiParser.java
+public class HiParser extends XX {
+$ grep 'public class' HiLexer.java
+public class HiLexer extends Lexer {
+```
+* `language` Generate code in the indicated language, if ANTLR is able to do so. Otherwise, you will see an error message like this:
+```
+$ antlr4 -Dlanguage=C MyGrammar.g4
+error(31): ANTLR cannot generate C code as of version 4.0
+```
+* `tokenVocab` ANTLR assigns token type numbers to the tokens as it encounters them in a file. To use different token type values, such as with a separate lexer, use this option to have ANTLR pull in the <fileextension>tokens</fileextension> file. ANTLR generates a <fileextension>tokens</fileextension> file from each grammar.
+```
+$ cat SomeLexer.g4
+lexer grammar SomeLexer;
+ID : [a-z]+ ;
+$ cat R.g4
+parser grammar R;
+options {tokenVocab=SomeLexer;}
+tokens {A,B,C} // normally, these would be token types 1, 2, 3
+a : ID ;
+$ antlr4 SomeLexer.g4
+$ cat SomeLexer.tokens
+ID=1
+$ antlr4 R.g4
+$ cat R.tokens
+A=2
+B=3
+C=4
+ID=1
+```
+* `TokenLabelType` ANTLR normally uses type <class>Token</class> when it generates variables referencing tokens. If you have passed a <class>TokenFactory</class> to your parser and lexer so that they create custom tokens, you should set this option to your specific type. This ensures that the context objects know your type for fields and method return values.
+```
+$ cat T2.g4
+grammar T2;
+options {TokenLabelType=MyToken;}
+a : x=ID ;
+$ antlr4 T2.g4
+$ grep MyToken T2Parser.java
+ public MyToken x;
+```
+* `contextSuperClass`. Specify the super class of parse tree internal nodes. Default is `ParserRuleContext`. Should derive from ultimately `RuleContext` at minimum.
+Java target can use `contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum` for convenience. It adds a backing field for `altNumber`, the alt matched for the associated rule node.
+
+## Rule Options
+
+There are currently no valid rule-level options, but the tool still supports the following syntax for future use:
+
+```
+rulename
+options {...}
+ : ...
+ ;
+```
+
+## Rule Element Options
+
+Token options have the form `T<name=value>` as we saw in Section 5.4, [Dealing with Precedence, Left Recursion, and Associativity](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference). The only token option is `assoc`, and it accepts values `left` and `right`. Here’s a sample grammar with a left-recursive expression rule that specifies a token option on the `^` exponent operator token:
+
+```
+grammar ExprLR;
+
+expr : expr '^'<assoc=right> expr
+ | expr '*' expr // match subexpressions joined with '*' operator
+ | expr '+' expr // match subexpressions joined with '+' operator
+ | INT // matches simple integer atom
+ ;
+
+INT : '0'..'9'+ ;
+WS : [ \n]+ -> skip ;
+```
+
+Semantic predicates also accept an option, per [Catching failed semantic predicates](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference). The only valid option is the `fail` option, which takes either a string literal in double-quotes or an action that evaluates to a string. The string literal or string result from the action should be the message to emit upon predicate failure.
+
+```
+ints[int max]
+ locals [int i=1]
+ : INT ( ',' {$i++;} {$i<=$max}?<fail={"exceeded max "+$max}> INT )*
+ ;
+```
+
+The action can execute a function as well as compute a string when a predicate fails: `{...}?<fail={doSomethingAndReturnAString()}>`
diff --git a/doc/parser-rules.md b/doc/parser-rules.md
new file mode 100644
index 0000000..73c363b
--- /dev/null
+++ b/doc/parser-rules.md
@@ -0,0 +1,489 @@
+# Parser Rules
+
+Parsers consist of a set of parser rules either in a parser or a combined grammar. A Java application launches a parser by invoking the rule function, generated by ANTLR, associated with the desired start rule. The most basic rule is just a rule name followed by a single alternative terminated with a semicolon:
+
+```
+ /** Javadoc comment can precede rule */
+ retstat : 'return' expr ';' ;
+```
+
+Rules can also have alternatives separated by the |
+
+```
+operator:
+ stat: retstat
+ | 'break' ';'
+ | 'continue' ';'
+ ;
+```
+
+Alternatives are either a list of rule elements or empty. For example, here’s a rule with an empty alternative that makes the entire rule optional:
+
+```
+superClass
+ : 'extends' ID
+ | // empty means other alternative(s) are optional
+ ;
+```
+
+## Alternative Labels
+
+As we saw in Section 7.4, Labeling Rule Alternatives for Precise Event Methods, we can get more precise parse-tree listener events by labeling the outermost alternatives of a rule using the # operator. All alternatives within a rule must be labeled, or none of them. Here are two rules with labeled alternatives.
+
+```
+grammar T;
+stat: 'return' e ';' # Return
+ | 'break' ';' # Break
+ ;
+e : e '*' e # Mult
+ | e '+' e # Add
+ | INT # Int
+ ;
+```
+
+Alternative labels do not have to be at the end of the line and there does not have to be a space after the # symbol.
+ANTLR generates a rule context class definition for each label. For example, here is the listener that ANTLR generates:
+
+```java
+public interface AListener extends ParseTreeListener {
+ void enterReturn(AParser.ReturnContext ctx);
+ void exitReturn(AParser.ReturnContext ctx);
+ void enterBreak(AParser.BreakContext ctx);
+ void exitBreak(AParser.BreakContext ctx);
+ void enterMult(AParser.MultContext ctx);
+ void exitMult(AParser.MultContext ctx);
+ void enterAdd(AParser.AddContext ctx);
+ void exitAdd(AParser.AddContext ctx);
+ void enterInt(AParser.IntContext ctx);
+ void exitInt(AParser.IntContext ctx);
+}
+```
+
+There are enter and exit methods associated with each labeled alternative. The parameters to those methods are specific to alternatives.
+
+You can reuse the same label on multiple alternatives to indicate that the parse tree walker should trigger the same event for those alternatives. For example, here’s a variation on rule e from grammar A above:
+
+```
+ e : e '*' e # BinaryOp
+ | e '+' e # BinaryOp
+ | INT # Int
+ ;
+```
+
+ANTLR would generate the following listener methods for e:
+
+```java
+ void enterBinaryOp(AParser.BinaryOpContext ctx);
+ void exitBinaryOp(AParser.BinaryOpContext ctx);
+ void enterInt(AParser.IntContext ctx);
+ void exitInt(AParser.IntContext ctx);
+ ```
+
+ANTLR gives errors if an alternative name conflicts with a rule name. Here’s another rewrite of rule e where two
+alternative labels conflict with rule names:
+
+```
+ e : e '*' e # e
+ | e '+' e # Stat
+ | INT # Int
+ ;
+```
+
+The context objects generated from rule names and labels get capitalized and so label Stat conflicts with rule stat:
+
+```bash
+ $ antlr4 A.g4
+ error(124): A.g4:5:23: rule alt label e conflicts with rule e
+ error(124): A.g4:6:23: rule alt label Stat conflicts with rule stat
+ warning(125): A.g4:2:13: implicit definition of token INT in parser
+```
+
+## Rule Context Objects
+
+ANTLR generates methods to access the rule context objects (parse tree nodes) associated with each rule reference. For rules with a single rule reference, ANTLR generates a method with no arguments. Consider the following rule.
+
+```
+ inc : e '++' ;
+```
+
+ANTLR generates this context class:
+
+```java
+public static class IncContext extends ParserRuleContext {
+ public EContext e() { ... } // return context object associated with e
+ ...
+}
+```
+
+ANTLR also provide support to access context objects when there is more than a single reference to a rule:
+
+```
+field : e '.' e ;
+```
+
+ANTLR generates a method with an index to access the ith element as well as a method to get context for all references to that rule:
+
+```java
+public static class FieldContext extends ParserRuleContext {
+ public EContext e(int i) { ... } // get ith e context
+ public List<EContext> e() { ... } // return ALL e contexts
+ ...
+}
+```
+
+If we had another rule, s, that references field, an embedded action could access the list of e rule matches performed by field:
+
+```
+s : field
+ {
+ List<EContext> x = $field.ctx.e();
+ ...
+ }
+;
+```
+
+A listener or visitor could do the same thing. Given a pointer to a FieldContext object, f, f.e() would return List<EContext>.
+
+## Rule Element Labels
+
+You can label rule elements using the = operator to add fields to the rule context objects:
+
+```
+stat: 'return' value=e ';' # Return
+ | 'break' ';' # Break
+ ;
+```
+
+Here value is the label for the return value of rule e, which is defined elsewhere.
+Labels become fields in the appropriate parse tree node class. In this case, label value becomes a field in ReturnContext because of the Return alternative label:
+
+```java
+public static class ReturnContext extends StatContext {
+ public EContext value;
+ ...
+}
+```
+
+It’s often handy to track a number of tokens, which you can do with the += “list label” operator. For example, the following rule creates a list of the Token objects matched for a simple array construct:
+
+```
+ array : '{' el+=INT (',' el+=INT)* '}' ;
+```
+
+ANTLR generates a List field in the appropriate rule context class:
+
+```
+ public static class ArrayContext extends ParserRuleContext {
+ public List<Token> el = new ArrayList<Token>();
+ ...
+ }
+```
+
+These list labels also work for rule references:
+
+```
+ elist : exprs+=e (',' exprs+=e)* ;
+```
+
+ANTLR generates a field holding the list of context objects:
+
+```
+ public static class ElistContext extends ParserRuleContext {
+ public List<EContext> exprs = new ArrayList<EContext>();
+ ...
+ }
+```
+
+## Rule Elements
+
+Rule elements specify what the parser should do at a given moment just like statements in a programming language. The elements can be rule, token, string literal like expression, ID, and ’return’. Here’s a complete list of the rule elements (we’ll look at actions and predicates in more detail later):
+
+<table>
+<tr>
+<th>Syntax</th><th>Description</th>
+</tr>
+<tr>
+<td>T</td><td>
+Match token T at the current input position. Tokens always begin with a capital letter.</td>
+</tr>
+<tr>
+<td>’literal’</td><td>
+Match the string literal at the current input position. A string literal is simply a token with a fixed string.</td>
+</tr>
+<tr>
+<td>r</td><td>
+Match rule r at current input position, which amounts to invoking the rule just like a function call. Parser rule names always begin with a lowercase letter.</td>
+</tr>
+<tr>
+<td>r [«args»]</td><td>
+Match rule r at current input position, passing in a list of arguments just like a function call. The arguments inside the square brackets are in the syntax of the target language and are usually a comma-separated list of expressions.</td>
+</tr>
+<tr>
+<td>{«action»}</td><td>
+Execute an action immediately after the preceding alternative element and immediately before the following alternative element. The action conforms to the syntax of the target language. ANTLR copies the action code to the generated class verbatim, except for substituting attribute and token references such as $x and $x.y.</td>
+</tr>
+<tr>
+<td>{«p»}?</td><td>
+Evaluate semantic predicate «p». Do not continue parsing past a predicate if «p» evaluates to false at runtime. Predicates encountered during prediction, when ANTLR distinguishes between alternatives, enable or disable the alternative(s) surrounding the predicate(s).</td>
+</tr>
+<tr>
+<td>.</td><td>
+Match any single token except for the end of file token. The “dot” operator is called the wildcard.</td>
+</tr>
+</table>
+
+When you want to match everything but a particular token or set of tokens, use the `~` “not” operator. This operator is rarely used in the parser but is available. `~INT` matches any token except the `INT` token. `~’,’` matches any token except the comma. `~(INT|ID)` matches any token except an INT or an ID.
+
+Token, string literal, and semantic predicate rule elements can take options. See Rule Element Options.
+
+## Subrules
+
+A rule can contain alternative blocks called subrules (as allowed in Extended BNF Notation: EBNF). A subrule is like a rule that lacks a name and is enclosed in parentheses. Subrules can have one or more alternatives inside the parentheses. Subrules cannot define attributes with locals and returns like rules can. There are four kinds of subrules (x, y, and z represent grammar fragments):
+
+<table>
+<tr>
+<th>Syntax</th><th>Description</th>
+</tr>
+<tr>
+<td><img src=images/xyz.png></td><td>(x|y|z).
+Match any alternative within the subrule exactly once. Example:
+<br>
+<tt>
+returnType : (type | 'void') ;
+</tt>
+</td>
+</tr>
+<tr>
+<td><img src=images/xyz_opt.png></td><td>(x|y|z)?
+Match nothing or any alternative within subrule. Example:
+<br>
+<tt>
+classDeclaration
+ : 'class' ID (typeParameters)? ('extends' type)?
+ ('implements' typeList)?
+ classBody
+ ;
+</tt>
+<tr>
+<td><img src=images/xyz_star.png></td><td>(x|y|z)*
+Match an alternative within subrule zero or more times. Example:
+<br>
+<tt>
+annotationName : ID ('.' ID)* ;
+</tt>
+</tr>
+<tr>
+<td><img src=images/xyz_plus.png></td><td>(x|y|z)+
+Match an alternative within subrule one or more times. Example:
+<br>
+<tt>
+annotations : (annotation)+ ;
+</tt>
+</td>
+</tr>
+</table>
+
+You can suffix the `?`, `*`, and `+` subrule operators with the nongreedy operator, which is also a question mark: `??`, `*?`, and `+?`. See Section 15.6, Wildcard Operator and Nongreedy Subrules.
+
+As a shorthand, you can omit the parentheses for subrules composed of a single alternative with a single rule element reference. For example, `annotation+` is the same as `(annotation)+` and `ID+` is the same as `(ID)+`. Labels also work with the shorthand. `ids+=INT+` make a list of `INT` token objects.
+
+## Catching Exceptions
+
+When a syntax error occurs within a rule, ANTLR catches the exception, reports the error, attempts to recover (possibly by consuming more tokens), and then returns from the rule. Every rule is wrapped in a `try/catch/finally` statement:
+
+```
+void r() throws RecognitionException {
+ try {
+ rule-body
+ }
+ catch (RecognitionException re) {
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+}
+```
+
+In Section 9.5, Altering ANTLR’s Error Handling Strategy, we saw how to use a strategy object to alter ANTLR’s error handling. Replacing the strategy changes the strategy for all rules, however. To alter the exception handling for a single rule, specify an exception after the rule definition:
+
+```
+r : ...
+ ;
+ catch[RecognitionException e] { throw e; }
+```
+
+That example shows how to avoid default error reporting and recovery. r rethrows the exception, which is useful when it makes more sense for a higher-level rule to report the error. Specifying any exception clause, prevents ANTLR from generating a clause to handle `RecognitionException`.
+
+You can specify other exceptions as well:
+
+```
+r : ...
+ ;
+ catch[FailedPredicateException fpe] { ... }
+ catch[RecognitionException e] { ... }
+```
+
+The code snippets inside curly braces and the exception “argument” actions must be written in the target language; Java, in this case.
+When you need to execute an action even if an exception occurs, put it into the `finally` clause:
+
+```
+r : ...
+ ;
+ // catch blocks go first
+ finally { System.out.println("exit rule r"); }
+```
+
+The finally clause executes right before the rule triggers `exitRule` before returning. If you want to execute an action after the rule finishes matching the alternatives but before it does its cleanup work, use an `after` action.
+
+Here’s a complete list of exceptions:
+
+<table>
+<tr>
+<th>Exception name</th><th>Description</th>
+</tr>
+<tr>
+<td>RecognitionException</td><td>
+The superclass of all exceptions thrown by an ANTLR-generated recognizer. It’s a subclass of RuntimeException to avoid the hassles of checked exceptions. This exception records where the recognizer (lexer or parser) was in the input, where it was in the ATN (internal graph data structure representing the grammar), the rule invocation stack, and what kind of problem occurred.</td>
+</tr>
+<tr>
+<td>NoViableAltException</td><td>
+Indicates that the parser could not decide which of two or more paths to take by looking at the remaining input. This exception tracks the starting token of the offending input and also knows where the parser was in the various paths when the error occurred.</td>
+</tr>
+<tr>
+<td>LexerNoViableAltException</td><td>
+The equivalent of NoViableAltException but for lexers only.</td>
+</tr>
+<tr>
+<td>InputMismatchException</td><td>
+The current input Token does not match what the parser expected.</td>
+</tr>
+<tr>
+<td>FailedPredicateException</td><td>
+A semantic predicate that evaluates to false during prediction renders the surrounding alternative nonviable. Prediction occurs when a rule is predicting which alternative to take. If all viable paths disappear, parser will throw NoViableAltException. This predicate gets thrown by the parser when a semantic predicate evaluates to false outside of prediction, during the normal parsing process of matching tokens and calling rules.</td>
+</tr>
+</table>
+
+## Rule Attribute Definitions
+
+There are a number of action-related syntax elements associated with rules to be aware of. Rules can have arguments, return values, and local variables just like functions in a programming language. (Rules can have actions embedded among the rule elements, as we’ll see in Section 15.4, Actions and Attributes.) ANTLR collects all of the variables you define and stores them in the rule context object. These variables are usually called attributes. Here’s the general syntax showing all possible attribute definition locations:
+
+```
+rulename[args] returns [retvals] locals [localvars] : ... ;
+```
+
+The attributes defined within those [...] can be used like any other variable. Here is a sample rule that copies parameters to return values:
+
+```
+// Return the argument plus the integer value of the INT token
+add[int x] returns [int result] : '+=' INT {$result = $x + $INT.int;} ;
+```
+
+The args, locals, and return `[...]` are generally in the target language but with some constraints. The `[...]` string is a comma-separated list of declarations either with prefix or postfix type notation or no-type notation. The elements can have initializer such as `[int x = 32, float y]` but don't go too crazy as we are parsing this generic text manually in [ScopeParser](https://github.com/antlr/antlr4/blob/master/tool/src/org/antlr/v4/parse/ScopeParser.java).
+
+* Java, CSharp, C++ use `int x` notation but C++ must use a slightly altered notation for array references, `int[] x`, to fit in the *type* *id* syntax.
+* Go and Swift give the type after the variable name, but Swift requires a `:` in between. Go `i int`, Swift `i:int`. For Go target, you must either use `int i` or `i:int`.
+* Python and JavaScript don't specify static types so actions are just identifier lists such as `[i,j]`.
+
+Technically any target could use either notation. For examples, see [TestScopeParsing](https://github.com/antlr/antlr4/blob/master/tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java).
+
+As with the grammar level, you can specify rule-level named actions. For rules, the valid names are `init` and `after`. As the names imply, parsers execute init actions immediately before trying to match the associated rule and execute after actions immediately after matching the rule. ANTLR after actions do not execute as part of the finally code block of the generated rule function. Use the ANTLR finally action to place code in the generated rule function finally code block.
+
+The actions come after any argument, return value, or local attribute definition actions. The `row` rule preamble from Section 10.2, Accessing Token and Rule Attributes illustrates the syntax nicely:
+actions/CSV.g4
+
+```
+/** Derived from rule "row : field (',' field)* '\r'? '\n' ;" */
+row[String[] columns]
+ returns [Map<String,String> values]
+ locals [int col=0]
+ @init {
+ $values = new HashMap<String,String>();
+ }
+ @after {
+ if ($values!=null && $values.size()>0) {
+ System.out.println("values = "+$values);
+ }
+ }
+ : ...
+ ;
+```
+
+Rule row takes argument columns, returns values, and defines local variable col. The “actions” in square brackets are copied directly into the generated code:
+
+```java
+public class CSVParser extends Parser {
+ ...
+ public static class RowContext extends ParserRuleContext {
+ public String [] columns;
+ public Map<String,String> values;
+ public int col=0;
+ ...
+ }
+ ...
+}
+```
+
+The generated rule functions also specify the rule arguments as function arguments, but they are quickly copied into the local RowContext object:
+
+```java
+public class CSVParser extends Parser {
+ ...
+ public final RowContext row(String [] columns) throws RecognitionException {
+ RowContext _localctx = new RowContext(_ctx, 4, columns);
+ enterRule(_localctx, RULE_row);
+ ...
+ }
+ ...
+}
+```
+
+ANTLR tracks nested `[...]` within the action so that `String[]` columns is parsed properly. It also tracks angle brackets so that commas within generic type parameters do not signify the start of another attribute. `Map<String,String>` values is one attribute definition.
+
+There can be multiple attributes in each action, even for return values. Use a comma to separate attributes within the same action:
+
+```
+a[Map<String,String> x, int y] : ... ;
+```
+
+ANTLR interprets that action to define two arguments, x and y:
+
+```java
+public final AContext a(Map<String,String> x, int y)
+ throws RecognitionException
+{
+ AContext _localctx = new AContext(_ctx, 0, x, y);
+ enterRule(_localctx, RULE_a);
+ ...
+}
+```
+
+## Start Rules and EOF
+
+A start rule is the rule engaged first by the parser; it’s the rule function called by the language application. For example, a language application that parsed to Java code might call `parser.compilationUnit()` for a `JavaParser` object called `parser`. Any rule in the grammar can act as a start rule.
+
+Start rules don’t necessarily consume all of the input. They consume only as much input as needed to match an alternative of the rule. For example, consider the following rule that matches one, two, or three tokens, depending on the input.
+
+```
+s : ID
+ | ID '+'
+ | ID '+' INT
+ ;
+```
+
+Upon `a+3`, rule `s` matches the third alternative. Upon `a+b`, it matches the second alternative and ignores the final `b` token. Upon `a b`, it matches the first alternative, ignoring the `b` token. The parser does not consume the complete input in the latter two cases because rule `s` doesn’t explicitly say that end of file must occur after matching an alternative of the rule.
+
+This default functionality is very useful for building things like IDEs. Imagine the IDE wanting to parse a method somewhere in the middle of a big Java file. Calling rule `methodDeclaration` should try to match just a method and ignore whatever comes next.
+
+On the other hand, rules that describe entire input files should reference special predefined-token `EOF`. If they don’t, you might scratch your head for a while wondering why the start rule doesn’t report errors for any input no matter what you give it. Here’s a rule that’s part of a grammar for reading configuration files:
+
+```
+config : element*; // can "match" even with invalid input.
+```
+
+Invalid input would cause `config` to return immediately without matching any input and without reporting an error. Here’s the proper specification:
+
+```
+file : element* EOF; // don't stop early. must match all input
+``` \ No newline at end of file
diff --git a/doc/parsing-binary-files.md b/doc/parsing-binary-files.md
new file mode 100644
index 0000000..0014691
--- /dev/null
+++ b/doc/parsing-binary-files.md
@@ -0,0 +1,182 @@
+# Parsing Binary Files
+
+Parsing binary files is no different than parsing character-based files except that the "characters" are actually bytes not 16-bit unsigned short unicode characters. From a lexer/parser point of view, there is no difference except that the characters are likely not printable. If you want to match a special 2-byte marker 0xCA then 0xFE, the following rule is sufficient.
+
+```
+MARKER : '\u00CA' '\u00FE' ;
+```
+
+The parser of course would refer to that token like any other token.
+
+Here is a sample grammar for use with the code snippets below.
+
+```
+grammar IP;
+
+file : ip+ (MARKER ip)* ;
+
+ip : BYTE '.' BYTE '.' BYTE '.' BYTE ;
+
+MARKER : '\u00CA' '\u00FE' ;
+BYTE : '\u0000'..'\u00FF' ;
+```
+
+Notice that `BYTE` is using a range operator to match anything between 0 and 255. We can't use character classes like `[a-z]` naturally because we are not parsing character codes. All character specifiers must have `00` as their upper byte. E.g., `\uCAFE` is not a valid character because that 16-bit value will never be created from the input stream (bytes only remember).
+
+If there are actual characters like `$` or `!` encoded as bytes in the binary file, you can refer to them via literals like `'$'` as you normally would. See `'.'` in the grammar.
+
+## Binary streams
+
+There are many targets now so I'm not sure exactly how they process text files but most targets will pull in text per the machine's locale. Much of the time this will mean UTF-8 encoding of text converted to 16-bit Unicode. ANTLR's lexers operate on `int` so we can handle any kind of character you want to send in that fits in `int`.
+
+Once the lexer gets an input stream, it doesn't care whether the characters come from / represent bytes or actual Unicode characters.
+
+Let's get a binary file called `ips` and put it in our resources directory:
+
+```java
+public class WriteBinaryFile {
+ public static final byte[] bytes = {
+ (byte)172, 0, 0, 1, (byte)0xCA, (byte)0xFE,
+ (byte)10, 10, 10, 1, (byte)0xCA, (byte)0xFE,
+ (byte)10, 10, 10, 99
+ };
+
+ public static void main(String[] args) throws IOException {
+ Files.write(new File("resources/ips").toPath(), bytes);
+ }
+}
+```
+
+Now we need to create a stream of bytes satisfactory to ANTLR, which is as simple as:
+
+```java
+ANTLRFileStream bytesAsChar = new ANTLRFileStream("resources/ips", "ISO-8859-1");
+```
+
+The `ISO-8859-1` encoding is just the 8-bit char encoding for LATIN-1, which effectively tells the stream to treat each byte as a character. That's what we want. Then we have the usual test rig:
+
+
+```java
+ANTLRFileStream bytesAsChar = new ANTLRFileStream("resources/ips", "ISO-8859-1");
+IPLexer lexer = new IPLexer(bytesAsChar);
+CommonTokenStream tokens = new CommonTokenStream(lexer);
+IPParser parser = new IPParser(tokens);
+ParseTree tree = parser.file();
+IPBaseListener listener = new MyIPListener();
+ParseTreeWalker.DEFAULT.walk(listener, tree);
+```
+
+Here is the listener:
+
+```java
+class MyIPListener extends IPBaseListener {
+ @Override
+ public void exitIp(IPParser.IpContext ctx) {
+ List<TerminalNode> octets = ctx.BYTE();
+ short[] ip = new short[4];
+ for (int i = 0; i<octets.size(); i++) {
+ String oneCharStringHoldingOctet = octets.get(i).getText();
+ ip[i] = (short)oneCharStringHoldingOctet.charAt(0);
+ }
+ System.out.println(Arrays.toString(ip));
+ }
+}
+```
+
+We can't just print out the text because we are not reading in text. We need to emit each byte as a decimal value. The output should be the following when you run the test code:
+
+```
+[172, 0, 0, 1]
+[10, 10, 10, 1]
+[10, 10, 10, 99]
+```
+
+## Custom stream
+
+If you want to play around with the stream, you can. Here's an example that alters how "text" is computed from the byte stream (which changes how tokens print out their text as well):
+
+```java
+/** make a stream treating file as full of single unsigned byte characters */
+class BinaryANTLRFileStream extends ANTLRFileStream {
+ public BinaryANTLRFileStream(String fileName) throws IOException {
+ super(fileName, "ISO-8859-1");
+ }
+
+ /** Print the decimal value rather than treat as char */
+ @Override
+ public String getText(Interval interval) {
+ StringBuilder buf = new StringBuilder();
+ int start = interval.a;
+ int stop = interval.b;
+ if(stop >= this.n) {
+ stop = this.n - 1;
+ }
+
+ for (int i = start; i<=stop; i++) {
+ int v = data[i];
+ buf.append(v);
+ }
+ return buf.toString();
+ }
+}
+```
+
+The new test code starts out like this:
+
+```java
+ANTLRFileStream bytesAsChar = new BinaryANTLRFileStream("resources/ips");
+IPLexer lexer = new IPLexer(bytesAsChar);
+...
+```
+
+This simplifies our listener then:
+
+```java
+class MyIPListenerCustomStream extends IPBaseListener {
+ @Override
+ public void exitIp(IPParser.IpContext ctx) {
+ List<TerminalNode> octets = ctx.BYTE();
+ System.out.println(octets);
+ }
+}
+```
+
+You should get this enhanced output:
+
+```
+[172(0xAC), 0(0x0), 0(0x0), 1(0x1)]
+[10(0xA), 10(0xA), 10(0xA), 1(0x1)]
+[10(0xA), 10(0xA), 10(0xA), 99(0x63)]
+```
+
+## Error handling in binary files
+
+Error handling proceeds exactly like any other parser. For example, let's alter the binary file so that it is missing one of the 0's in the first IP address:
+
+```java
+public static final byte[] bytes = {
+ (byte)172, '.', 0, '.', '.', 1, (byte)0xCA, (byte)0xFE, // OOOPS
+ (byte)10, '.', 10, '.', 10, '.', 1, (byte)0xCA, (byte)0xFE,
+ (byte)10, '.', 10, '.', 10, '.', 99
+};
+```
+
+Running the original test case gives us:
+
+```
+line 1:4 extraneous input '.' expecting BYTE
+line 1:6 mismatched input 'Êþ' expecting '.'
+[172, 0, 1, 0]
+[10, 10, 10, 1]
+[10, 10, 10, 99]
+```
+
+That `'Êþ'` is just to the character representation of two bytes 0xCA and 0xFE. Using the enhanced binary stream, we see:
+
+```
+line 1:4 extraneous input '46(0x2E)' expecting BYTE
+line 1:6 mismatched input '202(0xCA)254(0xFE)' expecting '.'
+[172(0xAC), 0(0x0), 1(0x1)]
+[10(0xA), 10(0xA), 10(0xA), 1(0x1)]
+[10(0xA), 10(0xA), 10(0xA), 99(0x63)]
+``` \ No newline at end of file
diff --git a/doc/predicates.md b/doc/predicates.md
new file mode 100644
index 0000000..09998c4
--- /dev/null
+++ b/doc/predicates.md
@@ -0,0 +1,164 @@
+# Semantic Predicates
+
+Semantic predicates, `{...}?`, are boolean expressions written in the target language that indicate the validity of continuing the parse along the path "guarded" by the predicate. Predicates can appear anywhere within a parser rule just like actions can, but only those appearing on the left edge of alternatives can affect prediction (choosing between alternatives). This section provides all of the fine print regarding the use of semantic predicates in parser and lexer rules. Let's start out by digging deeper into how the parser incorporates predicates into parsing decisions.
+
+## Making Predicated Parsing Decisions
+
+ANTLR's general decision-making strategy is to find all viable alternatives and then ignore the alternatives guarded with predicates that currently evaluate to false. (A viable alternative is one that matches the current input.) If more than one viable alternative remains, the parser chooses the alternative specified first in the decision.
+
+Consider a variant of C++ where array references also use parentheses instead of square brackets. If we only predicate one of the alternatives, we still have an ambiguous decision in expr:
+
+```
+expr: ID '(' expr ')' // array reference (ANTLR picks this one)
+ | {istype()}? ID '(' expr ')' // ctor-style typecast
+ | ID '(' expr ')' // function call
+ ;
+```
+
+In this case, all three alternatives are viable for input `x(i)`. When `x` is not a type name, the predicate evaluates to false, leaving only the first and third alternatives as possible matches for expr. ANTLR automatically chooses the first alternative matching the array reference to resolve the ambiguity. Leaving ANTLR with more than one viable alternative because of too few predicates is probably not a good idea. It's best to cover n viable alternatives with at least n-1 predicates. In other words, don't build rules like expr with too few predicates.
+
+Sometimes, the parser finds multiple visible predicates associated with a single choice. No worries. ANTLR just combines the predicates with appropriate logical operators to conjure up a single meta-predicate on-the-fly.
+
+For example, the decision in rule `stat` joins the predicates from both alternatives of expr with the `||` operator to guard the second stat alternative:
+
+```
+stat: decl | expr ;
+decl: ID ID ;
+expr: {istype()}? ID '(' expr ')' // ctor-style typecast
+ | {isfunc()}? ID '(' expr ')' // function call
+ ;
+```
+
+The parser will only predict an expr from stat when `istype()||isfunc()` evaluates to true. This makes sense because the parser should only choose to match an expression if the upcoming `ID` is a type name or function name. It wouldn't make sense to just test one of the predicates in this case. Note that, when the parser gets to `expr` itself, the parsing decision tests the predicates individually, one for each alternative.
+
+If multiple predicates occur in a sequence, the parser joins them with the `&&` operator. For example, consider changing `stat` to include a predicate before the call `toexpr`:
+
+```
+stat: decl | {java5}? expr ;
+```
+
+Now, the parser would only predict the second alternative if `java5&&(istype()||isfunc())` evaluated to true.
+
+Turning to the code inside the predicates themselves now, keep in mind the following guidelines.
+
+Even when the parser isn't making decisions, predicates can deactivate alternatives, causing rules to fail. This happens when a rule only has a single alternative. There is no choice to make, but ANTLR evaluates the predicate as part of the normal parsing process, just like it does for actions. That means that the following rule always fails to match.
+
+```
+prog: {false}? 'return' INT ; // throws FailedPredicateException
+```
+
+ANTLR converts `{false}?` in the grammar to a conditional in the generated parser:
+
+```
+if ( !false ) throw new FailedPredicateException(...);
+```
+
+So far, all of the predicates we've seen have been visible and available to the prediction process, but that's not always the case.
+
+## Finding Visible Predicates
+
+The parser will not evaluate predicates during prediction that occur after an action or token reference. Let's think about the relationship between actions and predicates first.
+
+ANTLR has no idea what's inside the raw code of an action and so it must assume any predicate could depend on side effects of that action. Imagine an action that computed value `x` and a predicate that tested `x`. Evaluating that predicate before the action executed to create `x` would violate the implied order of operations within the grammar.
+
+More importantly, the parser can't execute actions until it has decided which alternative to match. That's because actions have side effects and we can't undo things like print statements. For example, in the following rule, the parser can't execute the action in front of the `{java5}?` predicate before committing to that alternative.
+
+```
+@members {boolean allowgoto=false;}
+stat: {System.out.println("goto"); allowgoto=true;} {java5}? 'goto' ID ';'
+ | ...
+ ;
+```
+
+If we can't execute the action during prediction, we shouldn't evaluate the `{java5}?` predicate because it depends on that action.
+
+The prediction process also can't see through token references. Token references have the side effect of advancing the input one symbol. A predicate that tested the current input symbol would find itself out of sync if the parser shifted it over the token reference. For example, in the following grammar, the predicates expect `getCurrentToken` to return an `ID` token.
+
+```
+stat: '{' decl '}'
+ | '{' stat '}'
+ ;
+decl: {istype(getCurrentToken().getText())}? ID ID ';' ;
+expr: {isvar(getCurrentToken().getText())}? ID ;
+```
+
+The decision in stat can't test those predicates because, at the start of stat, the current token is a left curly. To preserve the semantics, ANTLR won't test the predicates in that decision.
+
+Visible predicates are those that prediction encounters before encountering an action or token. The prediction process ignores nonvisible predicates, treating them as if they don't exist.
+
+In rare cases, the parser won't be able to use a predicate, even if it's visible to a particular decision. That brings us to our next fine print topic.
+
+## Using Context-Dependent Predicates
+
+A predicate that depends on a parameter or local variable of the surrounding rule, is considered a context-dependent predicate. Clearly, we can only evaluate such predicates within the rules in which they're defined. For example, it makes no sense for the decision in prog below to test context-dependent predicate `{$i<=5}?`. That `$i` local variable is not even defined in `prog`.
+
+```
+prog: vec5
+ | ...
+ ;
+vec5
+locals [int i=1]
+ : ( {$i<=5}? INT {$i++;} )* // match 5 INTs
+ ;
+```
+
+ANTLR ignores context-dependent predicates that it can't evaluate in the proper context. Normally the proper context is simply the rule defining the predicate, but sometimes the parser can't even evaluate a context-dependent predicate from within the same rule! Detecting these cases is done on-the-fly at runtime during adaptive LL(*) prediction.
+
+For example, prediction for the optional branch of the else subrule in stat below "falls off" the end of stat and continues looking for symbols in the invoking prog rule.
+
+```
+prog: stat+ ; // stat can follow stat
+stat
+locals [int i=0]
+ : {$i==0}? 'if' expr 'then' stat {$i=5;} ('else' stat)?
+ | 'break' ';'
+ ;
+```
+
+The prediction process is trying to figure out what can follow an if statement other than an else clause. Since the input can have multiple stats in a row, the prediction for the optional branch of the else subrule reenters stat. This time, of course, it gets a new copy of `$i` with a value of 0, not 5. ANTLR ignores context-dependent predicate `{$i==0}?` because it knows that the parser isn't in the original stat call. The predicate would test a different version of `$i` so the parser can't evaluate it.
+
+The fine print for predicates in the lexer more or less follow these same guidelines, except of course lexer rules can't have parameters and local variables. Let's look at all of the lexer-specific guidelines in the next section.
+
+## Predicates in Lexer Rules
+
+In parser rules, predicates must appear on the left edge of alternatives to aid in alternative prediction. Lexers, on the other hand, prefer predicates on the right edge of lexer rules because they choose rules after seeing a token's entire text. Predicates in lexer rules can technically be anywhere within the rule. Some positions might be more or less efficient than others; ANTLR makes no guarantees about the optimal spot. A predicate in a lexer rule might be executed multiple times even during a single token match. You can embed multiple predicates per lexer rule and they are evaluated as the lexer reaches them during matching.
+
+Loosely speaking, the lexer's goal is to choose the rule that matches the most input characters. At each character, the lexer decides which rules are still viable. Eventually, only a single rule will be still viable. At that point, the lexer creates a token object according the rule's token type and matched text.
+
+Sometimes the lexer is faced with more than a single viable matching rule. For example, input enum would match an `ENUM` rule and an `ID` rule. If the next character after enum is a space, neither rule can continue. The lexer resolves the ambiguity by choosing the viable rule specified first in the grammar. That's why we have to place keyword rules before an identifier rule like this:
+
+```
+ENUM : 'enum' ;
+ID : [a-z]+ ;
+```
+
+If, on the other hand, the next character after input `enum` is a letter, then only `ID` is viable.
+
+Predicates come into play by pruning the set of viable lexer rules. When the lexer encounters a false predicate, it deactivates that rule just like parsers deactivate alternatives with false predicates.
+
+Like parser predicates, lexer predicates can't depend on side effects from lexer actions. That's because actions can only execute after the lexer positively identifies the rule to match. Since predicates are part of the rule selection process, they can't rely on action side effects. Lexer actions must appear after predicates in lexer rules. As an example, here's another way to match enum as a keyword in the lexer:
+
+```
+ENUM: [a-z]+ {getText().equals("enum")}?
+ {System.out.println("enum!");}
+ ;
+ID : [a-z]+ {System.out.println("ID "+getText());} ;
+```
+
+The print action in `ENUM` appears last and executes only if the current input matches `[a-z]+` and the predicate is true. Let's build and test `Enum3` to see if it distinguishes between enum and an identifier:
+
+```bash
+$ antlr4 Enum3.g4
+$ javac Enum3.java
+$ grun Enum3 tokens
+=> enum abc
+=> EOF
+<= enum!
+ ID abc
+```
+
+That works great, but it's really just for instructional purposes. It's easier to understand and more efficient to match enum keywords with a simple rule like this:
+
+```
+ENUM : 'enum' ;
+```
diff --git a/doc/python-target.md b/doc/python-target.md
new file mode 100644
index 0000000..e3bd883
--- /dev/null
+++ b/doc/python-target.md
@@ -0,0 +1,129 @@
+# Python (2 and 3)
+
+The examples from the ANTLR 4 book converted to Python are [here](https://github.com/jszheng/py3antlr4book).
+
+There are 2 Python targets: `Python2` and `Python3`. This is because there is only limited compatibility between those 2 versions of the language. Please refer to the [Python documentation](https://wiki.python.org/moin/Python2orPython3) for full details.
+
+How to create a Python lexer or parser?
+This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
+
+```
+$ antlr4 -Dlanguage=Python2 MyGrammar.g4
+```
+
+or
+
+```
+$ antlr4 -Dlanguage=Python3 MyGrammar.g4
+```
+
+For a full list of antlr4 tool options, please visit the tool documentation page.
+
+## Where can I get the runtime?
+
+Once you've generated the lexer and/or parser code, you need to download the runtime. The Python runtimes are available from PyPI:
+
+* https://pypi.python.org/pypi/antlr4-python2-runtime/
+* https://pypi.python.org/pypi/antlr4-python3-runtime/
+
+The runtimes are provided in the form of source code, so no additional installation is required.
+
+We will not document here how to refer to the runtime from your Python project, since this would differ a lot depending on your project type and IDE.
+
+## How do I run the generated lexer and/or parser?
+
+Let's suppose that your grammar is named, as above, "MyGrammar". Let's suppose this parser comprises a rule named "startRule". The tool will have generated for you the following files:
+
+* MyGrammarLexer.py
+* MyGrammarParser.py
+* MyGrammarListener.py (if you have not activated the -no-listener option)
+* MyGrammarVisitor.py (if you have activated the -visitor option)
+
+(Developers used to Java/C# AntLR will notice that there is no base listener or visitor generated, this is because Python having no support for interfaces, the generated listener and visitor are fully fledged classes)
+
+Now a fully functioning script might look like the following:
+
+```python
+import sys
+from antlr4 import *
+from MyGrammarLexer import MyGrammarLexer
+from MyGrammarParser import MyGrammarParser
+
+def main(argv):
+ input = FileStream(argv[1])
+ lexer = MyGrammarLexer(input)
+ stream = CommonTokenStream(lexer)
+ parser = MyGrammarParser(stream)
+ tree = parser.startRule()
+
+if __name__ == '__main__':
+ main(sys.argv)
+```
+
+This program will work. But it won't be useful unless you do one of the following:
+
+* you visit the parse tree using a custom listener
+* you visit the parse tree using a custom visitor
+* your grammar comprises production code (like ANTLR3)
+
+(please note that production code is target specific, so you can't have multi target grammars that include production code, except for very limited use cases, see below)
+
+## How do I create and run a custom listener?
+
+Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value". The antlr4 tool will have generated the following listener:
+
+```python
+class MyGrammarListener(ParseTreeListener):
+ def enterKey(self, ctx):
+ pass
+ def exitKey(self, ctx):
+ pass
+ def enterValue(self, ctx):
+ pass
+ def exitValue(self, ctx):
+ pass
+```
+
+In order to provide custom behavior, you might want to create the following class:
+
+```python
+class KeyPrinter(MyGrammarListener):
+ def exitKey(self, ctx):
+ print("Oh, a key!")
+```
+
+In order to execute this listener, you would simply add the following lines to the above code:
+
+```
+ ...
+ tree = parser.startRule() - only repeated here for reference
+ printer = KeyPrinter()
+ walker = ParseTreeWalker()
+ walker.walk(printer, tree)
+```
+
+Further information can be found from the ANTLR 4 definitive guide.
+
+The Python implementation of ANTLR is as close as possible to the Java one, so you shouldn't find it difficult to adapt the examples for Python.
+
+## Target agnostic grammars
+
+If your grammar is targeted to Python only, you may ignore the following. But if your goal is to get your Java parser to also run in Python, then you might find it useful.
+
+1. Do not embed production code inside your grammar. This is not portable and will not be. Move all your code to listeners or visitors.
+1. The only production code absolutely required to sit with the grammar should be semantic predicates, like:
+```
+ID {$text.equals("test")}?
+```
+
+Unfortunately, this is not portable, but you can work around it. The trick involves:
+
+* deriving your parser from a parser you provide, such as BaseParser
+* implementing utility methods in this BaseParser, such as "isEqualText"
+* adding a "self" field to the Java/C# BaseParser, and initialize it with "this"
+
+Thanks to the above, you should be able to rewrite the above semantic predicate as follows:
+
+```
+ID {$self.isEqualText($text,"test")}?
+```
diff --git a/doc/releasing-antlr.md b/doc/releasing-antlr.md
new file mode 100644
index 0000000..ad0df08
--- /dev/null
+++ b/doc/releasing-antlr.md
@@ -0,0 +1,434 @@
+# Cutting an ANTLR Release
+
+## Github
+
+Create a pre-release or full release at github; [Example 4.5-rc-1](https://github.com/antlr/antlr4/releases/tag/4.5-rc-1).
+
+### Delete existing release tag
+
+Wack any existing tag as mvn will create one and it fails if already there.
+
+```
+$ git tag -d 4.6
+$ git push origin :refs/tags/4.6
+$ git push upstream :refs/tags/4.6
+```
+
+### Create release candidate tag
+
+```bash
+$ git tag -a 4.6-rc1 -m 'heading towards 4.6'
+$ git push origin 4.6-rc1
+$ git push upstream 4.6-rc1
+```
+
+## Bump version
+
+Edit the repository looking for 4.5 or whatever and update it. Bump version in the following files:
+
+ * runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
+ * runtime/Python2/setup.py
+ * runtime/Python2/src/antlr4/Recognizer.py
+ * runtime/Python3/setup.py
+ * runtime/Python3/src/antlr4/Recognizer.py
+ * runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs
+ * runtime/CSharp/build/version.ps1
+ * runtime/JavaScript/src/antlr4/package.json
+ * runtime/JavaScript/src/antlr4/Recognizer.js
+ * runtime/Cpp/VERSION
+ * runtime/Cpp/runtime/src/RuntimeMetaData.cpp
+ * runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
+ * tool/src/org/antlr/v4/codegen/target/CppTarget.java
+ * tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
+ * tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java
+ * tool/src/org/antlr/v4/codegen/target/Python2Target.java
+ * tool/src/org/antlr/v4/codegen/target/Python3Target.java
+
+Here is a simple script to display any line from the critical files with, say, `4.5` in it:
+
+```bash
+find /tmp/antlr4 -type f -exec grep -l '4\.5' {} \;
+```
+
+Commit to repository.
+
+## Maven Repository Settings
+
+First, make sure you have maven set up to communicate with staging servers etc... Create file `~/.m2/settings.xml` with appropriate username/password for staging server and gpg.keyname/passphrase for signing. Make sure it has strict visibility privileges to just you. On unix, it looks like:
+
+```bash
+beast:~/.m2 $ ls -l settings.xml
+-rw------- 1 parrt staff 914 Jul 15 14:42 settings.xml
+```
+
+Here is the file template
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ User-specific configuration for maven. Includes things that should not
+ be distributed with the pom.xml file, such as developer identity, along with
+ local settings, like proxy information.
+-->
+<settings>
+ <servers>
+ <server>
+ <id>sonatype-nexus-staging</id>
+ <username>sonatype-username</username>
+ <password>XXX</password>
+ </server>
+ <server>
+ <id>sonatype-nexus-snapshots</id>
+ <username>sonatype-username</username>
+ <password>XXX</password>
+ </server>
+ </servers>
+ <profiles>
+ <profile>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <gpg.keyname>UUU</gpg.keyname>
+ <gpg.passphrase>XXX</gpg.passphrase>
+ </properties>
+ </profile>
+ </profiles>
+</settings>
+```
+
+## Maven deploy snapshot
+
+The goal is to get a snapshot, such as `4.6-SNAPSHOT`, to the staging server: [antlr4 tool](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4) and [antlr4 java runtime](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-runtime).
+
+Do this:
+
+```bash
+$ mvn deploy -DskipTests
+...
+[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ antlr4-tool-testsuite ---
+Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/maven-metadata.xml
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/antlr4-tool-testsuite-4.6-20161211.173752-1.jar
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/antlr4-tool-testsuite-4.6-20161211.173752-1.jar (3 KB at 3.4 KB/sec)
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/antlr4-tool-testsuite-4.6-20161211.173752-1.pom
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/antlr4-tool-testsuite-4.6-20161211.173752-1.pom (3 KB at 6.5 KB/sec)
+Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml
+Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (371 B at 1.4 KB/sec)
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/maven-metadata.xml
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.6-SNAPSHOT/maven-metadata.xml (774 B at 1.8 KB/sec)
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (388 B at 0.9 KB/sec)
+[INFO] ------------------------------------------------------------------------
+[INFO] Reactor Summary:
+[INFO]
+[INFO] ANTLR 4 ............................................ SUCCESS [ 4.073 s]
+[INFO] ANTLR 4 Runtime .................................... SUCCESS [ 13.828 s]
+[INFO] ANTLR 4 Tool ....................................... SUCCESS [ 14.032 s]
+[INFO] ANTLR 4 Maven plugin ............................... SUCCESS [ 6.547 s]
+[INFO] ANTLR 4 Runtime Test Annotations ................... SUCCESS [ 2.519 s]
+[INFO] ANTLR 4 Runtime Test Processors .................... SUCCESS [ 2.385 s]
+[INFO] ANTLR 4 Runtime Tests (2nd generation) ............. SUCCESS [ 15.276 s]
+[INFO] ANTLR 4 Tool Tests ................................. SUCCESS [ 2.233 s]
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 01:01 min
+[INFO] Finished at: 2016-12-11T09:37:54-08:00
+[INFO] Final Memory: 44M/470M
+[INFO] ------------------------------------------------------------------------
+```
+
+## Maven release
+
+The maven deploy lifecycle phased deploys the artifacts and the poms for the ANTLR project to the [sonatype remote staging server](https://oss.sonatype.org/content/repositories/snapshots/).
+
+```bash
+mvn deploy -DskipTests
+```
+
+With JDK 1.7 (not 6 or 8), do this:
+
+```bash
+mvn release:prepare -Darguments="-DskipTests"
+```
+
+It will start out by asking you the version number:
+
+```
+...
+What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.6: : 4.6
+What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.6: :
+What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.6: :
+What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.6: :
+What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.6: :
+What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.6: :
+What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.6: : 4.6
+What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.6.1-SNAPSHOT:
+...
+```
+
+Maven will go through your pom.xml files to update versions from 4.6-SNAPSHOT to 4.6 for release and then to 4.6.1-SNAPSHOT after release, which is done with:
+
+```bash
+mvn release:perform -Darguments="-DskipTests"
+```
+
+Maven will use git to push pom.xml changes.
+
+Now, go here:
+
+&nbsp;&nbsp;&nbsp;&nbsp;[https://oss.sonatype.org/#welcome](https://oss.sonatype.org/#welcome)
+
+and on the left click "Staging Repositories". You click the staging repo and close it, then you refresh, click it and release it. It's done when you see it here:
+
+&nbsp;&nbsp;&nbsp;&nbsp;[http://repo1.maven.org/maven2/org/antlr/antlr4-runtime/](http://repo1.maven.org/maven2/org/antlr/antlr4-runtime/)
+
+Copy the jars to antlr.org site and update download/index.html
+
+```bash
+cp ~/.m2/repository/org/antlr/antlr4-runtime/4.6/antlr4-runtime-4.6.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.6.jar
+cp ~/.m2/repository/org/antlr/antlr4/4.6/antlr4-4.6-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.6-complete.jar
+cd ~/antlr/sites/website-antlr4/download
+git add antlr-4.6-complete.jar
+git add antlr-runtime-4.6.jar
+```
+
+Update on site:
+
+* download.html
+* index.html
+* api/index.html
+* download/index.html
+* scripts/topnav.js
+
+```
+git commit -a -m 'add 4.6 jars'
+git push origin gh-pages
+```
+
+## Deploying Targets
+
+### JavaScript
+
+```bash
+cd runtime/JavaScript/src
+zip -r /tmp/antlr-javascript-runtime-4.6.zip antlr4
+cp /tmp/antlr-javascript-runtime-4.6.zip ~/antlr/sites/website-antlr4/download
+# git add, commit, push
+```
+
+Move target to website
+
+```bash
+pushd ~/antlr/sites/website-antlr4/download
+git add antlr-javascript-runtime-4.6.zip
+git commit -a -m 'update JS runtime'
+git push origin gh-pages
+popd
+```
+
+### CSharp
+
+*Publishing to Nuget from Linux/MacOSX*
+
+**Getting ready to run Nuget**
+
+Of course you need Mono and `nuget` to be installed. On mac:
+
+```bash
+brew install mono
+brew install nuget
+```
+
+Or, you can [download nuget.exe](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe).
+
+From the shell on mac, you can check all is ok by typing
+
+```bash
+nuget
+```
+
+This should display the nuget help.
+
+**Creating the assembly**
+
+```bash
+$ cd runtime/CSharp/runtime/CSharp/Antlr4.Runtime
+$ xbuild /p:Configuration=Release Antlr4.Runtime.mono.csproj
+...
+ Copying file from '/Users/parrt/antlr/code/antlr4/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/obj/net20/Release/Antlr4.Runtime.Standard.dll' to '/Users/parrt/antlr/code/antlr4/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/lib/Release/Antlr4.Runtime.Standard.dll'
+Done building project "/Users/parrt/antlr/code/antlr4/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj".
+```
+
+Alternately, you may want to build ANTLR using Xamarin Studio Community (free).
+
+**Packaging for NuGet**
+
+```bash
+cd runtime/CSharp/runtime/CSharp
+```
+
+which is where the `Package.nuspec` file resides.
+
+Type the following command:
+
+```bash
+$ nuget pack Package.nuspec
+Attempting to build package from 'Package.nuspec'.
+Successfully created package '/Users/parrt/antlr/code/antlr4/runtime/CSharp/runtime/CSharp/Antlr4.Runtime.Standard.4.6.0.nupkg'.
+```
+
+This should display: Successfully created package *&lt;package-path>*
+
+**Publishing to NuGet**
+
+You need to be a NuGet owner for "ANTLR 4 Standard Runtime"
+As a registered NuGet user, you can then manually upload the package spec here (`runtime/CSharp/runtime/CSharp/Package.nuspec`): [https://www.nuget.org/packages/manage/upload](https://www.nuget.org/packages/manage/upload)
+
+Alternately, you can publish from the cmd line. You need to get your NuGet key from [https://www.nuget.org/account#](https://www.nuget.org/account#) and then from the cmd line, you can then type:
+
+```bash
+nuget push Antlr4.Runtime.Standard.<version>.nupkg <your-key> -Source https://www.nuget.org/api/v2/package
+```
+
+**Creating DLLs**
+
+```bash
+cd ~/antlr/code/antlr4/runtime/CSharp/runtime/CSharp
+# kill previous ones manually as "xbuild /t:Clean" didn't seem to do it
+rm Antlr4.Runtime/bin/net20/Release/Antlr4.Runtime.dll
+rm Antlr4.Runtime/obj/net20/Release/Antlr4.Runtime.dll
+# build
+xbuild /p:Configuration=Release Antlr4.Runtime/Antlr4.Runtime.mono.csproj
+# zip it up to get a version number on zip filename
+zip --junk-paths /tmp/antlr-csharp-runtime-4.6.zip Antlr4.Runtime/bin/net35/Release/Antlr4.Runtime.dll
+cp /tmp/antlr-csharp-runtime-4.6.zip ~/antlr/sites/website-antlr4/download
+```
+
+Move target to website
+
+```bash
+pushd ~/antlr/sites/website-antlr4/download
+git add antlr-csharp-runtime-4.6.zip
+git commit -a -m 'update C# runtime'
+git push origin gh-pages
+popd
+```
+
+### Python
+
+The Python targets get deployed with `setup.py`. First, set up `~/.pypirc` with tight privileges:
+
+```bash
+beast:~ $ ls -l ~/.pypirc
+-rw------- 1 parrt staff 267 Jul 15 17:02 /Users/parrt/.pypirc
+```
+
+```
+[distutils] # this tells distutils what package indexes you can push to
+index-servers =
+ pypi
+ pypitest
+
+[pypi]
+repository: https://pypi.python.org/pypi
+username: parrt
+password: XXX
+
+[pypitest]
+repository: https://testpypi.python.org/pypi
+username: parrt
+```
+
+Then run the usual python set up stuff:
+
+```bash
+cd ~/antlr/code/antlr4/runtime/Python2
+# assume you have ~/.pypirc set up
+python setup.py register -r pypi
+python setup.py sdist bdist_wininst upload -r pypi
+```
+
+and do again for Python 3 target
+
+```bash
+cd ~/antlr/code/antlr4/runtime/Python3
+# assume you have ~/.pypirc set up
+python setup.py register -r pypi
+python setup.py sdist bdist_wininst upload -r pypi
+```
+
+Add links to the artifacts from download.html
+
+### C++
+
+The C++ target is the most complex one, because it addresses multiple platforms, which require individual handling. We have 4 scenarios to cover:
+
+* **Windows**: static and dynamic libraries for the VC++ runtime 2013 or 2015 (corresponding to Visual Studio 2013 or 2015) + header files. All that in 32 and 64bit, debug + release.
+* **MacOS**: static and dynamic release libraries + header files.
+* **iOS**: no prebuilt binaries, but just a zip of the source, including the XCode project to build everything from source.
+* **Linux**: no prebuilt binaries, but just a zip of the source code, including the cmake file to build everything from source there.
+
+In theory we could also create a library for iOS, but that requires to sign it, which depends on an active iOS developer account. So we leave this up to the ANTLR user to build the iOS lib, like we do for Linux builds.
+
+For each platform there's a deployment script which generates zip archives and copies them to the target folder. The Windows deployment script must be run on a machine with VS 2013 + VS 2015 installed. The Mac script must be run on a machine with XCode 7+ installed. The source script can be executed on any Linux or Mac box.
+
+On a Mac (with XCode 7+ installed):
+
+```bash
+cd runtime/Cpp
+./deploy-macos.sh
+```
+
+On any Mac or Linux machine:
+
+```bash
+cd runtime/Cpp
+./deploy-source.sh
+```
+
+On a Windows machine the build scripts checks if VS 2013 and/or VS 2015 are installed and builds binaries for each, if found. This script requires 7z to be installed (http://7-zip.org).
+
+```bash
+cd runtime/Cpp
+deploy-windows.cmd
+```
+
+Move target to website (**_rename to a specific ANTLR version first if needed_**):
+
+```bash
+pushd ~/antlr/sites/website-antlr4/download
+git add antlr4cpp-runtime-macos.zip
+git add antlr4cpp-runtime-windows.zip
+git add antlr4cpp-runtime-source.zip
+git commit -a -m 'update C++ runtime'
+git push origin gh-pages
+popd
+```
+
+## Update javadoc for runtime and tool
+
+First gen javadoc:
+
+```bash
+$ cd antlr4
+$ mvn -DskipTests javadoc:jar install
+```
+
+Then copy to website:
+
+```bash
+cd ~/antlr/sites/website-antlr4/api
+git checkout gh-pages
+git pull origin gh-pages
+cd Java
+jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.6/antlr4-runtime-4.6-javadoc.jar
+cd ../JavaTool
+jar xvf ~/.m2/repository/org/antlr/antlr4/4.6/antlr4-4.6-javadoc.jar
+git commit -a -m 'freshen api doc'
+git push origin gh-pages
+```
+
+## Update Intellij plug-in
+
+Rebuild antlr plugin with new antlr jar.
diff --git a/doc/resources.md b/doc/resources.md
new file mode 100644
index 0000000..8ee31a3
--- /dev/null
+++ b/doc/resources.md
@@ -0,0 +1,33 @@
+# Articles and Resources
+
+## Books
+
+<a href=""><img src=images/tpantlr2.png width=120></a>
+<a href=""><img src=images/tpdsl.png width=120></a>
+
+<a href="https://www.youtube.com/watch?v=OAoA3E-cyug"><img src=images/teronbook.png width=250></a>
+
+## Articles
+
+* [Playing with ANTLR4, Primefaces extensions for Code Mirror and web-based DSLs](http://leonotepad.blogspot.com.br/2014/01/playing-with-antlr4-primefaces.html)
+* [A Tale of Two Grammars](https://dexvis.wordpress.com/2012/11/22/a-tale-of-two-grammars/)
+* [ANTLR 4: using the lexer, parser and listener with example grammar](http://www.theendian.com/blog/antlr-4-lexer-parser-and-listener-with-example-grammar/)
+* [Creating External DSLs using ANTLR and Java](http://java.dzone.com/articles/creating-external-dsls-using)
+
+## Presentations
+
+* [Introduction to ANTLR 4 by Oliver Zeigermann](https://docs.google.com/presentation/d/1XS_VIdicCQVonPK6AGYkWTp-3VeHfGuD2l8yNMpAfuQ/edit#slide=id.p)
+
+## Videos
+
+<a href="https://vimeo.com/59285751"><img src=images/tertalk.png width=200></a>
+
+## Resources
+
+* [Stack overflow ANTLR4 tag](http://stackoverflow.com/questions/tagged/antlr4)
+* [Antlr 4 with C# and Visual Studio 2012](http://programming-pages.com/2013/12/14/antlr-4-with-c-and-visual-studio-2012/)
+* [ANTLR Language Support in VisualStudio](http://visualstudiogallery.msdn.microsoft.com/25b991db-befd-441b-b23b-bb5f8d07ee9f)
+* [Upgrading to ANTLR 4 with C#](http://andrevdm.blogspot.com/2013/08/upgrading-to-antlr-4-with-c.html)
+* [Generate parsers with Antlr4 via Maven](http://ljelonek.wordpress.com/2014/01/03/generate-parsers-with-antlr4-via-maven/)
+* [Exploring ANTLR v4](http://johnsquibb.like97.com/blog/read/exploring-antlr-v4)
+* [antlr4dart](http://pub.dartlang.org/packages/antlr4dart) \ No newline at end of file
diff --git a/doc/resources/worker-base.js b/doc/resources/worker-base.js
new file mode 100644
index 0000000..3494b39
--- /dev/null
+++ b/doc/resources/worker-base.js
@@ -0,0 +1,1079 @@
+"no use strict";
+(function(e) {
+ if (typeof e.window != "undefined" && e.document) return;
+ e.console = function() {
+ var e = Array.prototype.slice.call(arguments, 0);
+ postMessage({
+ type: "log",
+ data: e
+ })
+ }, e.console.error = e.console.warn = e.console.log = e.console.trace = e.console, e.window = e, e.ace = e, e.onerror = function(e, t, n, r, i) {
+ postMessage({
+ type: "error",
+ data: {
+ message: e,
+ file: t,
+ line: n,
+ col: r,
+ stack: i.stack
+ }
+ })
+ }, e.normalizeModule = function(t, n) {
+ if (n.indexOf("!") !== -1) {
+ var r = n.split("!");
+ return e.normalizeModule(t, r[0]) + "!" + e.normalizeModule(t, r[1])
+ }
+ if (n.charAt(0) == ".") {
+ var i = t.split("/")
+ .slice(0, -1)
+ .join("/");
+ n = (i ? i + "/" : "") + n;
+ while (n.indexOf(".") !== -1 && s != n) {
+ var s = n;
+ n = n.replace(/^\.\//, "")
+ .replace(/\/\.\//, "/")
+ .replace(/[^\/]+\/\.\.\//, "")
+ }
+ }
+ return n
+ }, e.require = function(t, n) {
+ n || (n = t, t = null);
+ if (!n.charAt) throw new Error("worker.js require() accepts only (parentId, id) as arguments");
+ n = e.normalizeModule(t, n);
+ var r = e.require.modules[n];
+ if (r) return r.initialized || (r.initialized = !0, r.exports = r.factory()
+ .exports), r.exports;
+ var i = n.split("/");
+ if (!e.require.tlns) return console.log("unable to load " + n);
+ i[0] = e.require.tlns[i[0]] || i[0];
+ var s = i.join("/") + ".js";
+ return e.require.id = n, importScripts(s), e.require(t, n)
+ }, e.require.modules = {}, e.require.tlns = {}, e.define = function(t, n, r) {
+ arguments.length == 2 ? (r = n, typeof t != "string" && (n = t, t = e.require.id)) : arguments.length == 1 && (r = t, n = [], t = e.require.id);
+ if (typeof r != "function") {
+ e.require.modules[t] = {
+ exports: r,
+ initialized: !0
+ };
+ return
+ }
+ n.length || (n = ["require", "exports", "module"]);
+ var i = function(n) {
+ return e.require(t, n)
+ };
+ e.require.modules[t] = {
+ exports: {},
+ factory: function() {
+ var e = this,
+ t = r.apply(this, n.map(function(t) {
+ switch (t) {
+ case "require":
+ return i;
+ case "exports":
+ return e.exports;
+ case "module":
+ return e;
+ default:
+ return i(t)
+ }
+ }));
+ return t && (e.exports = t), e
+ }
+ }
+ }, e.define.amd = {}, e.initBaseUrls = function(t) {
+ require.tlns = t
+ }, e.initSender = function() {
+ var n = e.require("ace/lib/event_emitter")
+ .EventEmitter,
+ r = e.require("ace/lib/oop"),
+ i = function() {};
+ return function() {
+ r.implement(this, n), this.callback = function(e, t) {
+ postMessage({
+ type: "call",
+ id: t,
+ data: e
+ })
+ }, this.emit = function(e, t) {
+ postMessage({
+ type: "event",
+ name: e,
+ data: t
+ })
+ }
+ }.call(i.prototype), new i
+ };
+ var t = e.main = null,
+ n = e.sender = null;
+ e.onmessage = function(r) {
+ var i = r.data;
+ if (i.command) {
+ if (!t[i.command]) throw new Error("Unknown command:" + i.command);
+ t[i.command].apply(t, i.args)
+ } else if (i.init) {
+ initBaseUrls(i.tlns), require("ace/lib/es5-shim"), n = e.sender = initSender();
+ var s = require(i.module)[i.classname];
+ t = e.main = new s(n)
+ } else i.event && n && n._signal(i.event, i.data)
+ }
+})(this), ace.define("ace/lib/oop", ["require", "exports", "module"], function(e, t, n) {
+ "use strict";
+ t.inherits = function(e, t) {
+ e.super_ = t, e.prototype = Object.create(t.prototype, {
+ constructor: {
+ value: e,
+ enumerable: !1,
+ writable: !0,
+ configurable: !0
+ }
+ })
+ }, t.mixin = function(e, t) {
+ for (var n in t) e[n] = t[n];
+ return e
+ }, t.implement = function(e, n) {
+ t.mixin(e, n)
+ }
+}), ace.define("ace/lib/event_emitter", ["require", "exports", "module"], function(e, t, n) {
+ "use strict";
+ var r = {},
+ i = function() {
+ this.propagationStopped = !0
+ },
+ s = function() {
+ this.defaultPrevented = !0
+ };
+ r._emit = r._dispatchEvent = function(e, t) {
+ this._eventRegistry || (this._eventRegistry = {}), this._defaultHandlers || (this._defaultHandlers = {});
+ var n = this._eventRegistry[e] || [],
+ r = this._defaultHandlers[e];
+ if (!n.length && !r) return;
+ if (typeof t != "object" || !t) t = {};
+ t.type || (t.type = e), t.stopPropagation || (t.stopPropagation = i), t.preventDefault || (t.preventDefault = s), n = n.slice();
+ for (var o = 0; o < n.length; o++) {
+ n[o](t, this);
+ if (t.propagationStopped) break
+ }
+ if (r && !t.defaultPrevented) return r(t, this)
+ }, r._signal = function(e, t) {
+ var n = (this._eventRegistry || {})[e];
+ if (!n) return;
+ n = n.slice();
+ for (var r = 0; r < n.length; r++) n[r](t, this)
+ }, r.once = function(e, t) {
+ var n = this;
+ t && this.addEventListener(e, function r() {
+ n.removeEventListener(e, r), t.apply(null, arguments)
+ })
+ }, r.setDefaultHandler = function(e, t) {
+ var n = this._defaultHandlers;
+ n || (n = this._defaultHandlers = {
+ _disabled_: {}
+ });
+ if (n[e]) {
+ var r = n[e],
+ i = n._disabled_[e];
+ i || (n._disabled_[e] = i = []), i.push(r);
+ var s = i.indexOf(t);
+ s != -1 && i.splice(s, 1)
+ }
+ n[e] = t
+ }, r.removeDefaultHandler = function(e, t) {
+ var n = this._defaultHandlers;
+ if (!n) return;
+ var r = n._disabled_[e];
+ if (n[e] == t) {
+ var i = n[e];
+ r && this.setDefaultHandler(e, r.pop())
+ } else if (r) {
+ var s = r.indexOf(t);
+ s != -1 && r.splice(s, 1)
+ }
+ }, r.on = r.addEventListener = function(e, t, n) {
+ this._eventRegistry = this._eventRegistry || {};
+ var r = this._eventRegistry[e];
+ return r || (r = this._eventRegistry[e] = []), r.indexOf(t) == -1 && r[n ? "unshift" : "push"](t), t
+ }, r.off = r.removeListener = r.removeEventListener = function(e, t) {
+ this._eventRegistry = this._eventRegistry || {};
+ var n = this._eventRegistry[e];
+ if (!n) return;
+ var r = n.indexOf(t);
+ r !== -1 && n.splice(r, 1)
+ }, r.removeAllListeners = function(e) {
+ this._eventRegistry && (this._eventRegistry[e] = [])
+ }, t.EventEmitter = r
+}), ace.define("ace/range", ["require", "exports", "module"], function(e, t, n) {
+ "use strict";
+ var r = function(e, t) {
+ return e.row - t.row || e.column - t.column
+ },
+ i = function(e, t, n, r) {
+ this.start = {
+ row: e,
+ column: t
+ }, this.end = {
+ row: n,
+ column: r
+ }
+ };
+ (function() {
+ this.isEqual = function(e) {
+ return this.start.row === e.start.row && this.end.row === e.end.row && this.start.column === e.start.column && this.end.column === e.end.column
+ }, this.toString = function() {
+ return "Range: [" + this.start.row + "/" + this.start.column + "] -> [" + this.end.row + "/" + this.end.column + "]"
+ }, this.contains = function(e, t) {
+ return this.compare(e, t) == 0
+ }, this.compareRange = function(e) {
+ var t, n = e.end,
+ r = e.start;
+ return t = this.compare(n.row, n.column), t == 1 ? (t = this.compare(r.row, r.column), t == 1 ? 2 : t == 0 ? 1 : 0) : t == -1 ? -2 : (t = this.compare(r.row, r.column), t == -1 ? -1 : t == 1 ? 42 : 0)
+ }, this.comparePoint = function(e) {
+ return this.compare(e.row, e.column)
+ }, this.containsRange = function(e) {
+ return this.comparePoint(e.start) == 0 && this.comparePoint(e.end) == 0
+ }, this.intersects = function(e) {
+ var t = this.compareRange(e);
+ return t == -1 || t == 0 || t == 1
+ }, this.isEnd = function(e, t) {
+ return this.end.row == e && this.end.column == t
+ }, this.isStart = function(e, t) {
+ return this.start.row == e && this.start.column == t
+ }, this.setStart = function(e, t) {
+ typeof e == "object" ? (this.start.column = e.column, this.start.row = e.row) : (this.start.row = e, this.start.column = t)
+ }, this.setEnd = function(e, t) {
+ typeof e == "object" ? (this.end.column = e.column, this.end.row = e.row) : (this.end.row = e, this.end.column = t)
+ }, this.inside = function(e, t) {
+ return this.compare(e, t) == 0 ? this.isEnd(e, t) || this.isStart(e, t) ? !1 : !0 : !1
+ }, this.insideStart = function(e, t) {
+ return this.compare(e, t) == 0 ? this.isEnd(e, t) ? !1 : !0 : !1
+ }, this.insideEnd = function(e, t) {
+ return this.compare(e, t) == 0 ? this.isStart(e, t) ? !1 : !0 : !1
+ }, this.compare = function(e, t) {
+ return !this.isMultiLine() && e === this.start.row ? t < this.start.column ? -1 : t > this.end.column ? 1 : 0 : e < this.start.row ? -1 : e > this.end.row ? 1 : this.start.row === e ? t >= this.start.column ? 0 : -1 : this.end.row === e ? t <= this.end.column ? 0 : 1 : 0
+ }, this.compareStart = function(e, t) {
+ return this.start.row == e && this.start.column == t ? -1 : this.compare(e, t)
+ }, this.compareEnd = function(e, t) {
+ return this.end.row == e && this.end.column == t ? 1 : this.compare(e, t)
+ }, this.compareInside = function(e, t) {
+ return this.end.row == e && this.end.column == t ? 1 : this.start.row == e && this.start.column == t ? -1 : this.compare(e, t)
+ }, this.clipRows = function(e, t) {
+ if (this.end.row > t) var n = {
+ row: t + 1,
+ column: 0
+ };
+ else if (this.end.row < e) var n = {
+ row: e,
+ column: 0
+ };
+ if (this.start.row > t) var r = {
+ row: t + 1,
+ column: 0
+ };
+ else if (this.start.row < e) var r = {
+ row: e,
+ column: 0
+ };
+ return i.fromPoints(r || this.start, n || this.end)
+ }, this.extend = function(e, t) {
+ var n = this.compare(e, t);
+ if (n == 0) return this;
+ if (n == -1) var r = {
+ row: e,
+ column: t
+ };
+ else var s = {
+ row: e,
+ column: t
+ };
+ return i.fromPoints(r || this.start, s || this.end)
+ }, this.isEmpty = function() {
+ return this.start.row === this.end.row && this.start.column === this.end.column
+ }, this.isMultiLine = function() {
+ return this.start.row !== this.end.row
+ }, this.clone = function() {
+ return i.fromPoints(this.start, this.end)
+ }, this.collapseRows = function() {
+ return this.end.column == 0 ? new i(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0) : new i(this.start.row, 0, this.end.row, 0)
+ }, this.toScreenRange = function(e) {
+ var t = e.documentToScreenPosition(this.start),
+ n = e.documentToScreenPosition(this.end);
+ return new i(t.row, t.column, n.row, n.column)
+ }, this.moveBy = function(e, t) {
+ this.start.row += e, this.start.column += t, this.end.row += e, this.end.column += t
+ }
+ })
+ .call(i.prototype), i.fromPoints = function(e, t) {
+ return new i(e.row, e.column, t.row, t.column)
+ }, i.comparePoints = r, i.comparePoints = function(e, t) {
+ return e.row - t.row || e.column - t.column
+ }, t.Range = i
+}), ace.define("ace/anchor", ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter"], function(e, t, n) {
+ "use strict";
+ var r = e("./lib/oop"),
+ i = e("./lib/event_emitter")
+ .EventEmitter,
+ s = t.Anchor = function(e, t, n) {
+ this.$onChange = this.onChange.bind(this), this.attach(e), typeof n == "undefined" ? this.setPosition(t.row, t.column) : this.setPosition(t, n)
+ };
+ (function() {
+ r.implement(this, i), this.getPosition = function() {
+ return this.$clipPositionToDocument(this.row, this.column)
+ }, this.getDocument = function() {
+ return this.document
+ }, this.$insertRight = !1, this.onChange = function(e) {
+ var t = e.data,
+ n = t.range;
+ if (n.start.row == n.end.row && n.start.row != this.row) return;
+ if (n.start.row > this.row) return;
+ if (n.start.row == this.row && n.start.column > this.column) return;
+ var r = this.row,
+ i = this.column,
+ s = n.start,
+ o = n.end;
+ if (t.action === "insertText")
+ if (s.row === r && s.column <= i) {
+ if (s.column !== i || !this.$insertRight) s.row === o.row ? i += o.column - s.column : (i -= s.column, r += o.row - s.row)
+ } else s.row !== o.row && s.row < r && (r += o.row - s.row);
+ else t.action === "insertLines" ? (s.row !== r || i !== 0 || !this.$insertRight) && s.row <= r && (r += o.row - s.row) : t.action === "removeText" ? s.row === r && s.column < i ? o.column >= i ? i = s.column : i = Math.max(0, i - (o.column - s.column)) : s.row !== o.row && s.row < r ? (o.row === r && (i = Math.max(0, i - o.column) + s.column), r -= o.row - s.row) : o.row === r && (r -= o.row - s.row, i = Math.max(0, i - o.column) + s.column) : t.action == "removeLines" && s.row <= r && (o.row <= r ? r -= o.row - s.row : (r = s.row, i = 0));
+ this.setPosition(r, i, !0)
+ }, this.setPosition = function(e, t, n) {
+ var r;
+ n ? r = {
+ row: e,
+ column: t
+ } : r = this.$clipPositionToDocument(e, t);
+ if (this.row == r.row && this.column == r.column) return;
+ var i = {
+ row: this.row,
+ column: this.column
+ };
+ this.row = r.row, this.column = r.column, this._signal("change", {
+ old: i,
+ value: r
+ })
+ }, this.detach = function() {
+ this.document.removeEventListener("change", this.$onChange)
+ }, this.attach = function(e) {
+ this.document = e || this.document, this.document.on("change", this.$onChange)
+ }, this.$clipPositionToDocument = function(e, t) {
+ var n = {};
+ return e >= this.document.getLength() ? (n.row = Math.max(0, this.document.getLength() - 1), n.column = this.document.getLine(n.row)
+ .length) : e < 0 ? (n.row = 0, n.column = 0) : (n.row = e, n.column = Math.min(this.document.getLine(n.row)
+ .length, Math.max(0, t))), t < 0 && (n.column = 0), n
+ }
+ })
+ .call(s.prototype)
+}), ace.define("ace/document", ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter", "ace/range", "ace/anchor"], function(e, t, n) {
+ "use strict";
+ var r = e("./lib/oop"),
+ i = e("./lib/event_emitter")
+ .EventEmitter,
+ s = e("./range")
+ .Range,
+ o = e("./anchor")
+ .Anchor,
+ u = function(e) {
+ this.$lines = [], e.length === 0 ? this.$lines = [""] : Array.isArray(e) ? this._insertLines(0, e) : this.insert({
+ row: 0,
+ column: 0
+ }, e)
+ };
+ (function() {
+ r.implement(this, i), this.setValue = function(e) {
+ var t = this.getLength();
+ this.remove(new s(0, 0, t, this.getLine(t - 1)
+ .length)), this.insert({
+ row: 0,
+ column: 0
+ }, e)
+ }, this.getValue = function() {
+ return this.getAllLines()
+ .join(this.getNewLineCharacter())
+ }, this.createAnchor = function(e, t) {
+ return new o(this, e, t)
+ }, "aaa".split(/a/)
+ .length === 0 ? this.$split = function(e) {
+ return e.replace(/\r\n|\r/g, "\n")
+ .split("\n")
+ } : this.$split = function(e) {
+ return e.split(/\r\n|\r|\n/)
+ }, this.$detectNewLine = function(e) {
+ var t = e.match(/^.*?(\r\n|\r|\n)/m);
+ this.$autoNewLine = t ? t[1] : "\n", this._signal("changeNewLineMode")
+ }, this.getNewLineCharacter = function() {
+ switch (this.$newLineMode) {
+ case "windows":
+ return "\r\n";
+ case "unix":
+ return "\n";
+ default:
+ return this.$autoNewLine || "\n"
+ }
+ }, this.$autoNewLine = "", this.$newLineMode = "auto", this.setNewLineMode = function(e) {
+ if (this.$newLineMode === e) return;
+ this.$newLineMode = e, this._signal("changeNewLineMode")
+ }, this.getNewLineMode = function() {
+ return this.$newLineMode
+ }, this.isNewLine = function(e) {
+ return e == "\r\n" || e == "\r" || e == "\n"
+ }, this.getLine = function(e) {
+ return this.$lines[e] || ""
+ }, this.getLines = function(e, t) {
+ return this.$lines.slice(e, t + 1)
+ }, this.getAllLines = function() {
+ return this.getLines(0, this.getLength())
+ }, this.getLength = function() {
+ return this.$lines.length
+ }, this.getTextRange = function(e) {
+ if (e.start.row == e.end.row) return this.getLine(e.start.row)
+ .substring(e.start.column, e.end.column);
+ var t = this.getLines(e.start.row, e.end.row);
+ t[0] = (t[0] || "")
+ .substring(e.start.column);
+ var n = t.length - 1;
+ return e.end.row - e.start.row == n && (t[n] = t[n].substring(0, e.end.column)), t.join(this.getNewLineCharacter())
+ }, this.$clipPosition = function(e) {
+ var t = this.getLength();
+ return e.row >= t ? (e.row = Math.max(0, t - 1), e.column = this.getLine(t - 1)
+ .length) : e.row < 0 && (e.row = 0), e
+ }, this.insert = function(e, t) {
+ if (!t || t.length === 0) return e;
+ e = this.$clipPosition(e), this.getLength() <= 1 && this.$detectNewLine(t);
+ var n = this.$split(t),
+ r = n.splice(0, 1)[0],
+ i = n.length == 0 ? null : n.splice(n.length - 1, 1)[0];
+ return e = this.insertInLine(e, r), i !== null && (e = this.insertNewLine(e), e = this._insertLines(e.row, n), e = this.insertInLine(e, i || "")), e
+ }, this.insertLines = function(e, t) {
+ return e >= this.getLength() ? this.insert({
+ row: e,
+ column: 0
+ }, "\n" + t.join("\n")) : this._insertLines(Math.max(e, 0), t)
+ }, this._insertLines = function(e, t) {
+ if (t.length == 0) return {
+ row: e,
+ column: 0
+ };
+ while (t.length > 2e4) {
+ var n = this._insertLines(e, t.slice(0, 2e4));
+ t = t.slice(2e4), e = n.row
+ }
+ var r = [e, 0];
+ r.push.apply(r, t), this.$lines.splice.apply(this.$lines, r);
+ var i = new s(e, 0, e + t.length, 0),
+ o = {
+ action: "insertLines",
+ range: i,
+ lines: t
+ };
+ return this._signal("change", {
+ data: o
+ }), i.end
+ }, this.insertNewLine = function(e) {
+ e = this.$clipPosition(e);
+ var t = this.$lines[e.row] || "";
+ this.$lines[e.row] = t.substring(0, e.column), this.$lines.splice(e.row + 1, 0, t.substring(e.column, t.length));
+ var n = {
+ row: e.row + 1,
+ column: 0
+ },
+ r = {
+ action: "insertText",
+ range: s.fromPoints(e, n),
+ text: this.getNewLineCharacter()
+ };
+ return this._signal("change", {
+ data: r
+ }), n
+ }, this.insertInLine = function(e, t) {
+ if (t.length == 0) return e;
+ var n = this.$lines[e.row] || "";
+ this.$lines[e.row] = n.substring(0, e.column) + t + n.substring(e.column);
+ var r = {
+ row: e.row,
+ column: e.column + t.length
+ },
+ i = {
+ action: "insertText",
+ range: s.fromPoints(e, r),
+ text: t
+ };
+ return this._signal("change", {
+ data: i
+ }), r
+ }, this.remove = function(e) {
+ e instanceof s || (e = s.fromPoints(e.start, e.end)), e.start = this.$clipPosition(e.start), e.end = this.$clipPosition(e.end);
+ if (e.isEmpty()) return e.start;
+ var t = e.start.row,
+ n = e.end.row;
+ if (e.isMultiLine()) {
+ var r = e.start.column == 0 ? t : t + 1,
+ i = n - 1;
+ e.end.column > 0 && this.removeInLine(n, 0, e.end.column), i >= r && this._removeLines(r, i), r != t && (this.removeInLine(t, e.start.column, this.getLine(t)
+ .length), this.removeNewLine(e.start.row))
+ } else this.removeInLine(t, e.start.column, e.end.column);
+ return e.start
+ }, this.removeInLine = function(e, t, n) {
+ if (t == n) return;
+ var r = new s(e, t, e, n),
+ i = this.getLine(e),
+ o = i.substring(t, n),
+ u = i.substring(0, t) + i.substring(n, i.length);
+ this.$lines.splice(e, 1, u);
+ var a = {
+ action: "removeText",
+ range: r,
+ text: o
+ };
+ return this._signal("change", {
+ data: a
+ }), r.start
+ }, this.removeLines = function(e, t) {
+ return e < 0 || t >= this.getLength() ? this.remove(new s(e, 0, t + 1, 0)) : this._removeLines(e, t)
+ }, this._removeLines = function(e, t) {
+ var n = new s(e, 0, t + 1, 0),
+ r = this.$lines.splice(e, t - e + 1),
+ i = {
+ action: "removeLines",
+ range: n,
+ nl: this.getNewLineCharacter(),
+ lines: r
+ };
+ return this._signal("change", {
+ data: i
+ }), r
+ }, this.removeNewLine = function(e) {
+ var t = this.getLine(e),
+ n = this.getLine(e + 1),
+ r = new s(e, t.length, e + 1, 0),
+ i = t + n;
+ this.$lines.splice(e, 2, i);
+ var o = {
+ action: "removeText",
+ range: r,
+ text: this.getNewLineCharacter()
+ };
+ this._signal("change", {
+ data: o
+ })
+ }, this.replace = function(e, t) {
+ e instanceof s || (e = s.fromPoints(e.start, e.end));
+ if (t.length == 0 && e.isEmpty()) return e.start;
+ if (t == this.getTextRange(e)) return e.end;
+ this.remove(e);
+ if (t) var n = this.insert(e.start, t);
+ else n = e.start;
+ return n
+ }, this.applyDeltas = function(e) {
+ for (var t = 0; t < e.length; t++) {
+ var n = e[t],
+ r = s.fromPoints(n.range.start, n.range.end);
+ n.action == "insertLines" ? this.insertLines(r.start.row, n.lines) : n.action == "insertText" ? this.insert(r.start, n.text) : n.action == "removeLines" ? this._removeLines(r.start.row, r.end.row - 1) : n.action == "removeText" && this.remove(r)
+ }
+ }, this.revertDeltas = function(e) {
+ for (var t = e.length - 1; t >= 0; t--) {
+ var n = e[t],
+ r = s.fromPoints(n.range.start, n.range.end);
+ n.action == "insertLines" ? this._removeLines(r.start.row, r.end.row - 1) : n.action == "insertText" ? this.remove(r) : n.action == "removeLines" ? this._insertLines(r.start.row, n.lines) : n.action == "removeText" && this.insert(r.start, n.text)
+ }
+ }, this.indexToPosition = function(e, t) {
+ var n = this.$lines || this.getAllLines(),
+ r = this.getNewLineCharacter()
+ .length;
+ for (var i = t || 0, s = n.length; i < s; i++) {
+ e -= n[i].length + r;
+ if (e < 0) return {
+ row: i,
+ column: e + n[i].length + r
+ }
+ }
+ return {
+ row: s - 1,
+ column: n[s - 1].length
+ }
+ }, this.positionToIndex = function(e, t) {
+ var n = this.$lines || this.getAllLines(),
+ r = this.getNewLineCharacter()
+ .length,
+ i = 0,
+ s = Math.min(e.row, n.length);
+ for (var o = t || 0; o < s; ++o) i += n[o].length + r;
+ return i + e.column
+ }
+ })
+ .call(u.prototype), t.Document = u
+}), ace.define("ace/lib/lang", ["require", "exports", "module"], function(e, t, n) {
+ "use strict";
+ t.last = function(e) {
+ return e[e.length - 1]
+ }, t.stringReverse = function(e) {
+ return e.split("")
+ .reverse()
+ .join("")
+ }, t.stringRepeat = function(e, t) {
+ var n = "";
+ while (t > 0) {
+ t & 1 && (n += e);
+ if (t >>= 1) e += e
+ }
+ return n
+ };
+ var r = /^\s\s*/,
+ i = /\s\s*$/;
+ t.stringTrimLeft = function(e) {
+ return e.replace(r, "")
+ }, t.stringTrimRight = function(e) {
+ return e.replace(i, "")
+ }, t.copyObject = function(e) {
+ var t = {};
+ for (var n in e) t[n] = e[n];
+ return t
+ }, t.copyArray = function(e) {
+ var t = [];
+ for (var n = 0, r = e.length; n < r; n++) e[n] && typeof e[n] == "object" ? t[n] = this.copyObject(e[n]) : t[n] = e[n];
+ return t
+ }, t.deepCopy = function s(e) {
+ if (typeof e != "object" || !e) return e;
+ var t;
+ if (Array.isArray(e)) {
+ t = [];
+ for (var n = 0; n < e.length; n++) t[n] = s(e[n]);
+ return t
+ }
+ var r = e.constructor;
+ if (r === RegExp) return e;
+ t = r();
+ for (var n in e) t[n] = s(e[n]);
+ return t
+ }, t.arrayToMap = function(e) {
+ var t = {};
+ for (var n = 0; n < e.length; n++) t[e[n]] = 1;
+ return t
+ }, t.createMap = function(e) {
+ var t = Object.create(null);
+ for (var n in e) t[n] = e[n];
+ return t
+ }, t.arrayRemove = function(e, t) {
+ for (var n = 0; n <= e.length; n++) t === e[n] && e.splice(n, 1)
+ }, t.escapeRegExp = function(e) {
+ return e.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
+ }, t.escapeHTML = function(e) {
+ return e.replace(/&/g, "&#38;")
+ .replace(/"/g, "&#34;")
+ .replace(/'/g, "&#39;")
+ .replace(/</g, "&#60;")
+ }, t.getMatchOffsets = function(e, t) {
+ var n = [];
+ return e.replace(t, function(e) {
+ n.push({
+ offset: arguments[arguments.length - 2],
+ length: e.length
+ })
+ }), n
+ }, t.deferredCall = function(e) {
+ var t = null,
+ n = function() {
+ t = null, e()
+ },
+ r = function(e) {
+ return r.cancel(), t = setTimeout(n, e || 0), r
+ };
+ return r.schedule = r, r.call = function() {
+ return this.cancel(), e(), r
+ }, r.cancel = function() {
+ return clearTimeout(t), t = null, r
+ }, r.isPending = function() {
+ return t
+ }, r
+ }, t.delayedCall = function(e, t) {
+ var n = null,
+ r = function() {
+ n = null, e()
+ },
+ i = function(e) {
+ n == null && (n = setTimeout(r, e || t))
+ };
+ return i.delay = function(e) {
+ n && clearTimeout(n), n = setTimeout(r, e || t)
+ }, i.schedule = i, i.call = function() {
+ this.cancel(), e()
+ }, i.cancel = function() {
+ n && clearTimeout(n), n = null
+ }, i.isPending = function() {
+ return n
+ }, i
+ }
+}), ace.define("ace/worker/mirror", ["require", "exports", "module", "ace/document", "ace/lib/lang"], function(e, t, n) {
+ "use strict";
+ var r = e("../document")
+ .Document,
+ i = e("../lib/lang"),
+ s = t.Mirror = function(e) {
+ this.sender = e;
+ var t = this.doc = new r(""),
+ n = this.deferredUpdate = i.delayedCall(this.onUpdate.bind(this)),
+ s = this;
+ e.on("change", function(e) {
+ t.applyDeltas(e.data);
+ if (s.$timeout) return n.schedule(s.$timeout);
+ s.onUpdate()
+ })
+ };
+ (function() {
+ this.$timeout = 500, this.setTimeout = function(e) {
+ this.$timeout = e
+ }, this.setValue = function(e) {
+ this.doc.setValue(e), this.deferredUpdate.schedule(this.$timeout)
+ }, this.getValue = function(e) {
+ this.sender.callback(this.doc.getValue(), e)
+ }, this.onUpdate = function() {}, this.isPending = function() {
+ return this.deferredUpdate.isPending()
+ }
+ })
+ .call(s.prototype)
+}), ace.define("ace/lib/es5-shim", ["require", "exports", "module"], function(e, t, n) {
+ function r() {}
+
+ function w(e) {
+ try {
+ return Object.defineProperty(e, "sentinel", {}), "sentinel" in e
+ } catch (t) {}
+ }
+
+ function H(e) {
+ return e = +e, e !== e ? e = 0 : e !== 0 && e !== 1 / 0 && e !== -1 / 0 && (e = (e > 0 || -1) * Math.floor(Math.abs(e))), e
+ }
+
+ function B(e) {
+ var t = typeof e;
+ return e === null || t === "undefined" || t === "boolean" || t === "number" || t === "string"
+ }
+
+ function j(e) {
+ var t, n, r;
+ if (B(e)) return e;
+ n = e.valueOf;
+ if (typeof n == "function") {
+ t = n.call(e);
+ if (B(t)) return t
+ }
+ r = e.toString;
+ if (typeof r == "function") {
+ t = r.call(e);
+ if (B(t)) return t
+ }
+ throw new TypeError
+ }
+ Function.prototype.bind || (Function.prototype.bind = function(t) {
+ var n = this;
+ if (typeof n != "function") throw new TypeError("Function.prototype.bind called on incompatible " + n);
+ var i = u.call(arguments, 1),
+ s = function() {
+ if (this instanceof s) {
+ var e = n.apply(this, i.concat(u.call(arguments)));
+ return Object(e) === e ? e : this
+ }
+ return n.apply(t, i.concat(u.call(arguments)))
+ };
+ return n.prototype && (r.prototype = n.prototype, s.prototype = new r, r.prototype = null), s
+ });
+ var i = Function.prototype.call,
+ s = Array.prototype,
+ o = Object.prototype,
+ u = s.slice,
+ a = i.bind(o.toString),
+ f = i.bind(o.hasOwnProperty),
+ l, c, h, p, d;
+ if (d = f(o, "__defineGetter__")) l = i.bind(o.__defineGetter__), c = i.bind(o.__defineSetter__), h = i.bind(o.__lookupGetter__), p = i.bind(o.__lookupSetter__);
+ if ([1, 2].splice(0)
+ .length != 2)
+ if (! function() {
+ function e(e) {
+ var t = new Array(e + 2);
+ return t[0] = t[1] = 0, t
+ }
+ var t = [],
+ n;
+ t.splice.apply(t, e(20)), t.splice.apply(t, e(26)), n = t.length, t.splice(5, 0, "XXX"), n + 1 == t.length;
+ if (n + 1 == t.length) return !0
+ }()) Array.prototype.splice = function(e, t) {
+ var n = this.length;
+ e > 0 ? e > n && (e = n) : e == void 0 ? e = 0 : e < 0 && (e = Math.max(n + e, 0)), e + t < n || (t = n - e);
+ var r = this.slice(e, e + t),
+ i = u.call(arguments, 2),
+ s = i.length;
+ if (e === n) s && this.push.apply(this, i);
+ else {
+ var o = Math.min(t, n - e),
+ a = e + o,
+ f = a + s - o,
+ l = n - a,
+ c = n - o;
+ if (f < a)
+ for (var h = 0; h < l; ++h) this[f + h] = this[a + h];
+ else if (f > a)
+ for (h = l; h--;) this[f + h] = this[a + h];
+ if (s && e === c) this.length = c, this.push.apply(this, i);
+ else {
+ this.length = c + s;
+ for (h = 0; h < s; ++h) this[e + h] = i[h]
+ }
+ }
+ return r
+ };
+ else {
+ var v = Array.prototype.splice;
+ Array.prototype.splice = function(e, t) {
+ return arguments.length ? v.apply(this, [e === void 0 ? 0 : e, t === void 0 ? this.length - e : t].concat(u.call(arguments, 2))) : []
+ }
+ }
+ Array.isArray || (Array.isArray = function(t) {
+ return a(t) == "[object Array]"
+ });
+ var m = Object("a"),
+ g = m[0] != "a" || !(0 in m);
+ Array.prototype.forEach || (Array.prototype.forEach = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = arguments[1],
+ s = -1,
+ o = r.length >>> 0;
+ if (a(t) != "[object Function]") throw new TypeError;
+ while (++s < o) s in r && t.call(i, r[s], s, n)
+ }), Array.prototype.map || (Array.prototype.map = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0,
+ s = Array(i),
+ o = arguments[1];
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ for (var u = 0; u < i; u++) u in r && (s[u] = t.call(o, r[u], u, n));
+ return s
+ }), Array.prototype.filter || (Array.prototype.filter = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0,
+ s = [],
+ o, u = arguments[1];
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ for (var f = 0; f < i; f++) f in r && (o = r[f], t.call(u, o, f, n) && s.push(o));
+ return s
+ }), Array.prototype.every || (Array.prototype.every = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0,
+ s = arguments[1];
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ for (var o = 0; o < i; o++)
+ if (o in r && !t.call(s, r[o], o, n)) return !1;
+ return !0
+ }), Array.prototype.some || (Array.prototype.some = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0,
+ s = arguments[1];
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ for (var o = 0; o < i; o++)
+ if (o in r && t.call(s, r[o], o, n)) return !0;
+ return !1
+ }), Array.prototype.reduce || (Array.prototype.reduce = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0;
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ if (!i && arguments.length == 1) throw new TypeError("reduce of empty array with no initial value");
+ var s = 0,
+ o;
+ if (arguments.length >= 2) o = arguments[1];
+ else
+ do {
+ if (s in r) {
+ o = r[s++];
+ break
+ }
+ if (++s >= i) throw new TypeError("reduce of empty array with no initial value")
+ } while (!0);
+ for (; s < i; s++) s in r && (o = t.call(void 0, o, r[s], s, n));
+ return o
+ }), Array.prototype.reduceRight || (Array.prototype.reduceRight = function(t) {
+ var n = F(this),
+ r = g && a(this) == "[object String]" ? this.split("") : n,
+ i = r.length >>> 0;
+ if (a(t) != "[object Function]") throw new TypeError(t + " is not a function");
+ if (!i && arguments.length == 1) throw new TypeError("reduceRight of empty array with no initial value");
+ var s, o = i - 1;
+ if (arguments.length >= 2) s = arguments[1];
+ else
+ do {
+ if (o in r) {
+ s = r[o--];
+ break
+ }
+ if (--o < 0) throw new TypeError("reduceRight of empty array with no initial value")
+ } while (!0);
+ do o in this && (s = t.call(void 0, s, r[o], o, n)); while (o--);
+ return s
+ });
+ if (!Array.prototype.indexOf || [0, 1].indexOf(1, 2) != -1) Array.prototype.indexOf = function(t) {
+ var n = g && a(this) == "[object String]" ? this.split("") : F(this),
+ r = n.length >>> 0;
+ if (!r) return -1;
+ var i = 0;
+ arguments.length > 1 && (i = H(arguments[1])), i = i >= 0 ? i : Math.max(0, r + i);
+ for (; i < r; i++)
+ if (i in n && n[i] === t) return i;
+ return -1
+ };
+ if (!Array.prototype.lastIndexOf || [0, 1].lastIndexOf(0, -3) != -1) Array.prototype.lastIndexOf = function(t) {
+ var n = g && a(this) == "[object String]" ? this.split("") : F(this),
+ r = n.length >>> 0;
+ if (!r) return -1;
+ var i = r - 1;
+ arguments.length > 1 && (i = Math.min(i, H(arguments[1]))), i = i >= 0 ? i : r - Math.abs(i);
+ for (; i >= 0; i--)
+ if (i in n && t === n[i]) return i;
+ return -1
+ };
+ Object.getPrototypeOf || (Object.getPrototypeOf = function(t) {
+ return t.__proto__ || (t.constructor ? t.constructor.prototype : o)
+ });
+ if (!Object.getOwnPropertyDescriptor) {
+ var y = "Object.getOwnPropertyDescriptor called on a non-object: ";
+ Object.getOwnPropertyDescriptor = function(t, n) {
+ if (typeof t != "object" && typeof t != "function" || t === null) throw new TypeError(y + t);
+ if (!f(t, n)) return;
+ var r, i, s;
+ r = {
+ enumerable: !0,
+ configurable: !0
+ };
+ if (d) {
+ var u = t.__proto__;
+ t.__proto__ = o;
+ var i = h(t, n),
+ s = p(t, n);
+ t.__proto__ = u;
+ if (i || s) return i && (r.get = i), s && (r.set = s), r
+ }
+ return r.value = t[n], r
+ }
+ }
+ Object.getOwnPropertyNames || (Object.getOwnPropertyNames = function(t) {
+ return Object.keys(t)
+ });
+ if (!Object.create) {
+ var b;
+ Object.prototype.__proto__ === null ? b = function() {
+ return {
+ __proto__: null
+ }
+ } : b = function() {
+ var e = {};
+ for (var t in e) e[t] = null;
+ return e.constructor = e.hasOwnProperty = e.propertyIsEnumerable = e.isPrototypeOf = e.toLocaleString = e.toString = e.valueOf = e.__proto__ = null, e
+ }, Object.create = function(t, n) {
+ var r;
+ if (t === null) r = b();
+ else {
+ if (typeof t != "object") throw new TypeError("typeof prototype[" + typeof t + "] != 'object'");
+ var i = function() {};
+ i.prototype = t, r = new i, r.__proto__ = t
+ }
+ return n !== void 0 && Object.defineProperties(r, n), r
+ }
+ }
+ if (Object.defineProperty) {
+ var E = w({}),
+ S = typeof document == "undefined" || w(document.createElement("div"));
+ if (!E || !S) var x = Object.defineProperty
+ }
+ if (!Object.defineProperty || x) {
+ var T = "Property description must be an object: ",
+ N = "Object.defineProperty called on non-object: ",
+ C = "getters & setters can not be defined on this javascript engine";
+ Object.defineProperty = function(t, n, r) {
+ if (typeof t != "object" && typeof t != "function" || t === null) throw new TypeError(N + t);
+ if (typeof r != "object" && typeof r != "function" || r === null) throw new TypeError(T + r);
+ if (x) try {
+ return x.call(Object, t, n, r)
+ } catch (i) {}
+ if (f(r, "value"))
+ if (d && (h(t, n) || p(t, n))) {
+ var s = t.__proto__;
+ t.__proto__ = o, delete t[n], t[n] = r.value, t.__proto__ = s
+ } else t[n] = r.value;
+ else {
+ if (!d) throw new TypeError(C);
+ f(r, "get") && l(t, n, r.get), f(r, "set") && c(t, n, r.set)
+ }
+ return t
+ }
+ }
+ Object.defineProperties || (Object.defineProperties = function(t, n) {
+ for (var r in n) f(n, r) && Object.defineProperty(t, r, n[r]);
+ return t
+ }), Object.seal || (Object.seal = function(t) {
+ return t
+ }), Object.freeze || (Object.freeze = function(t) {
+ return t
+ });
+ try {
+ Object.freeze(function() {})
+ } catch (k) {
+ Object.freeze = function(t) {
+ return function(n) {
+ return typeof n == "function" ? n : t(n)
+ }
+ }(Object.freeze)
+ }
+ Object.preventExtensions || (Object.preventExtensions = function(t) {
+ return t
+ }), Object.isSealed || (Object.isSealed = function(t) {
+ return !1
+ }), Object.isFrozen || (Object.isFrozen = function(t) {
+ return !1
+ }), Object.isExtensible || (Object.isExtensible = function(t) {
+ if (Object(t) === t) throw new TypeError;
+ var n = "";
+ while (f(t, n)) n += "?";
+ t[n] = !0;
+ var r = f(t, n);
+ return delete t[n], r
+ });
+ if (!Object.keys) {
+ var L = !0,
+ A = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"],
+ O = A.length;
+ for (var M in {
+ toString: null
+ }) L = !1;
+ Object.keys = function I(e) {
+ if (typeof e != "object" && typeof e != "function" || e === null) throw new TypeError("Object.keys called on a non-object");
+ var I = [];
+ for (var t in e) f(e, t) && I.push(t);
+ if (L)
+ for (var n = 0, r = O; n < r; n++) {
+ var i = A[n];
+ f(e, i) && I.push(i)
+ }
+ return I
+ }
+ }
+ Date.now || (Date.now = function() {
+ return (new Date)
+ .getTime()
+ });
+ var _ = " \n \f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff";
+ if (!String.prototype.trim || _.trim()) {
+ _ = "[" + _ + "]";
+ var D = new RegExp("^" + _ + _ + "*"),
+ P = new RegExp(_ + _ + "*$");
+ String.prototype.trim = function() {
+ return String(this)
+ .replace(D, "")
+ .replace(P, "")
+ }
+ }
+ var F = function(e) {
+ if (e == null) throw new TypeError("can't convert " + e + " to object");
+ return Object(e)
+ }
+}) \ No newline at end of file
diff --git a/doc/runtimetests-overview.md b/doc/runtimetests-overview.md
new file mode 100644
index 0000000..1308586
--- /dev/null
+++ b/doc/runtimetests-overview.md
@@ -0,0 +1,41 @@
+# Overview of the ANTLR Runtime Test Suite
+
+An important part of ANTLR4 is its runtime test suite, which consist of 2 subparts:
+
+* Tests for the tool itself
+* Tests for the ANTLR runtime
+
+Usually the tests are executed while compiling and installing an ANTLR4 jar from source code. The command for that is simply:
+
+```bash
+$ mvn install
+```
+
+to be executed in the root of the ANTLR4 repository. More details about this can be found in [Building ANTLR](building-antlr.md).
+
+However, you don't need to run the installation again and again just to run the tests. Instead use
+
+```bash
+$ mvn test
+```
+
+to only trigger testing. You can find all runtime tests in the [runtime-testsuite/resources/org/antlr/v4/test/runtime](../runtime-testsuite/resources/org/antlr/v4/test/runtime) subfolder (tool tests under [tool-testsuite/test/org/antlr/v4/test/tool](../tool-testsuite/test/org/antlr/v4/test/tool)). The tool tests are just a bunch of Java test cases that test the tool's internal behavior (e.g. for code generation). We focus on the runtime tests here.
+
+The underlying process of running the tests is quite a complicated setup to cater especially for a flexible test specification that can run with different target runtimes. Everything runs in Java, except for the actual target runtime tests. Runtime tests run first, followed by the tool tests. If there was a test failure in the first step, the tool tests are not executed, however. These are the steps involved when running the runtime tests:
+
+* Generate Java JUnit test cases from the test templates, once for each target (C++, C#, Python, Java, Javascript atm.).
+* These test cases generate grammar files when executed and run the target specific parser generation step, including compiling a binary, if necessary (e.g. for C++ and C#).
+* Finally run the compiled test module using the input specified in the test template. The output (usually a token or parse tree dump) is then compared against the expected output, specified in the test template as well. This also includes any error messages written to the console.
+
+## Generating JUnit Tests
+
+The test specification part makes heavy use of the StringTemplate engine to allow defining target language agnostic tests. For that all tests are described in template (`stg`) files. You can find them in the [templates](../runtime-testsuite/resources/org/antlr/v4/test/runtime/templates) subfolder of the runtime tests folder. Read more about the folder structure in the [antlr-project-testing.md](antlr-project-testing.md) file. As lined out there you have to run
+
+```bash
+$ mvn -Pgen generate-test-sources
+```
+everytime you change any of the test templates or your target language specific template (which is used to translate certain text to your specific language). And a small hint: this command can be executed from the ANTLR source root as well. No need to dig into a subfolder.
+
+## Running the Generated Tests
+
+After generation you can run the tests as written above (`mvn install` or `mvn test`, both recompile ANTLR if necessary), which takes about 40 minutes for the full set (of which 30 mins are alone consumed by the C++ target tests). Which tests actually run is controlled by the [runtime tests pom.xml file](../runtime-testsuite/pom.xml). Look for the `maven-surefire-plugin` plugin entry and especially its includes. If you ever want to run tests only for a specific target, comment out all other `<include>` elements. For a specific test change the wildcard to that specific test name. This is especially helpful when debugging a test (e.g. when it fails) or when creating/changing tests. Additionally, some targets require to install additional dependencies you may not want to add to your box (e.g. mono, python 3.5) just to run e.g. the Java or C++ tests.
diff --git a/doc/swift-target.md b/doc/swift-target.md
new file mode 100644
index 0000000..69eb88e
--- /dev/null
+++ b/doc/swift-target.md
@@ -0,0 +1,99 @@
+# ANTLR4 Language Target, Runtime for Swift
+
+## Install ANTLR4
+
+Make sure you have the ANTLR
+installed.[The getting started guide](getting-started.md) should get
+you started.
+
+## Create a Swift lexer or parser
+This is pretty much the same as creating a Java lexer or parser,
+except you need to specify the language target, for example:
+
+```
+$ antlr4 -Dlanguage=Swift MyGrammar.g4
+```
+For a full list of antlr4 tool options, please visit the
+[tool documentation page](tool-options.md).
+
+## Build your Swift project with ANTLR runtime
+
+The following instructions are assuming Xcode as the IDE:
+
+* __Add parser/lexer to project__. Make sure the parsers/lexers
+generated in __step 2__ are added to the project. To do this, you can
+drag the generated files from Finder to the Xcode IDE. Remember to
+check __Copy items if needed__ to make sure the files are actually
+moved into the project folder instead of symbolic links (see the
+screenshot below). After moving you will be able to see your files in
+the project navigator. But when you open one of the files, you will
+see Xcode complaining the module "Antlr4" could not be found at the
+import statement. This is expected, since we still need the ANTLR
+Swift runtime for those missing symbols.
+
+<img src=images/dragfile.png width="500">
+
+* __Download ANTLR runtime__. Due to unstable ABI of Swift language,
+there will not be a single "library" for the Swift ANTLR runtime for
+now. To get Swift ANTLR runtime, clone the ANTLR repository. Open it
+in finder. From the root directory of the repo, go to runtime/Swift
+folder. You will see the Xcode project manifest file:
+__Antlr4.xcodeproj__.
+
+* __Import ANTLR Swift runtime into project__. Drag Antlr4.xcodeproj
+into your project, after this is done, your Xcode project navigator
+will be something like the screenshot below. In this case, your own
+project is "Smalltalk", and you will be able to see the
+Antlr4.xcodeproj shown as a contained project. The error message will
+still be there, that's because we still need to tell Xcode how to find
+the runtime.
+
+<img src=images/xcodenav.png width="300">
+
+* __Build ANTLR runtime__. By expanding the "Products" folder in the
+inner project (Antlr4.xcodeproj), you will see two Antlr4.framework
+files. ".framework" file is the swift version of ".jar", ".a" as in
+JAVA, C/C++ Initially those two files should be red, that's because
+they are not built. To build, click the "target selection" button
+right next to your Xcode run button. And in the drop down select the
+target you want to build. And you will see the two Antlr4.framework
+files are for iOS and OSX, as shown below. After target selection,
+press "CMD+B", and Xcode will build the framework for you. Then you
+will see one of the frameworks become black.
+
+<img src=images/targetselection.png width="500">
+
+* __Add dependencies__. Simply adding ANTLR Swift runtime and build
+the artifact is not enough. You still need to specify
+dependencies. Click your own project (Smalltalk), and you will see
+project setting page. Go to "Build Phase", and inside it make sure
+your ANTLR Swift runtime framework is added to both "__Target
+Dependencies__" and "__Link Binary With Libraries__" sections, as
+shown below. After correctly added dependencies, the error message for
+importing library will be gone.
+
+<img src=images/xcodedep.png width="800">
+
+## Example playground
+
+The Swift runtime includes an Xcode playground to get started with.
+
+First go to the ANTLR4 repository, and open
+`runtime/Swift/Antlr4.xcworkspace` in Xcode. Select "Antlr4 OSX > My
+Mac" as the build target, and build the project as normal. The
+playground should then be active.
+
+The playground includes a simple grammar called "Hello", and an
+example for walking the parse tree. You should see in the playground
+output that it is printing messages for each node in the parse tree as
+it walks.
+
+The grammar is defined in the playground's `Resources/Hello.g4`. The
+parser was generated from the grammar using ANTLR like this:
+
+```
+antlr4 -Dlanguage=Swift -visitor -o ../Sources/Autogen Hello.g4
+```
+
+The example tree walker is in Sources/HelloWalker.swift.
+
diff --git a/doc/targets.md b/doc/targets.md
new file mode 100644
index 0000000..418630b
--- /dev/null
+++ b/doc/targets.md
@@ -0,0 +1,20 @@
+# Runtime Libraries and Code Generation Targets
+
+This page lists the available and upcoming ANTLR runtimes. Please note that you won't find here language specific code generators. This is because there is only one tool, written in Java, which is able to generate lexer and parser code for all targets, through command line options. The tool can be invoked from the command line, or any integration plugin to popular IDEs and build systems: Eclipse, IntelliJ, Visual Studio, Maven. So whatever your environment and target is, you should be able to run the tool and produce the code in the targeted language. As of writing, the available targets are the following:
+
+* [Java](java-target.md). The [ANTLR v4 book](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference) has a decent summary of the runtime library. We have added a useful XPath feature since the book was printed that lets you select bits of parse trees. See [Runtime API](http://www.antlr.org/api/Java/index.html) and [Getting Started with ANTLR v4](getting-started.md)
+* [C#](csharp-target.md)
+* [Python](python-target.md) (2 and 3)
+* [JavaScript](javascript-target.md)
+* [Go](go-target.md)
+* [C++](cpp-target.md)
+* [Swift](swift-target.md)
+
+## Target feature parity
+
+New features generally appear in the Java target and then migrate to the other targets, but these other targets don't always get updated in the same overall tool release. This section tries to identify features added to Java that have not been added to the other targets.
+
+|Feature|Java|C&sharp;|Python2|Python3|JavaScript|Go|C++|Swift|
+|---|---|---|---|---|---|---|---|---|
+|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|
+
diff --git a/doc/tool-options.md b/doc/tool-options.md
new file mode 100644
index 0000000..fe5d4a3
--- /dev/null
+++ b/doc/tool-options.md
@@ -0,0 +1,161 @@
+# ANTLR Tool Command Line Options
+
+If you invoke the ANTLR tool without command line arguments, you’ll get a help message:
+
+```bash
+$ antlr4
+ANTLR Parser Generator Version 4.5
+ -o ___ specify output directory where all output is generated
+ -lib ___ specify location of grammars, tokens files
+ -atn generate rule augmented transition network diagrams
+ -encoding ___ specify grammar file encoding; e.g., euc-jp
+ -message-format ___ specify output style for messages in antlr, gnu, vs2005
+ -long-messages show exception details when available for errors and warnings
+ -listener generate parse tree listener (default)
+ -no-listener don't generate parse tree listener
+ -visitor generate parse tree visitor
+ -no-visitor don't generate parse tree visitor (default)
+ -package ___ specify a package/namespace for the generated code
+ -depend generate file dependencies
+ -D<option>=value set/override a grammar-level option
+ -Werror treat warnings as errors
+ -XdbgST launch StringTemplate visualizer on generated code
+ -XdbgSTWait wait for STViz to close before continuing
+ -Xforce-atn use the ATN simulator for all predictions
+ -Xlog dump lots of logging info to antlr-timestamp.log
+```
+
+Here are more details on the options:
+
+## `-o outdir`
+
+ANTLR generates output files in the current directory by default. This option specifies the output directory where ANTLR should generate parsers, listeners, visitors, and tokens files.
+
+```bash
+$ antlr4 -o /tmp T.g4
+$ ls /tmp/T*
+/tmp/T.tokens /tmp/TListener.java
+/tmp/TBaseListener.java /tmp/TParser.java
+```
+
+## `-lib libdir`
+
+When looking for tokens files and imported grammars, ANTLR normally looks in the current directory. This option specifies which directory to look in instead. It is only used for resolving grammar references for the import statement and the tokenVocab option. The path to the primary grammar must always be fully specified.
+
+$ cat /tmp/B.g4
+
+parser grammar B;
+
+x : ID ;
+
+$ cat A.g4
+
+grammar A;
+
+import B;
+
+s : x ;
+
+ID : [a-z]+ ;
+
+$ antlr4 -lib /tmp A.g4
+
+## `-atn`
+
+Generate DOT graph files that represent the internal ATN (augmented transition network) data structures that ANTLR uses to represent grammars. The files come out as Grammar.rule .dot. If the grammar is a combined grammar, the lexer rules are named Grammar Lexer.rule .dot.
+
+$ cat A.g4
+
+grammar A;
+
+s : b ;
+
+b : ID ;
+
+ID : [a-z]+ ;
+
+$ antlr4 -atn A.g4
+
+$ ls *.dot
+
+A.b.dot A.s.dot ALexer.ID.dot
+
+## `-encoding encodingname`
+
+By default ANTLR loads grammar files using the UTF-8 encoding, which is a very common character file encoding that degenerates to ASCII for characters that fit in one byte. There are many character file encodings from around the world. If that grammar file is not the default encoding for your locale, you need this option so that ANTLR can properly interpret grammar files. This does not affect the input to the generated parsers, just the encoding of the grammars themselves.
+
+## `-message-format format`
+
+ANTLR generates warning and error messages using templates from directory tool/resources/org/antlr/v4/tool/templates/messages/formats. By default, ANTLR uses the antlr.stg (StringTemplate group) file. You can change this to gnu or vs2005 to have ANTLR generate messages appropriate for Emacs or Visual Studio. To make your own called X, create resource org/antlr/v4/tool/templates/messages/formats/ X and place it in the CLASSPATH.
+
+## `-listener`
+
+This option tells ANTLR to generate a parse tree listener and is the default.
+
+## `-no-listener`
+
+This option tells ANTLR not to generate a parse tree listener.
+
+## `-visitor`
+
+ANTLR does not generate parse tree visitors by default. This option turns that feature on. ANTLR can generate both parse tree listeners and visitors; this option and -listener aren’t mutually exclusive.
+
+## `-no-visitor`
+
+Tell ANTLR not to generate a parse tree visitor; this is the default.
+
+## `-package`
+
+Use this option to specify a package or namespace for ANTLR-generated files. Alternatively, you can add a @header {...} action but that ties the grammar to a specific language. If you use this option and @header, make sure that the header action does not contain a package specification otherwise the generated code will have two of them.
+
+## `-depend`
+
+Instead of generating a parser and/or lexer, generate a list of file dependencies, one per line. The output shows what each grammar depends on and what it generates. This is useful for build tools that need to know ANTLR grammar dependencies. Here’s an example:
+
+```bash
+$ antlr4 -depend T.g
+T.g: A.tokens
+TParser.java : T.g
+T.tokens : T.g
+TLexer.java : T.g
+TListener.java : T.g
+TBaseListener.java : T.g
+```
+
+If you use -lib libdir with -depend and grammar option tokenVocab=A, then the dependencies include the library path as well: T.g: libdir/A.tokens. The output is also sensitive to the -o outdir option: outdir/TParser.java : T.g.
+
+## `-D<option>=value`
+
+Use this option to override or set a grammar-level option in the specified grammar or grammars. This option is useful for generating parsers in different languages without altering the grammar itself. (I expect to have other targets in the near future.)
+
+```bash
+$ antlr4 -Dlanguage=Java T.g4 # default
+$ antlr4 -Dlanguage=C T.g4
+error(31): ANTLR cannot generate C code as of version 4.0b3
+```
+
+## `-Werror`
+
+As part of a large build, ANTLR warning messages could go unnoticed. Turn on this option to have warnings treated as errors, causing the ANTLR tool to report failure back to the invoking commandline shell.
+There are also some extended options that are useful mainly for debugging ANTLR itself:
+
+## `-Xsave-lexer`
+
+ANTLR generates both a parser and a lexer from a combined grammar. To create the lexer, ANTLR extracts a lexer grammar from the combined grammar. Sometimes it’s useful to see what that looks like if it’s not clear what token rules ANTLR is creating. This does not affect the generated parsers or lexers.
+
+## `-XdbgST`
+
+For those building a code generation target, this option brings up a window showing the generated code and the templates used to generate that code. It invokes the StringTemplate inspector window.
+
+## `-Xforce-atn`
+
+ANTLR normally builds traditional “switch on token type” decisions where possible (one token of lookahead is sufficient to distinguish between all alternatives in a decision). To force even these simple decisions into the adaptive LL(*) mechanism, use this option.
+
+## `-Xlog`
+
+This option creates a log file containing lots of information messages from ANTLR as it processes your grammar. If you would like to see how ANTLR translates your left-recursive rules, turn on this option and look in the resulting log file.
+
+```bash
+$ antlr4 -Xlog T.g4
+wrote ./antlr-2012-09-06-17.56.19.log
+```
diff --git a/doc/tree-matching.md b/doc/tree-matching.md
new file mode 100644
index 0000000..f4c6d27
--- /dev/null
+++ b/doc/tree-matching.md
@@ -0,0 +1,156 @@
+# Parse Tree Matching and XPath
+
+*Since ANTLR 4.2*
+
+ANTLR 4 introduced a visitor and listener mechanism that lets you implement DOM visiting or SAX-analogous event processing of tree nodes. This works great. For example, if all you care about is looking at Java method declarations, grab the `Java.g4` file and then override methodDeclaration in `JavaBaseListener`. From there, a `ParseTreeWalker` can trigger calls to your overridden method as it walks the tree. Easy things are easy.
+
+This mechanism works more or less on a node-level basis. In other words, for every method declaration subtree root, your `methodDeclaration()` would get called. There are many situations where we care more about subtrees not just nodes. We might want to:
+
+* Collect method declarations within a particular context (i.e., nested within another method) or methods with specific structure or specific types (e.g., `void <ID>() { }`). We'll combine `XPath` and tree pattern matching for this.
+* Group translation operations by patterns in the tree rather than spreading operations across listener event methods.
+* Get a list of all assignments anywhere in the tree. It's much easier to say *go find me all "... = ... ;" subtrees* rather than creating a class just to get a listener method for rule assignment and then passing the listener to the parse tree walker.
+
+The other important idea here is that, since we're talking about parse trees not abstract syntax trees, we can use concrete patterns instead of tree syntax. For example, we can say `x = 0;` instead of AST `(= x 0)` where the `;` would probably stripped before it went into the AST.
+
+## Parse tree patterns
+
+To test a subtree to see if it has a particular structure, we use a tree pattern. We also often want to extract descendents from the subtree based upon the structure. A very simple example is checking to see if a subtree matches an assignment statement. The pattern might look like the following in your language:
+
+```
+<ID> = <expr>;
+```
+
+where "tags" in angle brackets represent either token or rule references in the associated grammar. ANTLR converts that string to a parse tree with special nodes that represent any token `ID` and rule `expr` subtree. To create this parse tree, the pattern matching compiler needs to know which rule in the grammar the pattern conforms to. In this case it might be statement. Here is how we could test a tree, `t`, to see if it matches that pattern:
+
+```java
+ParseTree t = ...; // assume t is a statement
+ParseTreePattern p = parser.compileParseTreePattern("<ID> = <expr>;", MyParser.RULE_statement);
+ParseTreeMatch m = p.match(t);
+if ( m.succeeded() ) {...}
+```
+
+We can also test for specific expressions or token values. For example, the following checks to see if `t` is an expression consisting of an identifier added to 0:
+
+```java
+ParseTree t = ...; // assume t is an expression
+ParseTreePattern p = parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
+ParseTreeMatch m = p.match(t);
+```
+
+We can also ask the `ParseTreeMatch` result to pull out the token matched to the `<ID>` tag:
+
+```java
+String id = m.get("ID");
+```
+
+You can change the tag delimiters using a method on the pattern matcher:
+
+```java
+ParseTreePatternMatcher m = new ParseTreePatternMatcher();
+m.setDelimiters("<<", ">>", "$"); // $ is the escape character
+```
+
+This would allow pattern `<<ID>> = <<expr>> ;$<< ick $>>` to be interpreted as elements: `ID`, ` = `, `expr`, and ` ;<< ick >>`.
+
+```java
+String xpath = "//blockStatement/*";
+String treePattern = "int <Identifier> = <expression>;";
+ParseTreePattern p =
+parser.compileParseTreePattern(treePattern,
+JavaParser.RULE_localVariableDeclarationStatement);
+List<ParseTreeMatch> matches = p.findAll(tree, xpath);
+```
+
+### Pattern labels
+
+The tree pattern matcher tracks the nodes in the tree at matches against the tags in a tree pattern. That way we can use the `get()` and `getAll()` methods to retrieve components of the matched subtree. For example, for pattern `<ID>`, `get("ID")` returns the node matched for that `ID`. If more than one node matched the specified token or rule tag, only the first match is returned. If there is no node associated with the label, this returns null.
+
+You can also label the tags with identifiers. If the label is the name of a parser rule or token in the grammar, the resulting list from `getAll()` (or node from `get()`) will contain both the parse trees matching rule or tags explicitly labeled with the label and the complete set of parse trees matching the labeled and unlabeled tags in the pattern for the parser rule or token. For example, if label is `foo`, the result will contain all of the following.
+
+* Parse tree nodes matching tags of the form `<foo:anyRuleName>` and `<foo:AnyTokenName>`.
+* Parse tree nodes matching tags of the form `<anyLabel:foo>`.
+* Parse tree nodes matching tags of the form `<foo>`.
+
+### Creating parse trees with the pattern matcher
+
+You can use the parse tree pattern compiler to create parse trees for partial input fragments. Just use method `ParseTreePattern.getPatternTree()`.
+
+See [TestParseTreeMatch.java](https://github.com/antlr/antlr4/blob/master/tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java).
+
+## Using XPath to identify parse tree node sets
+
+XPath paths are strings representing nodes or subtrees you would like to select within a parse tree. It's useful to collect subsets of the parse tree to process. For example you might want to know where all assignments are in a method or all variable declarations that are initialized.
+
+A path is a series of node names with the following separators.
+
+| Expression |Description|
+|---------|-----------|
+|nodename| Nodes with the token or rule name nodename
+|/| The root node but `/X` is the same as `X` since the tree you pass to xpath is assumed to be the root. Because it looks better, start all of your patterns with `/` (or `//` below).|
+|//| All nodes in the tree that match the next element in the path. E.g., `//ID` finds all `ID` token nodes in the tree.|
+|!| Any node except for the next element in the path. E.g., `/classdef/!field` should find all children of `classdef` root node that are not `field` subtrees.|
+
+Examples:
+
+```
+/prog/func, -> all funcs under prog at root
+/prog/*, -> all children of prog at root
+/*/func, -> all func kids of any root node
+prog, -> prog must be root node
+/prog, -> prog must be root node
+/*, -> any root
+*, -> any root
+//ID, -> any ID in tree
+//expr/primary/ID, -> any ID child of a primary under any expr
+//body//ID, -> any ID under a body
+//'return', -> any 'return' literal in tree
+//primary/*, -> all kids of any primary
+//func/*/stat, -> all stat nodes grandkids of any func node
+/prog/func/'def', -> all def literal kids of func kid of prog
+//stat/';', -> all ';' under any stat node
+//expr/primary/!ID, -> anything but ID under primary under any expr node
+//expr/!primary, -> anything but primary under any expr node
+//!*, -> nothing anywhere
+/!*, -> nothing at root
+```
+
+Given a parse tree, the typical mechanism for visiting those nodes is the following loop:
+
+```java
+for (ParseTree t : XPath.findAll(tree, xpath, parser) ) {
+ ... process t ...
+}
+```
+
+E.g., here is a general formula for making a list of the text associated with every node identified by a path specification:
+
+```java
+List<String> nodes = new ArrayList<String>();
+for (ParseTree t : XPath.findAll(tree, xpath, parser) ) {
+ if ( t instanceof RuleContext) {
+ RuleContext r = (RuleContext)t;
+ nodes.add(parser.getRuleNames()[r.getRuleIndex()]); }
+ else {
+ TerminalNode token = (TerminalNode)t;
+ nodes.add(token.getText());
+ }
+}
+```
+
+## Combining XPath and tree pattern matching
+
+Naturally you can combine the use of XPath to find a set of root nodes and then use tree pattern matching to identify a certain subset of those and extract component nodes.
+
+```java
+// assume we are parsing Java
+ParserRuleContext tree = parser.compilationUnit();
+String xpath = "//blockStatement/*"; // get children of blockStatement
+String treePattern = "int <Identifier> = <expression>;";
+ParseTreePattern p =
+ parser.compileParseTreePattern(treePattern,
+ ExprParser.RULE_localVariableDeclarationStatement);
+List<ParseTreeMatch> matches = p.findAll(tree, xpath);
+System.out.println(matches);
+```
+
+See [TestXPath.java](https://github.com/antlr/antlr4/blob/master/tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java).
diff --git a/doc/wildcard.md b/doc/wildcard.md
new file mode 100644
index 0000000..f3d1c3a
--- /dev/null
+++ b/doc/wildcard.md
@@ -0,0 +1,228 @@
+# Wildcard Operator and Nongreedy Subrules
+
+EBNF subrules like `(...)?`, `(...)*` and `(...)+` are greedy—They consume as much input as possible, but sometimes that’s not what’s needed. Constructs like `.*` consume until the end of the input in the lexer and sometimes in the parser. We want that loop to be nongreedy so we need to use different syntax: `.*?` borrowed from regular expression notation. We can make any subrule that has a `?`, `*`, or `+` suffix nongreedy by adding another `?` suffix. Such nongreedy subrules are allowed in both the parser and the lexer, but they are used much more frequently in the lexer.
+
+## Nongreedy Lexer Subrules
+
+Here’s the very common C-style comment lexer rule that consumes any characters until it sees the trailing `*/`:
+
+```
+COMMENT : '/*' .*? '*/' -> skip ; // .*? matches anything until the first */
+```
+
+Here’s another example that matches strings that allow \" as an escaped quote character:
+
+```
+grammar Nongreedy;
+s : STRING+ ;
+STRING : '"' ( '\\"' | . )*? '"' ; // match "foo", "\"", "x\"\"y", ...
+WS : [ \r\t\n]+ -> skip ;
+```
+
+```bash
+$ antlr4 Nongreedy.g4
+$ javac Nongreedy*.java
+$ grun Nongreedy s -tokens
+=> "quote:\""
+=> EOF
+<= [@0,0:9='"quote:\""',<1>,1:0]
+ [@1,11:10='<EOF>',<-1>,2:0]
+```
+
+Nongreedy subrules should be used sparingly because they complicate the recognition problem and sometimes make it tricky to decipher how the lexer will match text. Here is how the lexer chooses token rules:
+
+<ol>
+<li>The primary goal is to match the lexer rule that recognizes the most input characters.
+
+```
+INT : [0-9]+ ;
+DOT : '.' ; // match period
+FLOAT : [0-9]+ '.' ; // match FLOAT upon '34.' not INT then DOT
+```
+</li>
+<li>
+If more than one lexer rule matches the same input sequence, the priority goes to the rule occurring first in the grammar file.
+
+```
+DOC : '/**' .*? '*/' ; // both rules match /** foo */, resolve to DOC
+CMT : '/*' .*? '*/' ;
+```
+</li>
+<li>
+Nongreedy subrules match the fewest number of characters that still allows the surrounding lexical rule to match.
+
+```
+/** Match anything except \n inside of double angle brackets */
+STRING : '<<' ~'\n'*? '>>' ; // Input '<<foo>>>>' matches STRING then END
+END : '>>' ;
+```
+</li>
+<li>
+<p>After crossing through a nongreedy subrule within a lexical rule, all decision-making from then on is "first match wins."
+</p>
+<p>
+For example, literal `ab` in rule right-hand side (grammar fragment) `.*? (’a’|’ab’)` is dead code and can never be matched. If the input is ab, the first alternative, ’a’, matches the first character and therefore succeeds. (’a’|’ab’) by itself on the right-hand side of a rule properly matches the second alternative for input ab. This quirk arises from a nongreedy design decision that’s too complicated to go into here.</p>
+<li>
+</ol>
+
+To illustrate the different ways to use loops within lexer rules, consider the following grammar, which has three different action-like tokens (using different delimiters so that they all fit within one example grammar).
+
+```
+ACTION1 : '{' ( STRING | . )*? '}' ; // Allows {"foo}
+ACTION2 : '[' ( STRING | ~'"' )*? ']' ; // Doesn't allow ["foo]; nongreedy *?
+ACTION3 : '<' ( STRING | ~[">] )* '>' ; // Doesn't allow <"foo>; greedy *
+STRING : '"' ( '\\"' | . )*? '"' ;
+```
+
+Rule `ACTION1` allows unterminated strings, such as `"foo`, because input `"foo` matches to the wildcard part of the loop. It doesn’t have to go into rule `STRING` to match a quote. To fix that, rule `ACTION2` uses `~’"’` to match any character but the quote. Expression `~’"’` is still ambiguous with the `’]’` that ends the rule, but the fact that the subrule is nongreedy means that the lexer will exit the loop upon a right square bracket. To avoid a nongreedy subrule, make the alternatives explicit. Expression `~[">]` matches anything but the quote and right angle bracket. Here’s a sample run:
+
+```bash
+$ antlr4 Actions.g4
+$ javac Actions*.java
+$ grun Actions tokens -tokens
+=> {"foo}
+=> EOF
+<= [@0,0:5='{"foo}',<1>,1:0]
+ [@1,7:6='<EOF>',<-1>,2:0]
+=> $ grun Actions tokens -tokens
+=> ["foo]
+=> EOF
+<= line 1:0 token recognition error at: '["foo]
+ '
+ [@0,7:6='<EOF>',<-1>,2:0]
+=> $ grun Actions tokens -tokens
+=> <"foo>
+=> EOF
+<= line 1:0 token recognition error at: '<"foo>
+ '
+ [@0,7:6='<EOF>',<-1>,2:0]
+```
+
+## Nongreedy Parser Subrules
+
+Nongreedy subrules and wildcard are also useful within parsers to do *fuzzy parsing* where the goal is to extract information from an input file without having to specify the full grammar. In contrast to nongreedy lexer decision-making, parsers always make globally correct decisions. A parser never makes a decision that will ultimately cause valid input to fail later on during the parse. Here is the central idea: Nongreedy parser subrules match the shortest sequence of tokens that preserves a successful parse for a valid input sentence.
+
+For example, here are the key rules that demonstrate how to pull integer constants out of an arbitrary Java file:
+
+```
+grammar FuzzyJava;
+
+/** Match anything in between constant rule matches */
+file : .*? (constant .*?)+ ;
+
+/** Faster alternate version (Gets an ANTLR tool warning about
+ * a subrule like .* in parser that you can ignore.)
+ */
+altfile : (constant | .)* ; // match a constant or any token, 0-or-more times
+
+/** Match things like "public static final SIZE" followed by anything */
+constant
+ : 'public' 'static' 'final' 'int' Identifier
+ {System.out.println("constant: "+$Identifier.text);}
+ ;
+
+Identifier : [a-zA-Z_$] [a-zA-Z_$0-9]* ; // simplified
+```
+
+The grammar contains a greatly simplified set of lexer rules from a real Java lexer; the whole file about 60 lines. The recognizer still needs to handle string and character constants as well as comments so it doesn’t get out of sync, trying to match a constant inside of the string for example. The only unusual lexer rule performs “match any character not matched by another lexer rule” functionality:
+
+```
+OTHER : . -> skip ;
+```
+
+This catchall lexer rule and the `.*?` subrule in the parser are the critical ingredients for fuzzy parsing.
+
+Here’s a sample file that we can run into the fuzzy parser:
+
+```java
+import java.util.*;
+public class C {
+ public static final int A = 1;
+ public static final int B = 1;
+ public void foo() { }
+ public static final int C = 1;
+}
+```
+
+And here’s the build and test sequence:
+
+```bash
+$ antlr4 FuzzyJava.g4
+$ javac FuzzyJava*.java
+$ grun FuzzyJava file C.java
+constant: A
+constant: B
+constant: C
+```
+
+Notice that it totally ignores everything except for the `public static final int` declarations. This all happens with only two parser rules.
+
+Now let's try matching some simple class defs w/o having to build parser rules for the junk inside. Here want to catch just `A` and `B`:
+
+```
+class A {
+ String name = "parrt";
+}
+
+class B {
+ int x;
+ int getDubX() {
+ return 2*x;
+ }
+}
+```
+
+This grammar does it.
+
+```
+grammar Island;
+file : clazz* ;
+clazz : 'class' ID '{' ignore '}' ;
+ignore : (method|.)*? ;
+method : type ID '()' block ;
+type : 'int' | 'void' ;
+block : '{' (block | .)*? '}' ;
+ID : [a-zA-Z] [a-zA-Z0-9]* ;
+WS : [ \r\t\n]+ -> skip ;
+ANY : . ;
+```
+
+You get:
+
+<img src=images/nonnested-fuzzy.png width=450>
+
+Now let's try some nested classes
+
+```
+class A {
+ String name = "parrt";
+ class Nested {
+ any filthy shite we want in here { }}}}}}
+ }
+}
+
+class B {
+ int x;
+ int getDubX() {
+ return 2*x;
+ }
+}
+
+```
+
+```
+grammar Island;
+file : clazz* ;
+clazz : 'class' ID '{' ignore '}' ;
+ignore : (method|clazz|.)*? ; // <- only change is to add clazz alt here
+method : type ID '()' block ;
+type : 'int' | 'void' ;
+block : '{' (block | .)*? '}' ;
+ID : [a-zA-Z] [a-zA-Z0-9]* ;
+WS : [ \r\t\n]+ -> skip ;
+ANY : . ;
+```
+
+You get:
+
+<img src=images/nested-fuzzy.png width=600> \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e8cb3f6..f2ba6ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,9 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -7,7 +13,7 @@
</parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
+ <version>4.6</version>
<packaging>pom</packaging>
<name>ANTLR 4</name>
@@ -30,7 +36,7 @@
<developers>
<developer>
<name>Terence Parr</name>
- <url>http://antlr.org/wiki/display/~admin/Home</url>
+ <url>http://parrt.cs.usfca.edu</url>
<roles>
<role>Project lead - ANTLR</role>
</roles>
@@ -49,6 +55,12 @@
</roles>
</developer>
<developer>
+ <name>Peter Boyer</name>
+ <roles>
+ <role>Developer - Go</role>
+ </roles>
+ </developer>
+ <developer>
<name>Jim Idle</name>
<email>jimi@idle.ws</email>
<url>http://www.linkedin.com/in/jimidle</url>
@@ -56,6 +68,12 @@
<role>Developer - Maven Plugin</role>
</roles>
</developer>
+ <developer>
+ <name>Mike Lischke</name>
+ <roles>
+ <role>Developer - C++ Target</role>
+ </roles>
+ </developer>
</developers>
<modules>
@@ -63,6 +81,8 @@
<module>tool</module>
<module>antlr4-maven-plugin</module>
<module>tool-testsuite</module>
+ <module>runtime-testsuite/annotations</module>
+ <module>runtime-testsuite/processors</module>
<module>runtime-testsuite</module>
</modules>
@@ -70,8 +90,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<antlr.testinprocess>true</antlr.testinprocess>
- <maven.compiler.source>1.6</maven.compiler.source>
- <maven.compiler.target>1.6</maven.compiler.target>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<mailingLists>
@@ -99,7 +119,6 @@
<directory>resources</directory>
</resource>
</resources>
- <testSourceDirectory>test</testSourceDirectory>
<testResources>
<testResource>
<directory>test</directory>
@@ -110,6 +129,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
diff --git a/runtime-testsuite/README.md b/runtime-testsuite/README.md
deleted file mode 100644
index 7073e00..0000000
--- a/runtime-testsuite/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Runtime Test Suite
-
-If you are tweaking the runtime test suite generator you can regenerate them using the following command:
-
-```
-mvn -Pgen generate-test-sources
-```
-
-This will generate the runtime test harness classes into the `test` directory where they can be checked in.
diff --git a/runtime-testsuite/annotations/pom.xml b/runtime-testsuite/annotations/pom.xml
new file mode 100644
index 0000000..87b617b
--- /dev/null
+++ b/runtime-testsuite/annotations/pom.xml
@@ -0,0 +1,51 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-master</artifactId>
+ <version>4.6</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>antlr4-runtime-test-annotations</artifactId>
+ <name>ANTLR 4 Runtime Test Annotations</name>
+ <description>The ANTLR 4 Runtime</description>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.antlr.antlr4-runtime-osgi</Bundle-SymbolicName>
+ <Implementation-Title>ANTLR 4 Runtime</Implementation-Title>
+ <Implementation-Vendor>ANTLR</Implementation-Vendor>
+ <Implementation-Vendor-Id>org.antlr</Implementation-Vendor-Id>
+ <Implementation-Version>${project.version}</Implementation-Version>
+ </instructions>
+ </configuration>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/runtime-testsuite/annotations/src/org/antlr/v4/test/runtime/CommentHasStringValue.java b/runtime-testsuite/annotations/src/org/antlr/v4/test/runtime/CommentHasStringValue.java
new file mode 100644
index 0000000..b2bf486
--- /dev/null
+++ b/runtime-testsuite/annotations/src/org/antlr/v4/test/runtime/CommentHasStringValue.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.test.runtime;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/** This is just a tag that indicates the javadoc comment has a multi-line string */
+@Retention(RetentionPolicy.SOURCE)
+@Target({ElementType.FIELD, ElementType.METHOD})
+@Inherited
+public @interface CommentHasStringValue {
+}
diff --git a/runtime-testsuite/pom.xml b/runtime-testsuite/pom.xml
index e09140d..824a4c0 100644
--- a/runtime-testsuite/pom.xml
+++ b/runtime-testsuite/pom.xml
@@ -1,145 +1,137 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
- </parent>
- <artifactId>antlr4-runtime-testsuite</artifactId>
- <name>ANTLR 4 Runtime Test Generator</name>
- <description>A collection of tests for ANTLR 4 Runtime libraries.</description>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-master</artifactId>
+ <version>4.6</version>
+ </parent>
+ <artifactId>antlr4-runtime-testsuite</artifactId>
+ <name>ANTLR 4 Runtime Tests (2nd generation)</name>
+ <description>A collection of tests for ANTLR 4 Runtime libraries.</description>
+
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
+ <inceptionYear>2009</inceptionYear>
- <inceptionYear>2009</inceptionYear>
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>ST4</artifactId>
+ <version>4.0.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime-test-annotations</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime-test-annotation-processors</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-java</artifactId>
+ <version>2.46.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>8.1.16.v20140903</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.json</artifactId>
+ <version>1.0.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <dependencies>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>ST4</artifactId>
- <version>4.0.8</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- <version>2.46.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>8.1.16.v20140903</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <build>
+ <testSourceDirectory>test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ <resource>
+ <directory>../runtime</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <includes>
+ <include>**/csharp/Test*.java</include>
+ <include>**/java/Test*.java</include>
+ <include>**/go/Test*.java</include>
+ <include>**/javascript/node/Test*.java</include>
+ <include>**/python2/Test*.java</include>
+ <include>**/python3/Test*.java</include>
+ <include>${antlr.tests.swift}</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <build>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <resources>
- <resource>
- <directory>resources</directory>
- </resource>
- <resource>
- <directory>../runtime</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.12.4</version>
- <configuration>
- <includes>
- <include>**/csharp/Test*.java</include>
- <include>**/java/Test*.java</include>
- <include>**/javascript/node/Test*.java</include>
- <include>**/python2/Test*.java</include>
- <include>**/python3/Test*.java</include>
- </includes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>gen</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.4.0</version>
- <executions>
- <execution>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.antlr.v4.testgen.TestGenerator</mainClass>
- <arguments>
- <argument>-root</argument>
- <argument>${basedir}</argument>
- <argument>-outdir</argument>
- <argument>${basedir}/test</argument>
- <argument>-templates</argument>
- <argument>${basedir}/resources/org/antlr/v4/test/runtime/templates</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>tests</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/Test*.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ <profiles>
+ <profile>
+ <id>includeSwiftTests</id>
+ <activation>
+ <os>
+ <family>mac</family>
+ </os>
+ </activation>
+ <properties>
+ <antlr.tests.swift>**/swift/Test*.java</antlr.tests.swift>
+ </properties>
+ </profile>
+ </profiles>
</project>
diff --git a/runtime-testsuite/processors/pom.xml b/runtime-testsuite/processors/pom.xml
new file mode 100644
index 0000000..69fd940
--- /dev/null
+++ b/runtime-testsuite/processors/pom.xml
@@ -0,0 +1,56 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-master</artifactId>
+ <version>4.6</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>antlr4-runtime-test-annotation-processors</artifactId>
+ <name>ANTLR 4 Runtime Test Processors</name>
+ <description>The ANTLR 4 Runtime</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.4.2</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime-test-annotations</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <verbose>true</verbose>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ <compilerArgument>
+ -proc:none
+ </compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/runtime-testsuite/processors/resources/META-INF/services/javax.annotation.processing.Processor b/runtime-testsuite/processors/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..08311da
--- /dev/null
+++ b/runtime-testsuite/processors/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.antlr.v4.test.runtime.CommentHasStringValueProcessor
diff --git a/runtime-testsuite/processors/src/org/antlr/v4/test/runtime/CommentHasStringValueProcessor.java b/runtime-testsuite/processors/src/org/antlr/v4/test/runtime/CommentHasStringValueProcessor.java
new file mode 100644
index 0000000..b4fcb06
--- /dev/null
+++ b/runtime-testsuite/processors/src/org/antlr/v4/test/runtime/CommentHasStringValueProcessor.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.test.runtime;
+
+import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.TreeMaker;
+import com.sun.tools.javac.util.List;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import java.util.Set;
+
+/**
+ I think I figured out how to use annotation processors in maven. It's
+ more or less automatic and you don't even need to tell maven, with one minor
+ exception. The idea is to create a project for the annotation and another
+ for the annotation processor. Then, a project that uses the annotation
+ can simply set up the dependency on the other projects. You have to turn
+ off processing, -proc:none on the processor project itself but other than
+ that, java 6+ more or less tries to apply any processors it finds during
+ compilation. maven just works.
+
+ Also you need a META-INF/services/javax.annotation.processing.Processor file
+ with "org.antlr.v4.test.runtime.CommentHasStringValueProcessor" in it.
+ */
+@SupportedAnnotationTypes({"org.antlr.v4.test.runtime.CommentHasStringValue"})
+@SupportedSourceVersion(SourceVersion.RELEASE_7)
+public class CommentHasStringValueProcessor extends AbstractProcessor {
+ protected JavacElements utilities;
+ protected TreeMaker treeMaker;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+// Messager messager = processingEnv.getMessager();
+// messager.printMessage(Diagnostic.Kind.NOTE, "WOW INIT--------------------");
+ JavacProcessingEnvironment javacProcessingEnv = (JavacProcessingEnvironment) processingEnv;
+ utilities = javacProcessingEnv.getElementUtils();
+ treeMaker = TreeMaker.instance(javacProcessingEnv.getContext());
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+// Messager messager = processingEnv.getMessager();
+// messager.printMessage(Diagnostic.Kind.NOTE, "PROCESS--------------------");
+ Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(CommentHasStringValue.class);
+ for (Element annotatedElement : annotatedElements) {
+ String docComment = utilities.getDocComment(annotatedElement);
+ JCTree.JCLiteral literal = treeMaker.Literal(docComment!=null ? docComment : "");
+ JCTree elementTree = utilities.getTree(annotatedElement);
+ if ( elementTree instanceof JCTree.JCVariableDecl ) {
+ ((JCTree.JCVariableDecl)elementTree).init = literal;
+ }
+ else if ( elementTree instanceof JCTree.JCMethodDecl ) {
+ JCTree.JCStatement[] statements = new JCTree.JCStatement[1];
+ statements[0] = treeMaker.Return(literal);
+ JCTree.JCBlock body = treeMaker.Block(0, List.from(statements));
+ ((JCTree.JCMethodDecl)elementTree).body = body;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latestSupported();
+ }
+}
diff --git a/runtime/Java/pom.xml b/runtime/Java/pom.xml
index 9824ffd..29627bc 100644
--- a/runtime/Java/pom.xml
+++ b/runtime/Java/pom.xml
@@ -1,66 +1,121 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <artifactId>antlr4-runtime</artifactId>
- <name>ANTLR 4 Runtime</name>
- <description>The ANTLR 4 Runtime</description>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-master</artifactId>
+ <version>4.6</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>antlr4-runtime</artifactId>
+ <name>ANTLR 4 Runtime</name>
+ <description>The ANTLR 4 Runtime</description>
+
+ <properties>
+ <!-- Assumes dot is in the system path, or specified for the build. -->
+ <dot.path>dot</dot.path>
+ </properties>
- <build>
- <sourceDirectory>src</sourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- <version>4.5</version>
- <executions>
- <execution>
- <id>antlr</id>
- <configuration>
- <sourceDirectory>src</sourceDirectory>
- </configuration>
- <goals>
- <goal>antlr4</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.5.4</version>
- <executions>
- <execution>
- <id>bundle-manifest</id>
- <phase>process-classes</phase>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>org.antlr.antlr4-runtime-osgi</Bundle-SymbolicName>
- <Implementation-Title>ANTLR 4 Runtime</Implementation-Title>
- <Implementation-Vendor>ANTLR</Implementation-Vendor>
- <Implementation-Vendor-Id>org.antlr</Implementation-Vendor-Id>
- <Implementation-Version>${project.version}</Implementation-Version>
- </instructions>
- </configuration>
- <goals>
- <goal>manifest</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <plugins>
+ <plugin> <!-- create src jar -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin> <!-- run dot on the images used by PredictionContext.java -->
+ <groupId>us.bryon</groupId>
+ <artifactId>graphviz-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>deploy</phase>
+ <goals>
+ <goal>dot</goal>
+ </goals>
+ <configuration>
+ <dot>${dot.path}</dot>
+ <destdir>${project.build.directory}/apidocs</destdir>
+ <output>svg</output>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin> <!-- create javadoc jar -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <javadocVersion>1.7</javadocVersion>
+ <failOnError>false</failOnError>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>4.5.3</version> <!-- use older version to process XPathLexer.g4, avoiding cyclic build dependency -->
+ <executions>
+ <execution>
+ <id>antlr</id>
+ <configuration>
+ <sourceDirectory>src</sourceDirectory>
+ </configuration>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.antlr.antlr4-runtime</Bundle-SymbolicName>
+ </instructions>
+ </configuration>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorListener.java
index 83c7d86..013f1cf 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java
index f123778..90c5528 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ANTLRFileStream.java b/runtime/Java/src/org/antlr/v4/runtime/ANTLRFileStream.java
index ba4a531..e31ff32 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ANTLRFileStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ANTLRFileStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ANTLRInputStream.java b/runtime/Java/src/org/antlr/v4/runtime/ANTLRInputStream.java
index 62c562e..7ee3cca 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ANTLRInputStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ANTLRInputStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/BailErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/BailErrorStrategy.java
index f4874dd..a7f08c9 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/BailErrorStrategy.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/BailErrorStrategy.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/BaseErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/BaseErrorListener.java
index 3a752f2..7f6ea8e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/BaseErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/BaseErrorListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java
index ba1417c..8ca3928 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -456,18 +432,15 @@ public class BufferedTokenStream implements TokenStream {
@Override
public String getText() {
- lazyInit();
- fill();
return getText(Interval.of(0,size()-1));
}
-
- @Override
- public String getText(Interval interval) {
+ @Override
+ public String getText(Interval interval) {
int start = interval.a;
int stop = interval.b;
- if ( start<0 || stop<0 ) return "";
- lazyInit();
+ if ( start<0 || stop<0 ) return "";
+ fill();
if ( stop>=tokens.size() ) stop = tokens.size()-1;
StringBuilder buf = new StringBuilder();
diff --git a/runtime/Java/src/org/antlr/v4/runtime/CharStream.java b/runtime/Java/src/org/antlr/v4/runtime/CharStream.java
index 5814fcf..fcd6bfb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/CharStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/CharStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java b/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java
index d552a1b..015df7f 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -282,6 +258,11 @@ public class CommonToken implements WritableToken, Serializable {
@Override
public String toString() {
+ return toString(null);
+ }
+
+ public String toString(Recognizer r) {
+
String channelStr = "";
if ( channel>0 ) {
channelStr=",channel="+channel;
@@ -295,6 +276,10 @@ public class CommonToken implements WritableToken, Serializable {
else {
txt = "<no text>";
}
- return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]";
+ String typeString = String.valueOf(type);
+ if ( r!=null ) {
+ typeString = r.getVocabulary().getDisplayName(type);
+ }
+ return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+typeString+">"+channelStr+","+line+":"+getCharPositionInLine()+"]";
}
}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenFactory.java b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenFactory.java
index bb764d4..da7bace 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenFactory.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java
index ea85afc..fd6a8eb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -52,7 +28,7 @@ package org.antlr.v4.runtime;
* Note: lexer rules which use the {@code ->skip} lexer command or call
* {@link Lexer#skip} do not produce tokens at all, so input text matched by
* such a rule will not be available as part of the token stream, regardless of
- * channel.</p>
+ * channel.</p>we
*/
public class CommonTokenStream extends BufferedTokenStream {
/**
@@ -101,7 +77,7 @@ public class CommonTokenStream extends BufferedTokenStream {
int i = p;
int n = 1;
// find k good tokens looking backwards
- while ( n<=k ) {
+ while ( n<=k && i>0 ) {
// skip off-channel tokens
i = previousTokenOnChannel(i - 1, channel);
n++;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ConsoleErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/ConsoleErrorListener.java
index b33dc2d..f7d36b5 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ConsoleErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ConsoleErrorListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java
index 4a7e69b..db5061c 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java
index c0d94d9..94a8e9b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/FailedPredicateException.java b/runtime/Java/src/org/antlr/v4/runtime/FailedPredicateException.java
index 71e03a4..422a7a9 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/FailedPredicateException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/FailedPredicateException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/InputMismatchException.java b/runtime/Java/src/org/antlr/v4/runtime/InputMismatchException.java
index ca2cefa..1f45d7c 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/InputMismatchException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/InputMismatchException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java
index 0108a4b..4fd59dc 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/InterpreterRuleContext.java b/runtime/Java/src/org/antlr/v4/runtime/InterpreterRuleContext.java
index 8a7001f..893a5a8 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/InterpreterRuleContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/InterpreterRuleContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/Lexer.java b/runtime/Java/src/org/antlr/v4/runtime/Lexer.java
index 3f6c4c4..bb082aa 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/Lexer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/Lexer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/LexerInterpreter.java b/runtime/Java/src/org/antlr/v4/runtime/LexerInterpreter.java
index dc79aa7..bb50c53 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/LexerInterpreter.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/LexerInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/LexerNoViableAltException.java b/runtime/Java/src/org/antlr/v4/runtime/LexerNoViableAltException.java
index 5aae99d..2540d10 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/LexerNoViableAltException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/LexerNoViableAltException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ListTokenSource.java b/runtime/Java/src/org/antlr/v4/runtime/ListTokenSource.java
index bc877b5..592c8d9 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ListTokenSource.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ListTokenSource.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime;
import org.antlr.v4.runtime.misc.Pair;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java b/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java
index e907d75..a805e80 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/NoViableAltException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/Parser.java b/runtime/Java/src/org/antlr/v4/runtime/Parser.java
index eda34a1..1edc457 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/Parser.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/Parser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ParserInterpreter.java b/runtime/Java/src/org/antlr/v4/runtime/ParserInterpreter.java
index 78c9ea2..568495b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ParserInterpreter.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ParserInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ParserRuleContext.java b/runtime/Java/src/org/antlr/v4/runtime/ParserRuleContext.java
index edca61e..9f3b97f 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ParserRuleContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ParserRuleContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -104,6 +80,14 @@ public class ParserRuleContext extends RuleContext {
/** COPY a ctx (I'm deliberately not using copy constructor) to avoid
* confusion with creating node with parent. Does not copy children.
+ *
+ * This is used in the generated parser code to flip a generic XContext
+ * node for rule X to a YContext for alt label Y. In that sense, it is
+ * not really a generic copy function.
+ *
+ * If we do an error sync() at start of a rule, we might add error nodes
+ * to the generic XContext so this function must copy those nodes to
+ * the YContext as well else they are lost!
*/
public void copyFrom(ParserRuleContext ctx) {
this.parent = ctx.parent;
@@ -111,6 +95,18 @@ public class ParserRuleContext extends RuleContext {
this.start = ctx.start;
this.stop = ctx.stop;
+
+ // copy any error nodes to alt label node
+ if ( ctx.children!=null ) {
+ this.children = new ArrayList<>();
+ // reset parent pointer for any error nodes
+ for (ParseTree child : ctx.children) {
+ if ( child instanceof ErrorNodeImpl ) {
+ this.children.add(child);
+ ((ErrorNodeImpl) child).parent = this;
+ }
+ }
+ }
}
public ParserRuleContext(ParserRuleContext parent, int invokingStateNumber) {
diff --git a/runtime/Java/src/org/antlr/v4/runtime/ProxyErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/ProxyErrorListener.java
index 2eebcbd..35d7546 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/ProxyErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/ProxyErrorListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/RecognitionException.java b/runtime/Java/src/org/antlr/v4/runtime/RecognitionException.java
index d80694d..5157421 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/RecognitionException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/RecognitionException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/Recognizer.java b/runtime/Java/src/org/antlr/v4/runtime/Recognizer.java
index 603a39c..6b407bc 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/Recognizer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/Recognizer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -93,7 +69,7 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
Map<String, Integer> result = tokenTypeMapCache.get(vocabulary);
if (result == null) {
result = new HashMap<String, Integer>();
- for (int i = 0; i < getATN().maxTokenType; i++) {
+ for (int i = 0; i <= getATN().maxTokenType; i++) {
String literalName = vocabulary.getLiteralName(i);
if (literalName != null) {
result.put(literalName, i);
diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java b/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java
index 0103966..91eafd0 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -50,7 +26,7 @@ import java.util.List;
* The root node always has a null pointer and invokingState of -1.
*
* Upon entry to parsing, the first invoked rule function creates a
- * context object (asubclass specialized for that rule such as
+ * context object (a subclass specialized for that rule such as
* SContext) and makes it the root of a parse tree, recorded by field
* Parser._ctx.
*
diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuleContextWithAltNum.java b/runtime/Java/src/org/antlr/v4/runtime/RuleContextWithAltNum.java
index 63d3b22..81fe476 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/RuleContextWithAltNum.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/RuleContextWithAltNum.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime;
import org.antlr.v4.runtime.atn.ATN;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
index b8bf0d5..9355d31 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -91,7 +67,7 @@ public class RuntimeMetaData {
* omitted.</li>
* </ul>
*/
- public static final String VERSION = "4.5.3";
+ public static final String VERSION = "4.6";
/**
* Gets the currently executing version of the ANTLR 4 runtime library.
diff --git a/runtime/Java/src/org/antlr/v4/runtime/Token.java b/runtime/Java/src/org/antlr/v4/runtime/Token.java
index 59c694d..f25bed5 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/Token.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/Token.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/TokenFactory.java b/runtime/Java/src/org/antlr/v4/runtime/TokenFactory.java
index a7b95aa..0053537 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/TokenFactory.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/TokenFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/TokenSource.java b/runtime/Java/src/org/antlr/v4/runtime/TokenSource.java
index 992b0ea..1e01bf8 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/TokenSource.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/TokenSource.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java
index 7bc2374..18b06f7 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/TokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/TokenStreamRewriter.java b/runtime/Java/src/org/antlr/v4/runtime/TokenStreamRewriter.java
index c9b74c1..8b8abca 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/TokenStreamRewriter.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/TokenStreamRewriter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
@@ -120,10 +96,10 @@ public class TokenStreamRewriter {
// Define the rewrite operation hierarchy
public class RewriteOperation {
- /** What index into rewrites List are we? */
- protected int instructionIndex;
- /** Token buffer index. */
- protected int index;
+ /** What index into rewrites List are we? */
+ protected int instructionIndex;
+ /** Token buffer index. */
+ protected int index;
protected Object text;
protected RewriteOperation(int index) {
@@ -166,6 +142,16 @@ public class TokenStreamRewriter {
}
}
+ /** Distinguish between insert after/before to do the "insert afters"
+ * first and then the "insert befores" at same index. Implementation
+ * of "insert after" is "insert before index+1".
+ */
+ class InsertAfterOp extends InsertBeforeOp {
+ public InsertAfterOp(int index, Object text) {
+ super(index+1, text); // insert after is insert before index+1
+ }
+ }
+
/** I'm going to try replacing range from x..y with (y-x)+1 ReplaceOp
* instructions.
*/
@@ -255,7 +241,10 @@ public class TokenStreamRewriter {
public void insertAfter(String programName, int index, Object text) {
// to insert after, just insert before next index (even if past end)
- insertBefore(programName,index+1, text);
+ RewriteOperation op = new InsertAfterOp(index, text);
+ List<RewriteOperation> rewrites = getProgram(programName);
+ op.instructionIndex = rewrites.size();
+ rewrites.add(op);
}
public void insertBefore(Token t, Object text) {
@@ -520,8 +509,6 @@ public class TokenStreamRewriter {
// throw exception unless disjoint or identical
boolean disjoint =
prevRop.lastIndex<rop.index || prevRop.index > rop.lastIndex;
- boolean same =
- prevRop.index==rop.index && prevRop.lastIndex==rop.lastIndex;
// Delete special case of replace (text==null):
// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
if ( prevRop.text==null && rop.text==null && !disjoint ) {
@@ -531,7 +518,7 @@ public class TokenStreamRewriter {
rop.lastIndex = Math.max(prevRop.lastIndex, rop.lastIndex);
System.out.println("new rop "+rop);
}
- else if ( !disjoint && !same ) {
+ else if ( !disjoint ) {
throw new IllegalArgumentException("replace op boundaries of "+rop+" overlap with previous "+prevRop);
}
}
@@ -546,12 +533,18 @@ public class TokenStreamRewriter {
// combine current insert with prior if any at same index
List<? extends InsertBeforeOp> prevInserts = getKindOfOps(rewrites, InsertBeforeOp.class, i);
for (InsertBeforeOp prevIop : prevInserts) {
- if ( prevIop.index == iop.index ) { // combine objects
- // convert to strings...we're in process of toString'ing
- // whole token buffer so no lazy eval issue with any templates
- iop.text = catOpText(iop.text,prevIop.text);
- // delete redundant prior insert
- rewrites.set(prevIop.instructionIndex, null);
+ if ( prevIop.index==iop.index ) {
+ if ( InsertAfterOp.class.isInstance(prevIop) ) {
+ iop.text = catOpText(prevIop.text, iop.text);
+ rewrites.set(prevIop.instructionIndex, null);
+ }
+ else if ( InsertBeforeOp.class.isInstance(prevIop) ) { // combine objects
+ // convert to strings...we're in process of toString'ing
+ // whole token buffer so no lazy eval issue with any templates
+ iop.text = catOpText(iop.text, prevIop.text);
+ // delete redundant prior insert
+ rewrites.set(prevIop.instructionIndex, null);
+ }
}
}
// look for replaces where iop.index is in range; error
diff --git a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java
index eb23ae7..712dc85 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedTokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedTokenStream.java
index fa8ba06..046d821 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedTokenStream.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/Vocabulary.java b/runtime/Java/src/org/antlr/v4/runtime/Vocabulary.java
index 2df5377..c3662ea 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/Vocabulary.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/Vocabulary.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/VocabularyImpl.java b/runtime/Java/src/org/antlr/v4/runtime/VocabularyImpl.java
index 93566bd..75b450e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/VocabularyImpl.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/VocabularyImpl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/WritableToken.java b/runtime/Java/src/org/antlr/v4/runtime/WritableToken.java
index 2f08619..bdaaac3 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/WritableToken.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/WritableToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java
index cdaa0f0..1e67bea 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATN.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -162,8 +138,23 @@ public class ATN {
* {@link RuleStopState} of the outermost context without matching any
* symbols, {@link Token#EOF} is added to the returned set.
*
- * <p>If {@code context} is {@code null}, it is treated as
- * {@link ParserRuleContext#EMPTY}.</p>
+ * <p>If {@code context} is {@code null}, it is treated as {@link ParserRuleContext#EMPTY}.</p>
+ *
+ * Note that this does NOT give you the set of all tokens that could
+ * appear at a given token position in the input phrase. In other words,
+ * it does not answer:
+ *
+ * "Given a specific partial input phrase, return the set of all tokens
+ * that can follow the last token in the input phrase."
+ *
+ * The big difference is that with just the input, the parser could
+ * land right in the middle of a lookahead decision. Getting
+ * all *possible* tokens given a partial input stream is a separate
+ * computation. See https://github.com/antlr/antlr4/issues/1428
+ *
+ * For this function, we are specifying an ATN state and call stack to compute
+ * what token(s) can come next and specifically: outside of a lookahead decision.
+ * That is what you want for error reporting and recovery upon parse error.
*
* @param stateNumber the ATN state number
* @param context the full parse context
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java
index 8b57bad..6cededb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java
index b03f7c4..423c5d3 100755
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java
index f1b8d1b..2191eb1 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java
index d83c449..9821b8b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java
index 4c31ac9..e5f0344 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -367,7 +343,12 @@ public class ATNSerializer {
// don't adjust the first value since that's the version number
for (int i = 1; i < data.size(); i++) {
if (data.get(i) < Character.MIN_VALUE || data.get(i) > Character.MAX_VALUE) {
- throw new UnsupportedOperationException("Serialized ATN data element out of range.");
+ throw new UnsupportedOperationException("Serialized ATN data element "+
+ data.get(i)+
+ " element "+i+" out of range "+
+ (int)Character.MIN_VALUE+
+ ".."+
+ (int)Character.MAX_VALUE);
}
int value = (data.get(i) + 2) & 0xFFFF;
@@ -424,6 +405,12 @@ public class ATNSerializer {
.append(ATNState.serializationNames.get(stype)).append(" ")
.append(ruleIndex).append(arg).append("\n");
}
+ // this code is meant to model the form of ATNDeserializer.deserialize,
+ // since both need to be updated together whenever a change is made to
+ // the serialization format. The "dead" code is only used in debugging
+ // and testing scenarios, so the form you see here was kept for
+ // improved maintainability.
+ // start
int numNonGreedyStates = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < numNonGreedyStates; i++) {
int stateNumber = ATNDeserializer.toInt(data[p++]);
@@ -432,6 +419,7 @@ public class ATNSerializer {
for (int i = 0; i < numPrecedenceStates; i++) {
int stateNumber = ATNDeserializer.toInt(data[p++]);
}
+ // finish
int nrules = ATNDeserializer.toInt(data[p++]);
for (int i=0; i<nrules; i++) {
int s = ATNDeserializer.toInt(data[p++]);
@@ -487,12 +475,17 @@ public class ATNSerializer {
buf.append(i).append(":").append(s).append("\n");
}
if (atn.grammarType == ATNType.LEXER) {
- int lexerActionCount = ATNDeserializer.toInt(data[p++]);
- for (int i = 0; i < lexerActionCount; i++) {
- LexerActionType actionType = LexerActionType.values()[ATNDeserializer.toInt(data[p++])];
- int data1 = ATNDeserializer.toInt(data[p++]);
- int data2 = ATNDeserializer.toInt(data[p++]);
- }
+ // this code is meant to model the form of ATNDeserializer.deserialize,
+ // since both need to be updated together whenever a change is made to
+ // the serialization format. The "dead" code is only used in debugging
+ // and testing scenarios, so the form you see here was kept for
+ // improved maintainability.
+ int lexerActionCount = ATNDeserializer.toInt(data[p++]);
+ for (int i = 0; i < lexerActionCount; i++) {
+ LexerActionType actionType = LexerActionType.values()[ATNDeserializer.toInt(data[p++])];
+ int data1 = ATNDeserializer.toInt(data[p++]);
+ int data2 = ATNDeserializer.toInt(data[p++]);
+ }
}
return buf.toString();
}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java
index 043144d..5a1abe0 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java
index 412c332..deb845d 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -191,7 +167,24 @@ public abstract class ATNState {
epsilonOnlyTransitions = false;
}
- transitions.add(index, e);
+ boolean alreadyPresent = false;
+ for (Transition t : transitions) {
+ if ( t.target.stateNumber == e.target.stateNumber ) {
+ if ( t.label()!=null && e.label()!=null && t.label().equals(e.label()) ) {
+// System.err.println("Repeated transition upon "+e.label()+" from "+stateNumber+"->"+t.target.stateNumber);
+ alreadyPresent = true;
+ break;
+ }
+ else if ( t.isEpsilon() && e.isEpsilon() ) {
+// System.err.println("Repeated epsilon transition from "+stateNumber+"->"+t.target.stateNumber);
+ alreadyPresent = true;
+ break;
+ }
+ }
+ }
+ if ( !alreadyPresent ) {
+ transitions.add(index, e);
+ }
}
public Transition transition(int i) { return transitions.get(i); }
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNType.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNType.java
index 9cd0134..2ac99b1 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNType.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNType.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -41,7 +17,7 @@ public enum ATNType {
* A lexer grammar.
*/
LEXER,
-
+
/**
* A parser grammar.
*/
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java
index 67822ce..d00a793 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ActionTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ActionTransition.java
index 1d4c32e..e89f5c2 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ActionTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ActionTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/AmbiguityInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/AmbiguityInfo.java
index 7ce9349..647f4b1 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/AmbiguityInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/AmbiguityInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java
index 68fbbc0..178b085 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/AtomTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/AtomTransition.java
index 018a4f7..446f5b3 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/AtomTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/AtomTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/BasicBlockStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/BasicBlockStartState.java
index ebb7f09..84216ae 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/BasicBlockStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/BasicBlockStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/BasicState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/BasicState.java
index 85c04c3..b139cea 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/BasicState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/BasicState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/BlockEndState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/BlockEndState.java
index 197b0e6..c8cc871 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/BlockEndState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/BlockEndState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/BlockStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/BlockStartState.java
index fbb3025..0fb8380 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/BlockStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/BlockStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java
index 3f7320b..e825a74 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionEventInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionEventInfo.java
index 3e8e272..a0a117e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionEventInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionEventInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionInfo.java
index 7780a49..98ff1c3 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -227,7 +203,7 @@ public class DecisionInfo {
* @see LexerATNSimulator#computeTargetState
*/
public long LL_ATNTransitions;
-
+
/**
* The total number of DFA transitions required during LL prediction for
* this decision.
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionState.java
index af4c38f..e4c710e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/DecisionState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java
index b02750d..a7c66e9 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/EmptyPredictionContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/EpsilonTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/EpsilonTransition.java
index aee9ce2..ea1b639 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/EpsilonTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/EpsilonTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ErrorInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ErrorInfo.java
index 60b9e05..35d9277 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ErrorInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ErrorInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LL1Analyzer.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LL1Analyzer.java
index bd88ef2..2df50c3 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LL1Analyzer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LL1Analyzer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -174,7 +150,8 @@ public class LL1Analyzer {
if (ctx == null) {
look.add(Token.EPSILON);
return;
- } else if (ctx.isEmpty() && addEOF) {
+ }
+ else if (ctx.isEmpty() && addEOF) {
look.add(Token.EOF);
return;
}
@@ -184,26 +161,26 @@ public class LL1Analyzer {
if ( ctx==null ) {
look.add(Token.EPSILON);
return;
- } else if (ctx.isEmpty() && addEOF) {
+ }
+ else if (ctx.isEmpty() && addEOF) {
look.add(Token.EOF);
return;
}
if ( ctx != PredictionContext.EMPTY ) {
// run thru all possible stack tops in ctx
- for (int i = 0; i < ctx.size(); i++) {
- ATNState returnState = atn.states.get(ctx.getReturnState(i));
-// System.out.println("popping back to "+retState);
-
- boolean removed = calledRuleStack.get(returnState.ruleIndex);
- try {
- calledRuleStack.clear(returnState.ruleIndex);
+ boolean removed = calledRuleStack.get(s.ruleIndex);
+ try {
+ calledRuleStack.clear(s.ruleIndex);
+ for (int i = 0; i < ctx.size(); i++) {
+ ATNState returnState = atn.states.get(ctx.getReturnState(i));
+// System.out.println("popping back to "+retState);
_LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
}
- finally {
- if (removed) {
- calledRuleStack.set(returnState.ruleIndex);
- }
+ }
+ finally {
+ if (removed) {
+ calledRuleStack.set(s.ruleIndex);
}
}
return;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java
index a2fc1fc..db7b8e8 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java
index 6f8cd89..81f7f64 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerAction.java
index 367cb24..9657f63 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionExecutor.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionExecutor.java
index f6075fd..f8c214b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionExecutor.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionExecutor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionType.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionType.java
index 1d9b9f5..e1413d4 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionType.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerActionType.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerChannelAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerChannelAction.java
index 5737c79..b37f773 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerChannelAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerChannelAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerCustomAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerCustomAction.java
index 78040e4..04bec9f 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerCustomAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerCustomAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerIndexedCustomAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerIndexedCustomAction.java
index b4566fa..9fcd797 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerIndexedCustomAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerIndexedCustomAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerModeAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerModeAction.java
index 9b3a43d..a7afcca 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerModeAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerModeAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerMoreAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerMoreAction.java
index ed98044..ee1543c 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerMoreAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerMoreAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPopModeAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPopModeAction.java
index 27c29c5..36e7445 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPopModeAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPopModeAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPushModeAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPushModeAction.java
index 70ebc9b..eb1c138 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPushModeAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerPushModeAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerSkipAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerSkipAction.java
index d0a1662..762477b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerSkipAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerSkipAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerTypeAction.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerTypeAction.java
index e5fcf07..9f30ecc 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerTypeAction.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerTypeAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LookaheadEventInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LookaheadEventInfo.java
index 19a4059..4f929fd 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LookaheadEventInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LookaheadEventInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LoopEndState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LoopEndState.java
index 56c22c1..e06fcbf 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/LoopEndState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LoopEndState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/NotSetTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/NotSetTransition.java
index 07b8217..36f0cbb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/NotSetTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/NotSetTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java b/runtime/Java/src/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java
index aafc2e7..5b3dc3d 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParseInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParseInfo.java
index 5545749..3f8bd88 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParseInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParseInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java
index 15f71ec..36965ad 100755
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -58,6 +34,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.antlr.v4.runtime.atn.ATNState.BLOCK_END;
+
/**
* The embodiment of the adaptive LL(*), ALL(*), parsing strategy.
*
@@ -291,6 +269,9 @@ public class ParserATNSimulator extends ATNSimulator {
public static final boolean dfa_debug = false;
public static final boolean retry_debug = false;
+ /** Just in case this optimization is bad, add an ENV variable to turn it off */
+ public static final boolean TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT = Boolean.parseBoolean(System.getenv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT"));
+
protected final Parser parser;
public final DFA[] decisionToDFA;
@@ -788,7 +769,8 @@ public class ParserATNSimulator extends ATNSimulator {
protected ATNConfigSet computeReachSet(ATNConfigSet closure, int t,
boolean fullCtx)
{
- if ( debug ) System.out.println("in computeReachSet, starting closure: " + closure);
+ if ( debug )
+ System.out.println("in computeReachSet, starting closure: " + closure);
if (mergeCache == null) {
mergeCache = new DoubleKeyMap<PredictionContext, PredictionContext, PredictionContext>();
@@ -980,10 +962,6 @@ public class ParserATNSimulator extends ATNSimulator {
/* parrt internal source braindump that doesn't mess up
* external API spec.
-
- applyPrecedenceFilter is an optimization to avoid highly
- nonlinear prediction of expressions and other left recursive
- rules. The precedence predicates such as {3>=prec}? Are highly
context-sensitive in that they can only be properly evaluated
in the context of the proper prec argument. Without pruning,
these predicates are normal predicates evaluated when we reach
@@ -1555,6 +1533,8 @@ public class ParserATNSimulator extends ATNSimulator {
}
for (int i=0; i<p.getNumberOfTransitions(); i++) {
+ if ( i==0 && canDropLoopEntryEdgeInLeftRecursiveRule(config) ) continue;
+
Transition t = p.transition(i);
boolean continueCollecting =
!(t instanceof ActionTransition) && collectPredicates;
@@ -1606,6 +1586,165 @@ public class ParserATNSimulator extends ATNSimulator {
}
}
+ /** Implements first-edge (loop entry) elimination as an optimization
+ * during closure operations. See antlr/antlr4#1398.
+ *
+ * The optimization is to avoid adding the loop entry config when
+ * the exit path can only lead back to the same
+ * StarLoopEntryState after popping context at the rule end state
+ * (traversing only epsilon edges, so we're still in closure, in
+ * this same rule).
+ *
+ * We need to detect any state that can reach loop entry on
+ * epsilon w/o exiting rule. We don't have to look at FOLLOW
+ * links, just ensure that all stack tops for config refer to key
+ * states in LR rule.
+ *
+ * To verify we are in the right situation we must first check
+ * closure is at a StarLoopEntryState generated during LR removal.
+ * Then we check that each stack top of context is a return state
+ * from one of these cases:
+ *
+ * 1. 'not' expr, '(' type ')' expr. The return state points at loop entry state
+ * 2. expr op expr. The return state is the block end of internal block of (...)*
+ * 3. 'between' expr 'and' expr. The return state of 2nd expr reference.
+ * That state points at block end of internal block of (...)*.
+ * 4. expr '?' expr ':' expr. The return state points at block end,
+ * which points at loop entry state.
+ *
+ * If any is true for each stack top, then closure does not add a
+ * config to the current config set for edge[0], the loop entry branch.
+ *
+ * Conditions fail if any context for the current config is:
+ *
+ * a. empty (we'd fall out of expr to do a global FOLLOW which could
+ * even be to some weird spot in expr) or,
+ * b. lies outside of expr or,
+ * c. lies within expr but at a state not the BlockEndState
+ * generated during LR removal
+ *
+ * Do we need to evaluate predicates ever in closure for this case?
+ *
+ * No. Predicates, including precedence predicates, are only
+ * evaluated when computing a DFA start state. I.e., only before
+ * the lookahead (but not parser) consumes a token.
+ *
+ * There are no epsilon edges allowed in LR rule alt blocks or in
+ * the "primary" part (ID here). If closure is in
+ * StarLoopEntryState any lookahead operation will have consumed a
+ * token as there are no epsilon-paths that lead to
+ * StarLoopEntryState. We do not have to evaluate predicates
+ * therefore if we are in the generated StarLoopEntryState of a LR
+ * rule. Note that when making a prediction starting at that
+ * decision point, decision d=2, compute-start-state performs
+ * closure starting at edges[0], edges[1] emanating from
+ * StarLoopEntryState. That means it is not performing closure on
+ * StarLoopEntryState during compute-start-state.
+ *
+ * How do we know this always gives same prediction answer?
+ *
+ * Without predicates, loop entry and exit paths are ambiguous
+ * upon remaining input +b (in, say, a+b). Either paths lead to
+ * valid parses. Closure can lead to consuming + immediately or by
+ * falling out of this call to expr back into expr and loop back
+ * again to StarLoopEntryState to match +b. In this special case,
+ * we choose the more efficient path, which is to take the bypass
+ * path.
+ *
+ * The lookahead language has not changed because closure chooses
+ * one path over the other. Both paths lead to consuming the same
+ * remaining input during a lookahead operation. If the next token
+ * is an operator, lookahead will enter the choice block with
+ * operators. If it is not, lookahead will exit expr. Same as if
+ * closure had chosen to enter the choice block immediately.
+ *
+ * Closure is examining one config (some loopentrystate, some alt,
+ * context) which means it is considering exactly one alt. Closure
+ * always copies the same alt to any derived configs.
+ *
+ * How do we know this optimization doesn't mess up precedence in
+ * our parse trees?
+ *
+ * Looking through expr from left edge of stat only has to confirm
+ * that an input, say, a+b+c; begins with any valid interpretation
+ * of an expression. The precedence actually doesn't matter when
+ * making a decision in stat seeing through expr. It is only when
+ * parsing rule expr that we must use the precedence to get the
+ * right interpretation and, hence, parse tree.
+ *
+ * @since 4.6
+ */
+ protected boolean canDropLoopEntryEdgeInLeftRecursiveRule(ATNConfig config) {
+ if ( TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT ) return false;
+ ATNState p = config.state;
+ // First check to see if we are in StarLoopEntryState generated during
+ // left-recursion elimination. For efficiency, also check if
+ // the context has an empty stack case. If so, it would mean
+ // global FOLLOW so we can't perform optimization
+ if ( p.getStateType() != ATNState.STAR_LOOP_ENTRY ||
+ !((StarLoopEntryState)p).isPrecedenceDecision || // Are we the special loop entry/exit state?
+ config.context.isEmpty() || // If SLL wildcard
+ config.context.hasEmptyPath())
+ {
+ return false;
+ }
+
+ // Require all return states to return back to the same rule
+ // that p is in.
+ int numCtxs = config.context.size();
+ for (int i = 0; i < numCtxs; i++) { // for each stack context
+ ATNState returnState = atn.states.get(config.context.getReturnState(i));
+ if ( returnState.ruleIndex != p.ruleIndex ) return false;
+ }
+
+ BlockStartState decisionStartState = (BlockStartState)p.transition(0).target;
+ int blockEndStateNum = decisionStartState.endState.stateNumber;
+ BlockEndState blockEndState = (BlockEndState)atn.states.get(blockEndStateNum);
+
+ // Verify that the top of each stack context leads to loop entry/exit
+ // state through epsilon edges and w/o leaving rule.
+ for (int i = 0; i < numCtxs; i++) { // for each stack context
+ int returnStateNumber = config.context.getReturnState(i);
+ ATNState returnState = atn.states.get(returnStateNumber);
+ // all states must have single outgoing epsilon edge
+ if ( returnState.getNumberOfTransitions()!=1 ||
+ !returnState.transition(0).isEpsilon() )
+ {
+ return false;
+ }
+ // Look for prefix op case like 'not expr', (' type ')' expr
+ ATNState returnStateTarget = returnState.transition(0).target;
+ if ( returnState.getStateType()==BLOCK_END && returnStateTarget==p ) {
+ continue;
+ }
+ // Look for 'expr op expr' or case where expr's return state is block end
+ // of (...)* internal block; the block end points to loop back
+ // which points to p but we don't need to check that
+ if ( returnState==blockEndState ) {
+ continue;
+ }
+ // Look for ternary expr ? expr : expr. The return state points at block end,
+ // which points at loop entry state
+ if ( returnStateTarget==blockEndState ) {
+ continue;
+ }
+ // Look for complex prefix 'between expr and expr' case where 2nd expr's
+ // return state points at block end state of (...)* internal block
+ if ( returnStateTarget.getStateType() == BLOCK_END &&
+ returnStateTarget.getNumberOfTransitions()==1 &&
+ returnStateTarget.transition(0).isEpsilon() &&
+ returnStateTarget.transition(0).target == p )
+ {
+ continue;
+ }
+
+ // anything else ain't conforming
+ return false;
+ }
+
+ return true;
+ }
+
public String getRuleName(int index) {
if ( parser!=null && index>=0 ) return parser.getRuleNames()[index];
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PlusBlockStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PlusBlockStartState.java
index 4627b9b..095a48a 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PlusBlockStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PlusBlockStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PlusLoopbackState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PlusLoopbackState.java
index b92bf6e..96b5d16 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PlusLoopbackState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PlusLoopbackState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java
index ad96a02..546bafd 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateEvalInfo.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateEvalInfo.java
index 59241e2..d2a73b4 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateEvalInfo.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateEvalInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateTransition.java
index 574d329..c4381bd 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredicateTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java
index 20fb171..8a23d34 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -117,12 +93,13 @@ public abstract class PredictionContext {
public abstract int getReturnState(int index);
- /** This means only the {@link #EMPTY} context is in set. */
+ /** This means only the {@link #EMPTY} (wildcard? not sure) context is in set. */
public boolean isEmpty() {
return this == EMPTY;
}
public boolean hasEmptyPath() {
+ // since EMPTY_RETURN_STATE can only appear in the last position, we check last one
return getReturnState(size() - 1) == EMPTY_RETURN_STATE;
}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java
index b9d12e4..62c9196 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionMode.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionMode.java
index e2e0f8f..b0ca601 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionMode.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionMode.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
@@ -545,7 +521,11 @@ public enum PredictionMode {
return all;
}
- /** Get union of all alts from configs. @since 4.5.1 */
+ /**
+ * Get union of all alts from configs.
+ *
+ * @since 4.5.1
+ */
public static BitSet getAlts(ATNConfigSet configs) {
BitSet alts = new BitSet();
for (ATNConfig config : configs) {
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ProfilingATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ProfilingATNSimulator.java
index 20ffbd2..51ded0a 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/ProfilingATNSimulator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ProfilingATNSimulator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/RangeTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/RangeTransition.java
index 9dbb0b1..92001cc 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/RangeTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/RangeTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStartState.java
index b2105d6..e7c9629 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStopState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStopState.java
index a9ea628..b72ee31 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStopState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleStopState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleTransition.java
index 0b6da67..ff855d7 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/RuleTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/RuleTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java
index 64dd21e..922e931 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/SetTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/SetTransition.java
index 5b4dfaf..86904bd 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/SetTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/SetTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java
index 9f7682b..582c6a6 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/SingletonPredictionContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/StarBlockStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/StarBlockStartState.java
index 09bdaa1..3321e0a 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/StarBlockStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/StarBlockStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopEntryState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopEntryState.java
index 621f1ec..aa1fe02 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopEntryState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopEntryState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopbackState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopbackState.java
index 7a27e19..f7ad420 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopbackState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/StarLoopbackState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/TokensStartState.java b/runtime/Java/src/org/antlr/v4/runtime/atn/TokensStartState.java
index ae97817..d1be204 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/TokensStartState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/TokensStartState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/Transition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/Transition.java
index 5568192..04b368f 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/Transition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/Transition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/WildcardTransition.java b/runtime/Java/src/org/antlr/v4/runtime/atn/WildcardTransition.java
index 6cca73d..1634196 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/atn/WildcardTransition.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/atn/WildcardTransition.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.atn;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFA.java b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFA.java
index 1f6890d..b508f8b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFA.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFA.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.dfa;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFASerializer.java b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFASerializer.java
index 7f4c4e5..54b0fab 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFASerializer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFASerializer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.dfa;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java
index fe5b3ea..5b74f6c 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.dfa;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/dfa/LexerDFASerializer.java b/runtime/Java/src/org/antlr/v4/runtime/dfa/LexerDFASerializer.java
index 8bacc7a..d1d0cca 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/dfa/LexerDFASerializer.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/dfa/LexerDFASerializer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.dfa;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java b/runtime/Java/src/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java
index 23bb690..c149d9e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java
index 4f25420..4595275 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
@@ -50,7 +26,7 @@ public class Array2DHashSet<T> implements Set<T> {
/** How many elements in set */
protected int n = 0;
- protected int threshold = (int)(INITAL_CAPACITY * LOAD_FACTOR); // when to expand
+ protected int threshold = (int)Math.floor(INITAL_CAPACITY * LOAD_FACTOR); // when to expand
protected int currentPrime = 1; // jump by 4 primes each expand or whatever
protected int initialBucketCapacity = INITAL_BUCKET_CAPACITY;
@@ -407,6 +383,7 @@ public class Array2DHashSet<T> implements Set<T> {
public void clear() {
buckets = createBuckets(INITAL_CAPACITY);
n = 0;
+ threshold = (int)Math.floor(INITAL_CAPACITY * LOAD_FACTOR);
}
@Override
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/DoubleKeyMap.java b/runtime/Java/src/org/antlr/v4/runtime/misc/DoubleKeyMap.java
index 966205e..a612347 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/DoubleKeyMap.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/DoubleKeyMap.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/EqualityComparator.java b/runtime/Java/src/org/antlr/v4/runtime/misc/EqualityComparator.java
index 2c6c4ff..0fee89b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/EqualityComparator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/EqualityComparator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java b/runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java
index 3e5582a..a05008e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java
index 606efbb..80d908b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java
index 18860fe..21d5bcd 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java
@@ -1,35 +1,10 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
-import java.lang.IllegalArgumentException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerStack.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerStack.java
index d5806e8..5250a72 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerStack.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerStack.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Interval.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Interval.java
index c2b3f81..b5d7d1d 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Interval.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Interval.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java
index 9f274be..27fb574 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/LogManager.java b/runtime/Java/src/org/antlr/v4/runtime/misc/LogManager.java
index e3e9985..d47b5a2 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/LogManager.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/LogManager.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/MultiMap.java b/runtime/Java/src/org/antlr/v4/runtime/misc/MultiMap.java
index 43bffb1..ce7972e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/MultiMap.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/MultiMap.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/MurmurHash.java b/runtime/Java/src/org/antlr/v4/runtime/misc/MurmurHash.java
index 4d5d0ea..c498b06 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/MurmurHash.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/MurmurHash.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/NotNull.java b/runtime/Java/src/org/antlr/v4/runtime/misc/NotNull.java
index 1277d8d..25c59e4 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/NotNull.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/NotNull.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java b/runtime/Java/src/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java
index 576e06f..256a17b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java
index 991c8b9..d8f9d1b 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Pair.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Pair.java
index 2b11efd..c01c907 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Pair.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Pair.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/ParseCancellationException.java b/runtime/Java/src/org/antlr/v4/runtime/misc/ParseCancellationException.java
index 6c6c49b..4e1ebdb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/ParseCancellationException.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/ParseCancellationException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Predicate.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Predicate.java
index 41c9af0..1c297a5 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Predicate.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Predicate.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.misc;
public interface Predicate<T> {
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java b/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java
index 9f656fe..de6f630 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.misc;
import java.lang.reflect.Method;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Triple.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Triple.java
index ad8c216..fdbf1c0 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Triple.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Triple.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Utils.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Utils.java
index 991ee2b..450c603 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/misc/Utils.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Utils.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.misc;
@@ -177,4 +153,58 @@ public class Utils {
}
return s;
}
+
+ /** @since 4.6 */
+ public static String expandTabs(String s, int tabSize) {
+ if ( s==null ) return null;
+ StringBuilder buf = new StringBuilder();
+ int col = 0;
+ for (int i = 0; i<s.length(); i++) {
+ char c = s.charAt(i);
+ switch ( c ) {
+ case '\n' :
+ col = 0;
+ buf.append(c);
+ break;
+ case '\t' :
+ int n = tabSize-col%tabSize;
+ col+=n;
+ buf.append(spaces(n));
+ break;
+ default :
+ col++;
+ buf.append(c);
+ break;
+ }
+ }
+ return buf.toString();
+ }
+
+ /** @since 4.6 */
+ public static String spaces(int n) {
+ return sequence(n, " ");
+ }
+
+ /** @since 4.6 */
+ public static String newlines(int n) {
+ return sequence(n, "\n");
+ }
+
+ /** @since 4.6 */
+ public static String sequence(int n, String s) {
+ StringBuilder buf = new StringBuilder();
+ for (int sp=1; sp<=n; sp++) buf.append(s);
+ return buf.toString();
+ }
+
+ /** @since 4.6 */
+ public static int count(String s, char x) {
+ int n = 0;
+ for (int i = 0; i<s.length(); i++) {
+ if ( s.charAt(i)==x ) {
+ n++;
+ }
+ }
+ return n;
+ }
}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/AbstractParseTreeVisitor.java b/runtime/Java/src/org/antlr/v4/runtime/tree/AbstractParseTreeVisitor.java
index 9477d96..f565fbf 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/AbstractParseTreeVisitor.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/AbstractParseTreeVisitor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNode.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNode.java
index f967c80..87bf2fa 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNode.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNode.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNodeImpl.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNodeImpl.java
index 750ee19..9295282 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNodeImpl.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ErrorNodeImpl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/IterativeParseTreeWalker.java b/runtime/Java/src/org/antlr/v4/runtime/tree/IterativeParseTreeWalker.java
new file mode 100644
index 0000000..edb0746
--- /dev/null
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/IterativeParseTreeWalker.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.runtime.tree;
+
+import org.antlr.v4.runtime.misc.IntegerStack;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+/**
+ * An iterative (read: non-recursive) pre-order and post-order tree walker that
+ * doesn't use the thread stack but heap-based stacks. Makes it possible to
+ * process deeply nested parse trees.
+ */
+public class IterativeParseTreeWalker extends ParseTreeWalker {
+
+ @Override
+ public void walk(ParseTreeListener listener, ParseTree t) {
+
+ final Deque<ParseTree> nodeStack = new ArrayDeque<ParseTree>();
+ final IntegerStack indexStack = new IntegerStack();
+
+ ParseTree currentNode = t;
+ int currentIndex = 0;
+
+ while (currentNode != null) {
+
+ // pre-order visit
+ if (currentNode instanceof ErrorNode) {
+ listener.visitErrorNode((ErrorNode) currentNode);
+ } else if (currentNode instanceof TerminalNode) {
+ listener.visitTerminal((TerminalNode) currentNode);
+ } else {
+ final RuleNode r = (RuleNode) currentNode;
+ enterRule(listener, r);
+ }
+
+ // Move down to first child, if exists
+ if (currentNode.getChildCount() > 0) {
+ nodeStack.push(currentNode);
+ indexStack.push(currentIndex);
+ currentIndex = 0;
+ currentNode = currentNode.getChild(0);
+ continue;
+ }
+
+ // No child nodes, so walk tree
+ do {
+
+ // post-order visit
+ if (currentNode instanceof RuleNode) {
+ exitRule(listener, (RuleNode) currentNode);
+ }
+
+ // No parent, so no siblings
+ if (nodeStack.isEmpty()) {
+ currentNode = null;
+ currentIndex = 0;
+ break;
+ }
+
+ // Move to next sibling if possible
+ currentNode = nodeStack.peek().getChild(++currentIndex);
+ if (currentNode != null) {
+ break;
+ }
+
+ // No next, sibling, so move up
+ currentNode = nodeStack.pop();
+ currentIndex = indexStack.pop();
+
+ } while (currentNode != null);
+ }
+ }
+}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java
index 7b49040..ebb20db 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeListener.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeListener.java
index 913e0bd..4fa245e 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeProperty.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeProperty.java
index 27db5dd..ca16b18 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeProperty.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeProperty.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java
index 48522db..f9519da 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeWalker.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeWalker.java
index 1065204..3d0546d 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeWalker.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeWalker.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/RuleNode.java b/runtime/Java/src/org/antlr/v4/runtime/tree/RuleNode.java
index 260b6b8..5e31437 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/RuleNode.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/RuleNode.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java b/runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java
index 8a46590..cedfa19 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNode.java b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNode.java
index 4e44ffc..d8a3e65 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNode.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNode.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java
index 05e2630..1882d16 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java b/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java
index 119dbee..78f2b75 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java b/runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java
index 3cb8668..9c07298 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/Chunk.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/Chunk.java
index 6947beb..fc33fed 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/Chunk.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/Chunk.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreeMatch.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreeMatch.java
index 62917cf..3101916 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreeMatch.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreeMatch.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePattern.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePattern.java
index 69651b4..a8f5d14 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePattern.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePattern.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java
index 9ee5bee..7c2c954 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java
index 5b3313c..1fcb0c6 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TagChunk.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TagChunk.java
index 8b5394a..420c892 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TagChunk.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TagChunk.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TextChunk.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TextChunk.java
index 82e224c..0ef75a3 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TextChunk.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TextChunk.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TokenTagToken.java b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TokenTagToken.java
index 2ce2e2d..740a898 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TokenTagToken.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/pattern/TokenTagToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.runtime.tree.pattern;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java
index 7bd249f..a4a91bb 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.ANTLRInputStream;
@@ -85,6 +91,7 @@ public class XPath {
throw new IllegalArgumentException("Could not read path: "+path, ioe);
}
XPathLexer lexer = new XPathLexer(in) {
+ @Override
public void recover(LexerNoViableAltException e) { throw e; }
};
lexer.removeErrorListeners();
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java
index 1385cf9..221a729 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java
index 30f163e..a669850 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.BaseErrorListener;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java
index 216b1ba..66684ae 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java
index 3131279..2827914 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.ParserRuleContext;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java
index eeeffa2..af08ec9 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java
index b6781ba..9560af1 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java
index b4f7c8a..43c63ed 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java
index c38e30d..e027299 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.runtime.tree.xpath;
import org.antlr.v4.runtime.tree.ParseTree;
diff --git a/tool-testsuite/pom.xml b/tool-testsuite/pom.xml
index c7b1564..ba6bcdf 100644
--- a/tool-testsuite/pom.xml
+++ b/tool-testsuite/pom.xml
@@ -1,10 +1,16 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
+ <version>4.6</version>
</parent>
<artifactId>antlr4-tool-testsuite</artifactId>
<name>ANTLR 4 Tool Tests</name>
@@ -21,67 +27,46 @@
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
<version>4.0.8</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- <version>${project.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime-testsuite</artifactId>
<version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime-testsuite</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- </dependency>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
+ <version>4.12</version>
+ <scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
- <groupId>com.googlecode.maven-download-plugin</groupId>
- <artifactId>download-maven-plugin</artifactId>
- <version>1.2.1</version>
- <configuration>
- <skipCache>true</skipCache>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.8</version>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
+ <includes>
+ <include>**/Test*.java</include>
+ </includes>
<systemPropertyVariables>
<antlr-python2-runtime>../../antlr4-python2/src</antlr-python2-runtime>
<antlr-python3-runtime>../../antlr4-python3/src</antlr-python3-runtime>
<antlr-csharp-runtime-project>../../antlr4-csharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj</antlr-csharp-runtime-project>
+ <antlr-cpp-runtime>../../antlr4-cpp/src</antlr-cpp-runtime>
<antlr-javascript-runtime>../../antlr4-javascript/src</antlr-javascript-runtime>
</systemPropertyVariables>
</configuration>
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/BaseJavaToolTest.java b/tool-testsuite/test/org/antlr/v4/test/tool/BaseJavaToolTest.java
new file mode 100644
index 0000000..d13af2d
--- /dev/null
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/BaseJavaToolTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.test.tool;
+
+import org.antlr.v4.Tool;
+import org.antlr.v4.test.runtime.BaseRuntimeTest;
+import org.antlr.v4.test.runtime.ErrorQueue;
+import org.antlr.v4.test.runtime.java.BaseJavaTest;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+
+public class BaseJavaToolTest extends BaseJavaTest {
+ public void testErrors(String[] pairs, boolean printTree) {
+ for (int i = 0; i < pairs.length; i+=2) {
+ String grammarStr = pairs[i];
+ String expect = pairs[i+1];
+
+ String[] lines = grammarStr.split("\n");
+ String fileName = getFilenameFromFirstLineOfGrammar(lines[0]);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, null, fileName, grammarStr, false); // use default language target in case test overrides
+
+ String actual = equeue.toString(true);
+ actual = actual.replace(tmpdir + File.separator, "");
+// System.err.println(actual);
+ String msg = grammarStr;
+ msg = msg.replace("\n","\\n");
+ msg = msg.replace("\r","\\r");
+ msg = msg.replace("\t","\\t");
+
+ assertEquals("error in: "+msg,expect,actual);
+ }
+ }
+
+ public String getFilenameFromFirstLineOfGrammar(String line) {
+ String fileName = "A" + Tool.GRAMMAR_EXTENSION;
+ int grIndex = line.lastIndexOf("grammar");
+ int semi = line.lastIndexOf(';');
+ if ( grIndex>=0 && semi>=0 ) {
+ int space = line.indexOf(' ', grIndex);
+ fileName = line.substring(space+1, semi)+Tool.GRAMMAR_EXTENSION;
+ }
+ if ( fileName.length()==Tool.GRAMMAR_EXTENSION.length() ) fileName = "A" + Tool.GRAMMAR_EXTENSION;
+ return fileName;
+ }
+}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/InterpreterTreeTextProvider.java b/tool-testsuite/test/org/antlr/v4/test/tool/InterpreterTreeTextProvider.java
index bff84ae..d973939 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/InterpreterTreeTextProvider.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/InterpreterTreeTextProvider.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
import org.antlr.v4.gui.TreeTextProvider;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/JavaUnicodeInputStream.java b/tool-testsuite/test/org/antlr/v4/test/tool/JavaUnicodeInputStream.java
index d51d000..cdbf9c3 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/JavaUnicodeInputStream.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/JavaUnicodeInputStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/ParserInterpreterForTesting.java b/tool-testsuite/test/org/antlr/v4/test/tool/ParserInterpreterForTesting.java
index 9fe58a1..2f5ac4d 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/ParserInterpreterForTesting.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/ParserInterpreterForTesting.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/PositionAdjustingLexer.g4 b/tool-testsuite/test/org/antlr/v4/test/tool/PositionAdjustingLexer.g4
index 4d52dfc..4d1522f 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/PositionAdjustingLexer.g4
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/PositionAdjustingLexer.g4
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestASTStructure.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestASTStructure.java
index d081fe8..7211efd 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestASTStructure.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestASTStructure.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNConstruction.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNConstruction.java
index 08648f5..5764175 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNConstruction.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNConstruction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -36,14 +12,14 @@ import org.antlr.v4.automata.ParserATNFactory;
import org.antlr.v4.parse.ANTLRParser;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNState;
-import org.antlr.v4.test.runtime.java.BaseTest;
-import org.antlr.v4.test.runtime.java.ErrorQueue;
+import org.antlr.v4.test.runtime.ErrorQueue;
import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.ast.GrammarAST;
import org.antlr.v4.tool.ast.GrammarRootAST;
import org.antlr.v4.tool.ast.RuleAST;
+import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
@@ -54,7 +30,13 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class TestATNConstruction extends BaseTest {
+public class TestATNConstruction extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test
public void testA() throws Exception {
Grammar g = new Grammar(
@@ -358,6 +340,20 @@ public class TestATNConstruction extends BaseTest {
"RuleStop_a_1-EOF->s9\n";
checkRuleATN(g, "a", expecting);
}
+ @Test public void testEmptyOrEmpty() throws Exception {
+ Grammar g = new Grammar(
+ "parser grammar P;\n"+
+ "a : | ;");
+ String expecting =
+ "RuleStart_a_0->BlockStart_4\n"+
+ "BlockStart_4->s2\n"+
+ "BlockStart_4->s3\n"+
+ "s2->BlockEnd_5\n"+
+ "s3->BlockEnd_5\n"+
+ "BlockEnd_5->RuleStop_a_1\n"+
+ "RuleStop_a_1-EOF->s6\n";
+ checkRuleATN(g, "a", expecting);
+ }
@Test public void testAStar() throws Exception {
Grammar g = new Grammar(
"parser grammar P;\n"+
@@ -464,6 +460,65 @@ public class TestATNConstruction extends BaseTest {
assertTrue(!threwException);
}
+ /** Test for https://github.com/antlr/antlr4/issues/1369
+ * Repeated edges:
+
+ RuleStop_e_3->BlockEnd_26
+ RuleStop_e_3->BlockEnd_26
+ RuleStop_e_3->BlockEnd_26
+
+ * @throws Exception
+ */
+ @Test public void testForRepeatedTransitionsToStopState() throws Exception {
+ String gstr =
+ "grammar T;\n"+
+ "\t s : e EOF;\n"+
+ "\t e :<assoc=right> e '*' e\n"+
+ "\t |<assoc=right> e '+' e\n"+
+ "\t |<assoc=right> e '?' e ':' e\n"+
+ "\t |<assoc=right> e '=' e\n"+
+ "\t | ID\n"+
+ "\t ;\n"+
+ "\t ID : 'a'..'z'+ ;\n"+
+ "\t WS : (' '|'\\n') -> skip ;";
+ Grammar g = new Grammar(gstr);
+ String expecting =
+ "RuleStart_e_2->s7\n"+
+ "s7-action_1:-1->s8\n"+
+ "s8-ID->s9\n"+
+ "s9->StarLoopEntry_27\n"+
+ "StarLoopEntry_27->StarBlockStart_25\n"+
+ "StarLoopEntry_27->s28\n"+
+ "StarBlockStart_25->s10\n"+
+ "StarBlockStart_25->s13\n"+
+ "StarBlockStart_25->s16\n"+
+ "StarBlockStart_25->s22\n"+
+ "s28->RuleStop_e_3\n"+
+ "s10-5 >= _p->s11\n"+
+ "s13-4 >= _p->s14\n"+
+ "s16-3 >= _p->s17\n"+
+ "s22-2 >= _p->s23\n"+
+ "RuleStop_e_3->s5\n"+
+ "RuleStop_e_3->BlockEnd_26\n"+
+ "RuleStop_e_3->s19\n"+
+ "RuleStop_e_3->s21\n"+
+ "s11-'*'->s12\n"+
+ "s14-'+'->s15\n"+
+ "s17-'?'->s18\n"+
+ "s23-'='->s24\n"+
+ "s12-e->RuleStart_e_2\n"+
+ "s15-e->RuleStart_e_2\n"+
+ "s18-e->RuleStart_e_2\n"+
+ "s24-e->RuleStart_e_2\n"+
+ "BlockEnd_26->StarLoopBack_29\n"+
+ "s19-':'->s20\n"+
+ "StarLoopBack_29->StarLoopEntry_27\n"+
+ "s20-e->RuleStart_e_2\n"+
+ "s21->BlockEnd_26\n";
+ checkRuleATN(g, "e", expecting);
+ }
+
+
/*
@Test public void testMultiplePredicates() throws Exception {
Grammar g = new Grammar(
@@ -610,311 +665,8 @@ public class TestATNConstruction extends BaseTest {
"RuleStop_a_1-EOF->s4\n";
checkRule(g, "a", expecting);
}
- // AUTO BACKTRACKING STUFF
- @Test public void testAutoBacktracking_RuleBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : 'a'{;}|'b';"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s1->.s9\n" +
- ".s10-'b'->.s11\n" +
- ".s11->.s6\n" +
- ".s2-{synpred1_t}?->.s3\n" +
- ".s3-'a'->.s4\n" +
- ".s4-{}->.s5\n" +
- ".s5->.s6\n" +
- ".s6->:s7\n" +
- ".s9->.s10\n" +
- ":s7-EOF->.s8\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_RuleSetBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : 'a'|'b';"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s2-'a'..'b'->.s3\n" +
- ".s3->:s4\n" +
- ":s4-EOF->.s5\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_SimpleBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'{;}|'b') ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s10->.s11\n" +
- ".s11-'b'->.s12\n" +
- ".s12->.s7\n" +
- ".s2->.s10\n" +
- ".s2->.s3\n" +
- ".s3-{synpred1_t}?->.s4\n" +
- ".s4-'a'->.s5\n" +
- ".s5-{}->.s6\n" +
- ".s6->.s7\n" +
- ".s7->:s8\n" +
- ":s8-EOF->.s9\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_SetBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'|'b') ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s2-'a'..'b'->.s3\n" +
- ".s3->:s4\n" +
- ":s4-EOF->.s5\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_StarBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'{;}|'b')* ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s12->.s13\n" +
- ".s13-{synpred2_t}?->.s14\n" +
- ".s14-'b'->.s15\n" +
- ".s15->.s8\n" +
- ".s16->.s9\n" +
- ".s2->.s16\n" +
- ".s2->.s3\n" +
- ".s3->.s12\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6-{}->.s7\n" +
- ".s7->.s8\n" +
- ".s8->.s3\n" +
- ".s8->.s9\n" +
- ".s9->:s10\n" +
- ":s10-EOF->.s11\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_StarSetBlock_IgnoresPreds() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'|'b')* ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s2->.s3\n" +
- ".s2->.s9\n" +
- ".s3->.s4\n" +
- ".s4-'a'..'b'->.s5\n" +
- ".s5->.s3\n" +
- ".s5->.s6\n" +
- ".s6->:s7\n" +
- ".s9->.s6\n" +
- ":s7-EOF->.s8\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_StarSetBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'|'b'{;})* ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s11->.s12\n" +
- ".s12-{synpred2_t}?->.s13\n" +
- ".s13-'b'->.s14\n" +
- ".s14-{}->.s15\n" +
- ".s15->.s7\n" +
- ".s16->.s8\n" +
- ".s2->.s16\n" +
- ".s2->.s3\n" +
- ".s3->.s11\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6->.s7\n" +
- ".s7->.s3\n" +
- ".s7->.s8\n" +
- ".s8->:s9\n" +
- ":s9-EOF->.s10\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_StarBlock1Alt() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a')* ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s10->.s7\n" +
- ".s2->.s10\n" +
- ".s2->.s3\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6->.s3\n" +
- ".s6->.s7\n" +
- ".s7->:s8\n" +
- ":s8-EOF->.s9\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_PlusBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'{;}|'b')+ ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s12->.s13\n" +
- ".s13-{synpred2_t}?->.s14\n" +
- ".s14-'b'->.s15\n" +
- ".s15->.s8\n" +
- ".s2->.s3\n" +
- ".s3->.s12\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6-{}->.s7\n" +
- ".s7->.s8\n" +
- ".s8->.s3\n" +
- ".s8->.s9\n" +
- ".s9->:s10\n" +
- ":s10-EOF->.s11\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_PlusSetBlock() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'|'b'{;})+ ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s11->.s12\n" +
- ".s12-{synpred2_t}?->.s13\n" +
- ".s13-'b'->.s14\n" +
- ".s14-{}->.s15\n" +
- ".s15->.s7\n" +
- ".s2->.s3\n" +
- ".s3->.s11\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6->.s7\n" +
- ".s7->.s3\n" +
- ".s7->.s8\n" +
- ".s8->:s9\n" +
- ":s9-EOF->.s10\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_PlusBlock1Alt() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a')+ ;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s2->.s3\n" +
- ".s3->.s4\n" +
- ".s4-{synpred1_t}?->.s5\n" +
- ".s5-'a'->.s6\n" +
- ".s6->.s3\n" +
- ".s6->.s7\n" +
- ".s7->:s8\n" +
- ":s8-EOF->.s9\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_OptionalBlock2Alts() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a'{;}|'b')?;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s10->.s11\n" +
- ".s10->.s14\n" +
- ".s11-{synpred2_t}?->.s12\n" +
- ".s12-'b'->.s13\n" +
- ".s13->.s7\n" +
- ".s14->.s7\n" +
- ".s2->.s10\n" +
- ".s2->.s3\n" +
- ".s3-{synpred1_t}?->.s4\n" +
- ".s4-'a'->.s5\n" +
- ".s5-{}->.s6\n" +
- ".s6->.s7\n" +
- ".s7->:s8\n" +
- ":s8-EOF->.s9\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_OptionalBlock1Alt() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a')?;"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s2->.s3\n" +
- ".s2->.s9\n" +
- ".s3-{synpred1_t}?->.s4\n" +
- ".s4-'a'->.s5\n" +
- ".s5->.s6\n" +
- ".s6->:s7\n" +
- ".s9->.s6\n" +
- ":s7-EOF->.s8\n";
- checkRule(g, "a", expecting);
- }
- @Test public void testAutoBacktracking_ExistingPred() throws Exception {
- Grammar g = new Grammar(
- "grammar t;\n" +
- "options {backtrack=true;}\n"+
- "a : ('a')=> 'a' | 'b';"
- );
- String expecting =
- ".s0->.s1\n" +
- ".s1->.s2\n" +
- ".s1->.s8\n" +
- ".s10->.s5\n" +
- ".s2-{synpred1_t}?->.s3\n" +
- ".s3-'a'->.s4\n" +
- ".s4->.s5\n" +
- ".s5->:s6\n" +
- ".s8->.s9\n" +
- ".s9-'b'->.s10\n" +
- ":s6-EOF->.s7\n";
- checkRule(g, "a", expecting);
- }
-*/
+ */
+
@Test public void testDefaultMode() throws Exception {
LexerGrammar g = new LexerGrammar(
"lexer grammar L;\n"+
@@ -934,6 +686,7 @@ public class TestATNConstruction extends BaseTest {
"s13->RuleStop_X_5\n";
checkTokensRule(g, "DEFAULT_MODE", expecting);
}
+
@Test public void testMode() throws Exception {
LexerGrammar g = new LexerGrammar(
"lexer grammar L;\n"+
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNDeserialization.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNDeserialization.java
index a8ef3af..5f19024 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNDeserialization.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNDeserialization.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -34,16 +10,22 @@ import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.atn.ATNSerializer;
import org.antlr.v4.runtime.misc.Utils;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
-public class TestATNDeserialization extends BaseTest {
+public class TestATNDeserialization extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testSimpleNoBlock() throws Exception {
Grammar g = new Grammar(
"parser grammar T;\n"+
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
index 2309a1c..14e82ae 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -39,11 +15,11 @@ import org.antlr.v4.runtime.atn.BlockStartState;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.IntegerList;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.DOTGenerator;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -52,7 +28,13 @@ import static org.junit.Assert.assertEquals;
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
-public class TestATNInterpreter extends BaseTest {
+public class TestATNInterpreter extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testSimpleNoBlock() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n" +
@@ -384,7 +366,7 @@ public class TestATNInterpreter extends BaseTest {
ATN lexatn = createATN(lg, true);
LexerATNSimulator lexInterp = new LexerATNSimulator(lexatn,new DFA[] { new DFA(lexatn.modeToStartState.get(Lexer.DEFAULT_MODE)) },null);
IntegerList types = getTokenTypesViaATN(inputString, lexInterp);
- System.out.println(types);
+// System.out.println(types);
g.importVocab(lg);
@@ -392,7 +374,7 @@ public class TestATNInterpreter extends BaseTest {
ATN atn = f.createATN();
IntTokenStream input = new IntTokenStream(types);
- System.out.println("input="+input.types);
+// System.out.println("input="+input.types);
ParserInterpreterForTesting interp = new ParserInterpreterForTesting(g, input);
ATNState startState = atn.ruleToStartState[g.getRule("a").index];
if ( startState.transition(0).target instanceof BlockStartState ) {
@@ -400,9 +382,9 @@ public class TestATNInterpreter extends BaseTest {
}
DOTGenerator dot = new DOTGenerator(g);
- System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
+// System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
Rule r = g.getRule("e");
- if ( r!=null ) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null ) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
int result = interp.matchATN(input, startState);
assertEquals(expected, result);
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNLexerInterpreter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNLexerInterpreter.java
index aaf28c3..0324d39 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNLexerInterpreter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNLexerInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -35,9 +11,9 @@ import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNState;
import org.antlr.v4.runtime.misc.Utils;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.DOTGenerator;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import java.util.List;
@@ -57,7 +33,13 @@ import static org.junit.Assert.assertEquals;
* want, but occasionally there are some quirks as you'll see from
* the tests below.
*/
-public class TestATNLexerInterpreter extends BaseTest {
+public class TestATNLexerInterpreter extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testLexerTwoRules() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n"+
@@ -314,12 +296,12 @@ public class TestATNLexerInterpreter extends BaseTest {
CharStream input = new ANTLRInputStream(inputString);
ATNState startState = atn.modeNameToStartState.get("DEFAULT_MODE");
DOTGenerator dot = new DOTGenerator(lg);
- System.out.println(dot.getDOT(startState, true));
+// System.out.println(dot.getDOT(startState, true));
List<String> tokenTypes = getTokenTypes(lg, atn, input);
String result = Utils.join(tokenTypes.iterator(), ", ");
- System.out.println(tokenTypes);
+// System.out.println(tokenTypes);
assertEquals(expecting, result);
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java
index 5e5731c..3049fd8 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -41,12 +17,12 @@ import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.IntegerList;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.DOTGenerator;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LeftRecursiveRule;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
+import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
@@ -58,7 +34,13 @@ import static org.junit.Assert.assertTrue;
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
-public class TestATNParserPrediction extends BaseTest {
+public class TestATNParserPrediction extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testAorB() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n" +
@@ -520,7 +502,7 @@ public class TestATNParserPrediction extends BaseTest {
LexerATNSimulator lexInterp =
new LexerATNSimulator(lexatn,new DFA[] { new DFA(lexatn.modeToStartState.get(Lexer.DEFAULT_MODE)) },new PredictionContextCache());
IntegerList types = getTokenTypesViaATN(inputString, lexInterp);
- System.out.println(types);
+// System.out.println(types);
semanticProcess(lg);
g.importVocab(lg);
@@ -532,15 +514,15 @@ public class TestATNParserPrediction extends BaseTest {
DOTGenerator dot = new DOTGenerator(g);
Rule r = g.getRule("a");
- if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
r = g.getRule("b");
- if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
r = g.getRule("e");
- if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
r = g.getRule("ifstat");
- if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
r = g.getRule("block");
- if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
// Check ATN prediction
// ParserATNSimulator interp = new ParserATNSimulator(atn);
@@ -576,7 +558,7 @@ public class TestATNParserPrediction extends BaseTest {
for (int i=0; i<inputString.length; i++) {
// Check DFA
IntegerList types = getTokenTypesViaATN(inputString[i], lexInterp);
- System.out.println(types);
+// System.out.println(types);
TokenStream input = new IntTokenStream(types);
try {
interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY);
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNSerialization.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNSerialization.java
index 2c1a2b0..5e2b57e 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNSerialization.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNSerialization.java
@@ -1,48 +1,30 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNSerializer;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.DOTGenerator;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
-public class TestATNSerialization extends BaseTest {
+public class TestATNSerialization extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testSimpleNoBlock() throws Exception {
Grammar g = new Grammar(
"parser grammar T;\n"+
@@ -127,7 +109,6 @@ public class TestATNSerialization extends BaseTest {
"3->1 EPSILON 0,0,0\n";
ATN atn = createATN(g, true);
DOTGenerator gen = new DOTGenerator(g);
- System.out.println(gen.getDOT(atn.ruleToStartState[0]));
String result = ATNSerializer.getDecoded(atn, Arrays.asList(g.getTokenNames()));
assertEquals(expecting, result);
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestActionSplitter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestActionSplitter.java
index d8ad87c..391da8e 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestActionSplitter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestActionSplitter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -34,7 +10,7 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.Token;
import org.antlr.v4.parse.ActionSplitter;
import org.antlr.v4.semantics.BlankActionSplitterListener;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
@@ -42,7 +18,13 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
-public class TestActionSplitter extends BaseTest {
+public class TestActionSplitter extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
static String[] exprs = {
"foo", "['foo'<" + ActionSplitter.TEXT + ">]",
"$x", "['$x'<" + ActionSplitter.ATTR + ">]",
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestActionTranslation.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestActionTranslation.java
index dfe1704..db73a81 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestActionTranslation.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestActionTranslation.java
@@ -1,42 +1,24 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
+import org.junit.Before;
import org.junit.Test;
/** */
@SuppressWarnings("unused")
-public class TestActionTranslation extends BaseTest {
+public class TestActionTranslation extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
String attributeTemplate =
"attributeTemplate(members,init,inline,finally,inline2) ::= <<\n" +
"parser grammar A;\n"+
@@ -169,6 +151,52 @@ public class TestActionTranslation extends BaseTest {
testActions(attributeTemplate, "inline", action, expected);
}
+ /** Added in response to https://github.com/antlr/antlr4/issues/1211 */
+ @Test public void testUnknownAttr() throws Exception {
+ String action = "$qqq.text";
+ String expected = ""; // was causing an exception
+ testActions(attributeTemplate, "inline", action, expected);
+ }
+
+ /**
+ * Regression test for issue #1295
+ * $e.v yields incorrect value 0 in "e returns [int v] : '1' {$v = 1;} | '(' e ')' {$v = $e.v;} ;"
+ * https://github.com/antlr/antlr4/issues/1295
+ */
+ @Test public void testRuleRefsRecursive() throws Exception {
+ String recursiveTemplate =
+ "recursiveTemplate(inline) ::= <<\n" +
+ "parser grammar A;\n"+
+ "e returns [int v]\n" +
+ " : INT {$v = $INT.int;}\n" +
+ " | '(' e ')' {\n" +
+ " #inline#<inline>#end-inline#\n" +
+ " }\n" +
+ " ;\n" +
+ ">>";
+ String leftRecursiveTemplate =
+ "recursiveTemplate(inline) ::= <<\n" +
+ "parser grammar A;\n"+
+ "e returns [int v]\n" +
+ " : a=e op=('*'|'/') b=e {$v = eval($a.v, $op.type, $b.v);}\n" +
+ " | INT {$v = $INT.int;}\n" +
+ " | '(' e ')' {\n" +
+ " #inline#<inline>#end-inline#\n" +
+ " }\n" +
+ " ;\n" +
+ ">>";
+ // ref to value returned from recursive call to rule
+ String action = "$v = $e.v;";
+ String expected = "((EContext)_localctx).v = ((EContext)_localctx).e.v;";
+ testActions(recursiveTemplate, "inline", action, expected);
+ testActions(leftRecursiveTemplate, "inline", action, expected);
+ // ref to predefined attribute obtained from recursive call to rule
+ action = "$v = $e.text.length();";
+ expected = "((EContext)_localctx).v = (((EContext)_localctx).e!=null?_input.getText(((EContext)_localctx).e.start,((EContext)_localctx).e.stop):null).length();";
+ testActions(recursiveTemplate, "inline", action, expected);
+ testActions(leftRecursiveTemplate, "inline", action, expected);
+ }
+
@Test public void testRefToTextAttributeForCurrentRule() throws Exception {
String action = "$ctx.text; $text";
@@ -190,67 +218,7 @@ public class TestActionTranslation extends BaseTest {
}
- @Test public void testDynamicRuleScopeRefInSubrule() throws Exception {
- String action = "$a::n;";
- }
- @Test public void testRuleScopeFromAnotherRule() throws Exception {
- String action = "$a::n;"; // must be qualified
- }
- @Test public void testFullyQualifiedRefToCurrentRuleParameter() throws Exception {
- String action = "$a.i;";
- }
- @Test public void testFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
- String action = "$a.i;";
- }
- @Test public void testSetFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
- String action = "$a.i = 1;";
- }
- @Test public void testIsolatedRefToCurrentRule() throws Exception {
- String action = "$a;";
- }
- @Test public void testIsolatedRefToRule() throws Exception {
- String action = "$x;";
- }
- @Test public void testFullyQualifiedRefToLabelInCurrentRule() throws Exception {
- String action = "$a.x;";
- }
- @Test public void testFullyQualifiedRefToListLabelInCurrentRule() throws Exception {
- String action = "$a.x;"; // must be qualified
- }
- @Test public void testFullyQualifiedRefToTemplateAttributeInCurrentRule() throws Exception {
- String action = "$a.st;"; // can be qualified
- }
- @Test public void testRuleRefWhenRuleHasScope() throws Exception {
- String action = "$b.start;";
- }
- @Test public void testDynamicScopeRefOkEvenThoughRuleRefExists() throws Exception {
- String action = "$b::n;";
- }
- @Test public void testRefToTemplateAttributeForCurrentRule() throws Exception {
- String action = "$st=null;";
- }
-
- @Test public void testRefToStartAttributeForCurrentRule() throws Exception {
- String action = "$start;";
- }
-
- @Test public void testTokenLabelFromMultipleAlts() throws Exception {
- String action = "$ID.text;"; // must be qualified
- }
- @Test public void testRuleLabelFromMultipleAlts() throws Exception {
- String action = "$b.text;"; // must be qualified
- }
- @Test public void testUnqualifiedRuleScopeAttribute() throws Exception {
- String action = "$n;"; // must be qualified
- }
- @Test public void testRuleAndTokenLabelTypeMismatch() throws Exception {
- }
- @Test public void testListAndTokenLabelTypeMismatch() throws Exception {
- }
- @Test public void testListAndRuleLabelTypeMismatch() throws Exception {
- }
- @Test public void testArgReturnValueMismatch() throws Exception {
- }
+/*
@Test public void testSimplePlusEqualLabel() throws Exception {
String action = "$ids.size();"; // must be qualified
}
@@ -431,6 +399,6 @@ public class TestActionTranslation extends BaseTest {
}
@Test public void testGenericsAsReturnValue() throws Exception {
}
-
+*/
// TODO: nonlocal $rule::x
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestAmbigParseTrees.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestAmbigParseTrees.java
index 992b116..546517e 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestAmbigParseTrees.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestAmbigParseTrees.java
@@ -1,5 +1,12 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
+import org.antlr.v4.gui.Trees;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.LexerInterpreter;
@@ -14,7 +21,6 @@ import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.atn.RuleStartState;
import org.antlr.v4.runtime.atn.Transition;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.gui.Trees;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarParserInterpreter;
import org.antlr.v4.tool.LexerGrammar;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestAttributeChecks.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestAttributeChecks.java
index cef7abd..33ca19b 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestAttributeChecks.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestAttributeChecks.java
@@ -1,43 +1,27 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.runtime.RecognitionException;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
+import org.junit.Before;
import org.junit.Test;
import org.stringtemplate.v4.ST;
+import org.stringtemplate.v4.STGroup;
+import org.stringtemplate.v4.misc.ErrorBuffer;
/** */
-public class TestAttributeChecks extends BaseTest {
+public class TestAttributeChecks extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
String attributeTemplate =
"parser grammar A;\n"+
"@members {<members>}\n" +
@@ -56,7 +40,7 @@ public class TestAttributeChecks extends BaseTest {
"c : ;\n";
String[] membersChecks = {
- "$a", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference a in $a\n",
+ "$a", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference a in $a\n",
"$a.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference a in $a.y\n",
};
@@ -265,7 +249,9 @@ public class TestAttributeChecks extends BaseTest {
for (int i = 0; i < pairs.length; i+=2) {
String action = pairs[i];
String expected = pairs[i+1];
- ST st = new ST(template);
+ STGroup g = new STGroup('<','>');
+ g.setListener(new ErrorBuffer()); // hush warnings
+ ST st = new ST(g, template);
st.add(location, action);
String grammar = st.render();
testErrors(new String[] {grammar, expected}, false);
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestBasicSemanticErrors.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestBasicSemanticErrors.java
index 807172f..661506d 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestBasicSemanticErrors.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestBasicSemanticErrors.java
@@ -1,41 +1,23 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
+import org.junit.Before;
import org.junit.Test;
import org.stringtemplate.v4.ST;
-public class TestBasicSemanticErrors extends BaseTest {
+public class TestBasicSemanticErrors extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
static String[] U = {
// INPUT
"parser grammar U;\n" +
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestBufferedTokenStream.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestBufferedTokenStream.java
index fd85b43..d9cbab5 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestBufferedTokenStream.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestBufferedTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -37,13 +13,18 @@ import org.antlr.v4.runtime.LexerInterpreter;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.TokenStream;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-public class TestBufferedTokenStream extends BaseTest {
+public class TestBufferedTokenStream extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
protected TokenStream createTokenStream(TokenSource src) {
return new BufferedTokenStream(src);
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestCodeGeneration.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestCodeGeneration.java
index 766c775..7574c7c 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestCodeGeneration.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestCodeGeneration.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -35,10 +11,10 @@ import org.antlr.v4.automata.LexerATNFactory;
import org.antlr.v4.automata.ParserATNFactory;
import org.antlr.v4.codegen.CodeGenerator;
import org.antlr.v4.semantics.SemanticPipeline;
-import org.antlr.v4.test.runtime.java.BaseTest;
-import org.antlr.v4.test.runtime.java.ErrorQueue;
+import org.antlr.v4.test.runtime.ErrorQueue;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import org.stringtemplate.v4.AutoIndentWriter;
import org.stringtemplate.v4.InstanceScope;
@@ -56,7 +32,13 @@ import java.util.List;
import static org.junit.Assert.assertFalse;
-public class TestCodeGeneration extends BaseTest {
+public class TestCodeGeneration extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testArgDecl() throws Exception { // should use template not string
/*ErrorQueue equeue = */new ErrorQueue();
String g =
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestCommonTokenStream.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestCommonTokenStream.java
index 8257824..2453add 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestCommonTokenStream.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestCommonTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -40,11 +16,17 @@ import org.antlr.v4.runtime.TokenFactory;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.WritableToken;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestCommonTokenStream extends TestBufferedTokenStream {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
@Override
protected TokenStream createTokenStream(TokenSource src) {
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java
index 02947ab..9b89b0e 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java
@@ -1,41 +1,18 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
-import org.antlr.v4.test.runtime.java.ErrorQueue;
+import org.antlr.v4.test.runtime.BaseRuntimeTest;
+import org.antlr.v4.test.runtime.ErrorQueue;
import org.antlr.v4.tool.ANTLRMessage;
import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarSemanticsMessage;
+import org.junit.Before;
import org.junit.Test;
import java.io.File;
@@ -43,16 +20,22 @@ import java.io.File;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-public class TestCompositeGrammars extends BaseTest {
+public class TestCompositeGrammars extends BaseJavaToolTest {
protected boolean debug = false;
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testImportFileLocationInSubdir() throws Exception {
String slave =
"parser grammar S;\n" +
"a : B {System.out.println(\"S.a\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
String subdir = tmpdir + "/sub";
- mkdir(subdir);
+ BaseRuntimeTest.mkdir(subdir);
writeFile(subdir, "S.g4", slave);
String master =
"grammar M;\n" +
@@ -61,21 +44,77 @@ public class TestCompositeGrammars extends BaseTest {
"B : 'b' ;" + // defines B from inherited token space
"WS : (' '|'\\n') -> skip ;\n" ;
writeFile(tmpdir, "M.g4", master);
- ErrorQueue equeue = antlr("M.g4", false, "-lib", subdir);
- assertEquals(equeue.size(), 0);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-lib", subdir);
+ assertEquals(0, equeue.size());
+ }
+
+ // Test for https://github.com/antlr/antlr4/issues/1317
+ @Test public void testImportSelfLoop() throws Exception {
+ BaseRuntimeTest.mkdir(tmpdir);
+ String master =
+ "grammar M;\n" +
+ "import M;\n" +
+ "s : 'a' ;\n";
+ writeFile(tmpdir, "M.g4", master);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-lib", tmpdir);
+ assertEquals(0, equeue.size());
+ }
+
+ @Test public void testDelegatesSeeSameTokenType() throws Exception {
+ String slaveS =
+ "parser grammar S;\n"+
+ "tokens { A, B, C }\n"+
+ "x : A ;\n";
+ String slaveT =
+ "parser grammar T;\n"+
+ "tokens { C, B, A } // reverse order\n"+
+ "y : A ;\n";
+
+ BaseRuntimeTest.mkdir(tmpdir);
+ writeFile(tmpdir, "S.g4", slaveS);
+ writeFile(tmpdir, "T.g4", slaveT);
+
+ String master =
+ "// The lexer will create rules to match letters a, b, c.\n"+
+ "// The associated token types A, B, C must have the same value\n"+
+ "// and all import'd parsers. Since ANTLR regenerates all imports\n"+
+ "// for use with the delegator M, it can generate the same token type\n"+
+ "// mapping in each parser:\n"+
+ "// public static final int C=6;\n"+
+ "// public static final int EOF=-1;\n"+
+ "// public static final int B=5;\n"+
+ "// public static final int WS=7;\n"+
+ "// public static final int A=4;\n"+
+ "grammar M;\n"+
+ "import S,T;\n"+
+ "s : x y ; // matches AA, which should be 'aa'\n"+
+ "B : 'b' ; // another order: B, A, C\n"+
+ "A : 'a' ;\n"+
+ "C : 'c' ;\n"+
+ "WS : (' '|'\\n') -> skip ;\n";
+ writeFile(tmpdir, "M.g4", master);
+ ErrorQueue equeue = new ErrorQueue();
+ Grammar g = new Grammar(tmpdir+"/M.g4", master, equeue);
+ String expectedTokenIDToTypeMap = "{EOF=-1, B=1, A=2, C=3, WS=4}";
+ String expectedStringLiteralToTypeMap = "{'a'=2, 'b'=1, 'c'=3}";
+ String expectedTypeToTokenList = "[B, A, C, WS]";
+ assertEquals(expectedTokenIDToTypeMap, g.tokenNameToTypeMap.toString());
+ assertEquals(expectedStringLiteralToTypeMap, sort(g.stringLiteralToTypeMap).toString());
+ assertEquals(expectedTypeToTokenList, realElements(g.typeToTokenList).toString());
+ assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
@Test public void testErrorInImportedGetsRightFilename() throws Exception {
String slave =
"parser grammar S;\n" +
"a : 'a' | c;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave);
String master =
"grammar M;\n" +
"import S;\n";
writeFile(tmpdir, "M.g4", master);
- ErrorQueue equeue = antlr("M.g4", false, "-lib", tmpdir);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-lib", tmpdir);
ANTLRMessage msg = equeue.errors.get(0);
assertEquals(ErrorType.UNDEFINED_RULE_REF, msg.getErrorType());
assertEquals("c", msg.getArgs()[0]);
@@ -88,9 +127,9 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar S;\n" +
"a : B {System.out.println(\"S.a\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
String outdir = tmpdir + "/out";
- mkdir(outdir);
+ BaseRuntimeTest.mkdir(outdir);
writeFile(outdir, "S.g4", slave);
String master =
"grammar M;\n" +
@@ -99,7 +138,7 @@ public class TestCompositeGrammars extends BaseTest {
"B : 'b' ;" + // defines B from inherited token space
"WS : (' '|'\\n') -> skip ;\n" ;
writeFile(tmpdir, "M.g4", master);
- ErrorQueue equeue = antlr("M.g4", false, "-o", outdir);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-o", outdir);
assertEquals(ErrorType.CANNOT_FIND_IMPORTED_GRAMMAR, equeue.errors.get(0).getErrorType());
}
@@ -107,9 +146,9 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar S;\n" +
"a : B {System.out.println(\"S.a\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
String subdir = tmpdir + "/sub";
- mkdir(subdir);
+ BaseRuntimeTest.mkdir(subdir);
writeFile(subdir, "S.g4", slave);
String master =
"grammar M;\n" +
@@ -119,8 +158,8 @@ public class TestCompositeGrammars extends BaseTest {
"WS : (' '|'\\n') -> skip ;\n" ;
writeFile(tmpdir, "M.g4", master);
String outdir = tmpdir + "/out";
- mkdir(outdir);
- ErrorQueue equeue = antlr("M.g4", false, "-o", outdir, "-lib", subdir);
+ BaseRuntimeTest.mkdir(outdir);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-o", outdir, "-lib", subdir);
assertEquals(0, equeue.size());
}
@@ -128,9 +167,9 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar S;\n" +
"a : B {System.out.println(\"S.a\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
String subdir = tmpdir + "/sub";
- mkdir(subdir);
+ BaseRuntimeTest.mkdir(subdir);
writeFile(subdir, "S.g4", slave);
String parser =
"parser grammar MParser;\n" +
@@ -144,10 +183,10 @@ public class TestCompositeGrammars extends BaseTest {
"WS : (' '|'\\n') -> skip ;\n" ;
writeFile(tmpdir, "MLexer.g4", lexer);
String outdir = tmpdir + "/out";
- mkdir(outdir);
- ErrorQueue equeue = antlr("MLexer.g4", false, "-o", outdir);
+ BaseRuntimeTest.mkdir(outdir);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "MLexer.g4", false, "-o", outdir);
assertEquals(0, equeue.size());
- equeue = antlr("MParser.g4", false, "-o", outdir, "-lib", subdir);
+ equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "MParser.g4", false, "-o", outdir, "-lib", subdir);
assertEquals(0, equeue.size());
}
@@ -158,7 +197,7 @@ public class TestCompositeGrammars extends BaseTest {
"options {tokenVocab=whatever;}\n" +
"tokens { A }\n" +
"x : A {System.out.println(\"S.x\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave);
String master =
@@ -184,7 +223,7 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar S;\n" +
"options {toke\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave);
String master =
@@ -204,13 +243,13 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar T;\n" +
"a : T ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "T.g4", slave);
String slave2 =
"parser grammar S;\n" +
"import T;\n" +
"a : S ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave2);
String master =
@@ -244,34 +283,34 @@ public class TestCompositeGrammars extends BaseTest {
"parser grammar T;\n" +
"tokens{T}\n" +
"x : T ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "T.g4", slave);
slave =
"parser grammar S;\n" +
"import T;\n" +
"tokens{S}\n" +
"y : S ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave);
slave =
"parser grammar C;\n" +
"tokens{C}\n" +
"i : C ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "C.g4", slave);
slave =
"parser grammar B;\n" +
"tokens{B}\n" +
"j : B ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "B.g4", slave);
slave =
"parser grammar A;\n" +
"import B,C;\n" +
"tokens{A}\n" +
"k : A ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "A.g4", slave);
String master =
@@ -305,13 +344,13 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar T;\n" +
"x : T ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "T.g4", slave);
String slave2 =
"parser grammar S;\n" + // A, B, C token type order
"import T;\n" +
"a : S ;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave2);
String master =
@@ -343,27 +382,27 @@ public class TestCompositeGrammars extends BaseTest {
"T2: '2';\n" +
"T3: '3';\n" +
"T4: '4';\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "L.g4", gstr);
gstr =
"parser grammar G1;\n" +
"s: a | b;\n" +
"a: T1;\n" +
"b: T2;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "G1.g4", gstr);
gstr =
"parser grammar G2;\n" +
"import G1;\n" +
"a: T3;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "G2.g4", gstr);
String G3str =
"grammar G3;\n" +
"import G2;\n" +
"b: T4;\n" ;
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "G3.g4", G3str);
Grammar g = new Grammar(tmpdir+"/G3.g4", G3str, equeue);
@@ -390,7 +429,7 @@ public class TestCompositeGrammars extends BaseTest {
String slave =
"parser grammar S;\n" +
"a : B {System.out.print(\"S.a\");} ;\n";
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "S.g4", slave);
String master =
"grammar M;\n" +
@@ -399,7 +438,7 @@ public class TestCompositeGrammars extends BaseTest {
"s : a ;\n" +
"B : 'b' ;" + // defines B from inherited token space
"WS : (' '|'\\n') -> skip ;\n" ;
- ErrorQueue equeue = antlr("M.g4", master, false);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", master, false);
int expecting = 0; // should be ok
assertEquals(expecting, equeue.errors.size());
}
@@ -418,11 +457,11 @@ public class TestCompositeGrammars extends BaseTest {
"grammar NewJava;\n" +
"import Java;\n";
- System.out.println("dir "+tmpdir);
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "Java.g4", slave);
- String found = execParser("NewJava.g4", master, "NewJavaParser", "NewJavaLexer", "compilationUnit", "package Foo;", debug);
- assertEquals("", found);
+ String found = execParser("NewJava.g4", master, "NewJavaParser", "NewJavaLexer",
+ null, null, "compilationUnit", "package Foo;", debug);
+ assertEquals(null, found);
assertNull(stderrDuringParse);
}
@@ -446,11 +485,11 @@ public class TestCompositeGrammars extends BaseTest {
"import Java;\n" +
"s : e ;\n";
- System.out.println("dir "+tmpdir);
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
writeFile(tmpdir, "Java.g4", slave);
- String found = execParser("T.g4", master, "TParser", "TLexer", "s", "a=b", debug);
- assertEquals("", found);
+ String found = execParser("T.g4", master, "TParser", "TLexer",
+ null, null, "s", "a=b", debug);
+ assertEquals(null, found);
assertNull(stderrDuringParse);
}
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestDollarParser.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestDollarParser.java
index 9519f9d..03f0f0e 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestDollarParser.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestDollarParser.java
@@ -1,12 +1,23 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-public class TestDollarParser extends BaseTest {
+public class TestDollarParser extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
@Test
public void testSimpleCall() throws Exception {
@@ -14,7 +25,8 @@ public class TestDollarParser extends BaseTest {
"a : ID { System.out.println( $parser.getSourceName() ); }\n" +
" ;\n" +
"ID : 'a'..'z'+ ;\n";
- String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "x", true);
+ String found = execParser("T.g4", grammar, "TParser", "TLexer",
+ null, null, "a", "x", true);
assertTrue(found.indexOf(this.getClass().getSimpleName())>=0);
assertNull(this.stderrDuringParse);
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestErrorSets.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestErrorSets.java
index 7afa2b7..7071500 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestErrorSets.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestErrorSets.java
@@ -1,42 +1,24 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
+import org.junit.Before;
import org.junit.Test;
/** Test errors with the set stuff in lexer and parser */
-public class TestErrorSets extends BaseTest {
+public class TestErrorSets extends BaseJavaToolTest {
protected boolean debug = false;
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
/** Public default constructor used by TestRig */
public TestErrorSets() {
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestFastQueue.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestFastQueue.java
index c28c8c7..926be09 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestFastQueue.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestFastQueue.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestGrammarParserInterpreter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestGrammarParserInterpreter.java
index d2afde6..b15ed09 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestGrammarParserInterpreter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestGrammarParserInterpreter.java
@@ -1,40 +1,16 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
+import org.antlr.v4.gui.Trees;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.InterpreterRuleContext;
import org.antlr.v4.runtime.LexerInterpreter;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.gui.Trees;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarParserInterpreter;
import org.antlr.v4.tool.LexerGrammar;
@@ -135,7 +111,7 @@ public class TestGrammarParserInterpreter {
ParseTree t = parser.parse(g.rules.get(startRule).index);
InterpreterTreeTextProvider nodeTextProvider = new InterpreterTreeTextProvider(g.getRuleNames());
String treeStr = Trees.toStringTree(t, nodeTextProvider);
- System.out.println("parse tree: "+treeStr);
+// System.out.println("parse tree: "+treeStr);
assertEquals(expectedParseTree, treeStr);
return (InterpreterRuleContext)t;
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestGraphNodes.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestGraphNodes.java
index 8081afc..fd7b781 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestGraphNodes.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestGraphNodes.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -61,7 +37,7 @@ public class TestGraphNodes {
PredictionContext r = PredictionContext.merge(PredictionContext.EMPTY,
PredictionContext.EMPTY,
rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -74,7 +50,7 @@ public class TestGraphNodes {
PredictionContext r = PredictionContext.merge(PredictionContext.EMPTY,
PredictionContext.EMPTY,
fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -85,7 +61,7 @@ public class TestGraphNodes {
@Test public void test_x_$() {
PredictionContext r = PredictionContext.merge(x(), PredictionContext.EMPTY, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -96,7 +72,7 @@ public class TestGraphNodes {
@Test public void test_x_$_fullctx() {
PredictionContext r = PredictionContext.merge(x(), PredictionContext.EMPTY, fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -109,7 +85,7 @@ public class TestGraphNodes {
@Test public void test_$_x() {
PredictionContext r = PredictionContext.merge(PredictionContext.EMPTY, x(), rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -120,7 +96,7 @@ public class TestGraphNodes {
@Test public void test_$_x_fullctx() {
PredictionContext r = PredictionContext.merge(PredictionContext.EMPTY, x(), fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -133,7 +109,7 @@ public class TestGraphNodes {
@Test public void test_a_a() {
PredictionContext r = PredictionContext.merge(a(), a(), rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -149,7 +125,7 @@ public class TestGraphNodes {
PredictionContext x = x();
PredictionContext a2 = createSingleton(x, 1);
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -165,7 +141,7 @@ public class TestGraphNodes {
PredictionContext x = x();
PredictionContext a2 = createSingleton(x, 1);
PredictionContext r = PredictionContext.merge(a1, a2, fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -183,7 +159,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = a();
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -201,7 +177,7 @@ public class TestGraphNodes {
PredictionContext left = createSingleton(right, 8);
PredictionContext merged = PredictionContext.merge(left, right, false, null);
String actual = toDOTString(merged, false);
- System.out.println(actual);
+// System.out.println(actual);
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -219,7 +195,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = a();
PredictionContext r = PredictionContext.merge(a1, a2, fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -234,7 +210,7 @@ public class TestGraphNodes {
@Test public void test_a_b() {
PredictionContext r = PredictionContext.merge(a(), b(), rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -251,7 +227,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = createSingleton(x, 1);
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -270,7 +246,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(x1, 1);
PredictionContext a2 = createSingleton(x2, 1);
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -291,7 +267,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(b1, 1);
PredictionContext a2 = createSingleton(b2, 1);
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -314,7 +290,7 @@ public class TestGraphNodes {
PredictionContext a1 = createSingleton(b, 1);
PredictionContext a2 = createSingleton(c, 1);
PredictionContext r = PredictionContext.merge(a1, a2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -335,7 +311,7 @@ public class TestGraphNodes {
PredictionContext a = createSingleton(x, 1);
PredictionContext b = createSingleton(x, 2);
PredictionContext r = PredictionContext.merge(a, b, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -355,7 +331,7 @@ public class TestGraphNodes {
PredictionContext a = createSingleton(x1, 1);
PredictionContext b = createSingleton(x2, 2);
PredictionContext r = PredictionContext.merge(a, b, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -373,7 +349,7 @@ public class TestGraphNodes {
PredictionContext a = createSingleton(x(), 1);
PredictionContext b = createSingleton(y(), 2);
PredictionContext r = PredictionContext.merge(a, b, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -394,7 +370,7 @@ public class TestGraphNodes {
PredictionContext a = a();
PredictionContext b = createSingleton(x2, 2);
PredictionContext r = PredictionContext.merge(a, b, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -413,7 +389,7 @@ public class TestGraphNodes {
PredictionContext a = a();
PredictionContext b = createSingleton(x2, 2);
PredictionContext r = PredictionContext.merge(a, b, fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -437,7 +413,7 @@ public class TestGraphNodes {
PredictionContext a = createSingleton(e, 1);
PredictionContext b = createSingleton(f, 2);
PredictionContext r = PredictionContext.merge(a, b, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -461,7 +437,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(PredictionContext.EMPTY);
ArrayPredictionContext A2 = array(PredictionContext.EMPTY);
PredictionContext r = PredictionContext.merge(A1, A2, fullCtx(), null);
- System.out.println(toDOTString(r, fullCtx()));
+// System.out.println(toDOTString(r, fullCtx()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -477,7 +453,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b);
ArrayPredictionContext A2 = array(c);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -496,7 +472,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a1);
ArrayPredictionContext A2 = array(a2);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -514,7 +490,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a);
ArrayPredictionContext A2 = array(b, c);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -534,7 +510,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, c);
ArrayPredictionContext A2 = array(b);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -551,7 +527,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a(), b());
ArrayPredictionContext A2 = array(a());
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -567,7 +543,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a(), b());
ArrayPredictionContext A2 = array(b());
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -585,7 +561,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a);
ArrayPredictionContext A2 = array(b);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -607,7 +583,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a1);
ArrayPredictionContext A2 = array(a2);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -627,7 +603,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a1, c());
ArrayPredictionContext A2 = array(a2, d());
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -651,7 +627,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b);
ArrayPredictionContext A2 = array(c, d);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -681,7 +657,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b1);
ArrayPredictionContext A2 = array(b2, d);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -708,7 +684,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b1);
ArrayPredictionContext A2 = array(b2, d);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -736,7 +712,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b1);
ArrayPredictionContext A2 = array(b2, d);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
@@ -761,7 +737,7 @@ public class TestGraphNodes {
ArrayPredictionContext A1 = array(a, b);
ArrayPredictionContext A2 = array(c, d);
PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
- System.out.println(toDOTString(r, rootIsWildcard()));
+// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting =
"digraph G {\n" +
"rankdir=LR;\n" +
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestIntervalSet.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestIntervalSet.java
index c06362e..1d3157b 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestIntervalSet.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestIntervalSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -33,19 +9,25 @@ package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.misc.IntervalSet;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-public class TestIntervalSet extends BaseTest {
+public class TestIntervalSet extends BaseJavaToolTest {
/** Public default constructor used by TestRig */
public TestIntervalSet() {
}
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testSingleElement() throws Exception {
IntervalSet s = IntervalSet.of(99);
String expecting = "99";
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestLeftRecursionToolIssues.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestLeftRecursionToolIssues.java
index 713dab8..1ac210c 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestLeftRecursionToolIssues.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestLeftRecursionToolIssues.java
@@ -1,43 +1,25 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
+import org.junit.Before;
import org.junit.Test;
/** */
-public class TestLeftRecursionToolIssues extends BaseTest {
+public class TestLeftRecursionToolIssues extends BaseJavaToolTest {
protected boolean debug = false;
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testCheckForNonLeftRecursiveRule() throws Exception {
String grammar =
"grammar T;\n" +
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestLexerActions.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestLexerActions.java
index 1e8740d..526efed 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestLexerActions.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestLexerActions.java
@@ -1,11 +1,24 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-public class TestLexerActions extends BaseTest {
+public class TestLexerActions extends BaseJavaToolTest {
+
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
// ----- ACTIONS --------------------------------------------------------
@Test public void testActionExecutedInDFA() throws Exception {
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestLookaheadTrees.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestLookaheadTrees.java
index 36c8163..3fdad47 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestLookaheadTrees.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestLookaheadTrees.java
@@ -1,5 +1,12 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
+import org.antlr.v4.gui.Trees;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.LexerInterpreter;
@@ -7,7 +14,6 @@ import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.atn.DecisionInfo;
import org.antlr.v4.runtime.atn.LookaheadEventInfo;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.gui.Trees;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarParserInterpreter;
import org.antlr.v4.tool.LexerGrammar;
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java
index 8f79005..a750880 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestParseTreeMatcher.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.CharStream;
@@ -12,7 +18,7 @@ import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.pattern.ParseTreeMatch;
import org.antlr.v4.runtime.tree.pattern.ParseTreePattern;
import org.antlr.v4.runtime.tree.pattern.ParseTreePatternMatcher;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import java.lang.reflect.Constructor;
@@ -24,7 +30,13 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-public class TestParseTreeMatcher extends BaseTest {
+public class TestParseTreeMatcher extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testChunking() throws Exception {
ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserExec.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserExec.java
index 3066d4c..fc9a62f 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserExec.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserExec.java
@@ -1,36 +1,12 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -69,8 +45,12 @@ import static org.junit.Assert.assertTrue;
* Nongreedy loops match as much input as possible while still allowing
* the remaining input to match.
*/
-public class TestParserExec extends BaseTest {
-
+public class TestParserExec extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
/**
* This is a regression test for antlr/antlr4#118.
@@ -86,7 +66,8 @@ public class TestParserExec extends BaseTest {
"ID : 'a'..'z'+ ;\n"+
"INT : '0'..'9'+ ;\n"+
"WS : (' '|'\\t'|'\\n')+ -> skip ;\n";
- String result = execParser("T.g4", grammar, "TParser", "TLexer", "s",
+ String result = execParser("T.g4", grammar, "TParser", "TLexer",
+ null, null, "s",
"abc 34", true);
String expecting =
"Decision 0:\n" +
@@ -105,8 +86,8 @@ public class TestParserExec extends BaseTest {
// TODO: port to test framework (can we simplify the Psl grammar?)
@Test public void testFailedPredicateExceptionState() throws Exception {
String grammar = load("Psl.g4", "UTF-8");
- String found = execParser("Psl.g4", grammar, "PslParser", "PslLexer", "floating_constant", " . 234", false);
- assertEquals("", found);
+ String found = execParser("Psl.g4", grammar, "PslParser", "PslLexer", null, null, "floating_constant", " . 234", false);
+ assertEquals(null, found);
assertEquals("line 1:6 rule floating_constant DEC:A floating-point constant cannot have internal white space\n", stderrDuringParse);
}
@@ -145,8 +126,9 @@ public class TestParserExec extends BaseTest {
"ModeTagsLexer");
assertTrue(success);
- String found = execParser("ModeTagsParser.g4", parserGrammar, "ModeTagsParser", "ModeTagsLexer", "file", "", false);
- assertEquals("", found);
+ String found = execParser("ModeTagsParser.g4", parserGrammar, "ModeTagsParser", "ModeTagsLexer",
+ null, null, "file", "", false);
+ assertEquals(null, found);
assertNull(stderrDuringParse);
}
@@ -173,7 +155,8 @@ public class TestParserExec extends BaseTest {
"WS : [ \\t\\n\\r]+ -> skip ; // toss out all whitespace\n";
String input = "2 9 10 3 1 2 3";
- String found = execParser("Data.g4", grammar, "DataParser", "DataLexer", "file", input, false);
+ String found = execParser("Data.g4", grammar, "DataParser", "DataLexer",
+ null, null, "file", input, false);
assertEquals("6\n", found);
assertNull(stderrDuringParse);
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java
index 04abbcc..2a8952f 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -35,15 +11,21 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.LexerInterpreter;
import org.antlr.v4.runtime.ParserInterpreter;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-public class TestParserInterpreter extends BaseTest {
+public class TestParserInterpreter extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testEmptyStartRule() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n" +
@@ -356,7 +338,6 @@ public class TestParserInterpreter extends BaseTest {
CommonTokenStream tokens = new CommonTokenStream(lexEngine);
ParserInterpreter parser = g.createParserInterpreter(tokens);
ParseTree t = parser.parse(g.rules.get(startRule).index);
- System.out.println("parse tree: "+t.toStringTree(parser));
assertEquals(expectedParseTree, t.toStringTree(parser));
return t;
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserProfiler.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserProfiler.java
index f1b0160..e18aa75 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestParserProfiler.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestParserProfiler.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -36,10 +12,10 @@ import org.antlr.v4.runtime.LexerInterpreter;
import org.antlr.v4.runtime.ParserInterpreter;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.atn.DecisionInfo;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -48,12 +24,13 @@ import java.util.Arrays;
import static org.junit.Assert.assertEquals;
@SuppressWarnings("unused")
-public class TestParserProfiler extends BaseTest {
+public class TestParserProfiler extends BaseJavaToolTest {
LexerGrammar lg;
+ @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void testSetUp() throws Exception {
+ super.testSetUp();
lg = new LexerGrammar(
"lexer grammar L;\n" +
"WS : [ \\r\\t\\n]+ -> channel(HIDDEN) ;\n" +
@@ -238,7 +215,7 @@ public class TestParserProfiler extends BaseTest {
"PLUS : '+' ;\n" +
"MULT : '*' ;\n";
- String found = execParser("T.g4", grammar, "TParser", "TLexer", "s",
+ String found = execParser("T.g4", grammar, "TParser", "TLexer", null, null, "s",
"xyz;abc;z.q", false, true);
String expecting =
"[{decision=0, contextSensitivities=0, errors=0, ambiguities=0, SLL_lookahead=6, SLL_ATNTransitions=4, " +
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java
index 990cac6..70ee764 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -63,9 +39,10 @@ import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeListener;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.antlr.v4.runtime.tree.TerminalNode;
-import org.antlr.v4.test.runtime.java.BaseTest;
-import org.antlr.v4.test.runtime.java.ErrorQueue;
+import org.antlr.v4.test.runtime.BaseRuntimeTest;
+import org.antlr.v4.test.runtime.ErrorQueue;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import java.io.File;
@@ -107,7 +84,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@SuppressWarnings("unused")
-public class TestPerformance extends BaseTest {
+public class TestPerformance extends BaseJavaToolTest {
/**
* Parse all java files under this package within the JDK_SOURCE_ROOT
* (environment variable or property defined on the Java command line).
@@ -408,6 +385,12 @@ public class TestPerformance extends BaseTest {
private final AtomicIntegerArray tokenCount = new AtomicIntegerArray(PASSES);
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test
@org.junit.Ignore
public void compileJdk() throws IOException, InterruptedException, ExecutionException {
@@ -699,7 +682,7 @@ public class TestPerformance extends BaseTest {
}
@Override
- protected void eraseTempDir() {
+ public void eraseTempDir() {
if (DELETE_TEMP_FILES) {
super.eraseTempDir();
}
@@ -1954,8 +1937,7 @@ public class TestPerformance extends BaseTest {
"\n" +
"rule_%d_%d : EOF;\n";
- System.out.println("dir "+tmpdir);
- mkdir(tmpdir);
+ BaseRuntimeTest.mkdir(tmpdir);
long startTime = System.nanoTime();
@@ -1970,7 +1952,7 @@ public class TestPerformance extends BaseTest {
}
}
- ErrorQueue equeue = antlr("Level_0_1.g4", false);
+ ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "Level_0_1.g4", false);
Assert.assertTrue(equeue.errors.isEmpty());
long endTime = System.nanoTime();
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java
index 3bcfa06..6c8f589 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestScopeParsing.java
@@ -1,68 +1,102 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
+import org.antlr.v4.misc.Utils;
import org.antlr.v4.parse.ScopeParser;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.antlr.v4.tool.Attribute;
import org.antlr.v4.tool.Grammar;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
import static org.junit.Assert.assertEquals;
-public class TestScopeParsing extends BaseTest {
- String[] argPairs = {
- "", "{}",
- " ", "{}",
- "int i", "{i=int i}",
- "int[] i, int j[]", "{i=int[] i, j=int [] j}",
- "Map<A,B>[] i, int j[]", "{i=Map<A,B>[] i, j=int [] j}",
- "Map<A,List<B>>[] i", "{i=Map<A,List<B>>[] i}",
+@RunWith(Parameterized.class)
+public class TestScopeParsing extends BaseJavaToolTest {
+ static String[] argPairs = {
+ "", "",
+ " ", "",
+ "int i", "i:int",
+ "int[] i, int j[]", "i:int[], j:int []",
+ "Map<A,B>[] i, int j[]", "i:Map<A,B>[], j:int []",
+ "Map<A,List<B>>[] i", "i:Map<A,List<B>>[]",
"int i = 34+a[3], int j[] = new int[34]",
- "{i=int i= 34+a[3], j=int [] j= new int[34]}",
- "char *foo32[3] = {1,2,3}", "{3=char *foo32[] 3= {1,2,3}}",
- "String[] headers", "{headers=String[] headers}",
+ "i:int=34+a[3], j:int []=new int[34]",
+ "char *[3] foo = {1,2,3}", "foo:char *[3]={1,2,3}", // not valid C really, C is "type name" however so this is cool (this was broken in 4.5 anyway)
+ "String[] headers", "headers:String[]",
+
+ // C++
+ "std::vector<std::string> x", "x:std::vector<std::string>", // yuck. Don't choose :: as the : of a declaration
// python/ruby style
- "i", "{i=null i}",
- "i,j", "{i=null i, j=null j}",
- "i,j, k", "{i=null i, j=null j, k=null k}",
+ "i", "i",
+ "i,j", "i, j",
+ "i\t,j, k", "i, j, k",
+
+ // swift style
+ "x: int", "x:int",
+ "x :int", "x:int",
+ "x:int", "x:int",
+ "x:int=3", "x:int=3",
+ "r:Rectangle=Rectangle(fromLength: 6, fromBreadth: 12)", "r:Rectangle=Rectangle(fromLength: 6, fromBreadth: 12)",
+ "p:pointer to int", "p:pointer to int",
+ "a: array[3] of int", "a:array[3] of int",
+ "a \t:\tfunc(array[3] of int)", "a:func(array[3] of int)",
+ "x:int, y:float", "x:int, y:float",
+ "x:T?, f:func(array[3] of int), y:int", "x:T?, f:func(array[3] of int), y:int",
+
+ // go is postfix type notation like "x int" but must use either "int x" or "x:int" in [...] actions
+ "float64 x = 3", "x:float64=3",
+ "map[string]int x", "x:map[string]int",
};
- @Test public void testArgs() throws Exception {
- for (int i = 0; i < argPairs.length; i+=2) {
- String input = argPairs[i];
- String expected = argPairs[i+1];
- Grammar dummy = new Grammar("grammar T; a:'a';");
- String actual = ScopeParser.parseTypedArgList(null, input, dummy).attributes.toString();
- assertEquals(expected, actual);
- }
+ String input;
+ String output;
+
+ public TestScopeParsing(String input, String output) {
+ this.input = input;
+ this.output = output;
+ }
+
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
+ @Test
+ public void testArgs() throws Exception {
+ Grammar dummy = new Grammar("grammar T; a:'a';");
+
+ LinkedHashMap<String, Attribute> attributes = ScopeParser.parseTypedArgList(null, input, dummy).attributes;
+ List<String> out = new ArrayList<>();
+ for (String arg : attributes.keySet()) {
+ Attribute attr = attributes.get(arg);
+ out.add(attr.toString());
+ }
+ String actual = Utils.join(out.toArray(), ", ");
+ assertEquals(output, actual);
}
+
+ @Parameterized.Parameters(name="{0}")
+ public static Collection<Object[]> getAllTestDescriptors() {
+ List<Object[]> tests = new ArrayList<>();
+ for (int i = 0; i < argPairs.length; i+=2) {
+ String arg = argPairs[i];
+ String output = argPairs[i+1];
+ tests.add(new Object[]{arg,output});
+ }
+ return tests;
+ }
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestSymbolIssues.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestSymbolIssues.java
index 1c68ba3..6d56775 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestSymbolIssues.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestSymbolIssues.java
@@ -1,44 +1,20 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/** */
-public class TestSymbolIssues extends BaseTest {
+public class TestSymbolIssues extends BaseJavaToolTest {
static String[] A = {
// INPUT
"grammar A;\n" +
@@ -64,7 +40,7 @@ public class TestSymbolIssues extends BaseTest {
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:10:20: implicit definition of token Y in parser\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:11:4: implicit definition of token FJKD in parser\n" +
"error(" + ErrorType.RULE_HAS_NO_ARGS.code + "): A.g4:9:37: rule b has no defined parameters\n" +
- "error(" + ErrorType.MISSING_RULE_ARGS.code + "): A.g4:10:31: missing arguments(s) on rule reference: a\n"
+ "error(" + ErrorType.MISSING_RULE_ARGS.code + "): A.g4:10:31: missing argument(s) on rule reference: a\n"
};
static String[] B = {
@@ -130,6 +106,12 @@ public class TestSymbolIssues extends BaseTest {
"error(" + ErrorType.MODE_CONFLICTS_WITH_TOKEN.code + "): F.g4:3:0: mode M1 conflicts with token with same name\n"
};
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testA() { super.testErrors(A, false); }
@Test public void testB() { super.testErrors(B, false); }
@Test public void testD() { super.testErrors(D, false); }
@@ -223,4 +205,136 @@ public class TestSymbolIssues extends BaseTest {
testErrors(test, false);
}
+
+ // https://github.com/antlr/antlr4/issues/1411
+ @Test public void testWrongIdForTypeChannelModeCommand() throws Exception {
+ String[] test = {
+ "lexer grammar L;\n" +
+ "tokens { TOKEN1 }\n" +
+ "channels { CHANNEL1 }\n" +
+ "TOKEN: 'asdf' -> type(CHANNEL1), channel(MODE1), mode(TOKEN1);\n" +
+ "mode MODE1;\n" +
+ "MODE1_TOKEN: 'qwer';",
+
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME.code + "): L.g4:4:22: CHANNEL1 is not a recognized token name\n" +
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME.code + "): L.g4:4:41: MODE1 is not a recognized channel name\n" +
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME.code + "): L.g4:4:54: TOKEN1 is not a recognized mode name\n"
+ };
+
+ testErrors(test, false);
+ }
+
+ // https://github.com/antlr/antlr4/issues/1388
+ @Test public void testDuplicatedCommands() throws Exception {
+ String[] test = {
+ "lexer grammar Lexer;\n" +
+ "channels { CHANNEL1, CHANNEL2 }\n" +
+ "tokens { TEST1, TEST2 }\n" +
+ "TOKEN: 'a' -> mode(MODE1), mode(MODE2);\n" +
+ "TOKEN1: 'b' -> pushMode(MODE1), mode(MODE2);\n" +
+ "TOKEN2: 'c' -> pushMode(MODE1), pushMode(MODE2); // pushMode is not duplicate\n" +
+ "TOKEN3: 'd' -> popMode, popMode; // popMode is not duplicate\n" +
+ "mode MODE1;\n" +
+ "MODE1_TOKEN: 'e';\n" +
+ "mode MODE2;\n" +
+ "MODE2_TOKEN: 'f';\n" +
+ "MODE2_TOKEN1: 'g' -> type(TEST1), type(TEST2);\n" +
+ "MODE2_TOKEN2: 'h' -> channel(CHANNEL1), channel(CHANNEL2), channel(DEFAULT_TOKEN_CHANNEL);",
+
+ "warning(" + ErrorType.DUPLICATED_COMMAND.code + "): Lexer.g4:4:27: duplicated command mode\n" +
+ "warning(" + ErrorType.DUPLICATED_COMMAND.code + "): Lexer.g4:12:34: duplicated command type\n" +
+ "warning(" + ErrorType.DUPLICATED_COMMAND.code + "): Lexer.g4:13:40: duplicated command channel\n" +
+ "warning(" + ErrorType.DUPLICATED_COMMAND.code + "): Lexer.g4:13:59: duplicated command channel\n"
+ };
+
+ testErrors(test, false);
+ }
+
+ // https://github.com/antlr/antlr4/issues/1388
+ @Test public void testIncompatibleCommands() throws Exception {
+ String[] test = {
+ "lexer grammar L;\n" +
+ "channels { CHANNEL1 }\n" +
+ "tokens { TYPE1 }\n" +
+ "// Incompatible\n" +
+ "T00: 'a00' -> skip, more;\n" +
+ "T01: 'a01' -> skip, type(TYPE1);\n" +
+ "T02: 'a02' -> skip, channel(CHANNEL1);\n" +
+ "T03: 'a03' -> more, type(TYPE1);\n" +
+ "T04: 'a04' -> more, channel(CHANNEL1);\n" +
+ "T05: 'a05' -> more, skip;\n" +
+ "T06: 'a06' -> type(TYPE1), skip;\n" +
+ "T07: 'a07' -> type(TYPE1), more;\n" +
+ "T08: 'a08' -> channel(CHANNEL1), skip;\n" +
+ "T09: 'a09' -> channel(CHANNEL1), more;\n" +
+ "// Allowed\n" +
+ "T10: 'a10' -> type(TYPE1), channel(CHANNEL1);\n" +
+ "T11: 'a11' -> channel(CHANNEL1), type(TYPE1);",
+
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:5:20: incompatible commands skip and more\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:6:20: incompatible commands skip and type\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:7:20: incompatible commands skip and channel\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:8:20: incompatible commands more and type\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:9:20: incompatible commands more and channel\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:10:20: incompatible commands more and skip\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:11:27: incompatible commands type and skip\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:12:27: incompatible commands type and more\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:13:33: incompatible commands channel and skip\n" +
+ "warning(" + ErrorType.INCOMPATIBLE_COMMANDS.code + "): L.g4:14:33: incompatible commands channel and more\n"
+ };
+
+ testErrors(test, false);
+ }
+
+ // https://github.com/antlr/antlr4/issues/1409
+ @Test public void testLabelsForTokensWithMixedTypes() {
+ String[] test = {
+ "grammar L;\n" +
+ "\n" +
+ "rule1 // Correct (Alternatives)\n" +
+ " : t1 = a #aLabel\n" +
+ " | t1 = b #bLabel\n" +
+ " ;\n" +
+ "rule2 //Incorrect type casting in generated code (RULE_LABEL)\n" +
+ " : t2 = a | t2 = b\n" +
+ " ;\n" +
+ "rule3\n" +
+ " : t3 += a+ b t3 += c+ //Incorrect type casting in generated code (RULE_LIST_LABEL)\n" +
+ " ;\n" +
+ "rule4\n" +
+ " : a t4 = A b t4 = B c // Correct (TOKEN_LABEL)\n" +
+ " ;\n" +
+ "rule5\n" +
+ " : a t5 += A b t5 += B c // Correct (TOKEN_LIST_LABEL)\n" +
+ " ;\n" +
+ "a: A;\n" +
+ "b: B;\n" +
+ "c: C;\n" +
+ "A: 'a';\n" +
+ "B: 'b';\n" +
+ "C: 'c';\n",
+
+ "error(" + ErrorType.LABEL_TYPE_CONFLICT.code + "): L.g4:8:15: label t2=b type mismatch with previous definition: t2=a\n" +
+ "error(" + ErrorType.LABEL_TYPE_CONFLICT.code + "): L.g4:11:17: label t3+=c type mismatch with previous definition: t3+=a\n"
+ };
+
+ testErrors(test, false);
+ }
+
+ @Test public void testCharsCollision() throws Exception {
+ String[] test = {
+ "lexer grammar L;\n" +
+ "TOKEN_RANGE: [aa-f];\n" +
+ "TOKEN_RANGE_2: [A-FD-J];\n" +
+ "TOKEN_RANGE_3: 'Z' | 'K'..'R' | 'O'..'V';\n" +
+ "TOKEN_RANGE_4: 'g'..'l' | [g-l];\n", // Handling in ATNOptimizer.
+
+ "warning(" + ErrorType.CHARACTERS_COLLISION_IN_SET.code + "): L.g4:2:18: chars \"a-f\" used multiple times in set [aa-f]\n" +
+ "warning(" + ErrorType.CHARACTERS_COLLISION_IN_SET.code + "): L.g4:3:18: chars \"D-J\" used multiple times in set [A-FD-J]\n" +
+ "warning(" + ErrorType.CHARACTERS_COLLISION_IN_SET.code + "): L.g4:4:13: chars \"O-V\" used multiple times in set 'Z' | 'K'..'R' | 'O'..'V'\n" +
+ "warning(" + ErrorType.CHARACTERS_COLLISION_IN_SET.code + "): L.g4::: chars \"g-l\" used multiple times in set [g-l]\n"
+ };
+
+ testErrors(test, false);
+ }
}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenPositionOptions.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenPositionOptions.java
index 8a6881d..c6af3ee 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenPositionOptions.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenPositionOptions.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -33,9 +9,9 @@ import org.antlr.runtime.Token;
import org.antlr.v4.misc.Utils;
import org.antlr.v4.parse.ANTLRParser;
import org.antlr.v4.runtime.misc.IntervalSet;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.ast.GrammarAST;
+import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
@@ -43,7 +19,13 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
-public class TestTokenPositionOptions extends BaseTest {
+public class TestTokenPositionOptions extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testLeftRecursionRewrite() throws Exception {
Grammar g = new Grammar(
"grammar T;\n" +
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenStreamRewriter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenStreamRewriter.java
deleted file mode 100644
index e2d8061..0000000
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenStreamRewriter.java
+++ /dev/null
@@ -1,909 +0,0 @@
-/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.antlr.v4.test.tool;
-
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.LexerInterpreter;
-import org.antlr.v4.runtime.TokenStreamRewriter;
-import org.antlr.v4.runtime.misc.Interval;
-import org.antlr.v4.test.runtime.java.BaseTest;
-import org.antlr.v4.tool.LexerGrammar;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class TestTokenStreamRewriter extends BaseTest {
-
- /** Public default constructor used by TestRig */
- public TestTokenStreamRewriter() {
- }
-
- @Test public void testInsertBeforeIndex0() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream("abc"));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "0");
- String result = tokens.getText();
- String expecting = "0abc";
- assertEquals(expecting, result);
- }
-
- @Test public void testInsertAfterLastIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertAfter(2, "x");
- String result = tokens.getText();
- String expecting = "abcx";
- assertEquals(expecting, result);
- }
-
- @Test public void test2InsertBeforeAfterMiddleIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "x");
- tokens.insertAfter(1, "x");
- String result = tokens.getText();
- String expecting = "axbxc";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceIndex0() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(0, "x");
- String result = tokens.getText();
- String expecting = "xbc";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceLastIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, "x");
- String result = tokens.getText();
- String expecting = "abx";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceMiddleIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, "x");
- String result = tokens.getText();
- String expecting = "axc";
- assertEquals(expecting, result);
- }
-
- @Test public void testToStringStartStop() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "ID : 'a'..'z'+;\n" +
- "INT : '0'..'9'+;\n" +
- "SEMI : ';';\n" +
- "MUL : '*';\n" +
- "ASSIGN : '=';\n" +
- "WS : ' '+;\n");
- // Tokens: 0123456789
- // Input: x = 3 * 0;
- String input = "x = 3 * 0;";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(4, 8, "0");
- stream.fill();
-// replace 3 * 0 with 0
-
- String result = tokens.getTokenStream().getText();
- String expecting = "x = 3 * 0;";
- assertEquals(expecting, result);
-
- result = tokens.getText();
- expecting = "x = 0;";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(0, 9));
- expecting = "x = 0;";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(4, 8));
- expecting = "0";
- assertEquals(expecting, result);
- }
-
- @Test public void testToStringStartStop2() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "ID : 'a'..'z'+;\n" +
- "INT : '0'..'9'+;\n" +
- "SEMI : ';';\n" +
- "ASSIGN : '=';\n" +
- "PLUS : '+';\n" +
- "MULT : '*';\n" +
- "WS : ' '+;\n");
- // Tokens: 012345678901234567
- // Input: x = 3 * 0 + 2 * 0;
- String input = "x = 3 * 0 + 2 * 0;";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
-
- String result = tokens.getTokenStream().getText();
- String expecting = "x = 3 * 0 + 2 * 0;";
- assertEquals(expecting, result);
-
- tokens.replace(4, 8, "0");
- stream.fill();
-// replace 3 * 0 with 0
- result = tokens.getText();
- expecting = "x = 0 + 2 * 0;";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(0, 17));
- expecting = "x = 0 + 2 * 0;";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(4, 8));
- expecting = "0";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(0, 8));
- expecting = "x = 0";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(12, 16));
- expecting = "2 * 0";
- assertEquals(expecting, result);
-
- tokens.insertAfter(17, "// comment");
- result = tokens.getText(Interval.of(12, 18));
- expecting = "2 * 0;// comment";
- assertEquals(expecting, result);
-
- result = tokens.getText(Interval.of(0, 8));
- stream.fill();
-// try again after insert at end
- expecting = "x = 0";
- assertEquals(expecting, result);
- }
-
-
- @Test public void test2ReplaceMiddleIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, "x");
- tokens.replace(1, "y");
- String result = tokens.getText();
- String expecting = "ayc";
- assertEquals(expecting, result);
- }
-
- @Test public void test2ReplaceMiddleIndex1InsertBefore() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "_");
- tokens.replace(1, "x");
- tokens.replace(1, "y");
- String result = tokens.getText();
- String expecting = "_ayc";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceThenDeleteMiddleIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, "x");
- tokens.delete(1);
- String result = tokens.getText();
- String expecting = "ac";
- assertEquals(expecting, result);
- }
-
- @Test public void testInsertInPriorReplace() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(0, 2, "x");
- tokens.insertBefore(1, "0");
- Exception exc = null;
- try {
- tokens.getText();
- }
- catch (IllegalArgumentException iae) {
- exc = iae;
- }
- String expecting = "insert op <InsertBeforeOp@[@1,1:1='b',<2>,1:1]:\"0\"> within boundaries of previous <ReplaceOp@[@0,0:0='a',<1>,1:0]..[@2,2:2='c',<3>,1:2]:\"x\">";
- assertNotNull(exc);
- assertEquals(expecting, exc.getMessage());
- }
-
- @Test public void testInsertThenReplaceSameIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "0");
- tokens.replace(0, "x");
- stream.fill();
-// supercedes insert at 0
- String result = tokens.getText();
- String expecting = "0xbc";
- assertEquals(expecting, result);
- }
-
- @Test public void test2InsertMiddleIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "x");
- tokens.insertBefore(1, "y");
- String result = tokens.getText();
- String expecting = "ayxbc";
- assertEquals(expecting, result);
- }
-
- @Test public void test2InsertThenReplaceIndex0() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "x");
- tokens.insertBefore(0, "y");
- tokens.replace(0, "z");
- String result = tokens.getText();
- String expecting = "yxzbc";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceThenInsertBeforeLastIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, "x");
- tokens.insertBefore(2, "y");
- String result = tokens.getText();
- String expecting = "abyx";
- assertEquals(expecting, result);
- }
-
- @Test public void testInsertThenReplaceLastIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(2, "y");
- tokens.replace(2, "x");
- String result = tokens.getText();
- String expecting = "abyx";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceThenInsertAfterLastIndex() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, "x");
- tokens.insertAfter(2, "y");
- String result = tokens.getText();
- String expecting = "abxy";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceRangeThenInsertAtLeftEdge() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "x");
- tokens.insertBefore(2, "y");
- String result = tokens.getText();
- String expecting = "abyxba";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceRangeThenInsertAtRightEdge() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "x");
- tokens.insertBefore(4, "y");
- stream.fill(); // no effect; within range of a replace
- Exception exc = null;
- try {
- tokens.getText();
- }
- catch (IllegalArgumentException iae) {
- exc = iae;
- }
- String expecting = "insert op <InsertBeforeOp@[@4,4:4='c',<3>,1:4]:\"y\"> within boundaries of previous <ReplaceOp@[@2,2:2='c',<3>,1:2]..[@4,4:4='c',<3>,1:4]:\"x\">";
- assertNotNull(exc);
- assertEquals(expecting, exc.getMessage());
- }
-
- @Test public void testReplaceRangeThenInsertAfterRightEdge() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "x");
- tokens.insertAfter(4, "y");
- String result = tokens.getText();
- String expecting = "abxyba";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceAll() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(0, 6, "x");
- String result = tokens.getText();
- String expecting = "x";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceSubsetThenFetch() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "xyz");
- String result = tokens.getText(Interval.of(0, 6));
- String expecting = "abxyzba";
- assertEquals(expecting, result);
- }
-
- @Test public void testReplaceThenReplaceSuperset() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "xyz");
- tokens.replace(3, 5, "foo");
- stream.fill();
-// overlaps, error
- Exception exc = null;
- try {
- tokens.getText();
- }
- catch (IllegalArgumentException iae) {
- exc = iae;
- }
- String expecting = "replace op boundaries of <ReplaceOp@[@3,3:3='c',<3>,1:3]..[@5,5:5='b',<2>,1:5]:\"foo\"> overlap with previous <ReplaceOp@[@2,2:2='c',<3>,1:2]..[@4,4:4='c',<3>,1:4]:\"xyz\">";
- assertNotNull(exc);
- assertEquals(expecting, exc.getMessage());
- }
-
- @Test public void testReplaceThenReplaceLowerIndexedSuperset() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcccba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 4, "xyz");
- tokens.replace(1, 3, "foo");
- stream.fill();
-// overlap, error
- Exception exc = null;
- try {
- tokens.getText();
- }
- catch (IllegalArgumentException iae) {
- exc = iae;
- }
- String expecting = "replace op boundaries of <ReplaceOp@[@1,1:1='b',<2>,1:1]..[@3,3:3='c',<3>,1:3]:\"foo\"> overlap with previous <ReplaceOp@[@2,2:2='c',<3>,1:2]..[@4,4:4='c',<3>,1:4]:\"xyz\">";
- assertNotNull(exc);
- assertEquals(expecting, exc.getMessage());
- }
-
- @Test public void testReplaceSingleMiddleThenOverlappingSuperset() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcba";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 2, "xyz");
- tokens.replace(0, 3, "foo");
- String result = tokens.getText();
- String expecting = "fooa";
- assertEquals(expecting, result);
- }
-
- @Test public void testCombineInserts() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "x");
- tokens.insertBefore(0, "y");
- String result = tokens.getText();
- String expecting = "yxabc";
- assertEquals(expecting, result);
- }
-
- @Test public void testCombine3Inserts() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "x");
- tokens.insertBefore(0, "y");
- tokens.insertBefore(1, "z");
- String result = tokens.getText();
- String expecting = "yazxbc";
- assertEquals(expecting, result);
- }
-
- @Test public void testCombineInsertOnLeftWithReplace() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(0, 2, "foo");
- tokens.insertBefore(0, "z");
- stream.fill();
-// combine with left edge of rewrite
- String result = tokens.getText();
- String expecting = "zfoo";
- assertEquals(expecting, result);
- }
-
- @Test public void testCombineInsertOnLeftWithDelete() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.delete(0, 2);
- tokens.insertBefore(0, "z");
- stream.fill();
-// combine with left edge of rewrite
- String result = tokens.getText();
- String expecting = "z";
- stream.fill();
-// make sure combo is not znull
- assertEquals(expecting, result);
- }
-
- @Test public void testDisjointInserts() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "x");
- tokens.insertBefore(2, "y");
- tokens.insertBefore(0, "z");
- String result = tokens.getText();
- String expecting = "zaxbyc";
- assertEquals(expecting, result);
- }
-
- @Test public void testOverlappingReplace() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, 2, "foo");
- tokens.replace(0, 3, "bar");
- stream.fill();
-// wipes prior nested replace
- String result = tokens.getText();
- String expecting = "bar";
- assertEquals(expecting, result);
- }
-
- @Test public void testOverlappingReplace2() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(0, 3, "bar");
- tokens.replace(1, 2, "foo");
- stream.fill();
-// cannot split earlier replace
- Exception exc = null;
- try {
- tokens.getText();
- }
- catch (IllegalArgumentException iae) {
- exc = iae;
- }
- String expecting = "replace op boundaries of <ReplaceOp@[@1,1:1='b',<2>,1:1]..[@2,2:2='c',<3>,1:2]:\"foo\"> overlap with previous <ReplaceOp@[@0,0:0='a',<1>,1:0]..[@3,3:3='c',<3>,1:3]:\"bar\">";
- assertNotNull(exc);
- assertEquals(expecting, exc.getMessage());
- }
-
- @Test public void testOverlappingReplace3() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, 2, "foo");
- tokens.replace(0, 2, "bar");
- stream.fill();
-// wipes prior nested replace
- String result = tokens.getText();
- String expecting = "barc";
- assertEquals(expecting, result);
- }
-
- @Test public void testOverlappingReplace4() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, 2, "foo");
- tokens.replace(1, 3, "bar");
- stream.fill();
-// wipes prior nested replace
- String result = tokens.getText();
- String expecting = "abar";
- assertEquals(expecting, result);
- }
-
- @Test public void testDropIdenticalReplace() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(1, 2, "foo");
- tokens.replace(1, 2, "foo");
- stream.fill();
-// drop previous, identical
- String result = tokens.getText();
- String expecting = "afooc";
- assertEquals(expecting, result);
- }
-
- @Test public void testDropPrevCoveredInsert() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "foo");
- tokens.replace(1, 2, "foo");
- stream.fill();
-// kill prev insert
- String result = tokens.getText();
- String expecting = "afoofoo";
- assertEquals(expecting, result);
- }
-
- @Test public void testLeaveAloneDisjointInsert() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(1, "x");
- tokens.replace(2, 3, "foo");
- String result = tokens.getText();
- String expecting = "axbfoo";
- assertEquals(expecting, result);
- }
-
- @Test public void testLeaveAloneDisjointInsert2() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abcc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.replace(2, 3, "foo");
- tokens.insertBefore(1, "x");
- String result = tokens.getText();
- String expecting = "axbfoo";
- assertEquals(expecting, result);
- }
-
- @Test public void testInsertBeforeTokenThenDeleteThatToken() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "abc";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(2, "y");
- tokens.delete(2);
- String result = tokens.getText();
- String expecting = "aby";
- assertEquals(expecting, result);
- }
-
- // Test for https://github.com/antlr/antlr4/issues/550
- @Test
- @Ignore
- public void testPreservesOrderOfContiguousInserts() throws Exception {
- LexerGrammar g = new LexerGrammar(
- "lexer grammar T;\n"+
- "A : 'a';\n" +
- "B : 'b';\n" +
- "C : 'c';\n");
- String input = "aa";
- LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
- CommonTokenStream stream = new CommonTokenStream(lexEngine);
- stream.fill();
- TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
- tokens.insertBefore(0, "<b>");
- tokens.insertAfter(0, "</b>");
- tokens.insertBefore(1, "<b>");
- tokens.insertAfter(1, "</b>");
- String result = tokens.getText();
- String expecting = "<b>a</b><b>a</b>"; // fails with <b>a<b></b>a</b>"
- assertEquals(expecting, result);
- }
-
-}
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenTypeAssignment.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenTypeAssignment.java
index 635f15c..c338eec 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenTypeAssignment.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestTokenTypeAssignment.java
@@ -1,37 +1,12 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.Token;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
import org.junit.Test;
@@ -45,7 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-public class TestTokenTypeAssignment extends BaseTest {
+public class TestTokenTypeAssignment extends BaseJavaToolTest {
@Test
public void testParserSimpleTokens() throws Exception {
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestToolSyntaxErrors.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestToolSyntaxErrors.java
index c411434..639c638 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestToolSyntaxErrors.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestToolSyntaxErrors.java
@@ -1,47 +1,27 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.v4.Tool;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.ErrorType;
+import org.junit.Before;
import org.junit.Test;
-public class TestToolSyntaxErrors extends BaseTest {
+public class TestToolSyntaxErrors extends BaseJavaToolTest {
static String[] A = {
- // INPUT
- "grammar A;\n" +
- "",
- // YIELDS
- "error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",
+ // INPUT
+ "grammar A;\n" +
+ "",
+ // YIELDS
+ "error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",
+
+ "lexer grammar A;\n" +
+ "",
+ "error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",
"A;",
"error(" + ErrorType.SYNTAX_ERROR.code + "): A.g4:1:0: syntax error: 'A' came as a complete surprise to me\n",
@@ -74,6 +54,12 @@ public class TestToolSyntaxErrors extends BaseTest {
"error(" + ErrorType.SYNTAX_ERROR.code + "): A.g4:2:15: syntax error: mismatched input ';' expecting COLON while matching a lexer rule\n",
};
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testA() { super.testErrors(A, true); }
@Test public void testExtraColon() {
@@ -331,6 +317,40 @@ public class TestToolSyntaxErrors extends BaseTest {
super.testErrors(pair, true);
}
+ // Test for https://github.com/antlr/antlr4/issues/1203
+ @Test public void testEpsilonNestedClosureAnalysis() {
+ String grammar =
+ "grammar T;\n"+
+ "s : (a a)* ;\n"+
+ "a : 'foo'* ;\n";
+ String expected =
+ "error(" + ErrorType.EPSILON_CLOSURE.code + "): T.g4:2:0: rule s contains a closure with at least one alternative that can match an empty string\n";
+
+ String[] pair = new String[] {
+ grammar,
+ expected
+ };
+
+ super.testErrors(pair, true);
+ }
+
+ // Test for https://github.com/antlr/antlr4/issues/1203
+ @Test public void testEpsilonOptionalAndClosureAnalysis() {
+ String grammar =
+ "grammar T;\n"+
+ "s : (a a)? ;\n"+
+ "a : 'foo'* ;\n";
+ String expected =
+ "warning(" + ErrorType.EPSILON_OPTIONAL.code + "): T.g4:2:0: rule s contains an optional block with at least one alternative that can match an empty string\n";
+
+ String[] pair = new String[] {
+ grammar,
+ expected
+ };
+
+ super.testErrors(pair, true);
+ }
+
@Test public void testEpsilonOptionalAnalysis() {
String grammar =
"grammar A;\n"
@@ -467,11 +487,39 @@ public class TestToolSyntaxErrors extends BaseTest {
"Error3: '';\n" +
"NotError: ' ';";
String expected =
- "error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:8: string literals cannot be empty\n" +
- "error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:16: string literals cannot be empty\n" +
- "error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:3:8: string literals cannot be empty\n" +
- "error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:4:15: string literals cannot be empty\n" +
- "error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:5:8: string literals cannot be empty\n";
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): T.g4:2:8: string literals and sets cannot be empty: ''\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): T.g4:2:16: string literals and sets cannot be empty: ''\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): T.g4:3:8: string literals and sets cannot be empty: ''\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): T.g4:4:15: string literals and sets cannot be empty: ''\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): T.g4:5:8: string literals and sets cannot be empty: ''\n";
+
+ String[] pair = new String[] {
+ grammar,
+ expected
+ };
+
+ super.testErrors(pair, true);
+ }
+
+ @Test public void testInvalidCharSetAndRange() {
+ String grammar =
+ "lexer grammar Test;\n" +
+ "INVALID_RANGE: 'GH'..'LM';\n" +
+ "INVALID_RANGE_2: 'F'..'A' | 'Z';\n" +
+ "VALID_STRING_LITERALS: '\\u1234' | '\\t' | [\\-\\]];\n" +
+ "INVALID_CHAR_SET: [f-az][];\n" +
+ "INVALID_CHAR_SET_2: [\\u24\\uA2][\\u24];\n" + //https://github.com/antlr/antlr4/issues/1077
+ "INVALID_CHAR_SET_3: [\\t\\{];";
+
+ String expected =
+ "error(" + ErrorType.INVALID_LITERAL_IN_LEXER_SET.code + "): Test.g4:2:23: multi-character literals are not allowed in lexer sets: 'GH'\n" +
+ "error(" + ErrorType.INVALID_LITERAL_IN_LEXER_SET.code + "): Test.g4:2:29: multi-character literals are not allowed in lexer sets: 'LM'\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): Test.g4:3:26: string literals and sets cannot be empty: 'F'..'A'\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): Test.g4:5:23: string literals and sets cannot be empty: [f-a]\n" +
+ "error(" + ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED.code + "): Test.g4:5:29: string literals and sets cannot be empty: []\n" +
+ "error(" + ErrorType.INVALID_ESCAPE_SEQUENCE.code + "): Test.g4:6:23: invalid escape sequence\n" +
+ "error(" + ErrorType.INVALID_ESCAPE_SEQUENCE.code + "): Test.g4:6:33: invalid escape sequence\n" +
+ "error(" + ErrorType.INVALID_ESCAPE_SEQUENCE.code + "): Test.g4:7:23: invalid escape sequence\n";
String[] pair = new String[] {
grammar,
@@ -647,8 +695,8 @@ public class TestToolSyntaxErrors extends BaseTest {
"WHITESPACE: [ \\t]+ -> channel(WHITESPACE_CHANNEL);\n";
String expected =
- "warning(" + ErrorType.UNKNOWN_LEXER_CONSTANT.code + "): T.g4:10:35: rule COMMENT contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output\n" +
- "warning(" + ErrorType.UNKNOWN_LEXER_CONSTANT.code + "): T.g4:11:35: rule WHITESPACE contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output\n" +
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME.code + "): T.g4:10:35: COMMENT_CHANNEL is not a recognized channel name\n" +
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME.code + "): T.g4:11:35: WHITESPACE_CHANNEL is not a recognized channel name\n" +
"error(" + ErrorType.CHANNELS_BLOCK_IN_COMBINED_GRAMMAR.code + "): T.g4:3:0: custom channels are not supported in combined grammars\n";
String[] pair = { grammar, expected };
@@ -676,7 +724,7 @@ public class TestToolSyntaxErrors extends BaseTest {
// WHITESPACE_CHANNEL and COMMENT_CHANNEL are defined, but NEWLINE_CHANNEL is not
String expected =
- "warning(" + ErrorType.UNKNOWN_LEXER_CONSTANT.code + "): T.g4:10:34: rule NEWLINE contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output\n";
+ "error(" + ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME.code + "): T.g4:10:34: NEWLINE_CHANNEL is not a recognized channel name\n";
String[] pair = { grammar, expected };
super.testErrors(pair, true);
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestTopologicalSort.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestTopologicalSort.java
index 38a2e60..2c0b596 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestTopologicalSort.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestTopologicalSort.java
@@ -1,36 +1,12 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.v4.misc.Graph;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import java.util.List;
@@ -38,7 +14,13 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
/** Test topo sort in GraphNode. */
-public class TestTopologicalSort extends BaseTest {
+public class TestTopologicalSort extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test
public void testFairlyLargeGraph() throws Exception {
Graph<String> g = new Graph<String>();
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedCharStream.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedCharStream.java
index 52a8a1b..fec0936 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedCharStream.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedCharStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -37,8 +13,8 @@ import org.antlr.v4.runtime.IntStream;
import org.antlr.v4.runtime.LexerInterpreter;
import org.antlr.v4.runtime.UnbufferedCharStream;
import org.antlr.v4.runtime.misc.Interval;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import java.io.Reader;
@@ -47,7 +23,13 @@ import java.io.StringReader;
import static org.junit.Assert.assertEquals;
@SuppressWarnings("unused")
-public class TestUnbufferedCharStream extends BaseTest {
+public class TestUnbufferedCharStream extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testNoChar() throws Exception {
CharStream input = createStream("");
assertEquals(IntStream.EOF, input.LA(1));
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedTokenStream.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedTokenStream.java
index 9ab81b3..5d9795d 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedTokenStream.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestUnbufferedTokenStream.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -37,8 +13,8 @@ import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.UnbufferedTokenStream;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.LexerGrammar;
+import org.junit.Before;
import org.junit.Test;
import java.io.StringReader;
@@ -49,7 +25,13 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
@SuppressWarnings("unused")
-public class TestUnbufferedTokenStream extends BaseTest {
+public class TestUnbufferedTokenStream extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testLookahead() throws Exception {
LexerGrammar g = new LexerGrammar(
"lexer grammar t;\n"+
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestVocabulary.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestVocabulary.java
index b786e00..b956494 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestVocabulary.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestVocabulary.java
@@ -1,46 +1,27 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.Vocabulary;
import org.antlr.v4.runtime.VocabularyImpl;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
*
* @author Sam Harwell
*/
-public class TestVocabulary extends BaseTest {
+public class TestVocabulary extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
@Test
public void testEmptyVocabulary() {
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java
index 7a374ee..7dbd741 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.test.tool;
import org.antlr.v4.runtime.Lexer;
@@ -7,7 +13,7 @@ import org.antlr.v4.runtime.misc.Pair;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.antlr.v4.runtime.tree.xpath.XPath;
-import org.antlr.v4.test.runtime.java.BaseTest;
+import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
@@ -17,7 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-public class TestXPath extends BaseTest {
+public class TestXPath extends BaseJavaToolTest {
public static final String grammar =
"grammar Expr;\n" +
"prog: func+ ;\n" +
@@ -52,6 +58,12 @@ public class TestXPath extends BaseTest {
"def f(x,y) { x = 3+4; y; ; }\n" +
"def g(x) { return 1+2*x; }\n";
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testValidPaths() throws Exception {
boolean ok =
rawGenerateAndBuildRecognizer("Expr.g4", grammar, "ExprParser",
diff --git a/tool/pom.xml b/tool/pom.xml
index 42e5f82..b708168 100644
--- a/tool/pom.xml
+++ b/tool/pom.xml
@@ -1,78 +1,137 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
- <version>4.5.4-SNAPSHOT</version>
+ <version>4.6</version>
</parent>
<artifactId>antlr4</artifactId>
<name>ANTLR 4 Tool</name>
+ <url>http://www.antlr.org</url>
<description>The ANTLR 4 grammar compiler.</description>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- <version>2.44.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>8.1.16.v20140903</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr-runtime</artifactId>
- <version>3.5.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>ST4</artifactId>
- <version>4.0.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.abego.treelayout</groupId>
- <artifactId>org.abego.treelayout.core</artifactId>
- <version>1.0.1</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>ST4</artifactId>
+ <version>4.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.abego.treelayout</groupId>
+ <artifactId>org.abego.treelayout.core</artifactId>
+ <version>1.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.json</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
<build>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <testResources>
- <testResource>
- <directory>test</directory>
- </testResource>
- </testResources>
- <plugins>
+ <sourceDirectory>src</sourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>test</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin> <!-- create src jar -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin> <!-- create javadoc jar -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <javadocVersion>1.7</javadocVersion>
+ <failOnError>false</failOnError>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>deploy</phase>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin> <!-- this makes a fat jar with all dependencies -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <configuration>
+ <minimizeJar>false</minimizeJar>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>complete</shadedClassifierName>
+ </configuration>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- can't get this to add bundle items
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
<executions>
<execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.antlr.antlr4-tool</Bundle-SymbolicName>
+ </instructions>
+ </configuration>
<goals>
- <goal>test-jar</goal>
+ <goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
+ -->
+ <plugin> <!-- this just jars up tool stuff and sets main class -->
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <mainClass>org.antlr.v4.Tool</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
@@ -89,29 +148,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <configuration>
- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <manifestEntries>
- <Main-Class>org.antlr.v4.Tool</Main-Class>
- </manifestEntries>
- </transformer>
- </transformers>
- </configuration>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/tool/resources/org/antlr/v4/tool/templates/LeftRecursiveRules.stg b/tool/resources/org/antlr/v4/tool/templates/LeftRecursiveRules.stg
index f4085e2..9f1dbb0 100644
--- a/tool/resources/org/antlr/v4/tool/templates/LeftRecursiveRules.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/LeftRecursiveRules.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg
index 6d57109..07b9f8b 100644
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg
@@ -52,7 +52,7 @@ using DFA = Antlr4.Runtime.Dfa.DFA;
<endif>
>>
-ListenerFile(file, header) ::= <<
+ListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
namespace <file.genPackage> {
@@ -96,7 +96,7 @@ void Exit<lname; format="cap">([NotNull] <csIdentifier.(file.parserName)>.<lname
<endif>
>>
-BaseListenerFile(file, header) ::= <<
+BaseListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
namespace <file.genPackage> {
@@ -159,7 +159,7 @@ public virtual void Exit<lname; format="cap">([NotNull] <csIdentifier.(file.pars
<endif>
>>
-VisitorFile(file, header) ::= <<
+VisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
namespace <file.genPackage> {
@@ -195,7 +195,7 @@ Result Visit<lname; format="cap">([NotNull] <csIdentifier.(file.parserName)>.<ln
<endif>
>>
-BaseVisitorFile(file, header) ::= <<
+BaseVisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
namespace <file.genPackage> {
@@ -269,6 +269,8 @@ Parser_(parser, funcs, atn, sempredFuncs, ctor, superClass) ::= <<
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "<file.ANTLRVersion>")]
[System.CLSCompliant(false)]
public partial class <csIdentifier.(parser.name)> : <superClass; null="Parser"> {
+ protected static DFA[] decisionToDFA;
+ protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
<if(parser.tokens)>
public const int
<parser.tokens:{k | <k>=<parser.tokens.(k)>}; separator=", ", wrap, anchor>;
@@ -287,6 +289,13 @@ public partial class <csIdentifier.(parser.name)> : <superClass; null="Parser">
public override string SerializedAtn { get { return _serializedATN; } }
+ static <csIdentifier.(parser.name)>() {
+ decisionToDFA = new DFA[_ATN.NumberOfDecisions];
+ for (int i = 0; i \< _ATN.NumberOfDecisions; i++) {
+ decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i);
+ }
+ }
+
<namedActions.members>
<parser:(ctor)()>
<funcs; separator="\n">
@@ -351,7 +360,7 @@ parser_ctor(parser) ::= <<
public <csIdentifier.(parser.name)>(ITokenStream input)
: base(input)
{
- Interpreter = new ParserATNSimulator(this,_ATN);
+ Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache);
}
>>
@@ -537,9 +546,10 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
LL1AltBlock(choice, preamble, alts, error) ::= <<
State = <choice.stateNumber>;
-<if(choice.label)><labelref(choice.label)> = TokenStream.Lt(1);<endif>
+ErrorHandler.Sync(this);
+<if(choice.label)><labelref(choice.label)> = TokenStream.LT(1);<endif>
<preamble; separator="\n">
-switch (TokenStream.La(1)) {
+switch (TokenStream.LA(1)) {
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
break;}; separator="\n">
@@ -550,7 +560,8 @@ default:
LL1OptionalBlock(choice, alts, error) ::= <<
State = <choice.stateNumber>;
-switch (TokenStream.La(1)) {
+ErrorHandler.Sync(this);
+switch (TokenStream.LA(1)) {
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
break;}; separator="\n">
@@ -561,6 +572,7 @@ default:
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
State = <choice.stateNumber>;
+ErrorHandler.Sync(this);
<preamble; separator="\n">
if (<expr>) {
<alts; separator="\n">
@@ -597,7 +609,7 @@ do {
AltBlock(choice, preamble, alts, error) ::= <<
State = <choice.stateNumber>;
ErrorHandler.Sync(this);
-<if(choice.label)><labelref(choice.label)> = TokenStream.Lt(1);<endif>
+<if(choice.label)><labelref(choice.label)> = TokenStream.LT(1);<endif>
<preamble; separator="\n">
switch ( Interpreter.AdaptivePredict(TokenStream,<choice.decision>,Context) ) {
<alts:{alt |
@@ -622,7 +634,7 @@ StarBlock(choice, alts, sync, iteration) ::= <<
State = <choice.stateNumber>;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,<choice.decision>,Context);
-while ( _alt!=<choice.exitAlt> && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) {
+while ( _alt!=<choice.exitAlt> && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1<if(!choice.ast.greedy)>+1<endif> ) {
<iteration>
<alts> <! should only be one !>
@@ -649,7 +661,7 @@ case <i><if(!choice.ast.greedy)>+1<endif>:
State = <choice.loopBackStateNumber>;<! loopback/exit decision !>
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,<choice.decision>,Context);
-} while ( _alt!=<choice.exitAlt> && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber );
+} while ( _alt!=<choice.exitAlt> && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER );
>>
Sync(s) ::= "Sync(<s.expecting.name>);"
@@ -702,12 +714,13 @@ MatchNotSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, true)>"
CommonSetStuff(m, expr, capture, invert) ::= <<
State = <m.stateNumber>;
-<if(m.labels)><m.labels:{l | <labelref(l)> = }>TokenStream.Lt(1);<endif>
+<if(m.labels)><m.labels:{l | <labelref(l)> = }>TokenStream.LT(1);<endif>
<capture>
if ( <if(invert)><m.varName> \<= 0 || <else>!<endif>(<expr>) ) {
<if(m.labels)><m.labels:{l | <labelref(l)> = }><endif>ErrorHandler.RecoverInline(this);
}
else {
+ ErrorHandler.ReportMatch(this);
Consume();
}
>>
@@ -740,10 +753,10 @@ LexerSkipCommand() ::= "Skip();"
LexerMoreCommand() ::= "More();"
LexerPopModeCommand() ::= "PopMode();"
-LexerTypeCommand(arg) ::= "_type = <tokenType.(arg)>;"
-LexerChannelCommand(arg) ::= "_channel = <channelName.(arg)>;"
-LexerModeCommand(arg) ::= "_mode = <modeName.(arg)>;"
-LexerPushModeCommand(arg) ::= "PushMode(<modeName.(arg)>);"
+LexerTypeCommand(arg, grammar) ::= "_type = <tokenType.(arg)>;"
+LexerChannelCommand(arg, grammar) ::= "_channel = <channelName.(arg)>;"
+LexerModeCommand(arg, grammar) ::= "_mode = <modeName.(arg)>;"
+LexerPushModeCommand(arg, grammar) ::= "PushMode(<modeName.(arg)>);"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
@@ -776,7 +789,7 @@ RulePropertyRef_parser(r) ::= "this"
ThisRulePropertyRef_start(r) ::= "_localctx.Start"
ThisRulePropertyRef_stop(r) ::= "_localctx.Stop"
-ThisRulePropertyRef_text(r) ::= "TokenStream.GetText(_localctx.Start, TokenStream.Lt(-1))"
+ThisRulePropertyRef_text(r) ::= "TokenStream.GetText(_localctx.Start, TokenStream.LT(-1))"
ThisRulePropertyRef_ctx(r) ::= "_localctx"
ThisRulePropertyRef_parser(r) ::= "this"
@@ -834,8 +847,8 @@ ImplicitRuleLabel(ruleName) ::= "_<ruleName>"
ImplicitSetLabel(id) ::= "_tset<id>"
ListLabelName(label) ::= "_<label>"
-CaptureNextToken(d) ::= "<d.varName> = TokenStream.Lt(1);"
-CaptureNextTokenType(d) ::= "<d.varName> = TokenStream.La(1);"
+CaptureNextToken(d) ::= "<d.varName> = TokenStream.LT(1);"
+CaptureNextTokenType(d) ::= "<d.varName> = TokenStream.LA(1);"
StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,
superClass={ParserRuleContext}) ::= <<
@@ -899,7 +912,7 @@ typedContext(ctx) ::= "<if(ctx.provideCopyFrom)>((<ctx.name>)_localctx)<else>_lo
// used for left-recursive rules
recRuleAltPredicate(ruleName,opPrec) ::= "Precpred(Context, <opPrec>)"
recRuleSetReturnAction(src,name) ::= "$<name>=$<src>.<name>;"
-recRuleSetStopToken() ::= "Context.Stop = TokenStream.Lt(-1);"
+recRuleSetStopToken() ::= "Context.Stop = TokenStream.LT(-1);"
recRuleAltStartAction(ruleName, ctxName, label, isListLabel) ::= <<
_localctx = new <ctxName>Context(_parentctx, _parentState);
@@ -961,6 +974,8 @@ Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass) ::= <<
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "<file.ANTLRVersion>")]
[System.CLSCompliant(false)]
public partial class <csIdentifier.(lexer.name)> : <superClass; null="Lexer"> {
+ protected static DFA[] decisionToDFA;
+ protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
public const int
<lexer.tokens:{k | <tokenType.(k)>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>;
<if(lexer.channels)>
@@ -981,7 +996,7 @@ public partial class <csIdentifier.(lexer.name)> : <superClass; null="Lexer"> {
public <csIdentifier.(lexer.name)>(ICharStream input)
: base(input)
{
- Interpreter = new LexerATNSimulator(this,_ATN);
+ Interpreter = new LexerATNSimulator(this, _ATN, decisionToDFA, sharedContextCache);
}
<vocabulary(lexer.literalNames, lexer.symbolicNames)>
@@ -994,6 +1009,12 @@ public partial class <csIdentifier.(lexer.name)> : <superClass; null="Lexer"> {
public override string SerializedAtn { get { return _serializedATN; } }
+ static <csIdentifier.(lexer.name)>() {
+ decisionToDFA = new DFA[_ATN.NumberOfDecisions];
+ for (int i = 0; i \< _ATN.NumberOfDecisions; i++) {
+ decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i);
+ }
+ }
<dumpActions(lexer, "", actionFuncs, sempredFuncs)>
<atn>
}
@@ -1011,6 +1032,8 @@ private static string _serializeATN()
public static readonly ATN _ATN =
new ATNDeserializer().Deserialize(_serializedATN.ToCharArray());
+
+
>>
initValue(typeName) ::= <<
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg
new file mode 100644
index 0000000..78f9610
--- /dev/null
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg
@@ -0,0 +1,1112 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2015 Dan McLaughlin, Mike Lischke
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import "Files.stg" // All file specific stuff.
+
+cppTypeInitMap ::= [
+ "int":"0",
+ "long":"0",
+ "float":"0.0f",
+ "double":"0.0",
+ "bool":"false",
+ "short":"0",
+ "char":"0",
+ default: "nullptr" // anything other than a primitive type is an object
+]
+
+LexerHeader(lexer, atn, actionFuncs, sempredFuncs, superClass = {antlr4::Lexer}) ::= <<
+<namedActions.context>
+
+class <file.exportMacro> <lexer.name> : public <superClass> {
+public:
+<if (lexer.tokens)>
+ enum {
+ <lexer.tokens: {k | <k> = <lexer.tokens.(k)>}; separator=", ", wrap, anchor>
+ };
+<endif>
+
+<if (lexer.channels)>
+ enum {
+ <lexer.channels: {k | <k> = <lexer.channels.(k)>}; separator=", ", wrap, anchor>
+ };
+<endif>
+
+<if (rest(lexer.modes))>
+ enum {
+ <rest(lexer.modes): {m | <m> = <i>,}; separator="\n", anchor>
+ };
+<endif>
+
+ <lexer.name>(antlr4::CharStream *input);
+ ~<lexer.name>();
+
+ <namedActions.members>
+ virtual std::string getGrammarFileName() const override;
+ virtual const std::vector\<std::string>& getRuleNames() const override;
+
+ virtual const std::vector\<std::string>& getModeNames() const override;
+ virtual const std::vector\<std::string>& getTokenNames() const override; // deprecated, use vocabulary instead
+ virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
+
+ virtual const std::vector\<uint16_t> getSerializedATN() const override;
+ virtual const antlr4::atn::ATN& getATN() const override;
+
+ <if (actionFuncs)>
+ virtual void action(antlr4::RuleContext *context, size_t ruleIndex, size_t actionIndex) override;
+ <endif>
+ <if (sempredFuncs)>
+ virtual bool sempred(antlr4::RuleContext *_localctx, size_t ruleIndex, size_t predicateIndex) override;
+ <endif>
+
+private:
+ static std::vector\<antlr4::dfa::DFA> _decisionToDFA;
+ static antlr4::atn::PredictionContextCache _sharedContextCache;
+ static std::vector\<std::string> _ruleNames;
+ static std::vector\<std::string> _tokenNames;
+ static std::vector\<std::string> _modeNames;
+
+ static std::vector\<std::string> _literalNames;
+ static std::vector\<std::string> _symbolicNames;
+ static antlr4::dfa::Vocabulary _vocabulary;
+ <atn>
+
+ <namedActions.declarations>
+
+ // Individual action functions triggered by action() above.
+ <actionFuncs.values; separator="\n">
+
+ // Individual semantic predicate functions triggered by sempred() above.
+ <sempredFuncs.values; separator="\n">
+
+ struct Initializer {
+ Initializer();
+ };
+ static Initializer _init;
+};
+>>
+
+Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass = {Lexer}) ::= <<
+<lexer.name>::<lexer.name>(CharStream *input) : <superClass>(input) {
+ _interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
+}
+
+<lexer.name>::~<lexer.name>() {
+ delete _interpreter;
+}
+
+std::string <lexer.name>::getGrammarFileName() const {
+ return "<lexer.grammarFileName>";
+}
+
+const std::vector\<std::string>& <lexer.name>::getRuleNames() const {
+ return _ruleNames;
+}
+
+const std::vector\<std::string>& <lexer.name>::getModeNames() const {
+ return _modeNames;
+}
+
+const std::vector\<std::string>& <lexer.name>::getTokenNames() const {
+ return _tokenNames;
+}
+
+dfa::Vocabulary& <lexer.name>::getVocabulary() const {
+ return _vocabulary;
+}
+
+const std::vector\<uint16_t> <lexer.name>::getSerializedATN() const {
+ return _serializedATN;
+}
+
+const atn::ATN& <lexer.name>::getATN() const {
+ return _atn;
+}
+
+<namedActions.definitions>
+
+<if (actionFuncs)>
+void <lexer.name>::action(RuleContext *context, size_t ruleIndex, size_t actionIndex) {
+ switch (ruleIndex) {
+ <lexer.actionFuncs.values: {f | case <f.ruleIndex>: <f.name>Action(dynamic_cast\<<f.ctxType> *>(context), actionIndex); break;}; separator="\n">
+
+ default:
+ break;
+ }
+}
+<endif>
+
+<if (sempredFuncs)>
+bool <lexer.name>::sempred(RuleContext *context, size_t ruleIndex, size_t predicateIndex) {
+ switch (ruleIndex) {
+ <lexer.sempredFuncs.values: {f | case <f.ruleIndex>: return <f.name>Sempred(dynamic_cast\<<f.ctxType> *>(context), predicateIndex);}; separator="\n">
+
+ default:
+ break;
+ }
+ return true;
+}
+<endif>
+
+<actionFuncs.values; separator="\n">
+
+<sempredFuncs.values; separator="\n">
+
+// Static vars and initialization.
+std::vector\<dfa::DFA> <lexer.name>::_decisionToDFA;
+atn::PredictionContextCache <lexer.name>::_sharedContextCache;
+
+// We own the ATN which in turn owns the ATN states.
+atn::ATN <lexer.name>::_atn;
+std::vector\<uint16_t> <lexer.name>::_serializedATN;
+
+std::vector\<std::string> <lexer.name>::_ruleNames = {
+ <lexer.ruleNames: {r | "<r>"}; separator = ", ", wrap, anchor>
+};
+
+std::vector\<std::string> <lexer.name>::_modeNames = {
+ <lexer.modes: {m | "<m>"}; separator = ", ", wrap, anchor>
+};
+
+std::vector\<std::string> <lexer.name>::_literalNames = {
+ <lexer.literalNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
+};
+
+std::vector\<std::string> <lexer.name>::_symbolicNames = {
+ <lexer.symbolicNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
+};
+
+dfa::Vocabulary <lexer.name>::_vocabulary(_literalNames, _symbolicNames);
+
+std::vector\<std::string> <lexer.name>::_tokenNames;
+
+<lexer.name>::Initializer::Initializer() {
+ // This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there.
+ for (size_t i = 0; i \< _symbolicNames.size(); ++i) {
+ std::string name = _vocabulary.getLiteralName(i);
+ if (name.empty()) {
+ name = _vocabulary.getSymbolicName(i);
+ }
+
+ if (name.empty()) {
+ _tokenNames.push_back("\<INVALID>");
+ } else {
+ _tokenNames.push_back(name);
+ }
+ }
+
+ <atn>
+}
+
+<lexer.name>::Initializer <lexer.name>::_init;
+>>
+
+RuleActionFunctionHeader(r, actions) ::= <<
+void <r.name>Action(<r.ctxType> *context, size_t actionIndex);
+>>
+
+RuleActionFunction(r, actions) ::= <<
+void <r.factory.grammar.name>::<r.name>Action(<r.ctxType> *context, size_t actionIndex) {
+ switch (actionIndex) {
+ <actions: {index | case <index>: <actions.(index)> break;}; separator="\n">
+
+ default:
+ break;
+ }
+}
+
+>>
+
+RuleSempredFunctionHeader(r, actions) ::= <<
+bool <r.name>Sempred(<r.ctxType> *_localctx, size_t predicateIndex);
+>>
+
+RuleSempredFunction(r, actions) ::= <<
+<! Called for both lexer and parser. But only one of them is actually available. Testing for the parser directly
+ generates a warning, however. So do the check via the factory instead. !>
+bool <if (r.factory.g.lexer)><lexer.name><else><parser.name><endif>::<r.name>Sempred(<r.ctxType> *_localctx, size_t predicateIndex) {
+ switch (predicateIndex) {
+ <actions: {index | case <index>: return <actions.(index)>}; separator=";\n">;
+
+ default:
+ break;
+ }
+ return true;
+}
+
+>>
+
+//--------------------------------------------------------------------------------------------------
+
+ParserHeader(parser, funcs, atn, sempredFuncs, superClass = {antlr4::Parser}) ::= <<
+<namedActions.context>
+
+class <file.exportMacro> <parser.name> : public <superClass> {
+public:
+<if (parser.tokens)>
+ enum {
+ <parser.tokens: {k | <k> = <parser.tokens.(k)>}; separator=", ", wrap, anchor>
+ };
+<endif>
+
+<if (parser.tokens)>
+ enum {
+ <parser.rules: {r | Rule<r.name; format="cap"> = <r.index>}; separator=", ", wrap, anchor>
+ };
+<endif>
+
+ <parser.name>(antlr4::TokenStream *input);
+ ~<parser.name>();
+
+ virtual std::string getGrammarFileName() const override;
+ virtual const antlr4::atn::ATN& getATN() const override { return _atn; };
+ virtual const std::vector\<std::string>& getTokenNames() const override { return _tokenNames; }; // deprecated: use vocabulary instead.
+ virtual const std::vector\<std::string>& getRuleNames() const override;
+ virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
+
+ <namedActions.members>
+
+ <parser.funcs: {f | class <f.name; format = "cap">Context;}; separator = "\n"> <! Forward declare context classes. !>
+
+ <funcs; separator = "\n">
+
+ <if (sempredFuncs)>
+ virtual bool sempred(antlr4::RuleContext *_localctx, size_t ruleIndex, size_t predicateIndex) override;
+ <sempredFuncs.values; separator = "\n">
+ <endif>
+
+private:
+ static std::vector\<antlr4::dfa::DFA> _decisionToDFA;
+ static antlr4::atn::PredictionContextCache _sharedContextCache;
+ static std::vector\<std::string> _ruleNames;
+ static std::vector\<std::string> _tokenNames;
+
+ static std::vector\<std::string> _literalNames;
+ static std::vector\<std::string> _symbolicNames;
+ static antlr4::dfa::Vocabulary _vocabulary;
+ <atn>
+
+ <namedActions.declarations>
+
+ struct Initializer {
+ Initializer();
+ };
+ static Initializer _init;
+};
+>>
+
+Parser(parser, funcs, atn, sempredFuncs, superClass = {Parser}) ::= <<
+using namespace antlr4;
+
+<parser.name>::<parser.name>(TokenStream *input) : <superClass>(input) {
+ _interpreter = new atn::ParserATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
+}
+
+<parser.name>::~<parser.name>() {
+ delete _interpreter;
+}
+
+std::string <parser.name>::getGrammarFileName() const {
+ return "<parser.grammarFileName>";
+}
+
+const std::vector\<std::string>& <parser.name>::getRuleNames() const {
+ return _ruleNames;
+}
+
+dfa::Vocabulary& <parser.name>::getVocabulary() const {
+ return _vocabulary;
+}
+
+<namedActions.definitions>
+
+<funcs; separator = "\n\n">
+
+<if (sempredFuncs)>
+bool <parser.name>::sempred(RuleContext *context, size_t ruleIndex, size_t predicateIndex) {
+ switch (ruleIndex) {
+ <parser.sempredFuncs.values: {f |
+ case <f.ruleIndex>: return <f.name>Sempred(dynamic_cast\<<f.ctxType> *>(context), predicateIndex);}; separator="\n">
+
+ default:
+ break;
+ }
+ return true;
+}
+
+<sempredFuncs.values; separator="\n"><endif>
+
+// Static vars and initialization.
+std::vector\<dfa::DFA> <parser.name>::_decisionToDFA;
+atn::PredictionContextCache <parser.name>::_sharedContextCache;
+
+// We own the ATN which in turn owns the ATN states.
+atn::ATN <parser.name>::_atn;
+std::vector\<uint16_t> <parser.name>::_serializedATN;
+
+std::vector\<std::string> <parser.name>::_ruleNames = {
+ <parser.ruleNames: {r | "<r>"}; separator = ", ", wrap, anchor>
+};
+
+std::vector\<std::string> <parser.name>::_literalNames = {
+ <parser.literalNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
+};
+
+std::vector\<std::string> <parser.name>::_symbolicNames = {
+ <parser.symbolicNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
+};
+
+dfa::Vocabulary <parser.name>::_vocabulary(_literalNames, _symbolicNames);
+
+std::vector\<std::string> <parser.name>::_tokenNames;
+
+<parser.name>::Initializer::Initializer() {
+ for (size_t i = 0; i \< _symbolicNames.size(); ++i) {
+ std::string name = _vocabulary.getLiteralName(i);
+ if (name.empty()) {
+ name = _vocabulary.getSymbolicName(i);
+ }
+
+ if (name.empty()) {
+ _tokenNames.push_back("\<INVALID>");
+ } else {
+ _tokenNames.push_back(name);
+ }
+ }
+
+ <atn>
+}
+
+<parser.name>::Initializer <parser.name>::_init;
+>>
+
+SerializedATNHeader(model) ::= <<
+static antlr4::atn::ATN _atn;
+static std::vector\<uint16_t> _serializedATN;
+>>
+
+// Constructs the serialized ATN and writes init code for static member vars.
+SerializedATN(model) ::= <<
+<if (rest(model.segments))>
+<model.segments: {segment | static uint16_t serializedATNSegment<i0>[] = {
+ <segment; wrap={<\n> }>
+\};}; separator="\n">
+
+<model.segments: {segment | _serializedATN.insert(_serializedATN.end(), serializedATNSegment<i0>,
+ serializedATNSegment<i0> + sizeof(serializedATNSegment<i0>) / sizeof(serializedATNSegment<i0>[0]));
+}>
+
+<else>
+<! only one segment, can be inlined !>
+_serializedATN = {
+ <model.serialized; wrap = {<\n>}>
+};
+<endif>
+
+atn::ATNDeserializer deserializer;
+_atn = deserializer.deserialize(_serializedATN);
+
+size_t count = _atn.getNumberOfDecisions();
+_decisionToDFA.reserve(count);
+for (size_t i = 0; i \< count; i++) { <! Rework class ATN to allow standard iterations. !>
+ _decisionToDFA.emplace_back(_atn.getDecisionState(i), i);
+}
+>>
+
+RuleFunctionHeader(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble, exceptions) ::= <<
+<ruleCtx>
+<! TODO: untested !><if (altLabelCtxs)><altLabelCtxs: {l | <altLabelCtxs.(l)>}; separator="\n"><endif>
+<currentRule.ctxType>* <currentRule.name>(<args; separator=",">);
+
+>>
+
+RuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble, exceptions) ::= <<
+<ruleCtx>
+<! TODO: untested !><altLabelCtxs: {l | <altLabelCtxs.(l)>}; separator = "\n">
+<parser.name>::<currentRule.ctxType>* <parser.name>::<currentRule.name>(<args; separator=",">) {
+ <currentRule.ctxType> *_localctx = _tracker.createInstance\<<currentRule.ctxType>\>(_ctx, getState()<currentRule.args:{a | , <a.name>}>);
+ enterRule(_localctx, <currentRule.startState>, <parser.name>::Rule<currentRule.name; format = "cap">);
+ <namedActions.init>
+ <locals; separator = "\n">
+
+ auto onExit = finally([=] {
+ <finallyAction>
+ exitRule();
+ });
+ try {
+<! TODO: untested !><if (currentRule.hasLookaheadBlock)>
+ size_t alt;
+ <endif>
+ <code>
+<! TODO: untested !> <postamble; separator = "\n">
+ <namedActions.after>
+ }
+ <if (exceptions)>
+ <exceptions; separator="\n">
+ <else>
+ catch (RecognitionException &e) {
+ _errHandler->reportError(this, e);
+ _localctx->exception = std::current_exception();
+ _errHandler->recover(this, _localctx->exception);
+ }
+ <endif>
+
+ return _localctx;
+}
+>>
+
+LeftRecursiveRuleFunctionHeader(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble) ::= <<
+<ruleCtx>
+<! TODO: untested !><altLabelCtxs: {l | <altLabelCtxs.(l)>}; separator="\n">
+<currentRule.ctxType>* <currentRule.name>(<currentRule.args; separator = ", ">);
+<currentRule.ctxType>* <currentRule.name>(int precedence<currentRule.args: {a | , <a>}>);
+>>
+
+LeftRecursiveRuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble) ::= <<
+<ruleCtx>
+<altLabelCtxs: {l | <altLabelCtxs.(l)>}; separator="\n">
+
+<parser.name>::<currentRule.ctxType>* <parser.name>::<currentRule.name>(<currentRule.args; separator=", ">) {
+<! TODO: currentRule.args untested !> return <currentRule.name>(0<currentRule.args: {a | , <a.name>}>);
+}
+
+<parser.name>::<currentRule.ctxType>* <parser.name>::<currentRule.name>(int precedence<currentRule.args:{a | , <a>}>) {
+ ParserRuleContext *parentContext = _ctx;
+ size_t parentState = getState();
+ <parser.name>::<currentRule.ctxType> *_localctx = _tracker.createInstance\<<currentRule.ctxType>\>(_ctx, parentState<currentRule.args: {a | , <a.name>}>);
+ <parser.name>::<currentRule.ctxType> *previousContext = _localctx;
+ size_t startState = <currentRule.startState>;
+ enterRecursionRule(_localctx, <currentRule.startState>, <parser.name>::Rule<currentRule.name; format = "cap">, precedence);
+
+ <namedActions.init>
+<! TODO: untested !> <locals; separator = "\n">
+
+ auto onExit = finally([=] {
+ <if (finallyAction)><finallyAction><endif>
+ unrollRecursionContexts(parentContext);
+ });
+ try {
+ <if (currentRule.hasLookaheadBlock)>size_t alt;<endif>
+ <code>
+<! TODO: untested !><postamble; separator = "\n">
+ <namedActions.after>
+ }
+ catch (RecognitionException &e) {
+ _errHandler->reportError(this, e);
+ _localctx->exception = std::current_exception();
+ _errHandler->recover(this, _localctx->exception);
+ }
+ return _localctx;
+}
+>>
+
+StructDeclHeader(struct, ctorAttrs, attrs, getters, dispatchMethods, interfaces, extensionMembers) ::= <<
+class <file.exportMacro> <struct.name> : public <if (contextSuperClass)><contextSuperClass><else>antlr4::ParserRuleContext<endif><if(interfaces)>, <interfaces; separator=", "><endif> {
+public:
+ <attrs: {a | <a>;}; separator="\n">
+ <if (ctorAttrs)><struct.name>(antlr4::ParserRuleContext *parent, size_t invokingState);<endif>
+ <struct.name>(antlr4::ParserRuleContext *parent, size_t invokingState<ctorAttrs: {a | , <a>}>);
+<if (struct.provideCopyFrom)> <! don't need copy unless we have subclasses !>
+ <struct.name>() : antlr4::ParserRuleContext() { }
+ void copyFrom(<struct.name> *context);
+ using antlr4::ParserRuleContext::copyFrom;
+<endif>
+
+ virtual size_t getRuleIndex() const override;
+ <getters: {g | <g>}; separator = "\n">
+
+ <dispatchMethods; separator = "\n">
+<! TODO: untested !> <extensionMembers; separator = "\n">
+};
+
+>>
+
+StructDecl(struct, ctorAttrs, attrs, getters, dispatchMethods, interfaces, extensionMembers) ::= <<
+//----------------- <struct.name> ------------------------------------------------------------------
+
+<if (ctorAttrs)>
+<parser.name>::<struct.name>::<struct.name>(ParserRuleContext *parent, size_t invokingState)
+ : <if (contextSuperClass)><contextSuperClass><else>ParserRuleContext<endif>(parent, invokingState) {
+}
+<endif>
+
+<parser.name>::<struct.name>::<struct.name>(ParserRuleContext *parent, size_t invokingState<ctorAttrs: {a | , <a>}>)
+ : <if (contextSuperClass)><contextSuperClass><else>ParserRuleContext<endif>(parent, invokingState) {
+ <struct.ctorAttrs: {a | this-><a.name> = <a.name>;}; separator="\n">
+}
+
+<getters: {g | <g>}; separator = "\n">
+
+size_t <parser.name>::<struct.name>::getRuleIndex() const {
+ return <parser.name>::Rule<struct.derivedFromName; format = "cap">;
+}
+
+<if (struct.provideCopyFrom)>
+void <parser.name>::<struct.name>::copyFrom(<struct.name> *ctx) {
+ <if (contextSuperClass)><contextSuperClass><else>ParserRuleContext<endif>::copyFrom(ctx);
+ <struct.attrs: {a | this-><a.name> = ctx-><a.name>;}; separator = "\n">
+}
+<endif>
+<dispatchMethods; separator = "\n\n">
+<! TODO: untested !><extensionMembers; separator = "\n\n">
+
+>>
+
+AltLabelStructDeclHeader(struct, attrs, getters, dispatchMethods) ::= <<
+class <file.exportMacro> <struct.name> : public <currentRule.name; format = "cap">Context {
+public:
+ <struct.name>(<currentRule.name; format = "cap">Context *ctx);
+
+ <if (attrs)><attrs: {a | <a>}; separator = "\n"><endif>
+ <getters: {g | <g>}; separator = "\n">
+ <dispatchMethods; separator = "\n">
+};
+
+>>
+
+AltLabelStructDecl(struct, attrs, getters, dispatchMethods) ::= <<
+//----------------- <struct.name> ------------------------------------------------------------------
+
+<! TODO: untested !><if (attrs)><attrs: {a | <a>}; separator = "\n"><endif>
+<getters: {g | <g>}; separator = "\n">
+<parser.name>::<struct.name>::<struct.name>(<currentRule.name; format = "cap">Context *ctx) { copyFrom(ctx); }
+
+<dispatchMethods; separator="\n">
+>>
+
+
+CodeBlockForOuterMostAltHeader(currentOuterMostAltCodeBlock, locals, preamble, ops) ::= "<! Required to exist, but unused. !>"
+CodeBlockForOuterMostAlt(currentOuterMostAltCodeBlock, locals, preamble, ops) ::= <<
+<if (currentOuterMostAltCodeBlock.altLabel)>
+_localctx = dynamic_cast\<<currentRule.ctxType> *>(_tracker.createInstance\<<parser.name>::<currentOuterMostAltCodeBlock.altLabel; format = "cap">Context>(_localctx));
+<endif>
+enterOuterAlt(_localctx, <currentOuterMostAltCodeBlock.alt.altNum>);
+<CodeBlockForAlt(currentAltCodeBlock = currentOuterMostAltCodeBlock, ...)>
+>>
+
+CodeBlockForAltHeader(currentAltCodeBlock, locals, preamble, ops) ::= "<! Required to exist, but unused. !>"
+CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
+<! TODO: untested !><locals; separator = "\n">
+<! TODO: untested !><preamble; separator = "\n">
+<ops; separator = "\n">
+>>
+
+LL1AltBlockHeader(choice, preamble, alts, error) ::= "<! Required to exist, but unused. !>"
+LL1AltBlock(choice, preamble, alts, error) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+<! TODO: untested !><if (choice.label)>LL1AltBlock(choice, preamble, alts, error) <labelref(choice.label)> = _input->LT(1);<endif>
+<preamble; separator="\n">
+switch (_input->LA(1)) {
+ <choice.altLook, alts: {look, alt | <cases(ttypes = look)> {
+ <alt>
+ break;
+\}
+}; separator = "\n">
+default:
+ <error>
+}
+>>
+
+LL1OptionalBlockHeader(choice, alts, error) ::= "<! Required but unused. !>"
+LL1OptionalBlock(choice, alts, error) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+switch (_input->LA(1)) {
+ <choice.altLook, alts: {look, alt | <cases(ttypes = look)> {
+ <alt>
+ break;
+\}
+}; separator="\n">
+default:
+ <error>
+}
+>>
+
+LL1OptionalBlockSingleAltHeader(choice, expr, alts, preamble, error, followExpr) ::= "<! Required but unused. !>"
+LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+
+<preamble; separator = "\n">
+if (<expr>) {
+ <alts; separator = "\n">
+}
+>>
+
+LL1StarBlockSingleAltHeader(choice, loopExpr, alts, preamble, iteration) ::= "<! Required but unused. !>"
+LL1StarBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+<preamble; separator="\n">
+while (<loopExpr>) {
+ <alts; separator="\n">
+ setState(<choice.loopBackStateNumber>);
+ _errHandler->sync(this);
+ <iteration>
+}
+>>
+
+LL1PlusBlockSingleAltHeader(choice, loopExpr, alts, preamble, iteration) ::= "<! Required but unused. !>"
+LL1PlusBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+setState(<choice.blockStartStateNumber>); <! alt block decision !>
+_errHandler->sync(this);
+<preamble; separator="\n">
+do {
+ <alts; separator="\n">
+ setState(<choice.stateNumber>); <! loopback/exit decision !>
+ _errHandler->sync(this);
+ <iteration>
+} while (<loopExpr>);
+>>
+
+// LL(*) stuff
+
+AltBlockHeader(choice, preamble, alts, error) ::= "<! Unused but must be present. !>"
+AltBlock(choice, preamble, alts, error) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+<! TODO: untested !><if (choice.label)><labelref(choice.label)> = _input->LT(1);<endif>
+<! TODO: untested !><preamble; separator = "\n">
+switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx)) {
+<alts: {alt | case <i>: {
+ <alt>
+ break;
+\}
+}; separator="\n">
+}
+>>
+
+OptionalBlockHeader(choice, alts, error) ::= "<! Unused but must be present. !>"
+OptionalBlock(choice, alts, error) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+
+switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx)) {
+<alts: {alt | case <i><if (!choice.ast.greedy)> + 1<endif>: {
+ <alt>
+ break;
+\}
+}; separator = "\n">
+}
+>>
+
+StarBlockHeader(choice, alts, sync, iteration) ::= "<! Unused but must be present. !>"
+StarBlock(choice, alts, sync, iteration) ::= <<
+setState(<choice.stateNumber>);
+_errHandler->sync(this);
+alt = getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx);
+while (alt != <choice.exitAlt> && alt != atn::ATN::INVALID_ALT_NUMBER) {
+ if (alt == 1<if(!choice.ast.greedy)> + 1<endif>) {
+ <iteration>
+ <alts> <! should only be one !>
+ }
+ setState(<choice.loopBackStateNumber>);
+ _errHandler->sync(this);
+ alt = getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx);
+}
+>>
+
+PlusBlockHeader(choice, alts, error) ::= "<! Required to exist, but unused. !>"
+PlusBlock(choice, alts, error) ::= <<
+setState(<choice.blockStartStateNumber>); <! alt block decision !>
+_errHandler->sync(this);
+alt = 1<if(!choice.ast.greedy)> + 1<endif>;
+do {
+ switch (alt) {
+ <alts: {alt | case <i><if (!choice.ast.greedy)> + 1<endif>: {
+ <alt>
+ break;
+ \}
+}; separator="\n">
+ default:
+ <error>
+ }
+ setState(<choice.loopBackStateNumber>); <! loopback/exit decision !>
+ _errHandler->sync(this);
+ alt = getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx);
+} while (alt != <choice.exitAlt> && alt != atn::ATN::INVALID_ALT_NUMBER);
+>>
+
+Sync(s) ::= "Sync(s) sync(<s.expecting.name>);"
+
+ThrowNoViableAltHeader(t) ::= "<! Unused but must be present. !>"
+ThrowNoViableAlt(t) ::= "throw NoViableAltException(this);"
+
+TestSetInlineHeader(s) ::= "<! Required but unused. !>"
+TestSetInline(s) ::= <<
+<s.bitsets: {bits | <if (rest(rest(bits.ttypes)))><bitsetBitfieldComparison(s, bits)><else><bitsetInlineComparison(s, bits)><endif>}; separator=" || ">
+>>
+
+// Java language spec 15.19 - shift operators mask operands rather than overflow to 0... need range test
+testShiftInRange(shiftAmount) ::= <<
+((<shiftAmount> & ~ 0x3fULL) == 0)
+>>
+
+// produces smaller bytecode only when bits.ttypes contains more than two items
+bitsetBitfieldComparison(s, bits) ::= <<
+(<testShiftInRange({<offsetShift(s.varName, bits.shift)>})> &&
+ ((1ULL \<\< <offsetShift(s.varName, bits.shift)>) & (<bits.ttypes: {ttype | (1ULL \<\< <offsetShift(ttype, bits.shift, true)>)}; separator = "\n | ">)) != 0)
+>>
+
+isZero ::= [
+ "0": true,
+ default: false
+]
+
+offsetShift(shiftAmount, offset, prefix = false) ::= <%
+<if (!isZero.(offset))>(<if (prefix)><parser.name>::<endif><shiftAmount> - <offset>)<else><if (prefix)><parser.name>::<endif><shiftAmount><endif>
+%>
+
+// produces more efficient bytecode when bits.ttypes contains at most two items
+bitsetInlineComparison(s, bits) ::= <%
+<bits.ttypes: {ttype | <s.varName> == <parser.name>::<ttype>}; separator = "\n\n|| ">
+%>
+
+cases(ttypes) ::= <<
+<ttypes: {t | case <parser.name>::<t>:}; separator="\n">
+>>
+
+InvokeRuleHeader(r, argExprsChunks) ::= "InvokeRuleHeader"
+InvokeRule(r, argExprsChunks) ::= <<
+setState(<r.stateNumber>);
+<if(r.labels)><r.labels: {l | <labelref(l)> = }><endif><r.name>(<if(r.ast.options.p)><r.ast.options.p><if(argExprsChunks)>,<endif><endif><argExprsChunks>);
+>>
+
+MatchTokenHeader(m) ::= "<! Required but unused. !>"
+MatchToken(m) ::= <<
+setState(<m.stateNumber>);
+<if (m.labels)><m.labels: {l | <labelref(l)> = }><endif>match(<parser.name>::<m.name>);
+>>
+
+MatchSetHeader(m, expr, capture) ::= "<! Required but unused. !>"
+MatchSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, false)>"
+
+MatchNotSetHeader(m, expr, capture) ::= "<! Required but unused. !>"
+MatchNotSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, true)>"
+
+CommonSetStuff(m, expr, capture, invert) ::= <<
+setState(<m.stateNumber>);
+<if (m.labels)><m.labels: {l | <labelref(l)> = }>_input->LT(1);<endif>
+<capture>
+if (<if (invert)><m.varName> == 0 || <m.varName> == Token::EOF || <else>!<endif>(<expr>)) {
+ <if (m.labels)><m.labels: {l | <labelref(l)> = }><endif>_errHandler->recoverInline(this);
+}
+else {
+ _errHandler->reportMatch(this);
+ consume();
+}
+>>
+
+WildcardHeader(w) ::= "<! Required but unused. !>"
+Wildcard(w) ::= <<
+setState(<w.stateNumber>);
+<if (w.labels)><w.labels: {l | <labelref(l)> = }><endif>matchWildcard();
+>>
+
+// ACTION STUFF
+
+ActionHeader(a, foo, chunks) ::= "<chunks>"
+Action(a, foo, chunks) ::= "<chunks>"
+
+ArgAction(a, chunks) ::= "ArgAction(a, chunks) <chunks>"
+
+SemPredHeader(p, chunks, failChunks) ::= "<! Required but unused. !>"
+SemPred(p, chunks, failChunks) ::= <<
+setState(<p.stateNumber>);
+
+if (!(<chunks>)) throw FailedPredicateException(this, <p.predicate><if (failChunks)>, <failChunks><elseif (p.msg)>, <p.msg><endif>);
+>>
+
+ExceptionClauseHeader(e, catchArg, catchAction) ::= "<! Required but unused. !>"
+ExceptionClause(e, catchArg, catchAction) ::= <<
+catch (<catchArg>) {
+ <catchAction>
+}
+>>
+
+// Lexer actions are not associated with model objects.
+
+LexerSkipCommand() ::= "skip();"
+LexerMoreCommand() ::= "more();"
+LexerPopModeCommand() ::= "popMode();"
+
+LexerTypeCommand(arg, grammar) ::= "type = <grammar.name>::<arg>;"
+LexerChannelCommand(arg, grammar) ::= "channel = <arg>;"
+LexerModeCommand(arg, grammar) ::= "mode = <grammar.name>Mode::<arg>;"
+LexerPushModeCommand(arg, grammar) ::= "pushMode(<grammar.name>Mode::<arg>);"
+
+ActionTextHeader(t) ::= "<t.text>"
+ActionText(t) ::= "<t.text>"
+
+ActionTemplateHeader(t) ::= "<! Required but unused. !>"
+ActionTemplate(t) ::= "<t.st>"
+
+ArgRefHeader(t) ::= "<! Required but unused. !>"
+ArgRef(a) ::= "_localctx-><a.name>"
+
+LocalRefHeader(t) ::= "<! Required but unused. !>"
+LocalRef(a) ::= "_localctx-><a.name>"
+
+RetValueRefHeader(t) ::= "<! Required but unused. !>"
+RetValueRef(a) ::= "_localctx-><a.name>"
+
+QRetValueRefHeader(t) ::= "<! Required but unused. !>"
+QRetValueRef(a) ::= "<ctx(a)>-><a.dict>-><a.name>"
+/** How to translate $tokenLabel */
+
+TokenRefHeader(t) ::= "<! Required but unused. !>"
+TokenRef(t) ::= "<ctx(t)>-><t.name>"
+
+LabelRefHeader(t) ::= "<! Required but unused. !>"
+LabelRef(t) ::= "<ctx(t)>-><t.name>"
+
+ListLabelRefHeader(t) ::= "<! Required but unused. !>"
+ListLabelRef(t) ::= "<ctx(t)>-><ListLabelName(t.name)>"
+
+SetAttrHeader(t) ::= "<! Required but unused. !>"
+SetAttr(s,rhsChunks) ::= "<ctx(s)>-><s.name> = <rhsChunks>;"
+
+InputSymbolType() ::= "<file.InputSymbolType; null = {Token}> *"
+
+TokenPropertyRef_textHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_text(t) ::= <<(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getText() : "")>>
+
+TokenPropertyRef_typeHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_type(t) ::= "(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getType() : 0)"
+
+TokenPropertyRef_lineHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_line(t) ::= "(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getLine() : 0)"
+
+TokenPropertyRef_posHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_pos(t) ::= "(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getCharPositionInLine() : 0)"
+
+TokenPropertyRef_channelHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_channel(t) ::= "(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getChannel() : 0)"
+
+TokenPropertyRef_indexHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_index(t) ::= "(<ctx(t)>-><t.label> != nullptr ? <ctx(t)>-><t.label>->getTokenIndex() : 0)"
+
+TokenPropertyRef_intHeader(t) ::= "<! Required but unused. !>"
+TokenPropertyRef_int(t) ::= "(<ctx(t)>-><t.label> != nullptr ? std::stoi(<ctx(t)>-><t.label>->getText()) : 0)"
+
+RulePropertyRef_startHeader(r) ::= "<! Required but unused. !>"
+RulePropertyRef_start(r) ::= "(<ctx(r)>-><r.label> != nullptr ? (<ctx(r)>-><r.label>->start) : nullptr)"
+
+RulePropertyRef_stopHeader(r) ::= "<! Required but unused. !>"
+RulePropertyRef_stop(r) ::= "(<ctx(r)>-><r.label> != nullptr ? (<ctx(r)>-><r.label>->stop) : nullptr)"
+
+RulePropertyRef_textHeader(r) ::= "<! Required but unused. !>"
+RulePropertyRef_text(r) ::= "(<ctx(r)>-><r.label> != nullptr ? _input->getText(<ctx(r)>-><r.label>->start, <ctx(r)>-><r.label>->stop) : nullptr)"
+
+RulePropertyRef_ctxHeader(r) ::= "<! Required but unused. !>"
+RulePropertyRef_ctx(r) ::= "<ctx(r)>-><r.label>"
+
+ThisRulePropertyRef_start(r) ::= "ThisRulePropertyRef_start(r) _localctx->start"
+ThisRulePropertyRef_stop(r) ::= "ThisRulePropertyRef_stop(r) _localctx->stop"
+
+ThisRulePropertyRef_textHeader(r) ::= "<! Required but unused. !>"
+ThisRulePropertyRef_text(r) ::= "_input->getText(_localctx->start, _input->LT(-1))"
+
+ThisRulePropertyRef_ctxHeader(r) ::= "<! Required but unused. !>"
+ThisRulePropertyRef_ctx(r) ::= "_localctx"
+
+ThisRulePropertyRef_parserHeader(r) ::= "<! Required but unused. !>"
+ThisRulePropertyRef_parser(r) ::= "this"
+
+NonLocalAttrRef(s) ::= "NonLocalAttrRef(s) ((<s.ruleName; format=\"cap\">Context)getInvokingContext(<s.ruleIndex>)).<s.name>"
+SetNonLocalAttr(s, rhsChunks) ::=
+ "SetNonLocalAttr(s, rhsChunks) ((<s.ruleName; format=\"cap\">Context)getInvokingContext(<s.ruleIndex>)).<s.name> = <rhsChunks>;"
+
+AddToLabelListHeader(a) ::= "<! Required but unused. !>"
+AddToLabelList(a) ::= <<
+<ctx(a.label)>-><a.listName>.push_back(<labelref(a.label)>);
+>>
+
+TokenLabelType() ::= "<file.TokenLabelType; null = {Token}> *"
+
+TokenDeclHeader(t) ::= "antlr4::<TokenLabelType()><t.name> = nullptr;"
+TokenDecl(t) ::= "<! Variable Declaration !>"
+
+TokenTypeDeclHeader(t) ::= "<! Local Variable !>"
+TokenTypeDecl(t) ::= "size_t <t.name> = 0;"
+
+TokenListDeclHeader(t) ::= "std::vector\<antlr4::Token *> <t.name>;"
+TokenListDecl(t) ::= "<! Variable Declaration !>"
+
+RuleContextDeclHeader(r) ::= "<parser.name>::<r.ctxName> *<r.name> = nullptr;"
+RuleContextDecl(r) ::= "<! Variable Declaration !>"
+
+RuleContextListDeclHeader(rdecl) ::= "std::vector\<<rdecl.ctxName> *> <rdecl.name>;"
+RuleContextListDecl(rdecl) ::= "<! Variable Declaration !>"
+
+ContextTokenGetterDeclHeader(t) ::= "antlr4::tree::TerminalNode *<t.name>();"
+ContextTokenGetterDecl(t) ::= <<
+tree::TerminalNode* <parser.name>::<t.ctx.name>::<t.name>() {
+ return getToken(<parser.name>::<t.name>, 0);
+}
+
+>>
+
+ContextTokenListGetterDeclHeader(t) ::= "std::vector\<antlr4::tree::TerminalNode *> <t.name>();"
+ContextTokenListGetterDecl(t) ::= <<
+std::vector\<tree::TerminalNode *> <parser.name>::<t.ctx.name>::<t.name>() {
+ return getTokens(<parser.name>::<t.name>);
+}
+
+>>
+
+ContextTokenListIndexedGetterDeclHeader(t) ::= "antlr4::tree::TerminalNode* <t.name>(size_t i);"
+ContextTokenListIndexedGetterDecl(t) ::= <<
+tree::TerminalNode* <parser.name>::<t.ctx.name>::<t.name>(size_t i) {
+ return getToken(<parser.name>::<t.name>, i);
+}
+
+>>
+
+ContextRuleGetterDeclHeader(r) ::= "<r.ctxName> *<r.name>();"
+ContextRuleGetterDecl(r) ::= <<
+<! Note: ctxName is the name of the context to return, while ctx is the owning context. !>
+<parser.name>::<r.ctxName>* <parser.name>::<r.ctx.name>::<r.name>() {
+ return getRuleContext\<<parser.name>::<r.ctxName>\>(0);
+}
+
+>>
+
+ContextRuleListGetterDeclHeader(r) ::= "std::vector\<<r.ctxName> *> <r.name>();"
+ContextRuleListGetterDecl(r) ::= <<
+std::vector\<<parser.name>::<r.ctxName> *> <parser.name>::<r.ctx.name>::<r.name>() {
+ return getRuleContexts\<<parser.name>::<r.ctxName>\>();
+}
+
+>>
+
+ContextRuleListIndexedGetterDeclHeader(r) ::= "<r.ctxName>* <r.name>(size_t i);"
+ContextRuleListIndexedGetterDecl(r) ::= <<
+<parser.name>::<r.ctxName>* <parser.name>::<r.ctx.name>::<r.name>(size_t i) {
+ return getRuleContext\<<parser.name>::<r.ctxName>\>(i);
+}
+
+>>
+
+LexerRuleContext() ::= "antlr4::RuleContext"
+
+// The rule context name is the rule followed by a suffix; e.g. r becomes rContext.
+RuleContextNameSuffix() ::= "Context"
+
+ImplicitTokenLabel(tokenName) ::= <<
+<tokenName; format = "lower">Token
+>>
+
+ImplicitRuleLabel(ruleName) ::= "<ruleName>Context"
+ImplicitSetLabel(id) ::= "_tset<id>"
+ListLabelName(label) ::= "<label>"
+
+CaptureNextToken(d) ::= "CaptureNextToken(d) <d.varName> = _input->LT(1);"
+
+CaptureNextTokenTypeHeader(d) ::= "<! Required but unused. !>"
+CaptureNextTokenType(d) ::= "<d.varName> = _input->LA(1);"
+
+ListenerDispatchMethodHeader(method) ::= <<
+virtual void <if (method.isEnter)>enter<else>exit<endif>Rule(antlr4::tree::ParseTreeListener *listener) override;
+>>
+ListenerDispatchMethod(method) ::= <<
+void <parser.name>::<struct.name>::<if (method.isEnter)>enter<else>exit<endif>Rule(tree::ParseTreeListener *listener) {
+ auto parserListener = dynamic_cast\<<parser.grammarName>Listener *>(listener);
+ if (parserListener != nullptr)
+ parserListener-><if(method.isEnter)>enter<else>exit<endif><struct.derivedFromName; format="cap">(this);
+}
+>>
+
+VisitorDispatchMethodHeader(method) ::= <<
+
+virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
+>>
+VisitorDispatchMethod(method) ::= <<
+
+antlrcpp::Any <parser.name>::<struct.name>::accept(tree::ParseTreeVisitor *visitor) {
+ if (auto parserVisitor = dynamic_cast\<<parser.grammarName>Visitor*>(visitor))
+ return parserVisitor->visit<struct.derivedFromName; format="cap">(this);
+ else
+ return visitor->visitChildren(this);
+}
+>>
+
+AttributeDeclHeader(d) ::= "<d.type> <d.name><if(d.initValue)> = <d.initValue><endif>"
+AttributeDecl(d) ::= "<d.type> <d.name>"
+
+/** If we don't know location of label def x, use this template */
+labelref(x) ::= "<if (!x.isLocal)>dynamic_cast\<<x.ctx.name> *>(_localctx)-><endif><x.name>"
+
+/** For any action chunk, what is correctly-typed context struct ptr? */
+ctx(actionChunk) ::= "dynamic_cast\<<actionChunk.ctx.name> *>(_localctx)"
+
+// used for left-recursive rules
+recRuleAltPredicate(ruleName,opPrec) ::= "precpred(_ctx, <opPrec>)"
+recRuleSetReturnAction(src,name) ::= "recRuleSetReturnAction(src,name) $<name>=$<src>.<name>;"
+recRuleSetStopToken() ::= "_ctx->stop = _input->LT(-1);"
+
+recRuleAltStartAction(ruleName, ctxName, label) ::= <<
+_localctx = _tracker.createInstance\<<ctxName>Context>(parentContext, parentState);
+<if (label)>_localctx-><label> = previousContext;<endif>
+pushNewRecursionContext(_localctx, startState, Rule<ruleName; format = "cap">);
+>>
+
+// Separate context variable to avoid frequent pointer type casts.
+recRuleLabeledAltStartAction(ruleName, currentAltLabel, label, isListLabel) ::= <<
+auto newContext = _tracker.createInstance\<<currentAltLabel; format = "cap">Context>(_tracker.createInstance\<<ruleName; format="cap">Context>(parentContext, parentState));
+_localctx = newContext;
+<if(label)>
+<if(isListLabel)>
+newContext-><label>.push_back(previousContext);
+<else>
+newContext-><label> = previousContext;
+<endif>
+<endif>
+pushNewRecursionContext(newContext, startState, Rule<ruleName; format = "cap">);
+>>
+
+recRuleReplaceContext(ctxName) ::= <<
+_localctx = _tracker.createInstance\<<ctxName>Context>(_localctx);
+_ctx = _localctx;
+previousContext = _localctx;
+>>
+
+recRuleSetPrevCtx() ::= <<
+if (!_parseListeners.empty())
+ triggerExitRuleEvent();
+previousContext = _localctx;
+>>
+
+/** Using a type to init value map, try to init a type; if not in table
+ * must be an object, default value is "null".
+ */
+initValue(typeName) ::= <<
+<cppTypeInitMap.(typeName)>
+>>
+
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Files.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Files.stg
new file mode 100644
index 0000000..dd30d53
--- /dev/null
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Files.stg
@@ -0,0 +1,344 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2016, Mike Lischke
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+codeFileExtension() ::= ".cpp"
+headerFileExtension() ::= ".h"
+
+fileHeader(grammarFileName, ANTLRVersion, header) ::= <<
+<header>
+
+// Generated from <grammarFileName> by ANTLR <ANTLRVersion>
+>>
+
+LexerFileHeader(file, lexer, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, namedActions.header)>
+
+#pragma once
+
+<namedActions.preinclude>
+
+#include "antlr4-runtime.h"
+
+<namedActions.postinclude>
+
+<if(file.genPackage)>namespace <file.genPackage> {<endif>
+
+<lexer>
+
+<if (file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+LexerFile(file, lexer, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, namedActions.header)>
+
+<namedActions.preinclude>
+
+#include "<file.lexer.name>.h"
+
+<namedActions.postinclude>
+
+using namespace antlr4;
+
+<if (file.genPackage)>using namespace <file.genPackage>;<endif>
+
+<lexer>
+
+>>
+
+ParserFileHeader(file, parser, namedActions, contextSuperClass) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, namedActions.header)>
+
+#pragma once
+
+<namedActions.preinclude>
+
+#include "antlr4-runtime.h"
+
+<namedActions.postinclude>
+
+<if (file.genPackage)>namespace <file.genPackage> {<endif>
+
+<parser>
+
+<if (file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+ParserFile(file, parser, namedActions, contextSuperClass) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, namedActions.header)>
+
+<namedActions.preinclude>
+
+<if (file.genListener)>#include "<file.grammarName>Listener.h"<endif>
+<if (file.genVisitor)>#include "<file.grammarName>Visitor.h"<endif>
+
+#include "<file.parser.name>.h"
+
+<namedActions.postinclude>
+
+using namespace antlrcpp;
+<if (file.genPackage)>using namespace <file.genPackage>;<endif>
+<parser>
+
+>>
+
+BaseListenerFileHeader(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+#pragma once
+
+<namedActions.baselistenerpreinclude>
+
+#include "antlr4-runtime.h"
+#include "<file.grammarName>Listener.h"
+
+<namedActions.baselistenerpostinclude>
+
+<if(file.genPackage)>
+namespace <file.genPackage> {
+<endif>
+
+/**
+ * This class provides an empty implementation of <file.grammarName>Listener,
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+class <file.exportMacro> <file.grammarName>BaseListener : public <file.grammarName>Listener {
+public:
+<namedActions.baselistenerdeclarations>
+
+<file.listenerNames: {lname |
+ virtual void enter<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) override { \}
+ virtual void exit<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) override { \}
+}; separator="\n">
+
+ virtual void enterEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
+ virtual void exitEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
+ virtual void visitTerminal(antlr4::tree::TerminalNode * /*node*/) override { }
+ virtual void visitErrorNode(antlr4::tree::ErrorNode * /*node*/) override { }
+
+<if (namedActions.baselistenermembers)>
+private:
+<namedActions.baselistenermembers>
+<endif>
+};
+
+<if (file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+BaseListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+<namedActions.baselistenerpreinclude>
+
+#include "<file.grammarName>BaseListener.h"
+
+<namedActions.baselistenerpostinclude>
+
+<if(file.genPackage)>
+using namespace <file.genPackage>;
+<endif>
+
+<namedActions.baselistenerdefinitions>
+>>
+
+ListenerFileHeader(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+#pragma once
+
+<namedActions.listenerpreinclude>
+
+#include "antlr4-runtime.h"
+#include "<file.parserName>.h"
+
+<namedActions.listenerpostinclude>
+
+<if(file.genPackage)>
+namespace <file.genPackage> {
+<endif>
+
+/**
+ * This interface defines an abstract listener for a parse tree produced by <file.parserName>.
+ */
+class <file.exportMacro> <file.grammarName>Listener : public antlr4::tree::ParseTreeListener {
+public:
+<namedActions.listenerdeclarations>
+
+<file.listenerNames: {lname |
+ virtual void enter<lname; format = "cap">(<file.parserName>::<lname; format ="cap">Context *ctx) = 0;
+ virtual void exit<lname; format = "cap">(<file.parserName>::<lname; format="cap">Context *ctx) = 0;
+}; separator = "\n">
+
+<if (namedActions.listenermembers)>
+private:
+<namedActions.listenermembers>
+<endif>
+};
+
+<if(file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+ListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+<namedActions.listenerpreinclude>
+
+#include "<file.grammarName>Listener.h"
+
+<namedActions.listenerpostinclude>
+
+<if(file.genPackage)>
+using namespace <file.genPackage>;
+<endif>
+
+<namedActions.listenerdefinitions>
+>>
+
+BaseVisitorFileHeader(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+#pragma once
+
+<namedActions.basevisitorpreinclude>
+
+#include "antlr4-runtime.h"
+#include "<file.grammarName>Visitor.h"
+
+<namedActions.basevisitorpostinclude>
+
+<if(file.genPackage)>
+namespace <file.genPackage> {
+<endif>
+
+/**
+ * This class provides an empty implementation of <file.grammarName>Visitor, which can be
+ * extended to create a visitor which only needs to handle a subset of the available methods.
+ */
+class <file.exportMacro> <file.grammarName>BaseVisitor : public <file.grammarName>Visitor {
+public:
+<namedActions.basevisitordeclarations>
+
+<file.visitorNames: { lname |
+ virtual antlrcpp::Any visit<lname; format = "cap">(<file.parserName>::<lname; format = "cap">Context *ctx) override {
+ return visitChildren(ctx);
+ \}
+}; separator="\n">
+
+<if (namedActions.basevisitormembers)>
+private:
+<namedActions.basevisitormembers>
+<endif>
+};
+
+<if(file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+BaseVisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+<namedActions.basevisitorpreinclude>
+
+#include "<file.grammarName>BaseVisitor.h"
+
+<namedActions.basevisitorpostinclude>
+
+<if(file.genPackage)>
+using namespace <file.genPackage>;
+<endif>
+
+<namedActions.basevisitordefinitions>
+
+>>
+
+VisitorFileHeader(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+#pragma once
+
+<namedActions.visitorpreinclude>
+
+#include "antlr4-runtime.h"
+#include "<file.parserName>.h"
+
+<namedActions.visitorpostinclude>
+
+<if(file.genPackage)>namespace <file.genPackage> {<endif>
+
+/**
+ * This class defines an abstract visitor for a parse tree
+ * produced by <file.parserName>.
+ */
+class <file.exportMacro> <file.grammarName>Visitor : public antlr4::tree::AbstractParseTreeVisitor {
+public:
+ <namedActions.visitordeclarations>
+
+ /**
+ * Visit parse trees produced by <file.parserName>.
+ */
+ <file.visitorNames: {lname |
+ virtual antlrcpp::Any visit<lname; format = "cap">(<file.parserName>::<lname; format = "cap">Context *context) = 0;
+ }; separator="\n">
+
+<if (namedActions.visitormembers)>
+private:
+<namedActions.visitormembers>
+<endif>
+};
+
+<if(file.genPackage)>
+} // namespace <file.genPackage>
+<endif>
+>>
+
+VisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion, header)>
+
+<namedActions.visitorpreinclude>
+
+#include "<file.grammarName>Visitor.h"
+
+<namedActions.visitorpostinclude>
+
+<if(file.genPackage)>
+using namespace <file.genPackage>;
+<endif>
+
+<namedActions.visitordefinitions>
+
+>>
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
new file mode 100644
index 0000000..7559f01
--- /dev/null
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
@@ -0,0 +1,1498 @@
+fileHeader(grammarFileName, ANTLRVersion) ::= <<
+// Generated from <grammarFileName; format="java-escape"> by ANTLR <ANTLRVersion>.
+>>
+
+ParserFile(file, parser, namedActions, contextSuperClass) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+
+<if(file.genPackage)>
+package <file.genPackage> // <file.grammarName>
+<else>
+package parser // <file.grammarName>
+<endif>
+
+import (
+ "fmt"
+ "reflect"
+ "strconv"
+
+ "github.com/antlr/antlr4/runtime/Go/antlr"
+)
+
+<if(namedActions.header)>
+
+<namedActions.header>
+<endif>
+
+// Suppress unused import errors
+var _ = fmt.Printf
+var _ = reflect.Copy
+var _ = strconv.Itoa
+
+<if(parser)>
+
+<parser>
+<endif>
+
+>>
+
+ListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+
+<if(file.genPackage)>
+package <file.genPackage> // <file.grammarName>
+<else>
+package parser // <file.grammarName>
+<endif>
+
+import "github.com/antlr/antlr4/runtime/Go/antlr"
+
+// <file.grammarName>Listener is a complete listener for a parse tree produced by <file.parserName>.
+type <file.grammarName>Listener interface {
+ antlr.ParseTreeListener
+
+ <file.listenerNames:{lname | // Enter<lname; format="cap"> is called when entering the <lname> production.
+Enter<lname; format="cap">(c *<lname; format="cap">Context)}; separator="\n\n">
+
+ <file.listenerNames:{lname | // Exit<lname; format="cap"> is called when exiting the <lname> production.
+Exit<lname; format="cap">(c *<lname; format="cap">Context)}; separator="\n\n">
+}
+
+>>
+
+BaseListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+
+<if(file.genPackage)>
+package <file.genPackage> // <file.grammarName>
+<else>
+package parser // <file.grammarName>
+<endif>
+
+import "github.com/antlr/antlr4/runtime/Go/antlr"
+
+// Base<file.grammarName>Listener is a complete listener for a parse tree produced by <file.parserName>.
+type Base<file.grammarName>Listener struct{}
+
+var _ <file.grammarName>Listener = &Base<file.grammarName>Listener{}
+
+// VisitTerminal is called when a terminal node is visited.
+func (s *Base<file.grammarName>Listener) VisitTerminal(node antlr.TerminalNode) {}
+
+// VisitErrorNode is called when an error node is visited.
+func (s *Base<file.grammarName>Listener) VisitErrorNode(node antlr.ErrorNode) {}
+
+// EnterEveryRule is called when any rule is entered.
+func (s *Base<file.grammarName>Listener) EnterEveryRule(ctx antlr.ParserRuleContext) {}
+
+// ExitEveryRule is called when any rule is exited.
+func (s *Base<file.grammarName>Listener) ExitEveryRule(ctx antlr.ParserRuleContext) {}
+
+<file.listenerNames:{lname | // Enter<lname; format="cap"> is called when production <lname> is entered.
+func (s *Base<file.grammarName>Listener) Enter<lname; format="cap">(ctx *<lname; format="cap">Context) {\}
+
+// Exit<lname; format="cap"> is called when production <lname> is exited.
+func (s *Base<file.grammarName>Listener) Exit<lname; format="cap">(ctx *<lname; format="cap">Context) {\}}; separator="\n\n">
+
+>>
+
+VisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+
+<if(file.genPackage)>
+package <file.genPackage> // <file.grammarName>
+<else>
+package parser // <file.grammarName>
+<endif>
+
+import "github.com/antlr/antlr4/runtime/Go/antlr"
+<if(header)>
+
+<header>
+<endif>
+
+// A complete Visitor for a parse tree produced by <file.parserName>.
+type <file.grammarName>Visitor interface {
+ antlr.ParseTreeVisitor
+
+<file.visitorNames:{lname |
+ // Visit a parse tree produced by <file.parserName>#<lname>.
+ Visit<lname; format="cap">(ctx *<lname; format="cap">Context) interface{\}
+}; separator="\n">
+}
+>>
+
+BaseVisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+
+<if(file.genPackage)>
+package <file.genPackage> // <file.grammarName>
+<else>
+package parser // <file.grammarName>
+<endif>
+
+import "github.com/antlr/antlr4/runtime/Go/antlr"
+
+type Base<file.grammarName>Visitor struct {
+ *antlr.BaseParseTreeVisitor
+}
+
+<file.visitorNames:{lname |
+func (v *Base<file.grammarName>Visitor) Visit<lname; format="cap">(ctx *<lname; format="cap">Context) interface{\} {
+ return v.VisitChildren(ctx)
+\}}; separator="\n\n">
+
+>>
+
+Parser(parser, funcs, atn, sempredFuncs, superClass) ::= <<
+<if(superClass)>
+import "./<superClass>"
+
+<endif>
+<if(atn)>
+var parserATN = <atn>
+<else>
+var parserATN []uint16
+<endif>
+
+
+var deserializer = antlr.NewATNDeserializer(nil)
+
+var deserializedATN = deserializer.DeserializeFromUInt16(parserATN)
+
+<if(parser.literalNames)>
+var literalNames = []string{
+ <parser.literalNames; null="\"\"", separator=", ", wrap>,
+}
+<else>
+var literalNames []string
+<endif>
+
+
+<if(parser.symbolicNames)>
+var symbolicNames = []string{
+ <parser.symbolicNames; null="\"\"", separator=", ", wrap>,
+}
+<else>
+var symbolicNames []string
+<endif>
+
+
+<if(parser.ruleNames)>
+var ruleNames = []string{
+ <parser.ruleNames:{r | "<r>"}; separator=", ", wrap>,
+}
+<else>
+var ruleNames []string
+<endif>
+
+
+type <parser.name> struct {
+ <superClass; null="*antlr.BaseParser">
+}
+
+func New<parser.name>(input antlr.TokenStream) *<parser.name> {
+ var decisionToDFA = make([]*antlr.DFA, len(deserializedATN.DecisionToState))
+ var sharedContextCache = antlr.NewPredictionContextCache()
+
+ for index, ds := range deserializedATN.DecisionToState {
+ decisionToDFA[index] = antlr.NewDFA(ds, index)
+ }
+
+ this := new(<parser.name>)
+
+ this.BaseParser = antlr.NewBaseParser(input)
+
+ this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, sharedContextCache)
+ this.RuleNames = ruleNames
+ this.LiteralNames = literalNames
+ this.SymbolicNames = symbolicNames
+ this.GrammarFileName = "<parser.grammarFileName; format="java-escape">"
+
+ return this
+}
+<if(namedActions.members)>
+
+<namedActions.members>
+<endif>
+
+<if(parser.tokens)>
+
+// <parser.name> tokens.
+const (
+ <parser.name>EOF = antlr.TokenEOF
+ <parser.tokens:{k | <parser.name><k> = <parser.tokens.(k)>}; separator="\n">
+)
+<else>
+
+// <parser.name>EOF is the <parser.name> token.
+const <parser.name>EOF = antlr.TokenEOF
+<endif>
+
+<if(rest(parser.rules))>
+
+// <parser.name> rules.
+const (
+ <parser.rules:{r | <parser.name>RULE_<r.name> = <r.index>}; separator="\n">
+)
+<elseif(parser.rules)>
+
+// <parser.name>RULE_<first(parser.rules).name> is the <parser.name> rule.
+const <parser.name>RULE_<first(parser.rules).name> = <first(parser.rules).index>
+<endif>
+
+<if(funcs)>
+
+<funcs; separator="\n\n">
+<endif>
+
+<if(sempredFuncs)>
+
+func (p *<parser.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool {
+ switch ruleIndex {
+ <if(parser.sempredFuncs.values)>
+ <parser.sempredFuncs.values:{f | case <f.ruleIndex>:
+ var t *<f.name; format="cap">Context = nil
+ if localctx != nil { t = localctx.(*<f.name; format="cap">Context) \}
+ return p.<f.name; format="cap">_Sempred(t, predIndex)}; separator="\n\n">
+
+
+ <endif>
+ default:
+ panic("No predicate with index: " + fmt.Sprint(ruleIndex))
+ }
+}
+<if(sempredFuncs.values)>
+
+<sempredFuncs.values; separator="\n\n">
+<endif>
+<endif>
+>>
+
+dumpActions(recog, argFuncs, actionFuncs, sempredFuncs) ::= <<
+<if(actionFuncs)>
+
+func (l *<lexer.name>) Action(localctx antlr.RuleContext, ruleIndex, actionIndex int) {
+ switch ruleIndex {
+ <if(recog.actionFuncs.values)>
+ <recog.actionFuncs.values:{f | case <f.ruleIndex>:
+ <if(f.factory.grammar.lexer)>
+ l.<f.name>_Action(localctx, actionIndex)
+ <else>
+ var t *<f.name; format="cap">Context = nil
+ if localctx != nil { t = localctx.(*<f.ctxType>) \}
+ l.<f.name>_Action(t, actionIndex)
+ <endif>
+ }; separator="\n\n">
+
+ <endif>
+ default:
+ panic("No registered action for: " + fmt.Sprint(ruleIndex))
+ }
+}
+<if(actionFuncs.values)>
+
+<actionFuncs.values; separator="\n">
+<endif>
+<endif>
+<if(actionFuncs && sempredFuncs)>
+
+
+<endif>
+<if(sempredFuncs)>
+func (l *<lexer.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool {
+ switch ruleIndex {
+ <if(recog.sempredFuncs.values)>
+ <recog.sempredFuncs.values:{f | case <f.ruleIndex>:
+ <if(f.factory.grammar.lexer)>
+ return l.<f.name>_Sempred(localctx, predIndex)
+ <else>
+ var t *<f.name; format="cap">Context = nil
+ if localctx != nil { t = localctx.(*<f.ctxType>) \}
+ return l.<f.name>_Sempred(t, predIndex)
+ <endif>
+ }; separator="\n\n">
+
+
+ <endif>
+ default:
+ panic("No registered predicate for: " + fmt.Sprint(ruleIndex))
+ }
+}
+<if(sempredFuncs.values)>
+
+<sempredFuncs.values; separator="\n\n">
+<endif>
+<endif>
+>>
+
+/* This generates a private method since the actionIndex is generated, making an
+ * overriding implementation impossible to maintain.
+ */
+RuleActionFunction(r, actions) ::= <<
+func (l *<lexer.name>) <r.name; format="cap">_Action(localctx <if(r.factory.grammar.lexer)>antlr.RuleContext<else>*<r.ctxType><endif>, actionIndex int) {
+ switch actionIndex {
+ <if(actions)>
+ <actions:{index | case <index>:
+ <actions.(index)>}; separator="\n\n">
+
+
+ <endif>
+ default:
+ panic("No registered action for: " + fmt.Sprint(actionIndex))
+ }
+}
+>>
+
+/* This generates a private method since the predIndex is generated, making an
+ * overriding implementation impossible to maintain.
+ */
+RuleSempredFunction(r, actions) ::= <<
+func (p *<r.factory.grammar.recognizerName>) <r.name; format="cap">_Sempred(localctx antlr.RuleContext, predIndex int) bool {
+ switch predIndex {
+ <if(actions)>
+ <actions:{index | case <index>:
+ return <actions.(index)>}; separator="\n\n">
+
+ <endif>
+ default:<! TODO: Should this return true like C#/Java? !>
+ panic("No predicate with index: " + fmt.Sprint(predIndex))
+ }
+}
+>>
+
+RuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble, exceptions) ::= <<
+<if(ruleCtx)>
+<ruleCtx>
+
+
+<endif>
+<if(altLabelCtxs)>
+<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n\n">
+
+
+<endif>
+func (p *<parser.name>) <currentRule.name; format="cap">(<currentRule.args:{a | <a.name> <a.type>}; separator=", ">) (localctx I<currentRule.ctxType>) {
+ localctx = New<currentRule.ctxType>(p, p.GetParserRuleContext(), p.GetState()<currentRule.args:{a | , <a.name>}>)
+ p.EnterRule(localctx, <currentRule.startState>, <parser.name>RULE_<currentRule.name>)
+ <if(namedActions.init)>
+ <namedActions.init>
+ <endif>
+ <if(locals)>
+ <locals:{l | var <l>}; separator="\n">
+ <endif>
+
+
+ defer func() {
+ <if(finallyAction)>
+ <finallyAction>
+ <endif>
+ p.ExitRule()
+ }()
+
+ defer func() {
+ if err := recover(); err != nil {
+ <if(exceptions)>
+ <exceptions; separator="\n">
+ <else>
+ if v, ok := err.(antlr.RecognitionException); ok {
+ localctx.SetException(v)
+ p.GetErrorHandler().ReportError(p, v)
+ p.GetErrorHandler().Recover(p, v)
+ } else {
+ panic(err)
+ }
+ <endif>
+ }
+ }()
+
+ <if(currentRule.hasLookaheadBlock)>
+ var _alt int
+ <endif>
+
+ <if(code)>
+ <code>
+
+
+ <endif>
+ <if(postamble)>
+ <postamble; separator="\n">
+
+
+ <endif>
+ <if(namedActions.after)>
+ <namedActions.after>
+
+
+ <endif>
+ return localctx
+}
+>>
+
+LeftRecursiveRuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs, namedActions, finallyAction, postamble) ::= <<
+<if(ruleCtx)>
+<ruleCtx>
+
+
+
+<endif>
+<if(altLabelCtxs)>
+<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n\n">
+
+
+<endif>
+func (p *<parser.name>) <currentRule.name; format="cap">(<args:{a | <a.name> <a.type>}; separator=", ">) (localctx I<currentRule.ctxType>) {
+ return p.<currentRule.name>(0<args:{a | , <a.name>}>)
+}
+
+func (p *<parser.name>) <currentRule.name>(_p int<args:{a | , <a.name> <a.type>}>) (localctx I<currentRule.ctxType>) {
+ var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext()
+ _parentState := p.GetState()
+ localctx = New<currentRule.ctxType>(p, p.GetParserRuleContext(), _parentState<args:{a | , <a.name>}>)
+ var _prevctx I<currentRule.ctxType> = localctx
+ var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning.
+ _startState := <currentRule.startState>
+ p.EnterRecursionRule(localctx, <currentRule.startState>, <parser.name>RULE_<currentRule.name>, _p)
+ <if(namedActions.init)>
+ <namedActions.init>
+ <endif>
+ <if(locals)>
+ <locals:{l | var <l>}; separator="\n">
+ <endif>
+
+
+ defer func() {
+ <if(finallyAction)>
+ <finallyAction>
+ <endif>
+ p.UnrollRecursionContexts(_parentctx)
+ }()
+
+ defer func() {
+ if err := recover(); err != nil {
+ if v, ok := err.(antlr.RecognitionException); ok {
+ localctx.SetException(v)
+ p.GetErrorHandler().ReportError(p, v)
+ p.GetErrorHandler().Recover(p, v)
+ } else {
+ panic(err)
+ }
+ }
+ }()
+
+ <if(currentRule.hasLookaheadBlock)>
+ var _alt int
+ <endif>
+
+ <if(code)>
+ <code>
+
+
+ <endif>
+ <if(postamble)>
+ <postamble; separator="\n">
+
+
+ <endif>
+ <if(namedActions.after)>
+ <namedActions.after>
+
+
+ <endif>
+ return localctx
+}
+>>
+
+CodeBlockForOuterMostAlt(currentOuterMostAltCodeBlock, locals, preamble, ops) ::= <<
+<if(currentOuterMostAltCodeBlock.altLabel)>localctx = New<currentOuterMostAltCodeBlock.altLabel; format="cap">Context(p, localctx)<endif>
+p.EnterOuterAlt(localctx, <currentOuterMostAltCodeBlock.alt.altNum>)
+<CodeBlockForAlt(currentAltCodeBlock=currentOuterMostAltCodeBlock, ...)>
+>>
+
+CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
+<if(locals)>
+<locals:{l | var <l>}; separator="\n">
+
+
+<endif>
+<if(preamble)>
+<preamble; separator="\n">
+
+
+<endif>
+<if(ops)>
+<ops; separator="\n">
+<endif>
+>>
+
+LL1AltBlock(choice, preamble, alts, error) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+<if(choice.label)>
+<labelref(choice.label)> = p.GetTokenStream().LT(1)
+<endif>
+<if(preamble)>
+
+<preamble; separator="\n">
+<endif>
+
+
+switch p.GetTokenStream().LA(1) {
+<if(choice.altLook && alts)>
+<choice.altLook, alts:{look, alt | case <look:{l | <parser.name><l>}; separator=", ">:
+ <alt>}; separator="\n\n">
+
+
+<endif>
+default:
+ <if(error)>
+ <error>
+ <endif>
+}
+>>
+
+LL1OptionalBlock(choice, alts, error) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+
+switch p.GetTokenStream().LA(1) {
+<if(choice.altLook && alts)>
+<choice.altLook, alts:{look, alt | case <look:{l | <parser.name><l>}; separator=", ">:
+ <alt>}; separator="\n\n">
+
+
+<endif>
+default:
+ <if(error)>
+ <error>
+ <endif>
+}
+>>
+
+LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
+p.SetState(<choice.stateNumber>)
+<! TODO: this should not consume anything but does I think;
+ See TokenMismatch2 test, which fails w/o this sync.
+ But, see TestLeftRecursion.testJavaExpressions_10, 11 which fails with sync()
+ !>
+p.GetErrorHandler().Sync(p)
+<if(preamble)>
+<preamble; separator="\n">
+
+
+<endif>
+if <expr> {
+ <if(alts)>
+ <alts; separator="\n">
+ <endif>
+}<! else if !(<followExpr>) {
+ <error>
+}!>
+>>
+
+LL1StarBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+<if(preamble)>
+<preamble; separator="\n">
+
+
+<endif>
+for <loopExpr> {
+ <if(alts)>
+ <alts; separator="\n">
+ <endif>
+ p.SetState(<choice.loopBackStateNumber>)
+ p.GetErrorHandler().Sync(p)
+ <if(iteration)>
+ <iteration>
+ <endif>
+}
+>>
+
+LL1PlusBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+p.SetState(<choice.blockStartStateNumber>)<! alt block decision !>
+p.GetErrorHandler().Sync(p)
+<if(preamble)>
+<preamble; separator="\n">
+
+
+<endif>
+for ok := true; ok; ok = <loopExpr> {
+ <if(alts)>
+ <alts; separator="\n">
+ <endif>
+ p.SetState(<choice.stateNumber>)<! loopback/exit decision !>
+ p.GetErrorHandler().Sync(p)
+ <if(iteration)>
+ <iteration>
+ <endif>
+}
+>>
+
+// LL(*) stuff
+
+AltBlock(choice, preamble, alts, error) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+<if(choice.label)>
+<labelref(choice.label)> = _input.LT(1)
+
+<endif>
+<if(preamble)>
+<preamble; separator="\n">
+
+<endif>
+
+switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), <choice.decision>, p.GetParserRuleContext()) {
+<if(alts)>
+<alts:{alt | case <i>:
+ <alt>}; separator="\n\n">
+<endif>
+}
+>>
+
+OptionalBlock(choice, alts, error) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+
+<if(alts)>
+
+<alts:{alt | if p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), <choice.decision>, p.GetParserRuleContext()) == <i><if(!choice.ast.greedy)>+1<endif> {
+ <alt>
+}; separator="} else ">
+<endif>
+}
+>>
+
+StarBlock(choice, alts, Sync, iteration) ::= <<
+p.SetState(<choice.stateNumber>)
+p.GetErrorHandler().Sync(p)
+_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), <choice.decision>, p.GetParserRuleContext())
+
+for _alt != <choice.exitAlt> && _alt != antlr.ATNInvalidAltNumber {
+ if _alt == 1<if(!choice.ast.greedy)>+1<endif> {
+ <if(iteration)>
+ <iteration>
+ <endif>
+ <if(alts)>
+ <alts><! should only be one !>
+ <endif>
+ }
+ p.SetState(<choice.loopBackStateNumber>)
+ p.GetErrorHandler().Sync(p)
+ _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), <choice.decision>, p.GetParserRuleContext())
+}
+>>
+
+PlusBlock(choice, alts, error) ::= <<
+p.SetState(<choice.blockStartStateNumber>)<! alt block decision !>
+p.GetErrorHandler().Sync(p)
+_alt = 1<if(!choice.ast.greedy)>+1<endif>
+for ok := true; ok; ok = _alt != <choice.exitAlt> && _alt != antlr.ATNInvalidAltNumber {
+ switch _alt {
+ <if(alts)>
+ <alts:{alt | case <i><if(!choice.ast.greedy)>+1<endif>:
+ <alt>}; separator="\n\n">
+
+
+ <endif>
+ default:
+ <if(error)>
+ <error>
+ <endif>
+ }
+
+ p.SetState(<choice.loopBackStateNumber>)<! loopback/exit decision !>
+ p.GetErrorHandler().Sync(p)
+ _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), <choice.decision>, p.GetParserRuleContext())
+}
+>>
+
+Sync(s) ::= "Sync(<s.expecting.name>)"
+
+ThrowNoViableAlt(t) ::= "panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))"
+
+TestSetInline(s) ::= <<
+<s.bitsets:{bits | <if(rest(rest(bits.ttypes)))><bitsetBitfieldComparison(s, bits)><else><bitsetInlineComparison(s, bits)><endif>}; separator=" || ">
+>>
+
+// Javascript language spec - shift operators are 32 bits long max
+testShiftInRange(shiftAmount) ::= <<
+((<shiftAmount>) & -(0x1f+1)) == 0
+>>
+
+// produces smaller bytecode only when bits.ttypes contains more than two items
+bitsetBitfieldComparison(s, bits) ::= <%
+(<testShiftInRange({<offsetShiftVar(s.varName, bits.shift)>})> && ((1 \<\< uint(<offsetShiftVar(s.varName, bits.shift)>)) & (<bits.ttypes:{ttype | (1 \<\< <offsetShiftType(ttype, bits.shift)>)}; separator=" | ">)) != 0)
+%>
+
+isZero ::= [
+"0":true,
+default:false
+]
+
+offsetShiftVar(shiftAmount, offset) ::= <%
+<if(!isZero.(offset))>(<shiftAmount> - <offset>)<else><shiftAmount><endif>
+%>
+
+offsetShiftType(shiftAmount, offset) ::= <%
+<if(!isZero.(offset))>(<parser.name><shiftAmount> - <offset>)<else><parser.name><shiftAmount><endif>
+%>
+
+// produces more efficient bytecode when bits.ttypes contains at most two items
+bitsetInlineComparison(s, bits) ::= <%
+<bits.ttypes:{ttype | <s.varName> == <parser.name><ttype>}; separator=" || ">
+%>
+
+InvokeRule(r, argExprsChunks) ::= <<
+{
+ p.SetState(<r.stateNumber>)
+ <if(r.labels)>
+
+ <if(r.ast.options.p)>
+ var _x = p.<r.name>(<r.ast.options.p><if(argExprsChunks)>, <endif><argExprsChunks>)
+ <else>
+ var _x = p.<r.name; format="cap">(<argExprsChunks>)
+ <endif>
+
+
+ <r.labels:{l | <labelref(l)> = _x}; separator="\n">
+ <else>
+ <if(r.ast.options.p)>
+ p.<r.name>(<r.ast.options.p><if(argExprsChunks)>, <endif><argExprsChunks>)
+ <else>
+ p.<r.name; format="cap">(<argExprsChunks>)
+ <endif>
+ <endif>
+}
+>>
+
+MatchToken(m) ::= <<
+{
+ p.SetState(<m.stateNumber>)
+ <if(m.labels)>
+
+ var _m = p.Match(<parser.name><m.name>)
+
+ <m.labels:{l | <labelref(l)> = _m}; separator="\n">
+ <else>
+ p.Match(<parser.name><m.name>)
+ <endif>
+}
+>>
+
+MatchSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, false)>"
+
+MatchNotSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, true)>"
+
+CommonSetStuff(m, expr, capture, invert) ::= <<
+p.SetState(<m.stateNumber>)
+<if(m.labels)>
+
+var _lt = p.GetTokenStream().LT(1)<! TODO: Should LT be called always like InvokeRule and MatchToken? !>
+
+<m.labels:{l | <labelref(l)> = _lt}; separator="\n">
+
+<endif>
+<if(capture)>
+<capture>
+
+<endif>
+<if(invert)>if <m.varName> \<= 0 || <expr> <else>if !(<expr>)<endif> {
+ <if(m.labels)>
+ var _ri = p.GetErrorHandler().RecoverInline(p)
+
+ <m.labels:{l | <labelref(l)> = _ri}; separator="\n">
+ <else>
+ p.GetErrorHandler().RecoverInline(p)
+ <endif>
+} else {
+ p.GetErrorHandler().ReportMatch(p)
+ p.Consume()
+}
+>>
+
+Wildcard(w) ::= <<
+p.SetState(<w.stateNumber>)
+<if(w.labels)>
+
+var _mwc = p.MatchWildcard()
+
+<w.labels:{l | <labelref(l)> = _mwc}; separator="\n">
+<else>
+p.MatchWildcard()
+<endif>
+>>
+
+// ACTION STUFF
+
+Action(a, foo, chunks) ::= "<chunks>"
+
+ArgAction(a, chunks) ::= "<chunks>"
+
+SemPred(p, chunks, failChunks) ::= <<
+p.SetState(<p.stateNumber>)
+
+if !(<chunks>) {
+ panic(antlr.NewFailedPredicateException(p, <p.predicate><if(failChunks)>, <failChunks><elseif(p.msg)>, <p.msg><else>, ""<endif>))
+}
+>>
+
+ExceptionClause(e, catchArg, catchAction) ::= <<
+catch (<catchArg>) {
+ <catchAction>
+}
+>>
+
+// lexer actions are not associated with model objects
+
+LexerSkipCommand() ::= "p.Skip()"
+LexerMoreCommand() ::= "p.More()"
+LexerPopModeCommand() ::= "p.PopMode()"
+LexerTypeCommand(arg, grammar) ::= "p.SetType(<arg>)"
+LexerChannelCommand(arg, grammar) ::= "p.SetChannel(<arg>)"
+LexerModeCommand(arg, grammar) ::= "p.SetMode(<arg>)"
+LexerPushModeCommand(arg, grammar) ::= "p.PushMode(<arg>)"
+
+ActionText(t) ::= "<t.text>"
+ActionTemplate(t) ::= "<t.st>"
+
+ArgRef(a) ::= "<ctx(a)>.<a.name>"
+LocalRef(a) ::= "<ctx(a)>.<a.name>"
+RetValueRef(a) ::= "<ctx(a)>.<a.name>"
+QRetValueRef(a) ::= "<ctx(a)>.Get<a.dict;format={cap}>().Get<a.name;format={cap}>()"
+
+/** How to translate $tokenLabel */
+TokenRef(t) ::= "<ctx(t)>.Get<t.name;format={cap}>()"
+LabelRef(t) ::= "<ctx(t)>.Get<t.name;format={cap}>()"
+ListLabelRef(t) ::= "<ctx(t)>.Get<ListLabelName(t.name);format={cap}>"
+
+SetAttr(s, rhsChunks) ::= "<ctx(s)>.Set<s.name; format={cap}>(<rhsChunks>)"
+
+TokenLabelType() ::= "<file.TokenLabelType; null={antlr.Token}>"
+InputSymbolType() ::= "<file.InputSymbolType; null={antlr.Token}>"
+
+TokenPropertyRef_text(t) ::= "(func() string { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return \"\" } else { return <ctx(t)>.Get<t.label; format={cap}>().GetText() }}())"
+TokenPropertyRef_type(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.Get<t.label; format={cap}>().GetTokenType() }}())"
+TokenPropertyRef_line(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.Get<t.label; format={cap}>().GetLine() }}())"
+TokenPropertyRef_pos(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.Get<t.label; format={cap}>().GetColumn() }}())"
+TokenPropertyRef_channel(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.Get<t.label; format={cap}>().GetChannel() }}())"
+TokenPropertyRef_index(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.Get<t.label; format={cap}>().GetTokenIndex() }}())"
+TokenPropertyRef_int(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}>() == nil { return 0 } else { i, _ := strconv.Atoi(<ctx(t)>.Get<t.label; format={cap}>().GetText()); return i }}())"
+
+RulePropertyRef_start(r) ::= "(func() antlr.Token { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.Get<r.label;format={cap}>().GetStart() }}())"
+RulePropertyRef_stop(r) ::= "(func() antlr.Token { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.Get<r.label;format={cap}>().GetStop() }}())"
+RulePropertyRef_text(r) ::= "(func() string { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return \"\" } else { return p.GetTokenStream().GetTextFromTokens(<ctx(r)>.Get<r.label;format={cap}>().GetStart(), <ctx(r)>.<r.label>.GetStop()) }}())"
+RulePropertyRef_ctx(r) ::= "<ctx(r)>.Get<r.label;format={cap}>()"
+RulePropertyRef_parser(r) ::= "p"
+
+ThisRulePropertyRef_start(r) ::= "localctx.GetStart()"
+ThisRulePropertyRef_stop(r) ::= "localctx.GetStop()"
+ThisRulePropertyRef_text(r) ::= "p.GetTokenStream().GetTextFromTokens(localctx.GetStart(), p.GetTokenStream().LT(-1))"
+ThisRulePropertyRef_ctx(r) ::= "<ctx(r)>"
+ThisRulePropertyRef_parser(r) ::= "p"
+
+NonLocalAttrRef(s) ::= "GetInvokingContext(<s.ruleIndex>).<s.name>"
+SetNonLocalAttr(s, rhsChunks) ::= "GetInvokingContext(<s.ruleIndex>).<s.name> = <rhsChunks>"
+
+AddToLabelList(a) ::= "<ctx(a.label)>.<a.listName> = append(<ctx(a.label)>.<a.listName>, <labelref(a.label)>)"
+
+TokenDecl(t) ::= "<t.name> <TokenLabelType()>"
+TokenTypeDecl(t) ::= "<t.name> int"
+TokenListDecl(t) ::= "<t.name> []antlr.Token"
+
+RuleContextDecl(r) ::= "<r.name> I<r.ctxName> "
+RuleContextListDecl(rdecl) ::= "<rdecl.name> []I<rdecl.ctxName>"
+
+AttributeDecl(d) ::= "<d.name> <d.type;format={lower}><if(d.initValue)>// TODO = <d.initValue><endif>"
+
+ContextTokenGetterDecl(t) ::= <<
+<t.name; format="cap">() antlr.TerminalNode {
+ return s.GetToken(<parser.name><t.name>, 0)
+}
+>>
+
+ContextTokenListGetterDecl(t) ::= <<
+All<t.name; format="cap">() []antlr.TerminalNode {
+ return s.GetTokens(<parser.name><t.name>)
+}
+>>
+
+ContextTokenListIndexedGetterDecl(t) ::= <<
+<t.name; format="cap">(i int) antlr.TerminalNode {
+ return s.GetToken(<parser.name><t.name>, i)
+}
+>>
+
+ContextRuleGetterDecl(r) ::= <<
+<r.name; format="cap">() I<r.ctxName> {
+ var t = s.GetTypedRuleContext(reflect.TypeOf((*I<r.ctxName>)(nil)).Elem(), 0)
+
+ if t == nil {
+ return nil
+ }
+
+ return t.(I<r.ctxName>)
+}
+>>
+
+ContextRuleListGetterDecl(r) ::= <<
+All<r.name; format="cap">() []I<r.ctxName> {
+ var ts = s.GetTypedRuleContexts(reflect.TypeOf((*I<r.ctxName>)(nil)).Elem())
+ var tst = make([]I<r.ctxName>, len(ts))
+
+ for i, t := range ts {
+ if t != nil {
+ tst[i] = t.(I<r.ctxName>)
+ }
+ }
+
+ return tst
+}
+>>
+
+ContextRuleListIndexedGetterDecl(r) ::= <<
+<r.name; format="cap">(i int) I<r.ctxName> {
+ var t = s.GetTypedRuleContext(reflect.TypeOf((*I<r.ctxName>)(nil)).Elem(), i)
+
+ if t == nil {
+ return nil
+ }
+
+ return t.(I<r.ctxName>)
+}
+>>
+
+LexerRuleContext() ::= "RuleContext"
+
+/** The rule context name is the rule followed by a suffix; e.g.,
+ * r becomes rContext.
+ */
+RuleContextNameSuffix() ::= "Context"
+
+ImplicitTokenLabel(tokenName) ::= "_<tokenName>"
+ImplicitRuleLabel(ruleName) ::= "_<ruleName>"
+ImplicitSetLabel(id) ::= "_tset<id>"
+ListLabelName(label) ::= "<label>"
+
+CaptureNextToken(d) ::= "<d.varName> = p.GetTokenStream().LT(1)"
+CaptureNextTokenType(d) ::= "<d.varName> = p.GetTokenStream().LA(1)"
+
+StructDecl(struct, ctorAttrs, attrs, getters, dispatchMethods, interfaces, extensionMembers) ::= <<
+// I<struct.name> is an interface to support dynamic dispatch.
+type I<struct.name> interface {
+ antlr.ParserRuleContext
+
+ // GetParser returns the parser.
+ GetParser() antlr.Parser
+ <if(struct.tokenDecls)>
+
+ <struct.tokenDecls:{a | // Get<a.name; format="cap"> returns the <a.name> token.
+Get<a.name; format="cap">() <TokenLabelType()> }; separator="\n\n">
+ <endif>
+
+ <if(struct.tokenDecls)>
+
+ <struct.tokenDecls:{a | // Set<a.name; format="cap"> sets the <a.name> token.
+Set<a.name; format="cap">(<TokenLabelType()>) }; separator="\n\n">
+ <endif>
+
+ <if(struct.tokenTypeDecls)>
+
+ <struct.tokenTypeDecls:{a | // Get<a.name; format="cap"> returns the <a.name> token type.
+Get<a.name; format="cap">() int }; separator="\n\n">
+ <endif>
+
+ <if(struct.tokenTypeDecls)>
+
+ <struct.tokenTypeDecls:{a | // Set<a.name; format="cap"> sets the <a.name> token type.
+Set<a.name; format="cap">(int) }; separator="\n\n">
+ <endif>
+
+ <if(struct.tokenListDecls)>
+
+ <struct.tokenListDecls:{a | // Get<a.name; format="cap"> returns the <a.name> token list.
+Get<a.name; format="cap">() []<TokenLabelType()>}; separator="\n\n">
+ <endif>
+
+ <if(struct.tokenListDecls)>
+
+ <struct.tokenListDecls:{a | // Set<a.name; format="cap"> sets the <a.name> token list.
+Set<a.name; format="cap">([]<TokenLabelType()>)}; separator="\n\n">
+ <endif>
+
+ <if(struct.ruleContextDecls)>
+
+ <struct.ruleContextDecls:{a | // Get<a.name; format="cap"> returns the <a.name> rule contexts.
+Get<a.name; format="cap">() I<a.ctxName>}; separator="\n\n">
+ <endif>
+
+ <if(struct.ruleContextDecls)>
+
+ <struct.ruleContextDecls:{a | // Set<a.name; format="cap"> sets the <a.name> rule contexts.
+Set<a.name; format="cap">(I<a.ctxName>)}; separator="\n\n">
+ <endif>
+
+ <if(struct.ruleContextListDecls)>
+
+ <struct.ruleContextListDecls:{a | // Get<a.name; format="cap"> returns the <a.name> rule context list.
+Get<a.name; format="cap">() []I<a.ctxName>}; separator="\n\n">
+ <endif>
+
+ <if(struct.ruleContextListDecls)>
+
+ <struct.ruleContextListDecls:{a | // Set<a.name; format="cap"> sets the <a.name> rule context list.
+Set<a.name; format="cap">([]I<a.ctxName>) }; separator="\n\n">
+ <endif>
+
+ <if(struct.attributeDecls)>
+
+ <struct.attributeDecls:{a | // Get<a.name; format="cap"> returns the <a.name> attribute.
+Get<a.name; format="cap">() <a.type;format="lower">}; separator="\n\n">
+ <endif>
+
+ <if(struct.attributeDecls)>
+
+ <struct.attributeDecls:{a | // Set<a.name; format="cap"> sets the <a.name> attribute.
+Set<a.name; format="cap">(<a.type;format="lower">)}; separator="\n\n">
+ <endif>
+
+
+ // Is<struct.name> differentiates from other interfaces.
+ Is<struct.name>()
+}
+
+type <struct.name> struct {
+ <if(contextSuperClass)>*<contextSuperClass><else>*antlr.BaseParserRuleContext<endif>
+ parser antlr.Parser
+ <if(attrs)>
+ <attrs; separator="\n">
+ <endif>
+}
+
+func NewEmpty<struct.name>() *<struct.name> {
+ var p = new(<struct.name>)
+ p.<if(contextSuperClass)><contextSuperClass><else>BaseParserRuleContext<endif> = <if(contextSuperClass)>New<contextSuperClass><else>antlr.NewBaseParserRuleContext<endif>(nil, -1)
+ p.RuleIndex = <parser.name>RULE_<struct.derivedFromName>
+ return p
+}
+
+func (*<struct.name>) Is<struct.name>() {}
+
+func New<struct.name>(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int<struct.ctorAttrs:{a | , <a.name> <a.type;format="lower">}>) *<struct.name> {
+ var p = new(<struct.name>)
+
+ p.<if(contextSuperClass)><contextSuperClass><else>BaseParserRuleContext<endif> = <if(contextSuperClass)>New<contextSuperClass><else>antlr.NewBaseParserRuleContext<endif>(parent, invokingState)
+
+ p.parser = parser
+ p.RuleIndex = <parser.name>RULE_<struct.derivedFromName>
+
+ <if(struct.ctorAttrs)>
+ <struct.ctorAttrs:{a | p.<a.name> = <a.name>}; separator="\n">
+
+ <endif>
+ return p
+}
+
+func (s *<struct.name>) GetParser() antlr.Parser { return s.parser }
+<if(struct.tokenDecls)>
+
+<struct.tokenDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() <TokenLabelType()> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenDecls)>
+
+<struct.tokenDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v <TokenLabelType()>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenTypeDecls)>
+
+<struct.tokenTypeDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() int { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenTypeDecls)>
+
+<struct.tokenTypeDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v int) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenListDecls)>
+
+<struct.tokenListDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() []<TokenLabelType()> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenListDecls)>
+
+<struct.tokenListDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v []<TokenLabelType()>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextDecls)>
+
+<struct.ruleContextDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() I<a.ctxName> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextDecls)>
+
+<struct.ruleContextDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v I<a.ctxName>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextListDecls)>
+
+<struct.ruleContextListDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() []I<a.ctxName> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextListDecls)>
+
+<struct.ruleContextListDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v []I<a.ctxName>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.attributeDecls)>
+
+<struct.attributeDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() <a.type;format="lower"> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.attributeDecls)>
+
+<struct.attributeDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v <a.type;format="lower">) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(getters)>
+
+<getters:{g | func (s *<struct.name>) <g>}; separator="\n\n">
+<endif>
+
+<if(struct.provideCopyFrom)>
+
+func (s *<struct.name>) CopyFrom(ctx *<struct.name>) {
+ s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext)
+ <struct.attrs:{a | s.<a.name> = ctx.<a.name>}; separator="\n">
+}
+<endif>
+
+func (s *<struct.name>) GetRuleContext() antlr.RuleContext {
+ return s
+}
+
+func (s *<struct.name>) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
+ return antlr.TreesStringTree(s, ruleNames, recog)
+}
+
+<if(dispatchMethods)>
+
+<dispatchMethods; separator="\n\n">
+<endif>
+
+<if(extensionMembers)>
+
+<extensionMembers; separator="\n\n">
+<endif>
+>>
+
+AltLabelStructDecl(struct, attrs, getters, dispatchMethods, tokenDecls, tokenTypeDecls, tokenListDecls, ruleContextDecls, ruleContextListDecls, attributeDecls) ::= <<
+type <struct.name> struct {
+ *<currentRule.name; format="cap">Context
+ <if(attrs)>
+ <attrs; separator="\n">
+ <endif>
+}
+
+func New<struct.name>(parser antlr.Parser, ctx antlr.ParserRuleContext) *<struct.name> {
+ var p = new(<struct.name>)
+
+ p.<currentRule.name; format="cap">Context = NewEmpty<currentRule.name; format="cap">Context()
+ p.parser = parser
+ p.CopyFrom(ctx.(*<currentRule.name; format="cap">Context))
+
+ return p
+}
+
+<if(struct.tokenDecls)>
+
+<struct.tokenDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() <TokenLabelType()> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenDecls)>
+
+<struct.tokenDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v <TokenLabelType()>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenTypeDecls)>
+
+<struct.tokenTypeDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() int { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenTypeDecls)>
+
+<struct.tokenTypeDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v int) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenListDecls)>
+
+<struct.tokenListDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() []<TokenLabelType()> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.tokenListDecls)>
+
+<struct.tokenListDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v []<TokenLabelType()>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextDecls)>
+
+<struct.ruleContextDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() I<a.ctxName> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextDecls)>
+
+<struct.ruleContextDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v I<a.ctxName>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextListDecls)>
+
+<struct.ruleContextListDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() []I<a.ctxName> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.ruleContextListDecls)>
+
+<struct.ruleContextListDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v []I<a.ctxName>) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+<if(struct.attributeDecls)>
+
+<struct.attributeDecls:{a | func (s *<struct.name>) Get<a.name; format="cap">() <a.type;format="lower"> { return s.<a.name> \}}; separator="\n\n">
+<endif>
+
+<if(struct.attributeDecls)>
+
+<struct.attributeDecls:{a | func (s *<struct.name>) Set<a.name; format="cap">(v <a.type;format="lower">) { s.<a.name> = v \}}; separator="\n\n">
+<endif>
+
+func (s *<struct.name>) GetRuleContext() antlr.RuleContext {
+ return s
+}
+<if(getters)>
+
+<getters:{g | func (s *<struct.name>) <g>}; separator="\n\n">
+<endif>
+
+<if(dispatchMethods)>
+
+<dispatchMethods; separator="\n\n">
+<endif>
+>>
+
+ListenerDispatchMethod(method) ::= <<
+func (s *<struct.name>) <if(method.isEnter)>Enter<else>Exit<endif>Rule(listener antlr.ParseTreeListener) {
+ if listenerT, ok := listener.(<parser.grammarName>Listener); ok {
+ listenerT.<if(method.isEnter)>Enter<else>Exit<endif><struct.derivedFromName; format="cap">(s)
+ }
+}
+>>
+
+VisitorDispatchMethod(method) ::= <<
+func (s *<struct.name>) Accept(visitor antlr.ParseTreeVisitor) interface{} {
+ switch t := visitor.(type) {
+ case <parser.grammarName>Visitor:
+ return t.Visit<struct.derivedFromName; format="cap">(s)
+
+ default:
+ return t.VisitChildren(s)
+ }
+}
+>>
+
+/** If we don't know location of label def x, use this template */
+labelref(x) ::= "<if(!x.isLocal)>localctx.(*<x.ctx.name>).<endif><x.name>"
+
+/** For any action chunk, what is correctly-typed context struct ptr? */
+ctx(actionChunk) ::= "localctx.(*<actionChunk.ctx.name>)"
+
+// used for left-recursive rules
+recRuleAltPredicate(ruleName, opPrec) ::= "p.Precpred(p.GetParserRuleContext(), <opPrec>)"
+recRuleSetReturnAction(src, name) ::= "$<name> = $<src>.<name>" // TODO: Is this valid Go syntax?
+recRuleSetStopToken() ::= "p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1))"
+
+recRuleAltStartAction(ruleName, ctxName, label) ::= <<
+localctx = New<ctxName>Context(p, _parentctx, _parentState)
+<if(label)>localctx.(*<ctxName>Context).<label> = _prevctx<endif>
+p.PushNewRecursionContext(localctx, _startState, <parser.name>RULE_<ruleName>)
+>>
+
+recRuleLabeledAltStartAction(ruleName, currentAltLabel, label, isListLabel) ::= <<
+localctx = New<currentAltLabel; format="cap">Context(p, New<ruleName; format="cap">Context(p, _parentctx, _parentState))
+<if(label)>
+<if(isListLabel)>
+localctx.(*<currentAltLabel; format="cap">Context).<label> = append(localctx.(*<currentAltLabel; format="cap">Context).<label>, _prevctx)
+<else>
+localctx.(*<currentAltLabel; format="cap">Context).<label> = _prevctx
+<endif>
+
+<endif>
+
+p.PushNewRecursionContext(localctx, _startState, <parser.name>RULE_<ruleName>)
+>>
+
+recRuleReplaceContext(ctxName) ::= <<
+localctx = New<ctxName>Context(p, localctx)
+p.SetParserRuleContext(localctx)
+_prevctx = localctx
+>>
+
+recRuleSetPrevCtx() ::= <<
+if p.GetParseListeners() != nil {
+ p.TriggerExitRuleEvent()
+}
+_prevctx = localctx
+>>
+
+LexerFile(lexerFile, lexer, namedActions) ::= <<
+<fileHeader(lexerFile.grammarFileName, lexerFile.ANTLRVersion)>
+
+<if(lexerFile.genPackage)>
+package <lexerFile.genPackage>
+<else>
+package parser
+<endif>
+
+import (
+ "fmt"
+ "unicode"
+
+ "github.com/antlr/antlr4/runtime/Go/antlr"
+)
+<if(namedActions.header)>
+
+<namedActions.header>
+<endif>
+
+// Suppress unused import error
+var _ = fmt.Printf
+var _ = unicode.IsLetter
+
+<if(lexer)>
+
+<lexer>
+<endif>
+
+>>
+
+Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass) ::= <<
+<if(atn)>
+var serializedLexerAtn = <atn>
+<else>
+var serializedLexerAtn []uint16
+<endif>
+
+
+var lexerDeserializer = antlr.NewATNDeserializer(nil)
+var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn)
+
+<if(lexer.modes)>
+var lexerModeNames = []string{
+ <lexer.modes:{m | "<m>"}; separator=", ", wrap>,
+}
+<else>
+var lexerModeNames []string
+<endif>
+
+
+<if(lexer.literalNames)>
+var lexerLiteralNames = []string{
+ <lexer.literalNames; null="\"\"", separator=", ", wrap>,
+}
+<else>
+var lexerLiteralNames []string
+<endif>
+
+
+<if(lexer.symbolicNames)>
+var lexerSymbolicNames = []string{
+ <lexer.symbolicNames; null="\"\"", separator=", ", wrap>,
+}
+<else>
+var lexerSymbolicNames []string
+<endif>
+
+
+<if(lexer.ruleNames)>
+var lexerRuleNames = []string{
+ <lexer.ruleNames:{r | "<r>"}; separator=", ", wrap>,
+}
+<else>
+var lexerRuleNames []string
+<endif>
+
+
+type <lexer.name> struct {
+ *<if(superClass)><superClass><else>antlr.BaseLexer<endif>
+ modeNames []string
+ // TODO: EOF string
+}
+
+func New<lexer.name>(input antlr.CharStream) *<lexer.name> {
+ var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState))
+
+ for index, ds := range lexerAtn.DecisionToState {
+ lexerDecisionToDFA[index] = antlr.NewDFA(ds, index)
+ }
+
+ l := new(<lexer.name>)
+
+ l.BaseLexer = antlr.NewBaseLexer(input)
+ l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache())
+
+ l.modeNames = lexerModeNames
+ l.RuleNames = lexerRuleNames
+ l.LiteralNames = lexerLiteralNames
+ l.SymbolicNames = lexerSymbolicNames
+ l.GrammarFileName = "<lexer.grammarFileName>"
+ // TODO: l.EOF = antlr.TokenEOF
+
+ return l
+}
+<if(rest(lexer.tokens))>
+
+// <lexer.name> tokens.
+const (
+ <lexer.tokens:{k | <lexer.name><k> = <lexer.tokens.(k)>}; separator="\n">
+)
+<elseif(lexer.tokens)>
+
+// <lexer.name><first(lexer.tokens)> is the <lexer.name> token.
+const <lexer.name><first(lexer.tokens)> = <lexer.tokens.(first(lexer.tokens))>
+<endif>
+
+<if(rest(rest(lexer.modes)))>
+
+// <lexer.name> modes
+const (
+ <first(rest(lexer.modes)):{m | <lexer.name><m> = iota + 1}>
+ <rest(rest(lexer.modes)):{m | <lexer.name><m>}; separator="\n">
+)
+<elseif(rest(lexer.modes))>
+
+// <lexer.name><first(rest(lexer.modes))> is the <lexer.name> mode.
+const <lexer.name><first(rest(lexer.modes))> = 1
+<endif>
+<if(namedActions.members)>
+
+<namedActions.members>
+<endif>
+
+<dumpActions(lexer, "", actionFuncs, sempredFuncs)>
+>>
+
+SerializedATN(model) ::= <<
+<if(model.serialized)>[]uint16{
+ <model.serialized; separator=", ", wrap>,
+}<endif>
+>>
+
+/**
+ * Using a type to init value map, try to init a type; if not in table
+ * must be an object, default value is "nil".
+ */
+initValue(typeName) ::= <<
+<javaTypeInitMap.(typeName)>
+>>
+
+codeFileExtension() ::= ".go"
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg
index af925be..a1b18fc 100644
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@ import java.util.ArrayList;
<parser>
>>
-ListenerFile(file, header) ::= <<
+ListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
package <file.genPackage>;
@@ -97,7 +97,7 @@ void exit<lname; format="cap">(<file.parserName>.<lname; format="cap">Context ct
}
>>
-BaseListenerFile(file, header) ::= <<
+BaseListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
package <file.genPackage>;
@@ -155,7 +155,7 @@ public class <file.grammarName>BaseListener implements <file.grammarName>Listene
}
>>
-VisitorFile(file, header) ::= <<
+VisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
package <file.genPackage>;
@@ -186,7 +186,7 @@ T visit<lname; format="cap">(<file.parserName>.<lname; format="cap">Context ctx)
}
>>
-BaseVisitorFile(file, header) ::= <<
+BaseVisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
<if(file.genPackage)>
package <file.genPackage>;
@@ -469,6 +469,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
LL1AltBlock(choice, preamble, alts, error) ::= <<
setState(<choice.stateNumber>);
+_errHandler.sync(this);
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
<preamble; separator="\n">
switch (_input.LA(1)) {
@@ -482,6 +483,7 @@ default:
LL1OptionalBlock(choice, alts, error) ::= <<
setState(<choice.stateNumber>);
+_errHandler.sync(this);
switch (_input.LA(1)) {
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
@@ -493,6 +495,7 @@ default:
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
setState(<choice.stateNumber>);
+_errHandler.sync(this);
<preamble; separator="\n">
if (<expr>) {
<alts; separator="\n">
@@ -640,7 +643,10 @@ setState(<m.stateNumber>);
<capture>
if ( <if(invert)><m.varName> \<= 0 || <else>!<endif>(<expr>) ) {
<if(m.labels)><m.labels:{l | <labelref(l)> = (Token)}><endif>_errHandler.recoverInline(this);
-} else {
+}
+else {
+ if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
+ _errHandler.reportMatch(this);
consume();
}
>>
@@ -673,10 +679,10 @@ LexerSkipCommand() ::= "skip();"
LexerMoreCommand() ::= "more();"
LexerPopModeCommand() ::= "popMode();"
-LexerTypeCommand(arg) ::= "_type = <arg>;"
-LexerChannelCommand(arg) ::= "_channel = <arg>;"
-LexerModeCommand(arg) ::= "_mode = <arg>;"
-LexerPushModeCommand(arg) ::= "pushMode(<arg>);"
+LexerTypeCommand(arg, grammar) ::= "_type = <arg>;"
+LexerChannelCommand(arg, grammar) ::= "_channel = <arg>;"
+LexerModeCommand(arg, grammar) ::= "_mode = <arg>;"
+LexerPushModeCommand(arg, grammar) ::= "pushMode(<arg>);"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg
index f8101b2..2e10728 100644
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* Copyright (c) 2014 Eric Vergnaud
* All rights reserved.
*
@@ -60,7 +60,7 @@ var <file.grammarName>Visitor = require('./<file.grammarName>Visitor').<file.gra
<parser>
>>
-ListenerFile(file, header) ::= <<
+ListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
var antlr4 = require('antlr4/index');
@@ -88,10 +88,9 @@ exports.<file.grammarName>Listener = <file.grammarName>Listener;
>>
-VisitorFile(file, header) ::= <<
+VisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
var antlr4 = require('antlr4/index');
-<header>
// This class defines a complete generic visitor for a parse tree produced by <file.parserName>.
@@ -106,6 +105,7 @@ function <file.grammarName>Visitor() {
<file.visitorNames:{lname |
// Visit a parse tree produced by <file.parserName>#<lname>.
<file.grammarName>Visitor.prototype.visit<lname; format="cap"> = function(ctx) {
+ return this.visitChildren(ctx);
\};
}; separator="\n">
@@ -236,7 +236,7 @@ case <index>:
* overriding implementation impossible to maintain.
*/
RuleSempredFunction(r, actions) ::= <<
-<if(parser)><parser.name><else><lexer.name><endif>.prototype.<r.name>_sempred = function(localctx, predIndex) {
+<if (r.factory.g.lexer)><lexer.name><else><parser.name><endif>.prototype.<r.name>_sempred = function(localctx, predIndex) {
switch(predIndex) {
<actions:{index| case <index>:
return <actions.(index)>;}; separator="\n">
@@ -340,6 +340,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
LL1AltBlock(choice, preamble, alts, error) ::= <<
this.state = <choice.stateNumber>;
+this._errHandler.sync(this);
<if(choice.label)><labelref(choice.label)> = this._input.LT(1);<endif>
<preamble; separator="\n">
switch(this._input.LA(1)) {
@@ -353,6 +354,7 @@ default:
LL1OptionalBlock(choice, alts, error) ::= <<
this.state = <choice.stateNumber>;
+this._errHandler.sync(this);
switch (this._input.LA(1)) {
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
@@ -364,6 +366,7 @@ default:
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
this.state = <choice.stateNumber>;
+this._errHandler.sync(this);
<preamble; separator="\n">
if(<expr>) {
<alts; separator="\n">
@@ -520,6 +523,7 @@ this.state = <m.stateNumber>;
<if(m.labels)><m.labels:{l | <labelref(l)> = }><endif>this._errHandler.recoverInline(this);
}
else {
+ this._errHandler.reportMatch(this);
this.consume();
}
>>
@@ -553,10 +557,10 @@ catch (<catchArg>) {
LexerSkipCommand() ::= "this.skip()"
LexerMoreCommand() ::= "this.more()"
LexerPopModeCommand() ::= "this.popMode()"
-LexerTypeCommand(arg) ::= "this._type = <arg>"
-LexerChannelCommand(arg) ::= "this._channel = <arg>"
-LexerModeCommand(arg) ::= "this._mode = <arg>"
-LexerPushModeCommand(arg) ::= "this.pushMode(<arg>)"
+LexerTypeCommand(arg, grammar) ::= "this._type = <arg>"
+LexerChannelCommand(arg, grammar) ::= "this._channel = <arg>"
+LexerModeCommand(arg, grammar) ::= "this._mode = <arg>"
+LexerPushModeCommand(arg, grammar) ::= "this.pushMode(<arg>)"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
@@ -819,15 +823,15 @@ function <lexer.name>(input) {
<rest(lexer.modes):{m| <lexer.name>.<m> = <i>;}; separator="\n">
-<lexer.name>.modeNames = [ <lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor> ];
+<lexer.name>.prototype.modeNames = [ <lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor> ];
-<lexer.name>.literalNames = [ <lexer.literalNames:{t | <t>}; null="null", separator=", ", wrap, anchor> ];
+<lexer.name>.prototype.literalNames = [ <lexer.literalNames:{t | <t>}; null="null", separator=", ", wrap, anchor> ];
-<lexer.name>.symbolicNames = [ <lexer.symbolicNames:{t | <t>}; null="null", separator=", ", wrap, anchor> ];
+<lexer.name>.prototype.symbolicNames = [ <lexer.symbolicNames:{t | <t>}; null="null", separator=", ", wrap, anchor> ];
-<lexer.name>.ruleNames = [ <lexer.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor> ];
+<lexer.name>.prototype.ruleNames = [ <lexer.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor> ];
-<lexer.name>.grammarFileName = "<lexer.grammarFileName>";
+<lexer.name>.prototype.grammarFileName = "<lexer.grammarFileName>";
<namedActions.members>
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg
index c4ab7cc..287f366 100644
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* Copyright (c) 2014 Eric Vergnaud
* All rights reserved.
*
@@ -58,7 +58,7 @@ from io import StringIO
>>
-ListenerFile(file, header) ::= <<
+ListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
from antlr4 import *
<header>
@@ -80,7 +80,7 @@ def exit<lname; format="cap">(self, ctx):
>>
-VisitorFile(file, header) ::= <<
+VisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
from antlr4 import *
<header>
@@ -314,12 +314,13 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
LL1AltBlock(choice, preamble, alts, error) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
<preamble; separator="\n">
token = self._input.LA(1)
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
- }; separator="\nel">
+ pass}; separator="\nel">
else:
<error>
@@ -327,6 +328,7 @@ else:
LL1OptionalBlock(choice, alts, error) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
token = self._input.LA(1)
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
@@ -337,6 +339,7 @@ else:
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
<preamble; separator="\n">
if <expr>:
<alts; separator="\n">
@@ -375,7 +378,7 @@ while True:
AltBlock(choice, preamble, alts, error) ::= <<
self.state = <choice.stateNumber>
-self._errHandler.sync(self);
+self._errHandler.sync(self)
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
<preamble; separator="\n">
la_ = self._interp.adaptivePredict(self._input,<choice.decision>,self._ctx)
@@ -389,7 +392,7 @@ if la_ == <i>:
OptionalBlock(choice, alts, error) ::= <<
self.state = <choice.stateNumber>
-self._errHandler.sync(self);
+self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,<choice.decision>,self._ctx)
<alts:{alt |
if la_ == <i><if(!choice.ast.greedy)>+1<endif>:
@@ -490,6 +493,7 @@ self.state = <m.stateNumber>
<if(invert)>if <m.varName> \<= 0 or <expr><else>if not(<expr>)<endif>:
<if(m.labels)><m.labels:{l | <labelref(l)> = }><else> <endif>self._errHandler.recoverInline(self)
else:
+ self._errHandler.reportMatch(self)
self.consume()
>>
@@ -523,10 +527,10 @@ LexerSkipCommand() ::= "skip()"
LexerMoreCommand() ::= "more()"
LexerPopModeCommand() ::= "popMode()"
-LexerTypeCommand(arg) ::= "_type = <arg>"
-LexerChannelCommand(arg) ::= "_channel = <arg>"
-LexerModeCommand(arg) ::= "_mode = <arg>"
-LexerPushModeCommand(arg) ::= "pushMode(<arg>)"
+LexerTypeCommand(arg, grammar) ::= "_type = <arg>"
+LexerChannelCommand(arg, grammar) ::= "_channel = <arg>"
+LexerModeCommand(arg, grammar) ::= "_mode = <arg>"
+LexerPushModeCommand(arg, grammar) ::= "pushMode(<arg>)"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg
index c341079..643cec7 100644
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* Copyright (c) 2014 Eric Vergnaud
* All rights reserved.
*
@@ -57,7 +57,7 @@ from io import StringIO
>>
-ListenerFile(file, header) ::= <<
+ListenerFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
from antlr4 import *
if __name__ is not None and "." in __name__:
@@ -83,7 +83,7 @@ def exit<lname; format="cap">(self, ctx:<file.parserName>.<lname; format="cap">C
>>
-VisitorFile(file, header) ::= <<
+VisitorFile(file, header, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion)>
from antlr4 import *
if __name__ is not None and "." in __name__:
@@ -322,12 +322,13 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
LL1AltBlock(choice, preamble, alts, error) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
<preamble; separator="\n">
token = self._input.LA(1)
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
- }; separator="\nel">
+ pass}; separator="\nel">
else:
<error>
@@ -335,6 +336,7 @@ else:
LL1OptionalBlock(choice, alts, error) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
token = self._input.LA(1)
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
<alt>
@@ -345,6 +347,7 @@ else:
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
self.state = <choice.stateNumber>
+self._errHandler.sync(self)
<preamble; separator="\n">
if <expr>:
<alts; separator="\n">
@@ -383,7 +386,7 @@ while True:
AltBlock(choice, preamble, alts, error) ::= <<
self.state = <choice.stateNumber>
-self._errHandler.sync(self);
+self._errHandler.sync(self)
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
<preamble; separator="\n">
la_ = self._interp.adaptivePredict(self._input,<choice.decision>,self._ctx)
@@ -397,7 +400,7 @@ if la_ == <i>:
OptionalBlock(choice, alts, error) ::= <<
self.state = <choice.stateNumber>
-self._errHandler.sync(self);
+self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,<choice.decision>,self._ctx)
<alts:{alt |
if la_ == <i><if(!choice.ast.greedy)>+1<endif>:
@@ -498,6 +501,7 @@ self.state = <m.stateNumber>
<if(invert)>if <m.varName> \<= 0 or <expr><else>if not(<expr>)<endif>:
<if(m.labels)><m.labels:{l | <labelref(l)> = }><else> <endif>self._errHandler.recoverInline(self)
else:
+ self._errHandler.reportMatch(self)
self.consume()
>>
@@ -531,10 +535,10 @@ LexerSkipCommand() ::= "skip()"
LexerMoreCommand() ::= "more()"
LexerPopModeCommand() ::= "popMode()"
-LexerTypeCommand(arg) ::= "_type = <arg>"
-LexerChannelCommand(arg) ::= "_channel = <arg>"
-LexerModeCommand(arg) ::= "_mode = <arg>"
-LexerPushModeCommand(arg) ::= "pushMode(<arg>)"
+LexerTypeCommand(arg, grammar) ::= "_type = <arg>"
+LexerChannelCommand(arg, grammar) ::= "_channel = <arg>"
+LexerModeCommand(arg, grammar) ::= "_mode = <arg>"
+LexerPushModeCommand(arg, grammar) ::= "pushMode(<arg>)"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
new file mode 100755
index 0000000..3fcdf38
--- /dev/null
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
@@ -0,0 +1,1026 @@
+/*
+ * [The "BSD license"]
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
+ * Copyright (c) 2015 Janyou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+SwiftTypeInitMap ::= [
+ "Int":"0",
+ "Int64":"0",
+ "Float":"0.0",
+ "Double":"0.0",
+ "Bool":"false",
+ default:"nil" // anything other than a primitive type is an object
+]
+SwiftTypeMap ::= [
+ "int":"Int",
+ "float":"Float",
+ "long":"Int64",
+ "double":"Double",
+ "bool":"Bool",
+ "boolean":"Bool",
+ default : key
+]
+// args must be <object-model-object>, <fields-resulting-in-STs>
+
+ParserFile(file, parser, namedActions,contextSuperClass) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+<if(file.genPackage)>
+<!package <file.genPackage>;!>
+<endif>
+<namedActions.header>
+import Antlr4
+
+<parser>
+>>
+
+ListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+<if(file.genPackage)>
+<!package <file.genPackage>;!>
+<endif>
+<header>
+import Antlr4
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link <file.parserName>}.
+ */
+public protocol <file.grammarName>Listener: ParseTreeListener {
+ <file.listenerNames:{lname |
+/**
+<if(file.listenerLabelRuleNames.(lname))>
+ * Enter a parse tree produced by the {@code <lname>\}
+ * labeled alternative in {@link <file.parserName>#<file.listenerLabelRuleNames.(lname)>\}.
+<else>
+ * Enter a parse tree produced by {@link <file.parserName>#<lname>\}.
+<endif>
+ - Parameters:
+ - ctx: the parse tree
+ */
+func enter<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context)
+/**
+<if(file.listenerLabelRuleNames.(lname))>
+ * Exit a parse tree produced by the {@code <lname>\}
+ * labeled alternative in {@link <file.parserName>#<file.listenerLabelRuleNames.(lname)>\}.
+<else>
+ * Exit a parse tree produced by {@link <file.parserName>#<lname>\}.
+<endif>
+ - Parameters:
+ - ctx: the parse tree
+ */
+func exit<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context)}; separator="\n">
+}
+>>
+
+BaseListenerFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+<if(file.genPackage)>
+<!package <file.genPackage>;!>
+<endif>
+<header>
+
+import Antlr4
+
+
+/**
+ * This class provides an empty implementation of {@link <file.grammarName>Listener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+open class <file.grammarName>BaseListener: <file.grammarName>Listener {
+ public init() { \}
+ <file.listenerNames:{lname |
+
+/**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+open func enter<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context) { \}
+/**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+open func exit<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context) { \}}; separator="\n">
+
+ /**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+ open func enterEveryRule(_ ctx: ParserRuleContext) { }
+ /**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+ open func exitEveryRule(_ ctx: ParserRuleContext) { }
+ /**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+ open func visitTerminal(_ node: TerminalNode) { }
+ /**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation does nothing.\</p>
+ */
+ open func visitErrorNode(_ node: ErrorNode) { }
+}
+>>
+
+VisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+<if(file.genPackage)>
+<!package <file.genPackage>;!>
+<endif>
+<header>
+import Antlr4
+
+/**
+ * This interface defines a complete generic visitor for a parse tree produced
+ * by {@link <file.parserName>}.
+ *
+ * @param \<T> The return type of the visit operation. Use {@link Void} for
+ * operations with no return type.
+ */
+open class <file.grammarName>Visitor\<T>: ParseTreeVisitor\<T> {
+ <file.visitorNames:{lname |
+/**
+<if(file.visitorLabelRuleNames.(lname))>
+ * Visit a parse tree produced by the {@code <lname>\}
+ * labeled alternative in {@link <file.parserName>#<file.visitorLabelRuleNames.(lname)>\}.
+<else>
+ * Visit a parse tree produced by {@link <file.parserName>#<lname>\}.
+<endif>
+- Parameters:
+ - ctx: the parse tree
+- returns: the visitor result
+ */
+open func visit<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context) -> T{
+ fatalError(#function + " must be overridden")
+\}
+}; separator="\n">
+}
+>>
+
+BaseVisitorFile(file, header, namedActions) ::= <<
+<fileHeader(file.grammarFileName, file.ANTLRVersion)>
+<if(file.genPackage)>
+<!package <file.genPackage>;!>
+<endif>
+<header>
+import Antlr4
+
+/**
+ * This class provides an empty implementation of {@link <file.grammarName>Visitor},
+ * which can be extended to create a visitor which only needs to handle a subset
+ * of the available methods.
+ *
+ * @param \<T> The return type of the visit operation. Use {@link Void} for
+ * operations with no return type.
+ */
+open class <file.grammarName>BaseVisitor\<T>: AbstractParseTreeVisitor\<T> {
+ <file.visitorNames:{lname |
+/**
+ * {@inheritDoc\}
+ *
+ * \<p>The default implementation returns the result of calling
+ * {@link #visitChildren\} on {@code ctx\}.\</p>
+ */
+open func visit<lname; format="cap">(_ ctx: <file.parserName>.<lname; format="cap">Context) -> T? { return visitChildren(ctx) \}}; separator="\n">
+}
+>>
+
+fileHeader(grammarFileName, ANTLRVersion) ::= <<
+// Generated from <grammarFileName; format="java-escape"> by ANTLR <ANTLRVersion>
+>>
+
+Parser(parser, funcs, atn, sempredFuncs, superClass) ::= <<
+<Parser_(ctor="parser_ctor", ...)>
+>>
+
+Parser_(parser, funcs, atn, sempredFuncs, ctor, superClass) ::= <<
+<!//@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})!>
+open class <parser.name>: <superClass; null="Parser"> {
+
+ internal static var _decisionToDFA: [DFA] = {
+ var decisionToDFA = [DFA]()
+ let length = <parser.name>._ATN.getNumberOfDecisions()
+ for i in 0..\<length {
+ <!// decisionToDFA[i] = DFA(<parser.name>._ATN.getDecisionState(i)!, i);!>
+ decisionToDFA.append(DFA(<parser.name>._ATN.getDecisionState(i)!, i))
+ }
+ return decisionToDFA
+ }()
+ internal static let _sharedContextCache: PredictionContextCache = PredictionContextCache()
+ <if(parser.tokens)>
+ public enum Tokens: Int {
+ case EOF = -1, <parser.tokens:{k | <k> = <parser.tokens.(k)>}; separator=", ", wrap, anchor>
+ }
+ <endif>
+ public static let <parser.rules:{r | RULE_<r.name> = <r.index>}; separator=", ", wrap, anchor>
+ public static let ruleNames: [String] = [
+ <parser.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor>
+ ]
+
+ <vocabulary(parser.literalNames, parser.symbolicNames)>
+
+ override
+ open func getGrammarFileName() -> String { return "<parser.grammarFileName; format="java-escape">" }
+
+ override
+ open func getRuleNames() -> [String] { return <parser.name>.ruleNames }
+
+ override
+ open func getSerializedATN() -> String { return <parser.name>._serializedATN }
+
+ override
+ open func getATN() -> ATN { return <parser.name>._ATN }
+
+ <namedActions.members>
+ <parser:(ctor)()>
+ <funcs; separator="\n">
+
+<if(sempredFuncs)>
+ override
+ open func sempred(_ _localctx: RuleContext?, _ ruleIndex: Int, _ predIndex: Int)throws -> Bool {
+ switch (ruleIndex) {
+ <parser.sempredFuncs.values:{f|
+case <f.ruleIndex>:
+ return try <f.name>_sempred(_localctx?.castdown(<f.ctxType>.self), predIndex)}; separator="\n">
+ default: return true
+ }
+ <!return true;!>
+ }
+ <sempredFuncs.values; separator="\n">
+<endif>
+
+ <atn>
+ public static let _serializedATN : String = <parser.name>ATN().jsonString
+ public static let _ATN: ATN = ATNDeserializer().deserializeFromJson(_serializedATN)
+}
+>>
+
+vocabulary(literalNames, symbolicNames) ::= <<
+private static let _LITERAL_NAMES: [String?] = [
+ <literalNames:{t | <t>}; null="nil", separator=", ", wrap, anchor>
+]
+private static let _SYMBOLIC_NAMES: [String?] = [
+ <symbolicNames:{t | <t>}; null="nil", separator=", ", wrap, anchor>
+]
+public static let VOCABULARY: Vocabulary = Vocabulary(_LITERAL_NAMES, _SYMBOLIC_NAMES)
+
+/**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+//@Deprecated
+public let tokenNames: [String?]? = {
+ let length = _SYMBOLIC_NAMES.count
+ var tokenNames = [String?](repeating: nil, count: length)
+ for i in 0..\<length {
+ var name = VOCABULARY.getLiteralName(i)
+ if name == nil {
+ name = VOCABULARY.getSymbolicName(i)
+ }
+ if name == nil {
+ name = "\<INVALID>"
+ }
+ tokenNames[i] = name
+ }
+ return tokenNames
+}()
+
+override
+<!//@Deprecated!>
+open func getTokenNames() -> [String?]? {
+ return tokenNames
+}
+>>
+
+dumpActions(recog, argFuncs, actionFuncs, sempredFuncs) ::= <<
+<if(actionFuncs)>
+override
+open func action(_ _localctx: RuleContext?, _ ruleIndex: Int, _ actionIndex: Int) throws {
+ switch (ruleIndex) {
+ <recog.actionFuncs.values:{f|
+case <f.ruleIndex>:
+ <f.name>_action((_localctx as <f.ctxType>?), actionIndex)
+ }; separator="\n">
+ default: break
+ }
+}
+<actionFuncs.values; separator="\n">
+<endif>
+<if(sempredFuncs)>
+override
+open func sempred(_ _localctx: RuleContext?, _ ruleIndex: Int,_ predIndex: Int) throws -> Bool{
+ switch (ruleIndex) {
+ <recog.sempredFuncs.values:{f|
+case <f.ruleIndex>:
+ return try <f.name>_sempred(_localctx?.castdown(<f.ctxType>.self), predIndex)}; separator="\n">
+ default: return true
+ }
+ <!return true;!>
+}
+<sempredFuncs.values; separator="\n">
+<endif>
+>>
+
+parser_ctor(p) ::= <<
+
+open override func getVocabulary() -> Vocabulary {
+ return <p.name>.VOCABULARY
+}
+
+public override init(_ input:TokenStream)throws {
+ RuntimeMetaData.checkVersion("4.6", RuntimeMetaData.VERSION)
+ try super.init(input)
+ _interp = ParserATNSimulator(self,<p.name>._ATN,<p.name>._decisionToDFA, <parser.name>._sharedContextCache)
+}
+>>
+
+/* This generates a private method since the actionIndex is generated, making an
+ * overriding implementation impossible to maintain.
+ */
+RuleActionFunction(r, actions) ::= <<
+private func <r.name>_action(_ _localctx: <r.ctxType>?, _ actionIndex: Int) {
+ switch (actionIndex) {
+ <actions:{index|
+case <index>:
+ <actions.(index)>
+ }; separator="\n">
+ default: break
+ }
+}
+>>
+
+/* This generates a private method since the predIndex is generated, making an
+ * overriding implementation impossible to maintain.
+ */
+RuleSempredFunction(r, actions) ::= <<
+private func <r.name>_sempred(_ _localctx: <r.ctxType>!, _ predIndex: Int) throws -> Bool {
+ switch (predIndex) {
+ <actions:{index|
+ case <index>:return <actions.(index)>}; separator="\n">
+ default: return true
+ }
+ <!return true;!>
+}
+>>
+
+RuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,namedActions,finallyAction,postamble,exceptions) ::= <<
+<ruleCtx>
+<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
+@discardableResult
+<if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>open func <endif><currentRule.name>(<if(first(args))>_ <endif><args; separator=", _">) throws -> <currentRule.ctxType> {
+ var _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, getState()<currentRule.args:{a | , <a.name>}>)
+ try enterRule(_localctx, <currentRule.startState>, <parser.name>.RULE_<currentRule.name>)
+ <namedActions.init>
+ <locals; separator="\n">
+ defer {
+ <finallyAction>
+ try! exitRule()
+ }
+ do {
+<if(currentRule.hasLookaheadBlock)>
+ var _alt:Int
+<endif>
+ <code>
+ <postamble; separator="\n">
+ <namedActions.after>
+ }
+ <if(exceptions)>
+ <exceptions; separator="\n">
+ <else>
+ catch ANTLRException.recognition(let re) {
+ _localctx.exception = re
+ _errHandler.reportError(self, re)
+ try _errHandler.recover(self, re)
+ }
+ <endif>
+
+ return _localctx
+}
+>>
+
+LeftRecursiveRuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,
+ namedActions,finallyAction,postamble) ::=
+<<
+
+<ruleCtx>
+<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
+
+<if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>public final <endif> func <currentRule.name>( <if(first(args))>_ <endif><args; separator=", _">) throws -> <currentRule.ctxType> {
+ return try <currentRule.name>(0<currentRule.args:{a | , <a.name>}>)
+}
+@discardableResult
+private func <currentRule.name>(_ _p<args:{a | , <a>}>: Int) throws -> <currentRule.ctxType> {
+ let _parentctx: ParserRuleContext? = _ctx
+ var _parentState: Int = getState()
+ var _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, _parentState<currentRule.args:{a | , <a.name>}>)
+ var _prevctx: <currentRule.ctxType> = _localctx
+ var _startState: Int = <currentRule.startState>
+ try enterRecursionRule(_localctx, <currentRule.startState>, <parser.name>.RULE_<currentRule.name>, _p)
+ <namedActions.init>
+ <locals; separator="\n">
+ defer {
+ <finallyAction>
+ try! unrollRecursionContexts(_parentctx)
+ }
+ do {
+<if(currentRule.hasLookaheadBlock)>
+ var _alt: Int
+<endif>
+ <code>
+ <postamble; separator="\n">
+ <namedActions.after>
+ }
+ catch ANTLRException.recognition(let re) {
+ _localctx.exception = re
+ _errHandler.reportError(self, re)
+ try _errHandler.recover(self, re)
+ }
+
+ return _localctx;
+}
+>>
+
+CodeBlockForOuterMostAlt(currentOuterMostAltCodeBlock, locals, preamble, ops) ::= <<
+<if(currentOuterMostAltCodeBlock.altLabel)>_localctx = <currentOuterMostAltCodeBlock.altLabel; format="cap">Context(_localctx);<endif>
+try enterOuterAlt(_localctx, <currentOuterMostAltCodeBlock.alt.altNum>)
+<CodeBlockForAlt(currentAltCodeBlock=currentOuterMostAltCodeBlock, ...)>
+>>
+
+CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
+<!//{!>
+<locals; separator="\n">
+<preamble; separator="\n">
+<ops; separator="\n">
+<!//}!>
+>>
+
+LL1AltBlock(choice, preamble, alts, error) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+<if(choice.label)><labelref(choice.label)> = try _input.LT(1)<endif>
+<preamble; separator="\n">
+switch (<parser.name>.Tokens(rawValue: try _input.LA(1))!) {
+<choice.altLook,alts:{look,alt | <cases(ttypes=look)>
+ <alt>
+ break}; separator="\n">
+default:
+ <error>
+}
+>>
+
+LL1OptionalBlock(choice, alts, error) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+switch (<parser.name>.Tokens(rawValue: try _input.LA(1))!) {
+<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
+ <alt>
+ break}; separator="\n">
+default:
+ <error>
+}
+>>
+
+LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+<preamble; separator="\n">
+if (<expr>) {
+ <alts; separator="\n">
+}
+<!else if ( !(<followExpr>) ) <error>!>
+>>
+
+LL1StarBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+<preamble; separator="\n">
+while (<loopExpr>) {
+ <alts; separator="\n">
+ setState(<choice.loopBackStateNumber>)
+ try _errHandler.sync(self)
+ <iteration>
+}
+>>
+
+LL1PlusBlockSingleAlt(choice, loopExpr, alts, preamble, iteration) ::= <<
+setState(<choice.blockStartStateNumber>) <! alt block decision !>
+try _errHandler.sync(self)
+<preamble; separator="\n">
+repeat {
+ <alts; separator="\n">
+ setState(<choice.stateNumber>); <! loopback/exit decision !>
+ try _errHandler.sync(self)
+ <iteration>
+} while (<loopExpr>)
+>>
+
+// LL(*) stuff
+
+AltBlock(choice, preamble, alts, error) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+<if(choice.label)><labelref(choice.label)> = try _input.LT(1)<endif>
+<preamble; separator="\n">
+switch(try getInterpreter().adaptivePredict(_input,<choice.decision>, _ctx)) {
+<alts:{alt |
+case <i>:
+ <alt>
+ break}; separator="\n">
+default: break
+}
+>>
+
+OptionalBlock(choice, alts, error) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+switch (try getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx)) {
+<alts:{alt |
+case <i><if(!choice.ast.greedy)>+1<endif>:
+ <alt>
+ break}; separator="\n">
+default: break
+}
+>>
+
+StarBlock(choice, alts, sync, iteration) ::= <<
+setState(<choice.stateNumber>)
+try _errHandler.sync(self)
+_alt = try getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx)
+while (_alt != <choice.exitAlt> && _alt != ATN.INVALID_ALT_NUMBER) {
+ if ( _alt==1<if(!choice.ast.greedy)>+1<endif> ) {
+ <iteration>
+ <alts> <! should only be one !>
+ }
+ setState(<choice.loopBackStateNumber>)
+ try _errHandler.sync(self)
+ _alt = try getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx)
+}
+>>
+
+PlusBlock(choice, alts, error) ::= <<
+setState(<choice.blockStartStateNumber>); <! alt block decision !>
+try _errHandler.sync(self)
+_alt = 1<if(!choice.ast.greedy)>+1<endif>;
+repeat {
+ switch (_alt) {
+ <alts:{alt|
+case <i><if(!choice.ast.greedy)>+1<endif>:
+ <alt>
+ break}; separator="\n">
+ default:
+ <error>
+ }
+ setState(<choice.loopBackStateNumber>); <! loopback/exit decision !>
+ try _errHandler.sync(self)
+ _alt = try getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx)
+} while (_alt != <choice.exitAlt> && _alt != ATN.INVALID_ALT_NUMBER)
+>>
+
+Sync(s) ::= "sync(<s.expecting.name>);"
+
+ThrowNoViableAlt(t) ::= "throw try ANTLRException.recognition(e: NoViableAltException(self))"
+
+TestSetInline(s) ::= <<
+<!<s.bitsets:{bits | <if(rest(rest(bits.ttypes)))><bitsetBitfieldComparison(s, bits)><else><bitsetInlineComparison(s, bits)><endif>}; separator=" || ">!>
+ //closure
+ { () -> Bool in
+ <if(rest(s.bitsets))>var<else>let<endif> testSet: Bool = <first(s.bitsets):{bits | <if(rest(rest(bits.ttypes)))><bitsetBitfieldComparison(s, bits)><else><bitsetInlineComparison(s, bits)><endif>}>
+ <rest(s.bitsets):{bits | testSet = testSet || <if(rest(rest(bits.ttypes)))><bitsetBitfieldComparison(s, bits)><else><bitsetInlineComparison(s, bits)><endif>}; separator="\n">
+ return testSet
+ }()
+>>
+
+// Java language spec 15.19 - shift operators mask operands rather than overflow to 0... need range test
+testShiftInRange(shiftAmount) ::= <<
+((<shiftAmount>) & ~0x3f) == 0
+>>
+
+// produces smaller bytecode only when bits.ttypes contains more than two items
+bitsetBitfieldComparison(s, bits) ::= <<
+<!(<testShiftInRange({<offsetShift(s.varName, bits.shift)>})> && ((1 \<\< <offsetShift(s.varName, bits.shift)>) & (<bits.ttypes:{ttype | (1 \<\< <offsetShift(ttype, bits.shift)>)}; separator=" | ">)) != 0)!>
+{ () -> Bool in
+ <! let test: Bool = (<testShiftInRange({<offsetShift(s.varName, bits.shift)>})>)!>
+ <!var temp: Int64 = Int64(<offsetShift(s.varName, bits.shift)>)!>
+ <!temp = (temp \< 0) ? (64 + (temp % 64 )) : (temp % 64)!>
+ <!let test1: Int64 = (Int64(1) \<\< temp)!>
+ <!var test2: Int64 = (<first(bits.ttypes):{ttype | Utils.bitLeftShift(<offsetShift(parserName(ttype), bits.shift)>)}>)!>
+ <!<rest(bits.ttypes):{ttype | test2 = test2 | Utils.bitLeftShift(<offsetShift(parserName(ttype), bits.shift)>)}; separator="\n">!>
+ let testArray: [Int] = [<s.varName>, <bits.ttypes:{ttype |<parserName(ttype)>}; separator=",">]
+ <!var test2: Int64 = Utils.testBitLeftShiftArray(testArray)!>
+ return Utils.testBitLeftShiftArray(testArray, <bits.shift>)
+}()
+>>
+
+isZero ::= [
+"0": true,
+default: false
+]
+parserName(ttype) ::= <%
+ <parser.name>.Tokens.<ttype>.rawValue
+%>
+offsetShift(shiftAmount, offset) ::= <%
+<if(!isZero.(offset))>(<shiftAmount> - <offset>)<else><shiftAmount><endif>
+%>
+
+// produces more efficient bytecode when bits.ttypes contains at most two items
+bitsetInlineComparison(s, bits) ::= <%
+<bits.ttypes:{ttype | <s.varName> == <parser.name>.Tokens.<ttype>.rawValue}; separator=" || ">
+%>
+
+cases(ttypes) ::= <<
+<trunc(ttypes): {t | case .<t>:fallthrough} ; separator="\n">
+<last(ttypes): {t | case .<t>:} ; separator="\n">
+>>
+
+InvokeRule(r, argExprsChunks) ::= <<
+setState(<r.stateNumber>)
+<if(r.labels)>
+try {
+ let assignmentValue = try <r.name>(<if(r.ast.options.p)><r.ast.options.p><if(argExprsChunks)>,<endif><endif><argExprsChunks>)
+ <r.labels:{l | <labelref(l)> = assignmentValue} ; separator="\n">
+ }()
+<else>try <r.name>(<if(r.ast.options.p)><r.ast.options.p><if(argExprsChunks)>,<endif><endif><argExprsChunks>)<endif>
+>>
+
+MatchToken(m) ::= <<
+setState(<m.stateNumber>)
+<if(m.labels)>
+try {
+ let assignmentValue = try match(<parser.name>.Tokens.<m.name>.rawValue)
+ <m.labels:{l | <labelref(l)> = assignmentValue} ; separator="\n">
+ }()
+<else>try match(<parser.name>.Tokens.<m.name>.rawValue)<endif>
+>>
+
+MatchSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, false)>"
+
+MatchNotSet(m, expr, capture) ::= "<CommonSetStuff(m, expr, capture, true)>"
+
+CommonSetStuff(m, expr, capture, invert) ::= <<
+setState(<m.stateNumber>)
+<if(m.labels)><m.labels:{l | <labelref(l)> = }>try _input.LT(1)<endif>
+<capture>
+if (<if(invert)><m.varName> \<= 0 || <else>!<endif>(<expr>)) {
+ <if(m.labels)><m.labels:{l | <labelref(l)> = }><endif>try _errHandler.recoverInline(self)<if(m.labels)> as Token<endif>
+}
+else {
+ _errHandler.reportMatch(self)
+ try consume()
+}
+>>
+
+Wildcard(w) ::= <<
+setState(<w.stateNumber>)
+<if(w.labels)><w.labels:{l | <labelref(l)> = }><endif>try matchWildcard();
+>>
+
+// ACTION STUFF
+
+Action(a, foo, chunks) ::= "<chunks>"
+
+ArgAction(a, chunks) ::= "<chunks>"
+
+SemPred(p, chunks, failChunks) ::= <<
+setState(<p.stateNumber>)
+if (!(<chunks>)) {
+ throw try ANTLRException.recognition(e:FailedPredicateException(self, <p.predicate><if(failChunks)>, <failChunks><elseif(p.msg)>, <p.msg><endif>))
+}
+>>
+
+ExceptionClause(e, catchArg, catchAction) ::= <<
+catch (<catchArg>) {
+ <catchAction>
+}
+>>
+
+// lexer actions are not associated with model objects
+
+LexerSkipCommand() ::= "skip()"
+LexerMoreCommand() ::= "more()"
+LexerPopModeCommand() ::= "popMode()"
+
+LexerTypeCommand(arg) ::= "_type = <arg>"
+LexerChannelCommand(arg) ::= "_channel = <arg>"
+LexerModeCommand(arg) ::= "_mode = <arg>"
+LexerPushModeCommand(arg) ::= "pushMode(<arg>)"
+
+ActionText(t) ::= "<t.text>"
+ActionTemplate(t) ::= "<t.st>"
+ArgRef(a) ::= "_localctx.<a.name>"
+LocalRef(a) ::= "_localctx.<a.name>"
+RetValueRef(a) ::= "_localctx.<a.name>"
+QRetValueRef(a) ::= "<ctx(a)>.<a.dict>.<a.name>"
+/** How to translate $tokenLabel */
+TokenRef(t) ::= "<ctx(t)>.<t.name>"
+LabelRef(t) ::= "<ctx(t)>.<t.name>"
+ListLabelRef(t) ::= "<ctx(t)>.<ListLabelName(t.name)>"
+SetAttr(s,rhsChunks) ::= "<ctx(s)>.<s.name> = <rhsChunks>"
+
+TokenLabelType() ::= "<file.TokenLabelType; null={Token}>"
+InputSymbolType() ::= "<file.InputSymbolType; null={Token}>"
+
+TokenPropertyRef_text(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getText()! : \"\")"
+TokenPropertyRef_type(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getType() : 0)"
+TokenPropertyRef_line(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getLine() : 0)"
+TokenPropertyRef_pos(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getCharPositionInLine() : 0)"
+TokenPropertyRef_channel(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getChannel() : 0)"
+TokenPropertyRef_index(t) ::= "(<ctx(t)>.<t.label> != nil ? <ctx(t)>.<t.label>!.getTokenIndex() : 0)"
+TokenPropertyRef_int(t) ::= "(<ctx(t)>.<t.label> != nil ? Int(<ctx(t)>.<t.label>!.getText()!) : 0)"
+
+RulePropertyRef_start(r) ::= "(<ctx(r)>.<r.label> != nil ? (<ctx(r)>.<r.label>!.start?.description ?? \"\") : \"\")"
+RulePropertyRef_stop(r) ::= "(<ctx(r)>.<r.label> != nil ? (<ctx(r)>.<r.label>!.stop?.description ?? \"\") : \"\")"
+RulePropertyRef_text(r) ::= "(<ctx(r)>.<r.label> != nil ? try _input.getText(<ctx(r)>.<r.label>!.start,<ctx(r)>.<r.label>!.stop) : \"\")"
+RulePropertyRef_ctx(r) ::= "<ctx(r)>.<r.label>"
+RulePropertyRef_parser(r) ::= "self"
+
+ThisRulePropertyRef_start(r) ::= "_localctx.start"
+ThisRulePropertyRef_stop(r) ::= "_localctx.stop"
+ThisRulePropertyRef_text(r) ::= "(try _input.getText(_localctx.start, try _input.LT(-1)))"
+ThisRulePropertyRef_ctx(r) ::= "_localctx"
+ThisRulePropertyRef_parser(r) ::= "self"
+
+NonLocalAttrRef(s) ::= "((<s.ruleName; format=\"cap\">Context)getInvokingContext(<s.ruleIndex>)).<s.name>"
+SetNonLocalAttr(s, rhsChunks) ::=
+ "((<s.ruleName; format=\"cap\">Context)getInvokingContext(<s.ruleIndex>)).<s.name> = <rhsChunks>"
+
+AddToLabelList(a) ::= "<ctx(a.label)>.<a.listName>.append(<labelref(a.label)>)"
+
+TokenDecl(t) ::= "<t.name>: <SwiftTypeMap.(TokenLabelType())>!"
+TokenTypeDecl(t) ::= "var <t.name>: Int = 0"
+TokenListDecl(t) ::= "<t.name>: Array\<Token> = Array\<Token>()"
+RuleContextDecl(r) ::= "<r.name>: <r.ctxName>!"
+RuleContextListDecl(rdecl) ::= "<rdecl.name>:Array\<<rdecl.ctxName>> = Array\<<rdecl.ctxName>>()"
+
+ContextTokenGetterDecl(t) ::=
+ "open func <t.name>() -> TerminalNode? { return getToken(<parser.name>.Tokens.<t.name>.rawValue, 0) }"
+ContextTokenListGetterDecl(t) ::=
+ "open func <t.name>() -> Array\<TerminalNode> { return getTokens(<parser.name>.Tokens.<t.name>.rawValue) }"
+ContextTokenListIndexedGetterDecl(t) ::= <<
+open func <t.name>(_ i:Int) -> TerminalNode?{
+ return getToken(<parser.name>.Tokens.<t.name>.rawValue, i)
+}
+>>
+ContextRuleGetterDecl(r) ::= <<
+open func <r.name>() -> <r.ctxName>? {
+ return getRuleContext(<r.ctxName>.self,0)
+}
+>>
+ContextRuleListGetterDecl(r) ::= <<
+open func <r.name>() -> Array\<<r.ctxName>\> {
+ return getRuleContexts(<r.ctxName>.self)
+}
+>>
+ContextRuleListIndexedGetterDecl(r) ::= <<
+open func <r.name>(_ i: Int) -> <r.ctxName>? {
+ return getRuleContext(<r.ctxName>.self,i)
+}
+>>
+
+LexerRuleContext() ::= "RuleContext"
+
+/** The rule context name is the rule followed by a suffix; e.g.,
+ * r becomes rContext.
+ */
+RuleContextNameSuffix() ::= "Context"
+
+ImplicitTokenLabel(tokenName) ::= "_<tokenName>"
+ImplicitRuleLabel(ruleName) ::= "_<ruleName>"
+ImplicitSetLabel(id) ::= "_tset<id>"
+ListLabelName(label) ::= "<label>"
+
+CaptureNextToken(d) ::= "<d.varName> = try _input.LT(1)"
+CaptureNextTokenType(d) ::= "<d.varName> = try _input.LA(1)"
+
+StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,
+ superClass={ParserRuleContext}) ::= <<
+open class <struct.name>:<if(contextSuperClass)><contextSuperClass><else>ParserRuleContext<endif><if(interfaces)>, <interfaces; separator=", "><endif> {
+ <attrs:{a | public var <a>}; separator="\n">
+ <getters:{g | <g>}; separator="\n">
+ <! <if(ctorAttrs)>public init(_ parent: ParserRuleContext,_ invokingState: Int) { super.init(parent, invokingState) }<endif> !>
+ <if(ctorAttrs)>
+ public convenience init(_ parent: ParserRuleContext?, _ invokingState: Int<ctorAttrs:{a | , _ <a>}>) {
+ self.init(parent, invokingState)
+ <struct.ctorAttrs:{a | self.<a.name> = <a.name>;}; separator="\n">
+ }
+ <endif>
+ open override func getRuleIndex() -> Int { return <parser.name>.RULE_<struct.derivedFromName> }
+<if(struct.provideCopyFrom)> <! don't need copy unless we have subclasses !>
+ <!public init() { }!>
+ public func copyFrom(_ ctx: <struct.name>) {
+ super.copyFrom(ctx)
+ <struct.attrs:{a | self.<a.name> = ctx.<a.name>;}; separator="\n">
+ }
+<endif>
+ <dispatchMethods; separator="\n">
+ <extensionMembers; separator="\n">
+}
+>>
+
+AltLabelStructDecl(struct,attrs,getters,dispatchMethods) ::= <<
+public final class <struct.name>: <currentRule.name; format="cap">Context {
+ <attrs:{a | public var <a>}; separator="\n">
+ <getters:{g | <g>}; separator="\n">
+ public init(_ ctx: <currentRule.name; format="cap">Context) {
+ super.init()
+ copyFrom(ctx)
+ }
+ <dispatchMethods; separator="\n">
+}
+>>
+
+ListenerDispatchMethod(method) ::= <<
+override
+open func <if(method.isEnter)>enter<else>exit<endif>Rule(_ listener: ParseTreeListener) {
+ if listener is <parser.grammarName>Listener {
+ (listener as! <parser.grammarName>Listener).<if(method.isEnter)>enter<else>exit<endif><struct.derivedFromName; format="cap">(self)
+ }
+}
+>>
+
+VisitorDispatchMethod(method) ::= <<
+override
+open func accept\<T>(_ visitor: ParseTreeVisitor\<T>) -> T? {
+ if visitor is <parser.grammarName>Visitor {
+ return (visitor as! <parser.grammarName>Visitor\<T>).visit<struct.derivedFromName; format="cap">(self)
+ }else if visitor is <parser.grammarName>BaseVisitor {
+ return (visitor as! <parser.grammarName>BaseVisitor\<T>).visit<struct.derivedFromName; format="cap">(self)
+ }
+ else {
+ return visitor.visitChildren(self)
+ }
+}
+>>
+
+AttributeDecl(d) ::= "<d.name>: <SwiftTypeMap.(d.type)><if(d.initValue)> = <d.initValue><else>!<endif>"
+
+/** If we don't know location of label def x, use this template (_localctx as! <x.ctx.name> */
+labelref(x) ::= "<if(!x.isLocal)>_localctx.castdown(<x.ctx.name>.self).<endif><x.name>"
+
+/** For any action chunk, what is correctly-typed context struct ptr? */
+ctx(actionChunk) ::= "_localctx.castdown(<actionChunk.ctx.name>.self)"
+
+// used for left-recursive rules
+recRuleAltPredicate(ruleName,opPrec) ::= "precpred(_ctx, <opPrec>)"
+recRuleSetReturnAction(src,name) ::= "$<name>=$<src>.<name>"
+recRuleSetStopToken() ::= "_ctx!.stop = try _input.LT(-1)"
+
+recRuleAltStartAction(ruleName, ctxName, label, isListLabel) ::= <<
+_localctx = <ctxName>Context(_parentctx, _parentState);
+<if(label)>
+<if(isListLabel)>
+_localctx.<label>.append(_prevctx)
+<else>
+_localctx.<label> = _prevctx
+<endif>
+<endif>
+<if(label)>_localctx.<label> = _prevctx;<endif>
+try pushNewRecursionContext(_localctx, _startState, <parser.name>.RULE_<ruleName>)
+>>
+
+recRuleLabeledAltStartAction(ruleName, currentAltLabel, label, isListLabel) ::= <<
+_localctx = <currentAltLabel; format="cap">Context( <ruleName; format="cap">Context(_parentctx, _parentState))
+<if(label)>
+<if(isListLabel)>
+(_localctx as! <currentAltLabel; format="cap">Context).<label>.append(_prevctx)
+<else>
+(_localctx as! <currentAltLabel; format="cap">Context).<label> = _prevctx
+<endif>
+<endif>
+try pushNewRecursionContext(_localctx, _startState, <parser.name>.RULE_<ruleName>)
+>>
+
+recRuleReplaceContext(ctxName) ::= <<
+_localctx = <ctxName>Context(_localctx)
+_ctx = _localctx
+_prevctx = _localctx
+>>
+
+recRuleSetPrevCtx() ::= <<
+if _parseListeners != nil {
+ try triggerExitRuleEvent()
+}
+_prevctx = _localctx
+>>
+
+
+LexerFile(lexerFile, lexer, namedActions) ::= <<
+<fileHeader(lexerFile.grammarFileName, lexerFile.ANTLRVersion)>
+<if(lexerFile.genPackage)>
+<!package <lexerFile.genPackage>;!>
+<endif>
+<namedActions.header>
+import Antlr4
+
+<lexer>
+>>
+Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass) ::= <<
+open class <lexer.name>: <superClass; null="Lexer"> {
+ internal static var _decisionToDFA: [DFA] = {
+ var decisionToDFA = [DFA]()
+ let length = <lexer.name>._ATN.getNumberOfDecisions()
+ for i in 0..\<length {
+ <! decisionToDFA[i] = DFA(<lexer.name>._ATN.getDecisionState(i)!, i);!>
+ decisionToDFA.append(DFA(<lexer.name>._ATN.getDecisionState(i)!, i))
+ }
+ return decisionToDFA
+ }()
+
+ internal static let _sharedContextCache:PredictionContextCache = PredictionContextCache()
+ public static let <lexer.tokens:{k | <k>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>
+ <if(lexer.channels)>
+ public let <lexer.channels:{k | <k>=<lexer.channels.(k)>}; separator=", ", wrap, anchor>
+ <endif>
+ <rest(lexer.modes):{m| public static let <m>: Int = <i>;}; separator="\n">
+ public static let modeNames: [String] = [
+ <lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor>
+ ]
+
+ public static let ruleNames: [String] = [
+ <lexer.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor>
+ ]
+
+ <vocabulary(lexer.literalNames, lexer.symbolicNames)>
+
+ <namedActions.members>
+ open override func getVocabulary() -> Vocabulary {
+ return <lexer.name>.VOCABULARY
+ }
+
+ public override init(_ input: CharStream) {
+ RuntimeMetaData.checkVersion("<lexerFile.ANTLRVersion>", RuntimeMetaData.VERSION)
+ super.init(input)
+ _interp = LexerATNSimulator(self, <lexer.name>._ATN, <lexer.name>._decisionToDFA, <lexer.name>._sharedContextCache)
+ }
+
+ override
+ open func getGrammarFileName() -> String { return "<lexer.grammarFileName>" }
+
+ override
+ open func getRuleNames() -> [String] { return <lexer.name>.ruleNames }
+
+ override
+ open func getSerializedATN() -> String { return <lexer.name>._serializedATN }
+
+ override
+ open func getModeNames() -> [String] { return <lexer.name>.modeNames }
+
+ override
+ open func getATN() -> ATN { return <lexer.name>._ATN }
+
+ <dumpActions(lexer, "", actionFuncs, sempredFuncs)>
+ <atn>
+ public static let _serializedATN: String = <lexer.name>ATN().jsonString
+ public static let _ATN: ATN = ATNDeserializer().deserializeFromJson(_serializedATN)
+}
+>>
+
+/** Don't need to define anything. The tool generates a XParserATN.swift file (and same for lexer)
+ * which is referenced from static field _serializedATN. This json string is passed to
+ * deserializeFromJson(). Note this is not the "serialization as array of ints" that other targets
+ * do. It is more or less the output of ATNPrinter which gets read back in.
+ */
+SerializedATN(model) ::= <<
+>>
+
+/** Using a type to init value map, try to init a type; if not in table
+ * must be an object, default value is "null".
+ */
+initValue(typeName) ::= <<
+ <SwiftTypeInitMap.(typeName)>
+>>
+
+codeFileExtension() ::= ".swift"
diff --git a/tool/resources/org/antlr/v4/tool/templates/depend.stg b/tool/resources/org/antlr/v4/tool/templates/depend.stg
index dad7568..3a1c01a 100644
--- a/tool/resources/org/antlr/v4/tool/templates/depend.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/depend.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/resources/org/antlr/v4/tool/templates/dot/graphs.stg b/tool/resources/org/antlr/v4/tool/templates/dot/graphs.stg
index cf071f1..5e706c9 100644
--- a/tool/resources/org/antlr/v4/tool/templates/dot/graphs.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/dot/graphs.stg
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/Tool.java b/tool/src/org/antlr/v4/Tool.java
index 2441268..93a59ff 100644
--- a/tool/src/org/antlr/v4/Tool.java
+++ b/tool/src/org/antlr/v4/Tool.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4;
@@ -521,6 +497,19 @@ public class Tool {
// Make grammars depend on any tokenVocab options
if ( tokenVocabNode!=null ) {
String vocabName = tokenVocabNode.getText();
+ // Strip quote characters if any
+ int len = vocabName.length();
+ int firstChar = vocabName.charAt(0);
+ int lastChar = vocabName.charAt(len - 1);
+ if (len >= 2 && firstChar == '\'' && lastChar == '\'') {
+ vocabName = vocabName.substring(1, len-1);
+ }
+ // If the name contains a path delimited by forward slashes,
+ // use only the part after the last slash as the name
+ int lastSlash = vocabName.lastIndexOf('/');
+ if (lastSlash >= 0) {
+ vocabName = vocabName.substring(lastSlash + 1);
+ }
g.addEdge(grammarName, vocabName);
}
// add cycle to graph so we always process a grammar if no error
@@ -713,7 +702,7 @@ public class Tool {
*
* The output dir -o spec takes precedence if it's absolute.
* E.g., if the grammar file dir is absolute the output dir is given
- * precendence. "-o /tmp /usr/lib/t.g4" results in "/tmp/T.java" as
+ * precedence. "-o /tmp /usr/lib/t.g4" results in "/tmp/T.java" as
* output (assuming t.g4 holds T.java).
*
* If no -o is specified, then just write to the directory where the
diff --git a/tool/src/org/antlr/v4/analysis/AnalysisPipeline.java b/tool/src/org/antlr/v4/analysis/AnalysisPipeline.java
index a04ec31..6c7b97a 100644
--- a/tool/src/org/antlr/v4/analysis/AnalysisPipeline.java
+++ b/tool/src/org/antlr/v4/analysis/AnalysisPipeline.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.analysis;
@@ -58,7 +34,8 @@ public class AnalysisPipeline {
if (g.isLexer()) {
processLexer();
- } else {
+ }
+ else {
// BUILD DFA FOR EACH DECISION
processParser();
}
diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursionDetector.java b/tool/src/org/antlr/v4/analysis/LeftRecursionDetector.java
index 44e4b4a..c180083 100644
--- a/tool/src/org/antlr/v4/analysis/LeftRecursionDetector.java
+++ b/tool/src/org/antlr/v4/analysis/LeftRecursionDetector.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.analysis;
diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAltInfo.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAltInfo.java
index a5ef7b4..980fcaf 100644
--- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAltInfo.java
+++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAltInfo.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.analysis;
diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java
index 7a1d233..a2040e7 100644
--- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java
+++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.analysis;
diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java
index 45cb517..610c550 100644
--- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java
+++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.analysis;
diff --git a/tool/src/org/antlr/v4/automata/ATNFactory.java b/tool/src/org/antlr/v4/automata/ATNFactory.java
index b1f61a8..a7de4ff 100644
--- a/tool/src/org/antlr/v4/automata/ATNFactory.java
+++ b/tool/src/org/antlr/v4/automata/ATNFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
diff --git a/tool/src/org/antlr/v4/automata/ATNOptimizer.java b/tool/src/org/antlr/v4/automata/ATNOptimizer.java
index 4f72b64..36e5009 100644
--- a/tool/src/org/antlr/v4/automata/ATNOptimizer.java
+++ b/tool/src/org/antlr/v4/automata/ATNOptimizer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
@@ -42,6 +18,7 @@ import org.antlr.v4.runtime.atn.SetTransition;
import org.antlr.v4.runtime.atn.Transition;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.misc.IntervalSet;
+import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.Rule;
@@ -118,20 +95,34 @@ public class ATNOptimizer {
Transition matchTransition = decision.transition(j).target.transition(0);
if (matchTransition instanceof NotSetTransition) {
throw new UnsupportedOperationException("Not yet implemented.");
- } else {
- matchSet.addAll(matchTransition.label());
}
+ IntervalSet set = matchTransition.label();
+ int minElem = set.getMinElement();
+ int maxElem = set.getMaxElement();
+ for (int k = minElem; k <= maxElem; k++) {
+ if (matchSet.contains(k)) {
+ char setMin = (char) set.getMinElement();
+ char setMax = (char) set.getMaxElement();
+ // TODO: Token is missing (i.e. position in source will not be displayed).
+ g.tool.errMgr.grammarError(ErrorType.CHARACTERS_COLLISION_IN_SET, g.fileName,
+ null, (char) minElem + "-" + (char) maxElem, "[" + setMin + "-" + setMax + "]");
+ break;
+ }
+ }
+ matchSet.addAll(set);
}
Transition newTransition;
if (matchSet.getIntervals().size() == 1) {
if (matchSet.size() == 1) {
newTransition = new AtomTransition(blockEndState, matchSet.getMinElement());
- } else {
+ }
+ else {
Interval matchInterval = matchSet.getIntervals().get(0);
newTransition = new RangeTransition(blockEndState, matchInterval.a, matchInterval.b);
}
- } else {
+ }
+ else {
newTransition = new SetTransition(blockEndState, matchSet);
}
diff --git a/tool/src/org/antlr/v4/automata/ATNPrinter.java b/tool/src/org/antlr/v4/automata/ATNPrinter.java
index 9fe1145..f3b44a1 100644
--- a/tool/src/org/antlr/v4/automata/ATNPrinter.java
+++ b/tool/src/org/antlr/v4/automata/ATNPrinter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
diff --git a/tool/src/org/antlr/v4/automata/ATNVisitor.java b/tool/src/org/antlr/v4/automata/ATNVisitor.java
index af5e18a..70eb6cb 100644
--- a/tool/src/org/antlr/v4/automata/ATNVisitor.java
+++ b/tool/src/org/antlr/v4/automata/ATNVisitor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
diff --git a/tool/src/org/antlr/v4/automata/LexerATNFactory.java b/tool/src/org/antlr/v4/automata/LexerATNFactory.java
index 8d16bd1..b596df5 100644
--- a/tool/src/org/antlr/v4/automata/LexerATNFactory.java
+++ b/tool/src/org/antlr/v4/automata/LexerATNFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
@@ -63,6 +39,7 @@ import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
import org.antlr.v4.tool.ast.ActionAST;
import org.antlr.v4.tool.ast.GrammarAST;
+import org.antlr.v4.tool.ast.RangeAST;
import org.antlr.v4.tool.ast.TerminalAST;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
@@ -95,6 +72,8 @@ public class LexerATNFactory extends ParserATNFactory {
COMMON_CONSTANTS.put("MIN_CHAR_VALUE", Lexer.MIN_CHAR_VALUE);
}
+ private List<String> ruleCommands = new ArrayList<String>();
+
/**
* Maps from an action index to a {@link LexerAction} object.
*/
@@ -160,6 +139,12 @@ public class LexerATNFactory extends ParserATNFactory {
}
@Override
+ public Handle rule(GrammarAST ruleAST, String name, Handle blk) {
+ ruleCommands.clear();
+ return super.rule(ruleAST, name, blk);
+ }
+
+ @Override
public Handle action(ActionAST action) {
int ruleIndex = currentRule.index;
int actionIndex = g.lexerActions.get(action);
@@ -235,6 +220,7 @@ public class LexerATNFactory extends ParserATNFactory {
}
cmdST.add("arg", arg.getText());
+ cmdST.add("grammar", arg.g);
return action(cmdST.render());
}
@@ -268,6 +254,7 @@ public class LexerATNFactory extends ParserATNFactory {
ATNState right = newState(b);
int t1 = CharSupport.getCharValueFromGrammarCharLiteral(a.getText());
int t2 = CharSupport.getCharValueFromGrammarCharLiteral(b.getText());
+ checkRange(a, b, t1, t2);
left.addTransition(new RangeTransition(right, t1, t2));
a.atnState = left;
b.atnState = left;
@@ -283,7 +270,10 @@ public class LexerATNFactory extends ParserATNFactory {
if ( t.getType()==ANTLRParser.RANGE ) {
int a = CharSupport.getCharValueFromGrammarCharLiteral(t.getChild(0).getText());
int b = CharSupport.getCharValueFromGrammarCharLiteral(t.getChild(1).getText());
- set.add(a, b);
+ if (checkRange((GrammarAST) t.getChild(0), (GrammarAST) t.getChild(1), a, b)) {
+ checkSetCollision(associatedAST, set, a, b);
+ set.add(a,b);
+ }
}
else if ( t.getType()==ANTLRParser.LEXER_CHAR_SET ) {
set.addAll(getSetFromCharSetLiteral(t));
@@ -291,12 +281,12 @@ public class LexerATNFactory extends ParserATNFactory {
else if ( t.getType()==ANTLRParser.STRING_LITERAL ) {
int c = CharSupport.getCharValueFromGrammarCharLiteral(t.getText());
if ( c != -1 ) {
+ checkSetCollision(associatedAST, set, c);
set.add(c);
}
else {
g.tool.errMgr.grammarError(ErrorType.INVALID_LITERAL_IN_LEXER_SET,
g.fileName, t.getToken(), t.getText());
-
}
}
else if ( t.getType()==ANTLRParser.TOKEN_REF ) {
@@ -322,6 +312,27 @@ public class LexerATNFactory extends ParserATNFactory {
return new Handle(left, right);
}
+ protected boolean checkRange(GrammarAST leftNode, GrammarAST rightNode, int leftValue, int rightValue) {
+ boolean result = true;
+ if (leftValue == -1) {
+ result = false;
+ g.tool.errMgr.grammarError(ErrorType.INVALID_LITERAL_IN_LEXER_SET,
+ g.fileName, leftNode.getToken(), leftNode.getText());
+ }
+ if (rightValue == -1) {
+ result = false;
+ g.tool.errMgr.grammarError(ErrorType.INVALID_LITERAL_IN_LEXER_SET,
+ g.fileName, rightNode.getToken(), rightNode.getText());
+ }
+ if (!result) return result;
+
+ if (rightValue < leftValue) {
+ g.tool.errMgr.grammarError(ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED,
+ g.fileName, leftNode.parent.getToken(), leftNode.getText() + ".." + rightNode.getText());
+ }
+ return result;
+ }
+
/** For a lexer, a string is a sequence of char to match. That is,
* "fog" is treated as 'f' 'o' 'g' not as a single transition in
* the DFA. Machine== o-'f'-&gt;o-'o'-&gt;o-'g'-&gt;o and has n+1 states
@@ -330,12 +341,19 @@ public class LexerATNFactory extends ParserATNFactory {
@Override
public Handle stringLiteral(TerminalAST stringLiteralAST) {
String chars = stringLiteralAST.getText();
+ ATNState left = newState(stringLiteralAST);
+ ATNState right;
chars = CharSupport.getStringFromGrammarStringLiteral(chars);
+ if (chars == null) {
+ g.tool.errMgr.grammarError(ErrorType.INVALID_ESCAPE_SEQUENCE,
+ g.fileName, stringLiteralAST.getToken());
+ return new Handle(left, left);
+ }
+
int n = chars.length();
- ATNState left = newState(stringLiteralAST);
ATNState prev = left;
- ATNState right = null;
- for (int i=0; i<n; i++) {
+ right = null;
+ for (int i = 0; i < n; i++) {
right = newState(stringLiteralAST);
prev.addTransition(new AtomTransition(right, chars.charAt(i)));
prev = right;
@@ -357,38 +375,94 @@ public class LexerATNFactory extends ParserATNFactory {
public IntervalSet getSetFromCharSetLiteral(GrammarAST charSetAST) {
String chars = charSetAST.getText();
- chars = chars.substring(1, chars.length()-1);
- String cset = '"'+ chars +'"';
+ chars = chars.substring(1, chars.length() - 1);
+ String cset = '"' + chars + '"';
IntervalSet set = new IntervalSet();
+ if (chars.length() == 0) {
+ g.tool.errMgr.grammarError(ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED,
+ g.fileName, charSetAST.getToken(), "[]");
+ return set;
+ }
// unescape all valid escape char like \n, leaving escaped dashes as '\-'
// so we can avoid seeing them as '-' range ops.
chars = CharSupport.getStringFromGrammarStringLiteral(cset);
- // now make x-y become set of char
+ if (chars == null) {
+ g.tool.errMgr.grammarError(ErrorType.INVALID_ESCAPE_SEQUENCE,
+ g.fileName, charSetAST.getToken());
+ return set;
+ }
int n = chars.length();
- for (int i=0; i< n; i++) {
+ // now make x-y become set of char
+ for (int i = 0; i < n; i++) {
int c = chars.charAt(i);
- if ( c=='\\' && (i+1)<n && chars.charAt(i+1)=='-' ) { // \-
+ if (c == '\\' && i+1 < n && chars.charAt(i+1) == '-') { // \-
+ checkSetCollision(charSetAST, set, '-');
set.add('-');
i++;
}
- else if ( (i+2)<n && chars.charAt(i+1)=='-' ) { // range x-y
+ else if (i+2 < n && chars.charAt(i+1) == '-') { // range x-y
int x = c;
int y = chars.charAt(i+2);
- if ( x<=y ) set.add(x,y);
- i+=2;
+ if (x <= y) {
+ checkSetCollision(charSetAST, set, x, y);
+ set.add(x,y);
+ }
+ else {
+ g.tool.errMgr.grammarError(ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED,
+ g.fileName, charSetAST.getToken(), "[" + (char) x + "-" + (char) y + "]");
+ }
+ i += 2;
}
else {
+ checkSetCollision(charSetAST, set, c);
set.add(c);
}
}
return set;
}
+ protected void checkSetCollision(GrammarAST ast, IntervalSet set, int el) {
+ if (set.contains(el)) {
+ g.tool.errMgr.grammarError(ErrorType.CHARACTERS_COLLISION_IN_SET, g.fileName, ast.getToken(),
+ (char)el, ast.getText());
+ }
+ }
+
+ protected void checkSetCollision(GrammarAST ast, IntervalSet set, int a, int b) {
+ for (int i = a; i <= b; i++) {
+ if (set.contains(i)) {
+ String setText;
+ if (ast.getChildren() == null) {
+ setText = ast.getText();
+ }
+ else {
+ StringBuilder sb = new StringBuilder();
+ for (Object child : ast.getChildren()) {
+ if (child instanceof RangeAST) {
+ sb.append(((RangeAST) child).getChild(0).getText());
+ sb.append("..");
+ sb.append(((RangeAST) child).getChild(1).getText());
+ }
+ else {
+ sb.append(((GrammarAST)child).getText());
+ }
+ sb.append(" | ");
+ }
+ sb.replace(sb.length() - 3, sb.length(), "");
+ setText = sb.toString();
+ }
+ g.tool.errMgr.grammarError(ErrorType.CHARACTERS_COLLISION_IN_SET, g.fileName, ast.getToken(),
+ (char)a + "-" + (char)b, setText);
+ break;
+ }
+ }
+ }
+
@Override
public Handle tokenRef(TerminalAST node) {
// Ref to EOF in lexer yields char transition on -1
- if ( node.getText().equals("EOF") ) {
+ if (node.getText().equals("EOF") ) {
ATNState left = newState(node);
ATNState right = newState(node);
left.addTransition(new AtomTransition(right, IntStream.EOF));
@@ -397,9 +471,10 @@ public class LexerATNFactory extends ParserATNFactory {
return _ruleRef(node);
}
-
- protected LexerAction createLexerAction(GrammarAST ID, GrammarAST arg) {
+ private LexerAction createLexerAction(GrammarAST ID, GrammarAST arg) {
String command = ID.getText();
+ checkCommands(command, ID.getToken());
+
if ("skip".equals(command) && arg == null) {
return LexerSkipAction.INSTANCE;
}
@@ -411,8 +486,7 @@ public class LexerATNFactory extends ParserATNFactory {
}
else if ("mode".equals(command) && arg != null) {
String modeName = arg.getText();
- checkMode(modeName, arg.token);
- Integer mode = getConstantValue(modeName, arg.getToken());
+ Integer mode = getModeConstantValue(modeName, arg.getToken());
if (mode == null) {
return null;
}
@@ -421,8 +495,7 @@ public class LexerATNFactory extends ParserATNFactory {
}
else if ("pushMode".equals(command) && arg != null) {
String modeName = arg.getText();
- checkMode(modeName, arg.token);
- Integer mode = getConstantValue(modeName, arg.getToken());
+ Integer mode = getModeConstantValue(modeName, arg.getToken());
if (mode == null) {
return null;
}
@@ -431,8 +504,7 @@ public class LexerATNFactory extends ParserATNFactory {
}
else if ("type".equals(command) && arg != null) {
String typeName = arg.getText();
- checkToken(typeName, arg.token);
- Integer type = getConstantValue(typeName, arg.getToken());
+ Integer type = getTokenConstantValue(typeName, arg.getToken());
if (type == null) {
return null;
}
@@ -441,8 +513,7 @@ public class LexerATNFactory extends ParserATNFactory {
}
else if ("channel".equals(command) && arg != null) {
String channelName = arg.getText();
- checkChannel(channelName, arg.token);
- Integer channel = getConstantValue(channelName, arg.getToken());
+ Integer channel = getChannelConstantValue(channelName, arg.getToken());
if (channel == null) {
return null;
}
@@ -454,54 +525,127 @@ public class LexerATNFactory extends ParserATNFactory {
}
}
- protected void checkMode(String modeName, Token token) {
- if (!modeName.equals("DEFAULT_MODE") && COMMON_CONSTANTS.containsKey(modeName)) {
- g.tool.errMgr.grammarError(ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ private void checkCommands(String command, Token commandToken) {
+ // Command combinations list: https://github.com/antlr/antlr4/issues/1388#issuecomment-263344701
+ if (!command.equals("pushMode") && !command.equals("popMode")) {
+ if (ruleCommands.contains(command)) {
+ g.tool.errMgr.grammarError(ErrorType.DUPLICATED_COMMAND, g.fileName, commandToken, command);
+ }
+
+ if (!ruleCommands.equals("mode")) {
+ String firstCommand = null;
+
+ if (command.equals("skip")) {
+ if (ruleCommands.contains("more")) {
+ firstCommand = "more";
+ } else if (ruleCommands.contains("type")) {
+ firstCommand = "type";
+ } else if (ruleCommands.contains("channel")) {
+ firstCommand = "channel";
+ }
+ } else if (command.equals("more")) {
+ if (ruleCommands.contains("skip")) {
+ firstCommand = "skip";
+ } else if (ruleCommands.contains("type")) {
+ firstCommand = "type";
+ } else if (ruleCommands.contains("channel")) {
+ firstCommand = "channel";
+ }
+ } else if (command.equals("type") || command.equals("channel")) {
+ if (ruleCommands.contains("more")) {
+ firstCommand = "more";
+ } else if (ruleCommands.contains("skip")) {
+ firstCommand = "skip";
+ }
+ }
+
+ if (firstCommand != null) {
+ g.tool.errMgr.grammarError(ErrorType.INCOMPATIBLE_COMMANDS, g.fileName, commandToken, firstCommand, command);
+ }
+ }
}
+
+ ruleCommands.add(command);
}
- protected void checkToken(String tokenName, Token token) {
- if (!tokenName.equals("EOF") && COMMON_CONSTANTS.containsKey(tokenName)) {
- g.tool.errMgr.grammarError(ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ private Integer getModeConstantValue(String modeName, Token token) {
+ if (modeName == null) {
+ return null;
}
- }
- protected void checkChannel(String channelName, Token token) {
- if (!channelName.equals("HIDDEN") && !channelName.equals("DEFAULT_TOKEN_CHANNEL") && COMMON_CONSTANTS.containsKey(channelName)) {
- g.tool.errMgr.grammarError(ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ if (modeName.equals("DEFAULT_MODE")) {
+ return Lexer.DEFAULT_MODE;
+ }
+ if (COMMON_CONSTANTS.containsKey(modeName)) {
+ g.tool.errMgr.grammarError(ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ return null;
+ }
+
+ List<String> modeNames = new ArrayList<String>(((LexerGrammar)g).modes.keySet());
+ int mode = modeNames.indexOf(modeName);
+ if (mode >= 0) {
+ return mode;
+ }
+
+ try {
+ return Integer.parseInt(modeName);
+ } catch (NumberFormatException ex) {
+ g.tool.errMgr.grammarError(ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME, g.fileName, token, token.getText());
+ return null;
}
}
- protected Integer getConstantValue(String name, Token token) {
- if (name == null) {
+ private Integer getTokenConstantValue(String tokenName, Token token) {
+ if (tokenName == null) {
return null;
}
- Integer commonConstant = COMMON_CONSTANTS.get(name);
- if (commonConstant != null) {
- return commonConstant;
+ if (tokenName.equals("EOF")) {
+ return Lexer.EOF;
+ }
+ if (COMMON_CONSTANTS.containsKey(tokenName)) {
+ g.tool.errMgr.grammarError(ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ return null;
}
- int tokenType = g.getTokenType(name);
+ int tokenType = g.getTokenType(tokenName);
if (tokenType != org.antlr.v4.runtime.Token.INVALID_TYPE) {
return tokenType;
}
- int channelValue = g.getChannelValue(name);
- if (channelValue >= org.antlr.v4.runtime.Token.MIN_USER_CHANNEL_VALUE) {
- return channelValue;
+ try {
+ return Integer.parseInt(tokenName);
+ } catch (NumberFormatException ex) {
+ g.tool.errMgr.grammarError(ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME, g.fileName, token, token.getText());
+ return null;
}
+ }
- List<String> modeNames = new ArrayList<String>(((LexerGrammar)g).modes.keySet());
- int mode = modeNames.indexOf(name);
- if (mode >= 0) {
- return mode;
+ private Integer getChannelConstantValue(String channelName, Token token) {
+ if (channelName == null) {
+ return null;
+ }
+
+ if (channelName.equals("HIDDEN")) {
+ return Lexer.HIDDEN;
+ }
+ if (channelName.equals("DEFAULT_TOKEN_CHANNEL")) {
+ return Lexer.DEFAULT_TOKEN_CHANNEL;
+ }
+ if (COMMON_CONSTANTS.containsKey(channelName)) {
+ g.tool.errMgr.grammarError(ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
+ return null;
+ }
+
+ int channelValue = g.getChannelValue(channelName);
+ if (channelValue >= org.antlr.v4.runtime.Token.MIN_USER_CHANNEL_VALUE) {
+ return channelValue;
}
try {
- return Integer.parseInt(name);
+ return Integer.parseInt(channelName);
} catch (NumberFormatException ex) {
- g.tool.errMgr.grammarError(ErrorType.UNKNOWN_LEXER_CONSTANT, g.fileName, token, currentRule.name, token != null ? token.getText() : null);
+ g.tool.errMgr.grammarError(ErrorType.CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME, g.fileName, token, token.getText());
return null;
}
}
diff --git a/tool/src/org/antlr/v4/automata/ParserATNFactory.java b/tool/src/org/antlr/v4/automata/ParserATNFactory.java
index d2114b4..2cfaccc 100644
--- a/tool/src/org/antlr/v4/automata/ParserATNFactory.java
+++ b/tool/src/org/antlr/v4/automata/ParserATNFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
@@ -137,7 +113,10 @@ public class ParserATNFactory implements ATNFactory {
for (Triple<Rule, ATNState, ATNState> pair : preventEpsilonClosureBlocks) {
LL1Analyzer analyzer = new LL1Analyzer(atn);
- if (analyzer.LOOK(pair.b, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) {
+ ATNState blkStart = pair.b;
+ ATNState blkStop = pair.c;
+ IntervalSet lookahead = analyzer.LOOK(blkStart, blkStop, null);
+ if ( lookahead.contains(org.antlr.v4.runtime.Token.EPSILON)) {
ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE;
g.tool.errMgr.grammarError(errorType, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name);
}
diff --git a/tool/src/org/antlr/v4/automata/TailEpsilonRemover.java b/tool/src/org/antlr/v4/automata/TailEpsilonRemover.java
index 35d1594..b534b43 100644
--- a/tool/src/org/antlr/v4/automata/TailEpsilonRemover.java
+++ b/tool/src/org/antlr/v4/automata/TailEpsilonRemover.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.automata;
diff --git a/tool/src/org/antlr/v4/codegen/ActionTranslator.java b/tool/src/org/antlr/v4/codegen/ActionTranslator.java
index 53a9a50..d9d8208 100644
--- a/tool/src/org/antlr/v4/codegen/ActionTranslator.java
+++ b/tool/src/org/antlr/v4/codegen/ActionTranslator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
@@ -211,26 +187,21 @@ public class ActionTranslator implements ActionSplitterListener {
return;
}
Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node);
+ if ( a==null ) {
+ // Added in response to https://github.com/antlr/antlr4/issues/1211
+ gen.g.tool.errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE,
+ gen.g.fileName, x,
+ x.getText(),
+ "rule");
+ return;
+ }
switch ( a.dict.type ) {
case ARG: chunks.add(new ArgRef(nodeContext,y.getText())); break; // has to be current rule
case RET:
- if ( factory.getCurrentRuleFunction()!=null &&
- factory.getCurrentRuleFunction().name.equals(x.getText()) )
- {
- chunks.add(new RetValueRef(rf.ruleCtx, y.getText())); break;
- }
- else {
- chunks.add(new QRetValueRef(nodeContext, getRuleLabel(x.getText()), y.getText())); break;
- }
+ chunks.add(new QRetValueRef(nodeContext, getRuleLabel(x.getText()), y.getText()));
+ break;
case PREDEFINED_RULE:
- if ( factory.getCurrentRuleFunction()!=null &&
- factory.getCurrentRuleFunction().name.equals(x.getText()) )
- {
- chunks.add(getRulePropertyRef(y));
- }
- else {
- chunks.add(getRulePropertyRef(x, y));
- }
+ chunks.add(getRulePropertyRef(x, y));
break;
case TOKEN:
chunks.add(getTokenPropertyRef(x, y));
diff --git a/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java b/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java
index bef03ac..148d2d5 100644
--- a/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java
+++ b/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java
index 85b779d..eb3e998 100644
--- a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java
+++ b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java
@@ -1,33 +1,8 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
-
package org.antlr.v4.codegen;
import org.antlr.v4.parse.ANTLRParser;
@@ -59,8 +34,8 @@ public class CodeGenPipeline {
for (GrammarAST idNode : idNodes) {
if ( gen.getTarget().grammarSymbolCausesIssueInGeneratedCode(idNode) ) {
g.tool.errMgr.grammarError(ErrorType.USE_OF_BAD_WORD,
- g.fileName, idNode.getToken(),
- idNode.getText());
+ g.fileName, idNode.getToken(),
+ idNode.getText());
}
}
@@ -70,46 +45,84 @@ public class CodeGenPipeline {
int errorCount = g.tool.errMgr.getNumErrors();
if ( g.isLexer() ) {
- ST lexer = gen.generateLexer();
+ if (gen.getTarget().needsHeader()) {
+ ST lexer = gen.generateLexer(true); // Header file if needed.
+ if (g.tool.errMgr.getNumErrors() == errorCount) {
+ writeRecognizer(lexer, gen, true);
+ }
+ }
+ ST lexer = gen.generateLexer(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- writeRecognizer(lexer, gen);
+ writeRecognizer(lexer, gen, false);
}
}
else {
- ST parser = gen.generateParser();
+ if (gen.getTarget().needsHeader()) {
+ ST parser = gen.generateParser(true);
+ if (g.tool.errMgr.getNumErrors() == errorCount) {
+ writeRecognizer(parser, gen, true);
+ }
+ }
+ ST parser = gen.generateParser(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- writeRecognizer(parser, gen);
+ writeRecognizer(parser, gen, false);
}
+
if ( g.tool.gen_listener ) {
- ST listener = gen.generateListener();
+ if (gen.getTarget().needsHeader()) {
+ ST listener = gen.generateListener(true);
+ if (g.tool.errMgr.getNumErrors() == errorCount) {
+ gen.writeListener(listener, true);
+ }
+ }
+ ST listener = gen.generateListener(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- gen.writeListener(listener);
+ gen.writeListener(listener, false);
}
- if (gen.getTarget().wantsBaseListener()) {
- ST baseListener = gen.generateBaseListener();
+
+ if (gen.getTarget().needsHeader()) {
+ ST baseListener = gen.generateBaseListener(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- gen.writeBaseListener(baseListener);
+ gen.writeBaseListener(baseListener, true);
+ }
+ }
+ if (gen.getTarget().wantsBaseListener()) {
+ ST baseListener = gen.generateBaseListener(false);
+ if ( g.tool.errMgr.getNumErrors()==errorCount ) {
+ gen.writeBaseListener(baseListener, false);
}
}
}
if ( g.tool.gen_visitor ) {
- ST visitor = gen.generateVisitor();
+ if (gen.getTarget().needsHeader()) {
+ ST visitor = gen.generateVisitor(true);
+ if (g.tool.errMgr.getNumErrors() == errorCount) {
+ gen.writeVisitor(visitor, true);
+ }
+ }
+ ST visitor = gen.generateVisitor(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- gen.writeVisitor(visitor);
+ gen.writeVisitor(visitor, false);
}
- if (gen.getTarget().wantsBaseVisitor()) {
- ST baseVisitor = gen.generateBaseVisitor();
+
+ if (gen.getTarget().needsHeader()) {
+ ST baseVisitor = gen.generateBaseVisitor(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
- gen.writeBaseVisitor(baseVisitor);
+ gen.writeBaseVisitor(baseVisitor, true);
+ }
+ }
+ if (gen.getTarget().wantsBaseVisitor()) {
+ ST baseVisitor = gen.generateBaseVisitor(false);
+ if ( g.tool.errMgr.getNumErrors()==errorCount ) {
+ gen.writeBaseVisitor(baseVisitor, false);
}
}
}
- gen.writeHeaderFile();
}
gen.writeVocabFile();
}
- protected void writeRecognizer(ST template, CodeGenerator gen) {
+ protected void writeRecognizer(ST template, CodeGenerator gen, boolean header) {
if ( g.tool.launch_ST_inspector ) {
STViz viz = template.inspect();
if (g.tool.ST_inspector_wait_for_close) {
@@ -122,6 +135,6 @@ public class CodeGenPipeline {
}
}
- gen.writeRecognizer(template);
+ gen.writeRecognizer(template, header);
}
}
diff --git a/tool/src/org/antlr/v4/codegen/CodeGenerator.java b/tool/src/org/antlr/v4/codegen/CodeGenerator.java
index e75a4f1..68115c1 100644
--- a/tool/src/org/antlr/v4/codegen/CodeGenerator.java
+++ b/tool/src/org/antlr/v4/codegen/CodeGenerator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
@@ -134,17 +110,28 @@ public class CodeGenerator {
return controller;
}
- private ST walk(OutputModelObject outputModel) {
+ private ST walk(OutputModelObject outputModel, boolean header) {
OutputModelWalker walker = new OutputModelWalker(tool, getTemplates());
- return walker.walk(outputModel);
+ return walker.walk(outputModel, header);
}
- public ST generateLexer() { return walk(createController().buildLexerOutputModel()); }
- public ST generateParser() { return walk(createController().buildParserOutputModel()); }
- public ST generateListener() { return walk(createController().buildListenerOutputModel()); }
- public ST generateBaseListener() { return walk(createController().buildBaseListenerOutputModel()); }
- public ST generateVisitor() { return walk(createController().buildVisitorOutputModel()); }
- public ST generateBaseVisitor() { return walk(createController().buildBaseVisitorOutputModel()); }
+ public ST generateLexer() { return generateLexer(false); }
+ public ST generateLexer(boolean header) { return walk(createController().buildLexerOutputModel(header), header); }
+
+ public ST generateParser() { return generateParser(false); }
+ public ST generateParser(boolean header) { return walk(createController().buildParserOutputModel(header), header); }
+
+ public ST generateListener() { return generateListener(false); }
+ public ST generateListener(boolean header) { return walk(createController().buildListenerOutputModel(header), header); }
+
+ public ST generateBaseListener() { return generateBaseListener(false); }
+ public ST generateBaseListener(boolean header) { return walk(createController().buildBaseListenerOutputModel(header), header); }
+
+ public ST generateVisitor() { return generateVisitor(false); }
+ public ST generateVisitor(boolean header) { return walk(createController().buildVisitorOutputModel(header), header); }
+
+ public ST generateBaseVisitor() { return generateBaseVisitor(false); }
+ public ST generateBaseVisitor(boolean header) { return walk(createController().buildBaseVisitorOutputModel(header), header); }
/** Generate a token vocab file with all the token names/types. For example:
* ID=7
@@ -178,35 +165,24 @@ public class CodeGenerator {
return vocabFileST;
}
- public void writeRecognizer(ST outputFileST) {
- getTarget().genFile(g, outputFileST, getRecognizerFileName());
+ public void writeRecognizer(ST outputFileST, boolean header) {
+ getTarget().genFile(g, outputFileST, getRecognizerFileName(header));
}
- public void writeListener(ST outputFileST) {
- getTarget().genFile(g, outputFileST, getListenerFileName());
+ public void writeListener(ST outputFileST, boolean header) {
+ getTarget().genFile(g, outputFileST, getListenerFileName(header));
}
- public void writeBaseListener(ST outputFileST) {
- getTarget().genFile(g, outputFileST, getBaseListenerFileName());
+ public void writeBaseListener(ST outputFileST, boolean header) {
+ getTarget().genFile(g, outputFileST, getBaseListenerFileName(header));
}
- public void writeVisitor(ST outputFileST) {
- getTarget().genFile(g, outputFileST, getVisitorFileName());
+ public void writeVisitor(ST outputFileST, boolean header) {
+ getTarget().genFile(g, outputFileST, getVisitorFileName(header));
}
- public void writeBaseVisitor(ST outputFileST) {
- getTarget().genFile(g, outputFileST, getBaseVisitorFileName());
- }
-
- public void writeHeaderFile() {
- String fileName = getHeaderFileName();
- if ( fileName==null ) return;
- if ( getTemplates().isDefined("headerFile") ) {
- ST extST = getTemplates().getInstanceOf("headerFileExtension");
- ST headerFileST = null;
- // TODO: don't hide this header file generation here!
- getTarget().genRecognizerHeaderFile(g, headerFileST, extST.render(lineWidth));
- }
+ public void writeBaseVisitor(ST outputFileST, boolean header) {
+ getTarget().genFile(g, outputFileST, getBaseVisitorFileName(header));
}
public void writeVocabFile() {
@@ -236,54 +212,17 @@ public class CodeGenerator {
}
}
- /** Generate TParser.java and TLexer.java from T.g4 if combined, else
- * just use T.java as output regardless of type.
- */
- public String getRecognizerFileName() {
- ST extST = getTemplates().getInstanceOf("codeFileExtension");
- String recognizerName = g.getRecognizerName();
- return recognizerName+extST.render();
- }
+ public String getRecognizerFileName() { return getRecognizerFileName(false); }
+ public String getListenerFileName() { return getListenerFileName(false); }
+ public String getVisitorFileName() { return getVisitorFileName(false); }
+ public String getBaseListenerFileName() { return getBaseListenerFileName(false); }
+ public String getBaseVisitorFileName() { return getBaseVisitorFileName(false); }
- /** A given grammar T, return the listener name such as
- * TListener.java, if we're using the Java target.
- */
- public String getListenerFileName() {
- assert g.name != null;
- ST extST = getTemplates().getInstanceOf("codeFileExtension");
- String listenerName = g.name + "Listener";
- return listenerName+extST.render();
- }
-
- /** A given grammar T, return the visitor name such as
- * TVisitor.java, if we're using the Java target.
- */
- public String getVisitorFileName() {
- assert g.name != null;
- ST extST = getTemplates().getInstanceOf("codeFileExtension");
- String listenerName = g.name + "Visitor";
- return listenerName+extST.render();
- }
-
- /** A given grammar T, return a blank listener implementation
- * such as TBaseListener.java, if we're using the Java target.
- */
- public String getBaseListenerFileName() {
- assert g.name != null;
- ST extST = getTemplates().getInstanceOf("codeFileExtension");
- String listenerName = g.name + "BaseListener";
- return listenerName+extST.render();
- }
-
- /** A given grammar T, return a blank listener implementation
- * such as TBaseListener.java, if we're using the Java target.
- */
- public String getBaseVisitorFileName() {
- assert g.name != null;
- ST extST = getTemplates().getInstanceOf("codeFileExtension");
- String listenerName = g.name + "BaseVisitor";
- return listenerName+extST.render();
- }
+ public String getRecognizerFileName(boolean header) { return getTarget().getRecognizerFileName(header); }
+ public String getListenerFileName(boolean header) { return getTarget().getListenerFileName(header); }
+ public String getVisitorFileName(boolean header) { return getTarget().getVisitorFileName(header); }
+ public String getBaseListenerFileName(boolean header) { return getTarget().getBaseListenerFileName(header); }
+ public String getBaseVisitorFileName(boolean header) { return getTarget().getBaseVisitorFileName(header); }
/** What is the name of the vocab file generated for this grammar?
* Returns null if no .tokens file should be generated.
diff --git a/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java
index e07180e..53cf2ea 100644
--- a/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java
+++ b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java b/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java
index c8a1498..3f84914 100644
--- a/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java
+++ b/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/LexerFactory.java b/tool/src/org/antlr/v4/codegen/LexerFactory.java
index add1c8c..b071861 100644
--- a/tool/src/org/antlr/v4/codegen/LexerFactory.java
+++ b/tool/src/org/antlr/v4/codegen/LexerFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/OutputModelController.java b/tool/src/org/antlr/v4/codegen/OutputModelController.java
index 6b0d9db..8a38b66 100644
--- a/tool/src/org/antlr/v4/codegen/OutputModelController.java
+++ b/tool/src/org/antlr/v4/codegen/OutputModelController.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
@@ -107,24 +83,23 @@ public class OutputModelController {
* controller as factory in SourceGenTriggers so it triggers codegen
* extensions too, not just the factory functions in this factory.
*/
- public OutputModelObject buildParserOutputModel() {
- Grammar g = delegate.getGrammar();
+ public OutputModelObject buildParserOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- ParserFile file = parserFile(gen.getRecognizerFileName());
+ ParserFile file = parserFile(gen.getRecognizerFileName(header));
setRoot(file);
- Parser parser = parser(file);
- file.parser = parser;
+ file.parser = parser(file);
+ Grammar g = delegate.getGrammar();
for (Rule r : g.rules.values()) {
- buildRuleFunction(parser, r);
+ buildRuleFunction(file.parser, r);
}
return file;
}
- public OutputModelObject buildLexerOutputModel() {
+ public OutputModelObject buildLexerOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- LexerFile file = lexerFile(gen.getRecognizerFileName());
+ LexerFile file = lexerFile(gen.getRecognizerFileName(header));
setRoot(file);
file.lexer = lexer(file);
@@ -136,24 +111,24 @@ public class OutputModelController {
return file;
}
- public OutputModelObject buildListenerOutputModel() {
+ public OutputModelObject buildListenerOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- return new ListenerFile(delegate, gen.getListenerFileName());
+ return new ListenerFile(delegate, gen.getListenerFileName(header));
}
- public OutputModelObject buildBaseListenerOutputModel() {
+ public OutputModelObject buildBaseListenerOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- return new BaseListenerFile(delegate, gen.getBaseListenerFileName());
+ return new BaseListenerFile(delegate, gen.getBaseListenerFileName(header));
}
- public OutputModelObject buildVisitorOutputModel() {
+ public OutputModelObject buildVisitorOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- return new VisitorFile(delegate, gen.getVisitorFileName());
+ return new VisitorFile(delegate, gen.getVisitorFileName(header));
}
- public OutputModelObject buildBaseVisitorOutputModel() {
+ public OutputModelObject buildBaseVisitorOutputModel(boolean header) {
CodeGenerator gen = delegate.getGenerator();
- return new BaseVisitorFile(delegate, gen.getBaseVisitorFileName());
+ return new BaseVisitorFile(delegate, gen.getBaseVisitorFileName(header));
}
public ParserFile parserFile(String fileName) {
diff --git a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java
index 86f9ae0..cab452d 100644
--- a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java
+++ b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/OutputModelWalker.java b/tool/src/org/antlr/v4/codegen/OutputModelWalker.java
index 486efd1..fc3d80b 100644
--- a/tool/src/org/antlr/v4/codegen/OutputModelWalker.java
+++ b/tool/src/org/antlr/v4/codegen/OutputModelWalker.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
@@ -75,7 +51,7 @@ public class OutputModelWalker {
this.templates = templates;
}
- public ST walk(OutputModelObject omo) {
+ public ST walk(OutputModelObject omo, boolean header) {
// CREATE TEMPLATE FOR THIS OUTPUT OBJECT
Class<? extends OutputModelObject> cl = omo.getClass();
String templateName = cl.getSimpleName();
@@ -83,6 +59,9 @@ public class OutputModelWalker {
tool.errMgr.toolError(ErrorType.NO_MODEL_TO_TEMPLATE_MAPPING, cl.getSimpleName());
return new ST("["+templateName+" invalid]");
}
+
+ if (header) templateName += "Header";
+
ST st = templates.getInstanceOf(templateName);
if ( st == null ) {
tool.errMgr.toolError(ErrorType.CODE_GEN_TEMPLATES_INCOMPLETE, templateName);
@@ -124,7 +103,7 @@ public class OutputModelWalker {
Object o = fi.get(omo);
if ( o instanceof OutputModelObject ) { // SINGLE MODEL OBJECT?
OutputModelObject nestedOmo = (OutputModelObject)o;
- ST nestedST = walk(nestedOmo);
+ ST nestedST = walk(nestedOmo, header);
// System.out.println("set ModelElement "+fieldName+"="+nestedST+" in "+templateName);
st.add(fieldName, nestedST);
}
@@ -136,7 +115,7 @@ public class OutputModelWalker {
Collection<?> nestedOmos = (Collection<?>)o;
for (Object nestedOmo : nestedOmos) {
if ( nestedOmo==null ) continue;
- ST nestedST = walk((OutputModelObject)nestedOmo);
+ ST nestedST = walk((OutputModelObject)nestedOmo, header);
// System.out.println("set ModelElement "+fieldName+"="+nestedST+" in "+templateName);
st.add(fieldName, nestedST);
}
@@ -145,7 +124,7 @@ public class OutputModelWalker {
Map<?, ?> nestedOmoMap = (Map<?, ?>)o;
Map<Object, ST> m = new LinkedHashMap<Object, ST>();
for (Map.Entry<?, ?> entry : nestedOmoMap.entrySet()) {
- ST nestedST = walk((OutputModelObject)entry.getValue());
+ ST nestedST = walk((OutputModelObject)entry.getValue(), header);
// System.out.println("set ModelElement "+fieldName+"="+nestedST+" in "+templateName);
m.put(entry.getKey(), nestedST);
}
diff --git a/tool/src/org/antlr/v4/codegen/ParserFactory.java b/tool/src/org/antlr/v4/codegen/ParserFactory.java
index dfb33f5..4086886 100644
--- a/tool/src/org/antlr/v4/codegen/ParserFactory.java
+++ b/tool/src/org/antlr/v4/codegen/ParserFactory.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g
index de3154f..85e3dc4 100644
--- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g
+++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java
index 3d4a93a..9a2fc5d 100644
--- a/tool/src/org/antlr/v4/codegen/Target.java
+++ b/tool/src/org/antlr/v4/codegen/Target.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
@@ -64,7 +40,7 @@ public abstract class Target {
*/
protected String[] targetCharValueEscape = new String[255];
- private final CodeGenerator gen;
+ protected final CodeGenerator gen;
private final String language;
private STGroup templates;
@@ -99,7 +75,6 @@ public abstract class Target {
*/
public abstract String getVersion();
-
public STGroup getTemplates() {
if (templates == null) {
String version = getVersion();
@@ -114,27 +89,11 @@ public abstract class Target {
return templates;
}
- protected void genFile(Grammar g,
- ST outputFileST,
- String fileName)
- {
- getCodeGenerator().write(outputFileST, fileName);
- }
-
- protected void genListenerFile(Grammar g,
- ST outputFileST)
+ protected void genFile(Grammar g, ST outputFileST, String fileName)
{
- String fileName = getCodeGenerator().getListenerFileName();
getCodeGenerator().write(outputFileST, fileName);
}
- protected void genRecognizerHeaderFile(Grammar g,
- ST headerFileST,
- String extName) // e.g., ".h"
- {
- // no header file by default
- }
-
/** Get a meaningful name for a token type useful during code generation.
* Literals without associated names are converted to the string equivalent
* of their integer values. Used to generate x==ID and x==34 type comparisons
@@ -392,6 +351,55 @@ public abstract class Target {
return getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
}
+ /** Generate TParser.java and TLexer.java from T.g4 if combined, else
+ * just use T.java as output regardless of type.
+ */
+ public String getRecognizerFileName(boolean header) {
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String recognizerName = gen.g.getRecognizerName();
+ return recognizerName+extST.render();
+ }
+
+ /** A given grammar T, return the listener name such as
+ * TListener.java, if we're using the Java target.
+ */
+ public String getListenerFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String listenerName = gen.g.name + "Listener";
+ return listenerName+extST.render();
+ }
+
+ /** A given grammar T, return the visitor name such as
+ * TVisitor.java, if we're using the Java target.
+ */
+ public String getVisitorFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String listenerName = gen.g.name + "Visitor";
+ return listenerName+extST.render();
+ }
+
+ /** A given grammar T, return a blank listener implementation
+ * such as TBaseListener.java, if we're using the Java target.
+ */
+ public String getBaseListenerFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String listenerName = gen.g.name + "BaseListener";
+ return listenerName+extST.render();
+ }
+
+ /** A given grammar T, return a blank listener implementation
+ * such as TBaseListener.java, if we're using the Java target.
+ */
+ public String getBaseVisitorFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String listenerName = gen.g.name + "BaseVisitor";
+ return listenerName+extST.render();
+ }
+
/**
* Gets the maximum number of 16-bit unsigned integers that can be encoded
* in a single segment of the serialized ATN.
@@ -524,4 +532,7 @@ public abstract class Target {
public boolean supportsOverloadedMethods() {
return true;
}
+
+ /** @since 4.6 */
+ public boolean needsHeader() { return false; }; // Override in targets that need header files.
}
diff --git a/tool/src/org/antlr/v4/codegen/Wildcard.java b/tool/src/org/antlr/v4/codegen/Wildcard.java
index 5cff64e..6537cc7 100644
--- a/tool/src/org/antlr/v4/codegen/Wildcard.java
+++ b/tool/src/org/antlr/v4/codegen/Wildcard.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen;
diff --git a/tool/src/org/antlr/v4/codegen/model/Action.java b/tool/src/org/antlr/v4/codegen/model/Action.java
index 0b9c692..5e1e0ef 100644
--- a/tool/src/org/antlr/v4/codegen/model/Action.java
+++ b/tool/src/org/antlr/v4/codegen/model/Action.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java b/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java
index 066b858..a492ee9 100644
--- a/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java
+++ b/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/AltBlock.java b/tool/src/org/antlr/v4/codegen/model/AltBlock.java
index b3459e9..a632921 100644
--- a/tool/src/org/antlr/v4/codegen/model/AltBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/AltBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ArgAction.java b/tool/src/org/antlr/v4/codegen/model/ArgAction.java
index 38ef4d9..c52c72c 100644
--- a/tool/src/org/antlr/v4/codegen/model/ArgAction.java
+++ b/tool/src/org/antlr/v4/codegen/model/ArgAction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/BaseListenerFile.java b/tool/src/org/antlr/v4/codegen/model/BaseListenerFile.java
index 505d505..206fcee 100644
--- a/tool/src/org/antlr/v4/codegen/model/BaseListenerFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/BaseListenerFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/BaseVisitorFile.java b/tool/src/org/antlr/v4/codegen/model/BaseVisitorFile.java
index 62e669b..9fff357 100644
--- a/tool/src/org/antlr/v4/codegen/model/BaseVisitorFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/BaseVisitorFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/CaptureNextToken.java b/tool/src/org/antlr/v4/codegen/model/CaptureNextToken.java
index 63dd3db..de49cdc 100644
--- a/tool/src/org/antlr/v4/codegen/model/CaptureNextToken.java
+++ b/tool/src/org/antlr/v4/codegen/model/CaptureNextToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/CaptureNextTokenType.java b/tool/src/org/antlr/v4/codegen/model/CaptureNextTokenType.java
index ffb4cfc..094d941 100644
--- a/tool/src/org/antlr/v4/codegen/model/CaptureNextTokenType.java
+++ b/tool/src/org/antlr/v4/codegen/model/CaptureNextTokenType.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/Choice.java b/tool/src/org/antlr/v4/codegen/model/Choice.java
index bef2c45..9fb8a46 100644
--- a/tool/src/org/antlr/v4/codegen/model/Choice.java
+++ b/tool/src/org/antlr/v4/codegen/model/Choice.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/CodeBlockForAlt.java b/tool/src/org/antlr/v4/codegen/model/CodeBlockForAlt.java
index 7c2c8b7..12023a7 100644
--- a/tool/src/org/antlr/v4/codegen/model/CodeBlockForAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/CodeBlockForAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/CodeBlockForOuterMostAlt.java b/tool/src/org/antlr/v4/codegen/model/CodeBlockForOuterMostAlt.java
index 856d15a..ef3e9d6 100644
--- a/tool/src/org/antlr/v4/codegen/model/CodeBlockForOuterMostAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/CodeBlockForOuterMostAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/DispatchMethod.java b/tool/src/org/antlr/v4/codegen/model/DispatchMethod.java
index ab119f6..f7b3290 100644
--- a/tool/src/org/antlr/v4/codegen/model/DispatchMethod.java
+++ b/tool/src/org/antlr/v4/codegen/model/DispatchMethod.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java b/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java
index 2226d37..ab5b86d 100644
--- a/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java
+++ b/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.codegen.model;
import org.antlr.runtime.tree.TreeNodeStream;
@@ -65,7 +71,7 @@ public class ElementFrequenciesVisitor extends GrammarTreeVisitor {
* @param b The second set.
* @param clip The maximum value to allow for any output.
* @return The sum of the two sets, with the individual elements clipped
- * to the maximum value gived by {@code clip}.
+ * to the maximum value given by {@code clip}.
*/
protected static FrequencySet<String> combineAndClip(FrequencySet<String> a, FrequencySet<String> b, int clip) {
FrequencySet<String> result = new FrequencySet<String>();
diff --git a/tool/src/org/antlr/v4/codegen/model/ExceptionClause.java b/tool/src/org/antlr/v4/codegen/model/ExceptionClause.java
index 3009a7d..0eb7ddc 100644
--- a/tool/src/org/antlr/v4/codegen/model/ExceptionClause.java
+++ b/tool/src/org/antlr/v4/codegen/model/ExceptionClause.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java
index 70c9f29..bf83499 100644
--- a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java
+++ b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java
index 1bac9a4..3437388 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java
index 3153ad9..9ef47d2 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java
index 6cd0779..839a14d 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java
index 74ca312..80f8d0b 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java
index eacfd5a..50579ca 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java
index a7076ce..227753f 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java
index 4c1bf94..fb787c1 100644
--- a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LabeledOp.java b/tool/src/org/antlr/v4/codegen/model/LabeledOp.java
index 26ad2d3..b8d5441 100644
--- a/tool/src/org/antlr/v4/codegen/model/LabeledOp.java
+++ b/tool/src/org/antlr/v4/codegen/model/LabeledOp.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LeftRecursiveRuleFunction.java b/tool/src/org/antlr/v4/codegen/model/LeftRecursiveRuleFunction.java
index adbc3a6..abe3f7f 100644
--- a/tool/src/org/antlr/v4/codegen/model/LeftRecursiveRuleFunction.java
+++ b/tool/src/org/antlr/v4/codegen/model/LeftRecursiveRuleFunction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/Lexer.java b/tool/src/org/antlr/v4/codegen/model/Lexer.java
index ef44e4c..2bc103e 100644
--- a/tool/src/org/antlr/v4/codegen/model/Lexer.java
+++ b/tool/src/org/antlr/v4/codegen/model/Lexer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/LexerFile.java b/tool/src/org/antlr/v4/codegen/model/LexerFile.java
index 8bec073..3fae78b 100644
--- a/tool/src/org/antlr/v4/codegen/model/LexerFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/LexerFile.java
@@ -1,55 +1,29 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
import org.antlr.v4.codegen.OutputModelFactory;
-import org.antlr.v4.tool.Grammar;
-import org.antlr.v4.tool.ast.ActionAST;
-import java.util.HashMap;
import java.util.Map;
public class LexerFile extends OutputFile {
public String genPackage; // from -package cmd-line
+ public String exportMacro; // from -DexportMacro cmd-line
+ public boolean genListener; // from -listener cmd-line
+ public boolean genVisitor; // from -visitor cmd-line
@ModelElement public Lexer lexer;
@ModelElement public Map<String, Action> namedActions;
public LexerFile(OutputModelFactory factory, String fileName) {
super(factory, fileName);
- namedActions = new HashMap<String, Action>();
- Grammar g = factory.getGrammar();
- for (String name : g.namedActions.keySet()) {
- ActionAST ast = g.namedActions.get(name);
- namedActions.put(name, new Action(factory, ast));
- }
+ namedActions = buildNamedActions(factory.getGrammar());
genPackage = factory.getGrammar().tool.genPackage;
+ exportMacro = factory.getGrammar().getOptionString("exportMacro");
+ genListener = factory.getGrammar().tool.gen_listener;
+ genVisitor = factory.getGrammar().tool.gen_visitor;
}
}
diff --git a/tool/src/org/antlr/v4/codegen/model/ListenerDispatchMethod.java b/tool/src/org/antlr/v4/codegen/model/ListenerDispatchMethod.java
index 9332d13..cc861f0 100644
--- a/tool/src/org/antlr/v4/codegen/model/ListenerDispatchMethod.java
+++ b/tool/src/org/antlr/v4/codegen/model/ListenerDispatchMethod.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ListenerFile.java b/tool/src/org/antlr/v4/codegen/model/ListenerFile.java
index 99f6ebf..24efd74 100644
--- a/tool/src/org/antlr/v4/codegen/model/ListenerFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/ListenerFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
@@ -47,6 +23,7 @@ import java.util.Set;
*/
public class ListenerFile extends OutputFile {
public String genPackage; // from -package cmd-line
+ public String exportMacro; // from -DexportMacro cmd-line
public String grammarName;
public String parserName;
/**
@@ -61,12 +38,14 @@ public class ListenerFile extends OutputFile {
public Map<String, String> listenerLabelRuleNames = new LinkedHashMap<String, String>();
@ModelElement public Action header;
+ @ModelElement public Map<String, Action> namedActions;
public ListenerFile(OutputModelFactory factory, String fileName) {
super(factory, fileName);
Grammar g = factory.getGrammar();
parserName = g.getRecognizerName();
grammarName = g.name;
+ namedActions = buildNamedActions(factory.getGrammar());
for (Rule r : g.rules.values()) {
Map<String, List<Pair<Integer,AltAST>>> labels = r.getAltLabels();
if ( labels!=null ) {
@@ -83,5 +62,6 @@ public class ListenerFile extends OutputFile {
ActionAST ast = g.namedActions.get("header");
if ( ast!=null ) header = new Action(factory, ast);
genPackage = factory.getGrammar().tool.genPackage;
+ exportMacro = factory.getGrammar().getOptionString("exportMacro");
}
}
diff --git a/tool/src/org/antlr/v4/codegen/model/Loop.java b/tool/src/org/antlr/v4/codegen/model/Loop.java
index 50fbd6f..695685e 100644
--- a/tool/src/org/antlr/v4/codegen/model/Loop.java
+++ b/tool/src/org/antlr/v4/codegen/model/Loop.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java b/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java
index 8df741c..4b86f5e 100644
--- a/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java
+++ b/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/MatchSet.java b/tool/src/org/antlr/v4/codegen/model/MatchSet.java
index e6d02a1..ab1f798 100644
--- a/tool/src/org/antlr/v4/codegen/model/MatchSet.java
+++ b/tool/src/org/antlr/v4/codegen/model/MatchSet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/MatchToken.java b/tool/src/org/antlr/v4/codegen/model/MatchToken.java
index 8405e78..5399113 100644
--- a/tool/src/org/antlr/v4/codegen/model/MatchToken.java
+++ b/tool/src/org/antlr/v4/codegen/model/MatchToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ModelElement.java b/tool/src/org/antlr/v4/codegen/model/ModelElement.java
index 0dc38c2..a0401de 100644
--- a/tool/src/org/antlr/v4/codegen/model/ModelElement.java
+++ b/tool/src/org/antlr/v4/codegen/model/ModelElement.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java
index c1f2cb3..50b8fe3 100644
--- a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/OutputFile.java b/tool/src/org/antlr/v4/codegen/model/OutputFile.java
index 16b2384..e238dae 100644
--- a/tool/src/org/antlr/v4/codegen/model/OutputFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/OutputFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
@@ -33,6 +9,10 @@ package org.antlr.v4.codegen.model;
import org.antlr.v4.Tool;
import org.antlr.v4.codegen.OutputModelFactory;
import org.antlr.v4.tool.Grammar;
+import org.antlr.v4.tool.ast.ActionAST;
+
+import java.util.HashMap;
+import java.util.Map;
public abstract class OutputFile extends OutputModelObject {
public final String fileName;
@@ -50,4 +30,13 @@ public abstract class OutputFile extends OutputModelObject {
TokenLabelType = g.getOptionString("TokenLabelType");
InputSymbolType = TokenLabelType;
}
+
+ public Map<String, Action> buildNamedActions(Grammar g) {
+ Map<String, Action> namedActions = new HashMap<String, Action>();
+ for (String name : g.namedActions.keySet()) {
+ ActionAST ast = g.namedActions.get(name);
+ namedActions.put(name, new Action(factory, ast));
+ }
+ return namedActions;
+ }
}
diff --git a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java
index 6f793be..5cfb1ee 100644
--- a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java
+++ b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/Parser.java b/tool/src/org/antlr/v4/codegen/model/Parser.java
index 770d904..298bcff 100644
--- a/tool/src/org/antlr/v4/codegen/model/Parser.java
+++ b/tool/src/org/antlr/v4/codegen/model/Parser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ParserFile.java b/tool/src/org/antlr/v4/codegen/model/ParserFile.java
index 808d4f9..49181dd 100644
--- a/tool/src/org/antlr/v4/codegen/model/ParserFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/ParserFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
@@ -34,31 +10,27 @@ import org.antlr.v4.codegen.OutputModelFactory;
import org.antlr.v4.codegen.model.chunk.ActionChunk;
import org.antlr.v4.codegen.model.chunk.ActionText;
import org.antlr.v4.tool.Grammar;
-import org.antlr.v4.tool.ast.ActionAST;
-import java.util.HashMap;
import java.util.Map;
/** */
public class ParserFile extends OutputFile {
public String genPackage; // from -package cmd-line
+ public String exportMacro; // from -DexportMacro cmd-line
+ public boolean genListener; // from -listener cmd-line
+ public boolean genVisitor; // from -visitor cmd-line
@ModelElement public Parser parser;
@ModelElement public Map<String, Action> namedActions;
@ModelElement public ActionChunk contextSuperClass;
- public Boolean genListener = false;
- public Boolean genVisitor = false;
public String grammarName;
public ParserFile(OutputModelFactory factory, String fileName) {
super(factory, fileName);
Grammar g = factory.getGrammar();
- namedActions = new HashMap<String, Action>();
- for (String name : g.namedActions.keySet()) {
- ActionAST ast = g.namedActions.get(name);
- namedActions.put(name, new Action(factory, ast));
- }
+ namedActions = buildNamedActions(factory.getGrammar());
genPackage = g.tool.genPackage;
- // need the below members in the ST for Python
+ exportMacro = factory.getGrammar().getOptionString("exportMacro");
+ // need the below members in the ST for Python, C++
genListener = g.tool.gen_listener;
genVisitor = g.tool.gen_visitor;
grammarName = g.name;
diff --git a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java
index a200d30..088089c 100644
--- a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/Recognizer.java b/tool/src/org/antlr/v4/codegen/model/Recognizer.java
index 7e3f95b..723dd08 100644
--- a/tool/src/org/antlr/v4/codegen/model/Recognizer.java
+++ b/tool/src/org/antlr/v4/codegen/model/Recognizer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
@@ -40,6 +16,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -55,10 +32,10 @@ public abstract class Recognizer extends OutputModelObject {
* {@link #literalNames} and {@link #symbolicNames}.
*/
@Deprecated
- public String[] tokenNames;
+ public List<String> tokenNames;
- public String[] literalNames;
- public String[] symbolicNames;
+ public List<String> literalNames;
+ public List<String> symbolicNames;
public Set<String> ruleNames;
public Collection<Rule> rules;
@ModelElement public ActionChunk superClass;
@@ -98,7 +75,7 @@ public abstract class Recognizer extends OutputModelObject {
symbolicNames = translateTokenStringsToTarget(g.getTokenSymbolicNames(), gen);
}
- protected static String[] translateTokenStringsToTarget(String[] tokenStrings, CodeGenerator gen) {
+ protected static List<String> translateTokenStringsToTarget(String[] tokenStrings, CodeGenerator gen) {
String[] result = tokenStrings.clone();
for (int i = 0; i < tokenStrings.length; i++) {
result[i] = translateTokenStringToTarget(tokenStrings[i], gen);
@@ -113,7 +90,7 @@ public abstract class Recognizer extends OutputModelObject {
result = Arrays.copyOf(result, lastTrueEntry + 1);
}
- return result;
+ return Arrays.asList(result);
}
protected static String translateTokenStringToTarget(String tokenName, CodeGenerator gen) {
diff --git a/tool/src/org/antlr/v4/codegen/model/RuleActionFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleActionFunction.java
index 8e65462..624ffd4 100644
--- a/tool/src/org/antlr/v4/codegen/model/RuleActionFunction.java
+++ b/tool/src/org/antlr/v4/codegen/model/RuleActionFunction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/RuleElement.java b/tool/src/org/antlr/v4/codegen/model/RuleElement.java
index c2b2f52..ba0c0c0 100644
--- a/tool/src/org/antlr/v4/codegen/model/RuleElement.java
+++ b/tool/src/org/antlr/v4/codegen/model/RuleElement.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java
index 25d6d0f..d6e165e 100644
--- a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java
+++ b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/RuleSempredFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleSempredFunction.java
index 2b1f6a1..aba9d7e 100644
--- a/tool/src/org/antlr/v4/codegen/model/RuleSempredFunction.java
+++ b/tool/src/org/antlr/v4/codegen/model/RuleSempredFunction.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/SemPred.java b/tool/src/org/antlr/v4/codegen/model/SemPred.java
index 605091f..e42649b 100644
--- a/tool/src/org/antlr/v4/codegen/model/SemPred.java
+++ b/tool/src/org/antlr/v4/codegen/model/SemPred.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java
index ae64c43..6a1094e 100644
--- a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java
+++ b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/SrcOp.java b/tool/src/org/antlr/v4/codegen/model/SrcOp.java
index d4a9834..ff9bd9d 100644
--- a/tool/src/org/antlr/v4/codegen/model/SrcOp.java
+++ b/tool/src/org/antlr/v4/codegen/model/SrcOp.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/StarBlock.java b/tool/src/org/antlr/v4/codegen/model/StarBlock.java
index e61ef72..41b49f2 100644
--- a/tool/src/org/antlr/v4/codegen/model/StarBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/StarBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/Sync.java b/tool/src/org/antlr/v4/codegen/model/Sync.java
index b9c20fc..db5287e 100644
--- a/tool/src/org/antlr/v4/codegen/model/Sync.java
+++ b/tool/src/org/antlr/v4/codegen/model/Sync.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java
index 0b3956c..d4c9381 100644
--- a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java
+++ b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java
index 17f8574..efadf44 100644
--- a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java
+++ b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java
index eb07be7..7bb6bbd 100644
--- a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java
+++ b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java
index 8815764..6653038 100644
--- a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java
+++ b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/VisitorDispatchMethod.java b/tool/src/org/antlr/v4/codegen/model/VisitorDispatchMethod.java
index a56dc6e..90c6e82 100644
--- a/tool/src/org/antlr/v4/codegen/model/VisitorDispatchMethod.java
+++ b/tool/src/org/antlr/v4/codegen/model/VisitorDispatchMethod.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/VisitorFile.java b/tool/src/org/antlr/v4/codegen/model/VisitorFile.java
index e1370a9..4abcdb1 100644
--- a/tool/src/org/antlr/v4/codegen/model/VisitorFile.java
+++ b/tool/src/org/antlr/v4/codegen/model/VisitorFile.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
@@ -44,6 +20,7 @@ import java.util.Set;
public class VisitorFile extends OutputFile {
public String genPackage; // from -package cmd-line
+ public String exportMacro; // from -DexportMacro cmd-line
public String grammarName;
public String parserName;
/**
@@ -58,10 +35,12 @@ public class VisitorFile extends OutputFile {
public Map<String, String> visitorLabelRuleNames = new LinkedHashMap<String, String>();
@ModelElement public Action header;
+ @ModelElement public Map<String, Action> namedActions;
public VisitorFile(OutputModelFactory factory, String fileName) {
super(factory, fileName);
Grammar g = factory.getGrammar();
+ namedActions = buildNamedActions(g);
parserName = g.getRecognizerName();
grammarName = g.name;
for (Rule r : g.rules.values()) {
@@ -80,5 +59,6 @@ public class VisitorFile extends OutputFile {
ActionAST ast = g.namedActions.get("header");
if ( ast!=null ) header = new Action(factory, ast);
genPackage = factory.getGrammar().tool.genPackage;
+ exportMacro = factory.getGrammar().getOptionString("exportMacro");
}
}
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ActionChunk.java b/tool/src/org/antlr/v4/codegen/model/chunk/ActionChunk.java
index 3c7e364..36775b5 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ActionChunk.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ActionChunk.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ActionTemplate.java b/tool/src/org/antlr/v4/codegen/model/chunk/ActionTemplate.java
index 2c2edc1..861fd8f 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ActionTemplate.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ActionTemplate.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ActionText.java b/tool/src/org/antlr/v4/codegen/model/chunk/ActionText.java
index de3acff..b1c64c2 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ActionText.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ActionText.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ArgRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/ArgRef.java
index 2d39271..8544692 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ArgRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ArgRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/LabelRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/LabelRef.java
index eae4a65..5e5418b 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/LabelRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/LabelRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ListLabelRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/ListLabelRef.java
index c7af76a..07dc911 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ListLabelRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ListLabelRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/LocalRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/LocalRef.java
index 3463dc8..6cf25ab 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/LocalRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/LocalRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/NonLocalAttrRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/NonLocalAttrRef.java
index d9a28f7..db6763f 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/NonLocalAttrRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/NonLocalAttrRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/QRetValueRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/QRetValueRef.java
index d799e78..245e77a 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/QRetValueRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/QRetValueRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RetValueRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/RetValueRef.java
index 59e45fe..07dfe64 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RetValueRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RetValueRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef.java
index ae14863..ded613f 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_ctx.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_ctx.java
index aebded7..26301a0 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_ctx.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_ctx.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_parser.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_parser.java
index a427810..16646b9 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_parser.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_parser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_start.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_start.java
index 826c5d0..ef485e5 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_start.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_start.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_stop.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_stop.java
index 7b9e3f2..d649967 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_stop.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_stop.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_text.java b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_text.java
index 1230105..f3d0a08 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_text.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/RulePropertyRef_text.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/SetAttr.java b/tool/src/org/antlr/v4/codegen/model/chunk/SetAttr.java
index 1b6e15b..6c5755c 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/SetAttr.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/SetAttr.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/SetNonLocalAttr.java b/tool/src/org/antlr/v4/codegen/model/chunk/SetNonLocalAttr.java
index 9872b6e..c2e7924 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/SetNonLocalAttr.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/SetNonLocalAttr.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_ctx.java b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_ctx.java
index e8dc913..0293664 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_ctx.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_ctx.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_parser.java b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_parser.java
index 7cbf5d6..22fc377 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_parser.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_parser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_start.java b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_start.java
index 614c973..c4cafec 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_start.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_start.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_stop.java b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_stop.java
index 65b5322..ea51694 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_stop.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_stop.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_text.java b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_text.java
index 7ee4d8e..696066a 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_text.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/ThisRulePropertyRef_text.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef.java
index 8a3f7d5..82c2f69 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_channel.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_channel.java
index 9c93690..1404bf9 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_channel.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_channel.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_index.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_index.java
index a456876..bb92a20 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_index.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_index.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_int.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_int.java
index 91c13bd..b02053f 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_int.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_int.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_line.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_line.java
index f9c08f4..0229204 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_line.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_line.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_pos.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_pos.java
index 469b228..7badb92 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_pos.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_pos.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_text.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_text.java
index 3da4f53..d049c6e 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_text.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_text.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_type.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_type.java
index d495e19..a8b4222 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_type.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenPropertyRef_type.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/chunk/TokenRef.java b/tool/src/org/antlr/v4/codegen/model/chunk/TokenRef.java
index ac2569b..d39115d 100644
--- a/tool/src/org/antlr/v4/codegen/model/chunk/TokenRef.java
+++ b/tool/src/org/antlr/v4/codegen/model/chunk/TokenRef.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.chunk;
diff --git a/tool/src/org/antlr/v4/codegen/model/dbg.java b/tool/src/org/antlr/v4/codegen/model/dbg.java
index 4eb8386..0aaeebf 100644
--- a/tool/src/org/antlr/v4/codegen/model/dbg.java
+++ b/tool/src/org/antlr/v4/codegen/model/dbg.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java
index f48f45d..b855b28 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java
index 7b77ecd..80af232 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/CodeBlock.java b/tool/src/org/antlr/v4/codegen/model/decl/CodeBlock.java
index 8a0890e..89e1f20 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/CodeBlock.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/CodeBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextGetterDecl.java
index 99ceef2..fc4b262 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleGetterDecl.java
index 2bb4f9b..b763965 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListGetterDecl.java
index c3bfae9..4daf182 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListIndexedGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListIndexedGetterDecl.java
index a2c3948..175394f 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListIndexedGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextRuleListIndexedGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenGetterDecl.java
index 431e817..d663181 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListGetterDecl.java
index d293720..7c8e2ff 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListIndexedGetterDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListIndexedGetterDecl.java
index ff7e48e..bc722c9 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListIndexedGetterDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ContextTokenListIndexedGetterDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/Decl.java b/tool/src/org/antlr/v4/codegen/model/decl/Decl.java
index c956555..2cbcf9c 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/Decl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/Decl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/ElementListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/ElementListDecl.java
index cf99a1a..f5fa1bb 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/ElementListDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/ElementListDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java
index 6f97bfa..a6c7eff 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java
index fbd22f6..8418dbf 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java
index 309d6ca..14a764c 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
@@ -57,6 +33,16 @@ public class StructDecl extends Decl {
@ModelElement public List<OutputModelObject> interfaces;
@ModelElement public List<OutputModelObject> extensionMembers;
+ // Track these separately; Go target needs to generate getters/setters
+ // Do not make them templates; we only need the Decl object not the ST
+ // built from it. Avoids adding args to StructDecl template
+ public OrderedHashSet<Decl> tokenDecls = new OrderedHashSet<Decl>();
+ public OrderedHashSet<Decl> tokenTypeDecls = new OrderedHashSet<Decl>();
+ public OrderedHashSet<Decl> tokenListDecls = new OrderedHashSet<Decl>();
+ public OrderedHashSet<Decl> ruleContextDecls = new OrderedHashSet<Decl>();
+ public OrderedHashSet<Decl> ruleContextListDecls = new OrderedHashSet<Decl>();
+ public OrderedHashSet<Decl> attributeDecls = new OrderedHashSet<Decl>();
+
public StructDecl(OutputModelFactory factory, Rule r) {
super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r));
addDispatchMethods(r);
@@ -80,8 +66,29 @@ public class StructDecl extends Decl {
public void addDecl(Decl d) {
d.ctx = this;
+
if ( d instanceof ContextGetterDecl ) getters.add(d);
else attrs.add(d);
+
+ // add to specific "lists"
+ if ( d instanceof TokenTypeDecl ) {
+ tokenTypeDecls.add(d);
+ }
+ else if ( d instanceof TokenListDecl ) {
+ tokenListDecls.add(d);
+ }
+ else if ( d instanceof TokenDecl ) {
+ tokenDecls.add(d);
+ }
+ else if ( d instanceof RuleContextListDecl ) {
+ ruleContextListDecls.add(d);
+ }
+ else if ( d instanceof RuleContextDecl ) {
+ ruleContextDecls.add(d);
+ }
+ else if ( d instanceof AttributeDecl ) {
+ attributeDecls.add(d);
+ }
}
public void addDecl(Attribute a) {
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java
index 0971fb0..6545125 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java
index 37b7b0e..ecbfac7 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java
index 2762ba3..c13ce63 100644
--- a/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java
+++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.model.decl;
diff --git a/tool/src/org/antlr/v4/codegen/target/CSharpTarget.java b/tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
index b4aa584..88d1438 100644
--- a/tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
+++ b/tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.target;
@@ -51,7 +27,7 @@ public class CSharpTarget extends Target {
@Override
public String getVersion() {
- return "4.5.3";
+ return "4.6";
}
@Override
diff --git a/tool/src/org/antlr/v4/codegen/target/CppTarget.java b/tool/src/org/antlr/v4/codegen/target/CppTarget.java
new file mode 100644
index 0000000..14ac858
--- /dev/null
+++ b/tool/src/org/antlr/v4/codegen/target/CppTarget.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.codegen.target;
+
+import org.antlr.v4.codegen.CodeGenerator;
+import org.antlr.v4.codegen.Target;
+import org.antlr.v4.tool.ErrorType;
+import org.antlr.v4.tool.ast.GrammarAST;
+import org.stringtemplate.v4.NumberRenderer;
+import org.stringtemplate.v4.ST;
+import org.stringtemplate.v4.STErrorListener;
+import org.stringtemplate.v4.STGroup;
+import org.stringtemplate.v4.StringRenderer;
+import org.stringtemplate.v4.misc.STMessage;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public class CppTarget extends Target {
+
+ protected static final String[] cppKeywords = {
+ "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand",
+ "bitor", "bool", "break", "case", "catch", "char", "char16_t",
+ "char32_t", "class", "compl", "concept", "const", "constexpr",
+ "const_cast", "continue", "decltype", "default", "delete", "do",
+ "double", "dynamic_cast", "else", "enum", "explicit", "export",
+ "extern", "false", "float", "for", "friend", "goto", "if",
+ "inline", "int", "long", "mutable", "namespace", "new",
+ "noexcept", "not", "not_eq", "nullptr", "operator", "or",
+ "or_eq", "private", "protected", "public", "register",
+ "reinterpret_cast", "requires", "return", "short", "signed",
+ "sizeof", "static", "static_assert", "static_cast", "struct",
+ "switch", "template", "this", "thread_local", "throw", "true",
+ "try", "typedef", "typeid", "typename", "union", "unsigned",
+ "using", "virtual", "void", "volatile", "wchar_t", "while",
+ "xor", "xor_eq"
+ };
+
+ /** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */
+ protected final Set<String> badWords = new HashSet<String>();
+
+ public CppTarget(CodeGenerator gen) {
+ super(gen, "Cpp");
+ }
+
+ public String getVersion() {
+ return "4.6";
+ }
+
+ public boolean needsHeader() { return true; }
+
+ public Set<String> getBadWords() {
+ if (badWords.isEmpty()) {
+ addBadWords();
+ }
+
+ return badWords;
+ }
+
+ protected void addBadWords() {
+ badWords.addAll(Arrays.asList(cppKeywords));
+ badWords.add("rule");
+ badWords.add("parserRule");
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p/>
+ * For C++, this is the translation {@code 'a\n"'} &rarr; {@code "a\n\""}.
+ * Expect single quotes around the incoming literal. Just flip the quotes
+ * and replace double quotes with {@code \"}.
+ * <p/>
+ * Note that we have decided to allow people to use '\"' without penalty, so
+ * we must build the target string in a loop as {@link String#replace}
+ * cannot handle both {@code \"} and {@code "} without a lot of messing
+ * around.
+ */
+ @Override
+ public String getTargetStringLiteralFromANTLRStringLiteral(
+ CodeGenerator generator,
+ String literal, boolean addQuotes)
+ {
+ StringBuilder sb = new StringBuilder();
+ String is = literal;
+
+ if ( addQuotes ) sb.append('"');
+
+ for (int i = 1; i < is.length() -1; i++) {
+ if (is.charAt(i) == '\\') {
+ // Anything escaped is what it is! We assume that
+ // people know how to escape characters correctly. However
+ // we catch anything that does not need an escape in Java (which
+ // is what the default implementation is dealing with and remove
+ // the escape. The C target does this for instance.
+ //
+ switch (is.charAt(i+1)) {
+ // Pass through any escapes that Java also needs
+ //
+ case '"':
+ case 'n':
+ case 'r':
+ case 't':
+ case 'b':
+ case 'f':
+ case '\\':
+ // Pass the escape through
+ sb.append('\\');
+ break;
+
+ case 'u': // Assume unnnn
+ // Pass the escape through as double \\
+ // so that Java leaves as \u0000 string not char
+ sb.append('\\');
+ sb.append('\\');
+ break;
+
+ default:
+ // Remove the escape by virtue of not adding it here
+ // Thus \' becomes ' and so on
+ break;
+ }
+
+ // Go past the \ character
+ i++;
+ } else {
+ // Characters that don't need \ in ANTLR 'strings' but do in Java
+ if (is.charAt(i) == '"') {
+ // We need to escape " in Java
+ sb.append('\\');
+ }
+ }
+ // Add in the next character, which may have been escaped
+ sb.append(is.charAt(i));
+ }
+
+ if ( addQuotes ) sb.append('"');
+
+ return sb.toString();
+ }
+
+ @Override
+ public String encodeIntAsCharEscape(int v) {
+ return "0x" + Integer.toHexString(v) + ", ";
+ }
+
+ @Override
+ public int getSerializedATNSegmentLimit() {
+ // 65535 is the class file format byte limit for a UTF-8 encoded string literal
+ // 3 is the maximum number of bytes it takes to encode a value in the range 0-0xFFFF
+ return 65535 / 3;
+ }
+
+ @Override
+ public String getRecognizerFileName(boolean header) {
+ ST extST = getTemplates().getInstanceOf(header ? "headerFileExtension" : "codeFileExtension");
+ String recognizerName = gen.g.getRecognizerName();
+ return recognizerName+extST.render();
+ }
+
+ @Override
+ public String getListenerFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf(header ? "headerFileExtension" : "codeFileExtension");
+ String listenerName = gen.g.name + "Listener";
+ return listenerName+extST.render();
+ }
+
+ @Override
+ public String getVisitorFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf(header ? "headerFileExtension" : "codeFileExtension");
+ String listenerName = gen.g.name + "Visitor";
+ return listenerName+extST.render();
+ }
+
+ @Override
+ public String getBaseListenerFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf(header ? "headerFileExtension" : "codeFileExtension");
+ String listenerName = gen.g.name + "BaseListener";
+ return listenerName+extST.render();
+ }
+
+ @Override
+ public String getBaseVisitorFileName(boolean header) {
+ assert gen.g.name != null;
+ ST extST = getTemplates().getInstanceOf(header ? "headerFileExtension" : "codeFileExtension");
+ String listenerName = gen.g.name + "BaseVisitor";
+ return listenerName+extST.render();
+ }
+
+ @Override
+ protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) {
+ return getBadWords().contains(idNode.getText());
+ }
+
+ @Override
+ protected STGroup loadTemplates() {
+ STGroup result = super.loadTemplates();
+ result.registerRenderer(Integer.class, new NumberRenderer());
+ result.registerRenderer(String.class, new StringRenderer());
+ result.setListener(new STErrorListener() {
+ @Override
+ public void compileTimeError(STMessage msg) {
+ reportError(msg);
+ }
+
+ @Override
+ public void runTimeError(STMessage msg) {
+ reportError(msg);
+ }
+
+ @Override
+ public void IOError(STMessage msg) {
+ reportError(msg);
+ }
+
+ @Override
+ public void internalError(STMessage msg) {
+ reportError(msg);
+ }
+
+ private void reportError(STMessage msg) {
+ getCodeGenerator().tool.errMgr.toolError(ErrorType.STRING_TEMPLATE_WARNING, msg.cause, msg.toString());
+ }
+ });
+
+ return result;
+ }
+}
diff --git a/tool/src/org/antlr/v4/codegen/target/GoTarget.java b/tool/src/org/antlr/v4/codegen/target/GoTarget.java
new file mode 100644
index 0000000..678b532
--- /dev/null
+++ b/tool/src/org/antlr/v4/codegen/target/GoTarget.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.codegen.target;
+
+import org.antlr.v4.codegen.CodeGenerator;
+import org.antlr.v4.codegen.Target;
+import org.antlr.v4.parse.ANTLRParser;
+import org.antlr.v4.tool.Grammar;
+import org.antlr.v4.tool.ast.GrammarAST;
+import org.stringtemplate.v4.ST;
+import org.stringtemplate.v4.STGroup;
+import org.stringtemplate.v4.StringRenderer;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ *
+ * @author Peter Boyer
+ *
+ * */
+public class GoTarget extends Target {
+
+ private static final String[] goKeywords = {
+ "break", "default", "func", "interface", "select",
+ "case", "defer", "go", "map", "struct",
+ "chan", "else", "goto", "package", "switch",
+ "const", "fallthrough", "if", "range", "type",
+ "continue", "for", "import", "return", "var"
+ };
+
+ // predeclared identifiers https://golang.org/ref/spec#Predeclared_identifiers
+ private static final String[] goPredeclaredIdentifiers = {
+ "bool", "byte", "complex64", "complex128", "error", "float32", "float64",
+ "int", ",int8", "int16", "int32", "int64", "rune", "string",
+ "uint", "uint8", "uint16", "uint32", "uint64", "uintptr",
+ "true", "false", "iota", "nil",
+ "append", "cap", "close", "complex", "copy", "delete", "imag", "len",
+ "make", "new", "panic", "print", "println", "real", "recover"
+ };
+
+ /** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */
+ private final Set<String> badWords = new HashSet<String>(goKeywords.length + goPredeclaredIdentifiers.length + 2);
+
+ private static final boolean DO_GOFMT = !Boolean.parseBoolean(System.getenv("ANTLR_GO_DISABLE_GOFMT"))
+ && !Boolean.parseBoolean(System.getProperty("antlr.go.disable-gofmt"));
+
+ public GoTarget(CodeGenerator gen) {
+ super(gen, "Go");
+ }
+
+ @Override
+ public String getVersion() {
+ return "4.6";
+ }
+
+ public Set<String> getBadWords() {
+ if (badWords.isEmpty()) {
+ addBadWords();
+ }
+
+ return badWords;
+ }
+
+ protected void addBadWords() {
+ badWords.addAll(Arrays.asList(goKeywords));
+ badWords.addAll(Arrays.asList(goPredeclaredIdentifiers));
+ badWords.add("rule");
+ badWords.add("parserRule");
+ }
+
+ @Override
+ protected void genFile(Grammar g, ST outputFileST, String fileName) {
+ super.genFile(g, outputFileST, fileName);
+ if (DO_GOFMT && !fileName.startsWith(".") /* criterion taken from gofmt */ && fileName.endsWith(".go")) {
+ gofmt(new File(getCodeGenerator().tool.getOutputDirectory(g.fileName), fileName));
+ }
+ }
+
+ private void gofmt(File fileName) {
+ // Optimistically run gofmt. If this fails, it doesn't matter at this point. Wait for termination though,
+ // because "gofmt -w" uses ioutil.WriteFile internally, which means it literally writes in-place with O_TRUNC.
+ // That could result in a race. (Why oh why doesn't it do tmpfile + rename?)
+ try {
+ // TODO: need something like: String goExecutable = locateGo();
+ ProcessBuilder gofmtBuilder = new ProcessBuilder("gofmt", "-w", "-s", fileName.getPath());
+ gofmtBuilder.redirectErrorStream(true);
+ Process gofmt = gofmtBuilder.start();
+ InputStream stdout = gofmt.getInputStream();
+ // TODO(wjkohnen): simplify to `while (stdout.Read() > 1) {}`
+ byte[] buf = new byte[1 << 10];
+ for (int l = 0; l > -1; l = stdout.read(buf)) {
+ // There should not be any output that exceeds the implicit output buffer. In normal ops there should be
+ // zero output. In case there is output, blocking and therefore killing the process is acceptable. This
+ // drains the buffer anyway to play it safe.
+
+ // dirty debug (change -w above to -d):
+ // System.err.write(buf, 0, l);
+ }
+ gofmt.waitFor();
+ } catch (IOException e) {
+ // Probably gofmt not in $PATH, in any case ignore.
+ } catch (InterruptedException forward) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @Override
+ public String encodeIntAsCharEscape(int v) {
+ return Integer.toString(v);
+ }
+
+ @Override
+ public int getSerializedATNSegmentLimit() {
+ return 2 ^ 31;
+ }
+
+ @Override
+ public int getInlineTestSetWordSize() {
+ return 32;
+ }
+
+ @Override
+ protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) {
+ return getBadWords().contains(idNode.getText());
+ }
+
+ @Override
+ protected STGroup loadTemplates() {
+ STGroup result = super.loadTemplates();
+ result.registerRenderer(String.class, new JavaStringRenderer(), true);
+ return result;
+ }
+
+ public String getRecognizerFileName(boolean header) {
+ CodeGenerator gen = getCodeGenerator();
+ Grammar g = gen.g;
+ assert g!=null;
+ String name;
+ switch ( g.getType()) {
+ case ANTLRParser.PARSER:
+ name = g.name.endsWith("Parser") ? g.name.substring(0, g.name.length()-6) : g.name;
+ return name.toLowerCase()+"_parser.go";
+ case ANTLRParser.LEXER:
+ name = g.name.endsWith("Lexer") ? g.name.substring(0, g.name.length()-5) : g.name; // trim off "lexer"
+ return name.toLowerCase()+"_lexer.go";
+ case ANTLRParser.COMBINED:
+ return g.name.toLowerCase()+"_parser.go";
+ default :
+ return "INVALID_FILE_NAME";
+ }
+ }
+
+ /** A given grammar T, return the listener name such as
+ * TListener.java, if we're using the Java target.
+ */
+ public String getListenerFileName(boolean header) {
+ CodeGenerator gen = getCodeGenerator();
+ Grammar g = gen.g;
+ assert g.name != null;
+ return g.name.toLowerCase()+"_listener.go";
+ }
+
+ /** A given grammar T, return the visitor name such as
+ * TVisitor.java, if we're using the Java target.
+ */
+ public String getVisitorFileName(boolean header) {
+ CodeGenerator gen = getCodeGenerator();
+ Grammar g = gen.g;
+ assert g.name != null;
+ return g.name.toLowerCase()+"_visitor.go";
+ }
+
+ /** A given grammar T, return a blank listener implementation
+ * such as TBaseListener.java, if we're using the Java target.
+ */
+ public String getBaseListenerFileName(boolean header) {
+ CodeGenerator gen = getCodeGenerator();
+ Grammar g = gen.g;
+ assert g.name != null;
+ return g.name.toLowerCase()+"_base_listener.go";
+ }
+
+ /** A given grammar T, return a blank listener implementation
+ * such as TBaseListener.java, if we're using the Java target.
+ */
+ public String getBaseVisitorFileName(boolean header) {
+ CodeGenerator gen = getCodeGenerator();
+ Grammar g = gen.g;
+ assert g.name != null;
+ return g.name.toLowerCase()+"_base_visitor.go";
+ }
+
+ protected static class JavaStringRenderer extends StringRenderer {
+
+ @Override
+ public String toString(Object o, String formatString, Locale locale) {
+
+ if ("java-escape".equals(formatString)) {
+ // 5C is the hex code for the \ itself
+ return ((String)o).replace("\\u", "\\u005Cu");
+ }
+
+ return super.toString(o, formatString, locale);
+ }
+
+ }
+}
+
diff --git a/tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java b/tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java
index 9648376..455c488 100644
--- a/tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java
+++ b/tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.target;
@@ -74,7 +50,7 @@ public class JavaScriptTarget extends Target {
@Override
public String getVersion() {
- return "4.5.3";
+ return "4.6";
}
public Set<String> getBadWords() {
@@ -220,14 +196,17 @@ public class JavaScriptTarget extends Target {
}
+ @Override
public boolean wantsBaseListener() {
return false;
}
+ @Override
public boolean wantsBaseVisitor() {
return false;
}
+ @Override
public boolean supportsOverloadedMethods() {
return false;
}
diff --git a/tool/src/org/antlr/v4/codegen/target/JavaTarget.java b/tool/src/org/antlr/v4/codegen/target/JavaTarget.java
index 6ee18da..a7cb900 100644
--- a/tool/src/org/antlr/v4/codegen/target/JavaTarget.java
+++ b/tool/src/org/antlr/v4/codegen/target/JavaTarget.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.target;
diff --git a/tool/src/org/antlr/v4/codegen/target/Python2Target.java b/tool/src/org/antlr/v4/codegen/target/Python2Target.java
index c80949a..85cdb9c 100644
--- a/tool/src/org/antlr/v4/codegen/target/Python2Target.java
+++ b/tool/src/org/antlr/v4/codegen/target/Python2Target.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.target;
@@ -117,7 +93,7 @@ public class Python2Target extends Target {
@Override
public String getVersion() {
- return "4.5.3";
+ return "4.6";
}
public Set<String> getBadWords() {
diff --git a/tool/src/org/antlr/v4/codegen/target/Python3Target.java b/tool/src/org/antlr/v4/codegen/target/Python3Target.java
index f70d2a2..e151ea0 100644
--- a/tool/src/org/antlr/v4/codegen/target/Python3Target.java
+++ b/tool/src/org/antlr/v4/codegen/target/Python3Target.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.codegen.target;
@@ -119,7 +95,7 @@ public class Python3Target extends Target {
@Override
public String getVersion() {
- return "4.5.3";
+ return "4.6";
}
/** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */
diff --git a/tool/src/org/antlr/v4/codegen/target/SwiftTarget.java b/tool/src/org/antlr/v4/codegen/target/SwiftTarget.java
new file mode 100644
index 0000000..b4db954
--- /dev/null
+++ b/tool/src/org/antlr/v4/codegen/target/SwiftTarget.java
@@ -0,0 +1,553 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.v4.codegen.target;
+
+import org.antlr.v4.codegen.CodeGenerator;
+import org.antlr.v4.codegen.Target;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.atn.ATN;
+import org.antlr.v4.runtime.atn.ATNDeserializer;
+import org.antlr.v4.runtime.atn.ATNState;
+import org.antlr.v4.runtime.atn.ATNType;
+import org.antlr.v4.runtime.atn.ActionTransition;
+import org.antlr.v4.runtime.atn.AtomTransition;
+import org.antlr.v4.runtime.atn.BlockStartState;
+import org.antlr.v4.runtime.atn.DecisionState;
+import org.antlr.v4.runtime.atn.LexerAction;
+import org.antlr.v4.runtime.atn.LexerChannelAction;
+import org.antlr.v4.runtime.atn.LexerCustomAction;
+import org.antlr.v4.runtime.atn.LexerModeAction;
+import org.antlr.v4.runtime.atn.LexerPushModeAction;
+import org.antlr.v4.runtime.atn.LexerTypeAction;
+import org.antlr.v4.runtime.atn.LoopEndState;
+import org.antlr.v4.runtime.atn.PrecedencePredicateTransition;
+import org.antlr.v4.runtime.atn.PredicateTransition;
+import org.antlr.v4.runtime.atn.RangeTransition;
+import org.antlr.v4.runtime.atn.RuleStartState;
+import org.antlr.v4.runtime.atn.RuleTransition;
+import org.antlr.v4.runtime.atn.SetTransition;
+import org.antlr.v4.runtime.atn.Transition;
+import org.antlr.v4.runtime.misc.IntegerList;
+import org.antlr.v4.runtime.misc.Interval;
+import org.antlr.v4.runtime.misc.IntervalSet;
+import org.antlr.v4.tool.ErrorType;
+import org.antlr.v4.tool.Grammar;
+import org.antlr.v4.tool.ast.GrammarAST;
+import org.stringtemplate.v4.ST;
+import org.stringtemplate.v4.STGroup;
+import org.stringtemplate.v4.StringRenderer;
+
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public class SwiftTarget extends Target {
+
+ /**
+ * The Swift target can cache the code generation templates.
+ */
+ private static final ThreadLocal<STGroup> targetTemplates = new ThreadLocal<STGroup>();
+
+ protected static final String[] swiftKeywords = {
+ "associatedtype", "class", "deinit", "enum", "extension", "func", "import", "init", "inout", "internal",
+ "let", "operator", "private", "protocol", "public", "static", "struct", "subscript", "typealias", "var",
+ "break", "case", "continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if",
+ "in", "repeat", "return", "switch", "where", "while",
+ "as", "catch", "dynamicType", "false", "is", "nil", "rethrows", "super", "self", "Self", "throw", "throws",
+ "true", "try", "__COLUMN__", "__FILE__", "__FUNCTION__","__LINE__", "#column", "#file", "#function", "#line", "_" , "#available", "#else", "#elseif", "#endif", "#if", "#selector",
+ "associativity", "convenience", "dynamic", "didSet", "final", "get", "infix", "indirect", "lazy",
+ "left", "mutating", "none", "nonmutating", "optional", "override", "postfix", "precedence",
+ "prefix", "Protocol", "required", "right", "set", "Type", "unowned", "weak", "willSet"
+ };
+
+ /** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */
+ protected final Set<String> badWords = new HashSet<String>();
+
+ public String lexerAtnJSON = null;
+ public String parserAtnJSON = null;
+ public SwiftTarget(CodeGenerator gen) {
+ super(gen, "Swift");
+ }
+
+ @Override
+ public String getVersion() {
+ return "4.6"; // Java and tool versions move in lock step
+ }
+
+ public Set<String> getBadWords() {
+ if (badWords.isEmpty()) {
+ addBadWords();
+ }
+
+ return badWords;
+ }
+
+ protected void addBadWords() {
+ badWords.addAll(Arrays.asList(swiftKeywords));
+ badWords.add("rule");
+ badWords.add("parserRule");
+ }
+
+ @Override
+ public int getSerializedATNSegmentLimit() {
+ // 65535 is the class file format byte limit for a UTF-8 encoded string literal
+ // 3 is the maximum number of bytes it takes to encode a value in the range 0-0xFFFF
+ return 65535 / 3;
+ }
+
+ @Override
+ protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) {
+ return getBadWords().contains(idNode.getText());
+ }
+ @Override
+ protected void genFile(Grammar g,
+ ST outputFileST,
+ String fileName)
+ {
+ super.genFile(g,outputFileST,fileName);
+
+ if (g.isLexer() && lexerAtnJSON == null) {
+ lexerAtnJSON = getLexerOrParserATNJson(g, fileName);
+ } else if (!g.isLexer() && parserAtnJSON == null && g.atn != null) {
+ parserAtnJSON = getLexerOrParserATNJson(g, fileName);
+ }
+
+ if (fileName.endsWith(CodeGenerator.VOCAB_FILE_EXTENSION)) {
+ String jsonFileName = fileName.substring(0,fileName.lastIndexOf(CodeGenerator.VOCAB_FILE_EXTENSION));
+ if (lexerAtnJSON != null) {
+ jsonFileName = jsonFileName + "ATN.swift";
+ // System.out.println(jsonFileName);
+ //System.out.println(lexerAtnJSON);
+ writeFile(lexerAtnJSON,g,jsonFileName);
+ }
+
+ if (parserAtnJSON != null) {
+ jsonFileName = jsonFileName + "ParserATN.swift";
+ // System.out.println(jsonFileName);
+ //System.out.println(parserAtnJSON);
+ writeFile(parserAtnJSON,g,jsonFileName);
+ }
+ }
+
+// else if (g instanceof ParseR) {
+// System.out.println("parserGrammar");
+// }
+//
+ //getCodeGenerator().write(outputFileST, fileName);
+ }
+
+ private String getLexerOrParserATNJson(Grammar g, String fileName) {
+ ST extST = getTemplates().getInstanceOf("codeFileExtension");
+ String className = fileName.substring(0,fileName.lastIndexOf(extST.render()));
+
+ String JSON = "class " + className + "ATN {\n" +
+ " let jsonString: String = \"" +
+ serializeTojson(g.atn).replaceAll("\"","\\\\\"") +"\"\n}" ; //.replaceAll("\"", "\\\\\"");
+ return JSON;
+ }
+
+ private void writeFile(String content,Grammar g,String fileName) {
+
+ try {
+ Writer w = this.getCodeGenerator().tool.getOutputFileWriter(g, fileName);
+ w.write(content);
+ w.close();
+ }
+ catch (IOException ioe) {
+ this.getCodeGenerator().tool.errMgr.toolError(ErrorType.CANNOT_WRITE_FILE,
+ ioe,
+ fileName);
+ }
+ }
+ @Override
+ protected STGroup loadTemplates() {
+ STGroup result = targetTemplates.get();
+ if (result == null) {
+ result = super.loadTemplates();
+ result.registerRenderer(String.class, new SwiftStringRenderer(), true);
+ targetTemplates.set(result);
+ }
+
+ return result;
+ }
+ //added by janyou -->
+ public String serializeTojson(ATN atn) {
+ JsonObjectBuilder builder = Json.createObjectBuilder();
+ builder.add("version", ATNDeserializer.SERIALIZED_VERSION);
+ builder.add("uuid", ATNDeserializer.SERIALIZED_UUID.toString());
+
+ // convert grammar type to ATN const to avoid dependence on ANTLRParser
+ builder.add("grammarType",atn.grammarType.ordinal());
+ builder.add("maxTokenType",atn.maxTokenType);
+
+ //states
+ int nedges = 0;
+
+ Map<IntervalSet, Integer> setIndices = new HashMap<IntervalSet, Integer>();
+ List<IntervalSet> sets = new ArrayList<IntervalSet>();
+ JsonArrayBuilder statesBuilder = Json.createArrayBuilder() ;
+ IntegerList nonGreedyStates = new IntegerList();
+ IntegerList precedenceStates = new IntegerList();
+ for (ATNState s : atn.states) {
+ JsonObjectBuilder stateBuilder = Json.createObjectBuilder();
+ if ( s==null ) { // might be optimized away
+ statesBuilder.addNull();
+ continue;
+ }
+
+ int stateType = s.getStateType();
+
+ stateBuilder.add("stateType",stateType);
+ //stateBuilder.add("stateNumber",s.stateNumber);
+ stateBuilder.add("ruleIndex",s.ruleIndex);
+
+ if (s instanceof DecisionState && ((DecisionState)s).nonGreedy) {
+ nonGreedyStates.add(s.stateNumber);
+ }
+
+ if (s instanceof RuleStartState && ((RuleStartState)s).isLeftRecursiveRule) {
+ precedenceStates.add(s.stateNumber);
+ }
+
+
+ if ( s.getStateType() == ATNState.LOOP_END ) {
+ stateBuilder.add("detailStateNumber",((LoopEndState)s).loopBackState.stateNumber);
+ }
+ else if ( s instanceof BlockStartState ) {
+ stateBuilder.add("detailStateNumber",((BlockStartState)s).endState.stateNumber);
+ }
+
+ if (s.getStateType() != ATNState.RULE_STOP) {
+ // the deserializer can trivially derive these edges, so there's no need to serialize them
+ nedges += s.getNumberOfTransitions();
+ }
+ for (int i=0; i<s.getNumberOfTransitions(); i++) {
+ Transition t = s.transition(i);
+ int edgeType = Transition.serializationTypes.get(t.getClass());
+ if ( edgeType == Transition.SET || edgeType == Transition.NOT_SET ) {
+ SetTransition st = (SetTransition)t;
+ if (!setIndices.containsKey(st.set)) {
+ sets.add(st.set);
+ setIndices.put(st.set, sets.size() - 1);
+ }
+ }
+ }
+ statesBuilder.add(stateBuilder);
+ }
+ builder.add("states",statesBuilder);
+
+
+ // non-greedy states
+ JsonArrayBuilder nonGreedyStatesBuilder = Json.createArrayBuilder() ;
+ for (int i = 0; i < nonGreedyStates.size(); i++) {
+ nonGreedyStatesBuilder.add(nonGreedyStates.get(i));
+ }
+ builder.add("nonGreedyStates",nonGreedyStatesBuilder);
+
+
+ // precedence states
+ JsonArrayBuilder precedenceStatesBuilder = Json.createArrayBuilder() ;
+ for (int i = 0; i < precedenceStates.size(); i++) {
+ precedenceStatesBuilder.add(precedenceStates.get(i));
+ }
+ builder.add("precedenceStates",precedenceStatesBuilder);
+
+ JsonArrayBuilder ruleToStartStateBuilder = Json.createArrayBuilder() ;
+ int nrules = atn.ruleToStartState.length;
+
+ for (int r=0; r<nrules; r++) {
+ JsonObjectBuilder stateBuilder = Json.createObjectBuilder();
+ ATNState ruleStartState = atn.ruleToStartState[r];
+
+ stateBuilder.add("stateNumber",ruleStartState.stateNumber);
+ if (atn.grammarType == ATNType.LEXER) {
+// if (atn.ruleToTokenType[r] == Token.EOF) {
+// //data.add(Character.MAX_VALUE);
+// stateBuilder.add("ruleToTokenType",-1);
+// }
+// else {
+// //data.add(atn.ruleToTokenType[r]);
+ stateBuilder.add("ruleToTokenType",atn.ruleToTokenType[r]);
+// }
+ }
+ ruleToStartStateBuilder.add(stateBuilder);
+ }
+ builder.add("ruleToStartState",ruleToStartStateBuilder);
+
+
+ JsonArrayBuilder modeToStartStateBuilder = Json.createArrayBuilder() ;
+ int nmodes = atn.modeToStartState.size();
+ if ( nmodes>0 ) {
+ for (ATNState modeStartState : atn.modeToStartState) {
+
+ modeToStartStateBuilder.add(modeStartState.stateNumber);
+ }
+ }
+ builder.add("modeToStartState",modeToStartStateBuilder);
+
+
+ JsonArrayBuilder nsetsBuilder = Json.createArrayBuilder() ;
+ int nsets = sets.size();
+ //data.add(nsets);
+ builder.add("nsets",nsets);
+
+ for (IntervalSet set : sets) {
+ JsonObjectBuilder setBuilder = Json.createObjectBuilder();
+ boolean containsEof = set.contains(Token.EOF);
+ if (containsEof && set.getIntervals().get(0).b == Token.EOF) {
+ //data.add(set.getIntervals().size() - 1);
+
+ setBuilder.add("size",set.getIntervals().size() - 1);
+ }
+ else {
+ //data.add(set.getIntervals().size());
+
+ setBuilder.add("size",set.getIntervals().size());
+ }
+ setBuilder.add("containsEof",containsEof ? 1 : 0);
+ JsonArrayBuilder IntervalsBuilder = Json.createArrayBuilder() ;
+ for (Interval I : set.getIntervals()) {
+ JsonObjectBuilder IntervalBuilder = Json.createObjectBuilder();
+ if (I.a == Token.EOF) {
+ if (I.b == Token.EOF) {
+ continue;
+ }
+ else {
+ IntervalBuilder.add("a",0);
+ //data.add(0);
+ }
+ }
+ else {
+ IntervalBuilder.add("a",I.a);
+
+ //data.add(I.a);
+ }
+ IntervalBuilder.add("b",I.b);
+ IntervalsBuilder.add(IntervalBuilder);
+ }
+ setBuilder.add("Intervals",IntervalsBuilder);
+ nsetsBuilder.add(setBuilder);
+ }
+
+ builder.add("IntervalSet",nsetsBuilder);
+ //builder.add("nedges",nedges);
+ JsonArrayBuilder allTransitionsBuilder = Json.createArrayBuilder() ;
+
+ for (ATNState s : atn.states) {
+
+ if ( s==null ) {
+ // might be optimized away
+ continue;
+ }
+
+ if (s.getStateType() == ATNState.RULE_STOP) {
+ continue;
+ }
+ JsonArrayBuilder transitionsBuilder = Json.createArrayBuilder() ;
+
+ for (int i=0; i<s.getNumberOfTransitions(); i++) {
+ JsonObjectBuilder transitionBuilder = Json.createObjectBuilder();
+ Transition t = s.transition(i);
+
+ if (atn.states.get(t.target.stateNumber) == null) {
+ throw new IllegalStateException("Cannot serialize a transition to a removed state.");
+ }
+
+ int src = s.stateNumber;
+ int trg = t.target.stateNumber;
+ int edgeType = Transition.serializationTypes.get(t.getClass());
+ int arg1 = 0;
+ int arg2 = 0;
+ int arg3 = 0;
+ switch ( edgeType ) {
+ case Transition.RULE :
+ trg = ((RuleTransition)t).followState.stateNumber;
+ arg1 = ((RuleTransition)t).target.stateNumber;
+ arg2 = ((RuleTransition)t).ruleIndex;
+ arg3 = ((RuleTransition)t).precedence;
+ break;
+ case Transition.PRECEDENCE:
+ PrecedencePredicateTransition ppt = (PrecedencePredicateTransition)t;
+ arg1 = ppt.precedence;
+ break;
+ case Transition.PREDICATE :
+ PredicateTransition pt = (PredicateTransition)t;
+ arg1 = pt.ruleIndex;
+ arg2 = pt.predIndex;
+ arg3 = pt.isCtxDependent ? 1 : 0 ;
+ break;
+ case Transition.RANGE :
+ arg1 = ((RangeTransition)t).from;
+ arg2 = ((RangeTransition)t).to;
+ if (arg1 == Token.EOF) {
+ arg1 = 0;
+ arg3 = 1;
+ }
+
+ break;
+ case Transition.ATOM :
+ arg1 = ((AtomTransition)t).label;
+ if (arg1 == Token.EOF) {
+ arg1 = 0;
+ arg3 = 1;
+ }
+
+ break;
+ case Transition.ACTION :
+ ActionTransition at = (ActionTransition)t;
+ arg1 = at.ruleIndex;
+ arg2 = at.actionIndex;
+// if (arg2 == -1) {
+// arg2 = 0xFFFF;
+// }
+
+ arg3 = at.isCtxDependent ? 1 : 0 ;
+ break;
+ case Transition.SET :
+ arg1 = setIndices.get(((SetTransition)t).set);
+ break;
+ case Transition.NOT_SET :
+ arg1 = setIndices.get(((SetTransition)t).set);
+ break;
+ case Transition.WILDCARD :
+ break;
+ }
+ transitionBuilder.add("src",src);
+ transitionBuilder.add("trg",trg);
+ transitionBuilder.add("edgeType",edgeType);
+ transitionBuilder.add("arg1",arg1);
+ transitionBuilder.add("arg2",arg2);
+ transitionBuilder.add("arg3",arg3);
+ transitionsBuilder.add(transitionBuilder);
+ }
+ allTransitionsBuilder.add(transitionsBuilder);
+ }
+
+ builder.add("allTransitionsBuilder",allTransitionsBuilder);
+ int ndecisions = atn.decisionToState.size();
+ //data.add(ndecisions);
+ JsonArrayBuilder decisionToStateBuilder = Json.createArrayBuilder() ;
+
+ for (DecisionState decStartState : atn.decisionToState) {
+ //data.add(decStartState.stateNumber);
+ decisionToStateBuilder.add(decStartState.stateNumber);
+ }
+ builder.add("decisionToState",decisionToStateBuilder);
+ //
+ // LEXER ACTIONS
+ //
+ JsonArrayBuilder lexerActionsBuilder = Json.createArrayBuilder() ;
+
+ if (atn.grammarType == ATNType.LEXER) {
+ //data.add(atn.lexerActions.length);
+ for (LexerAction action : atn.lexerActions) {
+ JsonObjectBuilder lexerActionBuilder = Json.createObjectBuilder();
+
+ lexerActionBuilder.add("actionType",action.getActionType().ordinal());
+ //data.add(action.getActionType().ordinal());
+ switch (action.getActionType()) {
+ case CHANNEL:
+ int channel = ((LexerChannelAction)action).getChannel();
+
+ lexerActionBuilder.add("a",channel);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ case CUSTOM:
+ int ruleIndex = ((LexerCustomAction)action).getRuleIndex();
+ int actionIndex = ((LexerCustomAction)action).getActionIndex();
+
+ lexerActionBuilder.add("a",ruleIndex);
+ lexerActionBuilder.add("b",actionIndex);
+ break;
+
+ case MODE:
+ int mode = ((LexerModeAction)action).getMode();
+
+ lexerActionBuilder.add("a",mode);
+ lexerActionBuilder.add("b",0);
+ break;
+
+
+ case MORE:
+
+ lexerActionBuilder.add("a",0);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ case POP_MODE:
+ lexerActionBuilder.add("a",0);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ case PUSH_MODE:
+ mode = ((LexerPushModeAction)action).getMode();
+
+ lexerActionBuilder.add("a",mode);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ case SKIP:
+ lexerActionBuilder.add("a",0);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ case TYPE:
+ int type = ((LexerTypeAction)action).getType();
+
+ lexerActionBuilder.add("a",type);
+ lexerActionBuilder.add("b",0);
+ break;
+
+ default:
+ String message = String.format(Locale.getDefault(), "The specified lexer action type %s is not valid.", action.getActionType());
+ throw new IllegalArgumentException(message);
+ }
+ lexerActionsBuilder.add(lexerActionBuilder);
+ }
+ }
+ builder.add("lexerActions",lexerActionsBuilder);
+ // don't adjust the first value since that's the version number
+// for (int i = 1; i < data.size(); i++) {
+// if (data.get(i) < Character.MIN_VALUE || data.get(i) > Character.MAX_VALUE) {
+// throw new UnsupportedOperationException("Serialized ATN data element out of range.");
+// }
+//
+// int value = (data.get(i) + 2) & 0xFFFF;
+// data.set(i, value);
+// }
+ JsonObject data = builder.build();
+ // System.out.print(data.toString());
+ return data.toString();
+ }
+
+ //<--
+ protected static class SwiftStringRenderer extends StringRenderer {
+
+ @Override
+ public String toString(Object o, String formatString, Locale locale) {
+ if ("java-escape".equals(formatString)) {
+ // 5C is the hex code for the \ itself
+ return ((String)o).replace("\\u", "\\u005Cu");
+ }
+
+ return super.toString(o, formatString, locale);
+ }
+
+ }
+}
diff --git a/tool/src/org/antlr/v4/gui/BasicFontMetrics.java b/tool/src/org/antlr/v4/gui/BasicFontMetrics.java
index b424a00..39ce6bd 100644
--- a/tool/src/org/antlr/v4/gui/BasicFontMetrics.java
+++ b/tool/src/org/antlr/v4/gui/BasicFontMetrics.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/GraphicsSupport.java b/tool/src/org/antlr/v4/gui/GraphicsSupport.java
index eb9546d..fbee7f4 100644
--- a/tool/src/org/antlr/v4/gui/GraphicsSupport.java
+++ b/tool/src/org/antlr/v4/gui/GraphicsSupport.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/JFileChooserConfirmOverwrite.java b/tool/src/org/antlr/v4/gui/JFileChooserConfirmOverwrite.java
index 59cbb69..f30b555 100644
--- a/tool/src/org/antlr/v4/gui/JFileChooserConfirmOverwrite.java
+++ b/tool/src/org/antlr/v4/gui/JFileChooserConfirmOverwrite.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2013 Terence Parr
- * Copyright (c) 2013 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/PostScriptDocument.java b/tool/src/org/antlr/v4/gui/PostScriptDocument.java
index 7faf2db..62e2216 100644
--- a/tool/src/org/antlr/v4/gui/PostScriptDocument.java
+++ b/tool/src/org/antlr/v4/gui/PostScriptDocument.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/SystemFontMetrics.java b/tool/src/org/antlr/v4/gui/SystemFontMetrics.java
index fb2b17a..f1b4d91 100644
--- a/tool/src/org/antlr/v4/gui/SystemFontMetrics.java
+++ b/tool/src/org/antlr/v4/gui/SystemFontMetrics.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/TestRig.java b/tool/src/org/antlr/v4/gui/TestRig.java
index e81a54c..1fc96f0 100644
--- a/tool/src/org/antlr/v4/gui/TestRig.java
+++ b/tool/src/org/antlr/v4/gui/TestRig.java
@@ -1,42 +1,20 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.DiagnosticErrorListener;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.atn.PredictionMode;
@@ -218,8 +196,13 @@ public class TestRig {
tokens.fill();
if ( showTokens ) {
- for (Object tok : tokens.getTokens()) {
- System.out.println(tok);
+ for (Token tok : tokens.getTokens()) {
+ if ( tok instanceof CommonToken ) {
+ System.out.println(((CommonToken)tok).toString(lexer));
+ }
+ else {
+ System.out.println(tok.toString());
+ }
}
}
diff --git a/tool/src/org/antlr/v4/gui/TreeLayoutAdaptor.java b/tool/src/org/antlr/v4/gui/TreeLayoutAdaptor.java
index 6024e3b..295ab99 100644
--- a/tool/src/org/antlr/v4/gui/TreeLayoutAdaptor.java
+++ b/tool/src/org/antlr/v4/gui/TreeLayoutAdaptor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/TreePostScriptGenerator.java b/tool/src/org/antlr/v4/gui/TreePostScriptGenerator.java
index d78a1c8..19f3512 100644
--- a/tool/src/org/antlr/v4/gui/TreePostScriptGenerator.java
+++ b/tool/src/org/antlr/v4/gui/TreePostScriptGenerator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/TreeTextProvider.java b/tool/src/org/antlr/v4/gui/TreeTextProvider.java
index 9a88fc0..ff3983e 100644
--- a/tool/src/org/antlr/v4/gui/TreeTextProvider.java
+++ b/tool/src/org/antlr/v4/gui/TreeTextProvider.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
diff --git a/tool/src/org/antlr/v4/gui/TreeViewer.java b/tool/src/org/antlr/v4/gui/TreeViewer.java
index 3cfd5e5..21d0f5c 100644
--- a/tool/src/org/antlr/v4/gui/TreeViewer.java
+++ b/tool/src/org/antlr/v4/gui/TreeViewer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.gui;
@@ -285,8 +261,8 @@ public class TreeViewer extends JComponent {
private static final String DIALOG_DIVIDER_LOC_PREFS_KEY = "dialog_divider_location";
private static final String DIALOG_VIEWER_SCALE_PREFS_KEY = "dialog_viewer_scale";
- protected static JDialog showInDialog(final TreeViewer viewer) {
- final JDialog dialog = new JDialog();
+ protected static JFrame showInDialog(final TreeViewer viewer) {
+ final JFrame dialog = new JFrame();
dialog.setTitle("Parse Tree Inspector");
final Preferences prefs = Preferences.userNodeForPackage(TreeViewer.class);
@@ -393,6 +369,7 @@ public class TreeViewer extends JComponent {
// make viz
WindowListener exitListener = new WindowAdapter() {
+ @Override
public void windowClosing(WindowEvent e) {
prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth());
prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight());
@@ -431,7 +408,7 @@ public class TreeViewer extends JComponent {
return dialog;
}
- private static void generatePNGFile(TreeViewer viewer, JDialog dialog) {
+ private static void generatePNGFile(TreeViewer viewer, JFrame dialog) {
BufferedImage bi = new BufferedImage(viewer.getSize().width,
viewer.getSize().height,
BufferedImage.TYPE_INT_ARGB);
@@ -536,14 +513,14 @@ public class TreeViewer extends JComponent {
}
- public Future<JDialog> open() {
+ public Future<JFrame> open() {
final TreeViewer viewer = this;
viewer.setScale(1.5);
- Callable<JDialog> callable = new Callable<JDialog>() {
- JDialog result;
+ Callable<JFrame> callable = new Callable<JFrame>() {
+ JFrame result;
@Override
- public JDialog call() throws Exception {
+ public JFrame call() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
@@ -566,7 +543,7 @@ public class TreeViewer extends JComponent {
}
public void save(String fileName) throws IOException, PrintException {
- JDialog dialog = new JDialog();
+ JFrame dialog = new JFrame();
Container contentPane = dialog.getContentPane();
((JComponent) contentPane).setBorder(BorderFactory.createEmptyBorder(
10, 10, 10, 10));
diff --git a/tool/src/org/antlr/v4/gui/Trees.java b/tool/src/org/antlr/v4/gui/Trees.java
index 53796ab..eca200a 100644
--- a/tool/src/org/antlr/v4/gui/Trees.java
+++ b/tool/src/org/antlr/v4/gui/Trees.java
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
package org.antlr.v4.gui;
import org.antlr.v4.runtime.Parser;
@@ -15,13 +21,13 @@ import java.util.concurrent.Future;
public class Trees {
/** Call this method to view a parse tree in a dialog box visually. */
- public static Future<JDialog> inspect(Tree t, List<String> ruleNames) {
+ public static Future<JFrame> inspect(Tree t, List<String> ruleNames) {
TreeViewer viewer = new TreeViewer(ruleNames, t);
return viewer.open();
}
/** Call this method to view a parse tree in a dialog box visually. */
- public static Future<JDialog> inspect(Tree t, Parser parser) {
+ public static Future<JFrame> inspect(Tree t, Parser parser) {
List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null;
return inspect(t, ruleNames);
}
diff --git a/tool/src/org/antlr/v4/misc/CharSupport.java b/tool/src/org/antlr/v4/misc/CharSupport.java
index 22e9648..50db0d9 100644
--- a/tool/src/org/antlr/v4/misc/CharSupport.java
+++ b/tool/src/org/antlr/v4/misc/CharSupport.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
@@ -52,6 +28,8 @@ public class CharSupport {
ANTLRLiteralEscapedCharValue['\\'] = '\\';
ANTLRLiteralEscapedCharValue['\''] = '\'';
ANTLRLiteralEscapedCharValue['"'] = '"';
+ ANTLRLiteralEscapedCharValue['-'] = '-';
+ ANTLRLiteralEscapedCharValue[']'] = ']';
ANTLRLiteralCharValueEscape['\n'] = "\\n";
ANTLRLiteralCharValueEscape['\r'] = "\\r";
ANTLRLiteralCharValueEscape['\t'] = "\\t";
@@ -100,15 +78,45 @@ public class CharSupport {
return getCharValueFromCharInGrammarLiteral(literal.substring(1,literal.length()-1));
}
+ public static String getStringFromGrammarStringLiteral(String literal) {
+ StringBuilder buf = new StringBuilder();
+ int i = 1; // skip first quote
+ int n = literal.length()-1; // skip last quote
+ while ( i < n ) { // scan all but last quote
+ int end = i+1;
+ if ( literal.charAt(i) == '\\' ) {
+ end = i+2;
+ if ( i+1 < n && literal.charAt(i+1) == 'u' ) {
+ for (end = i + 2; end < i + 6; end++) {
+ if ( end>n ) return null; // invalid escape sequence.
+ char charAt = literal.charAt(end);
+ if (!Character.isDigit(charAt) && !(charAt >= 'a' && charAt <= 'f') && !(charAt >= 'A' && charAt <= 'F')) {
+ return null; // invalid escape sequence.
+ }
+ }
+ }
+ }
+ if ( end>n ) return null; // invalid escape sequence.
+ String esc = literal.substring(i, end);
+ int c = getCharValueFromCharInGrammarLiteral(esc);
+ if ( c==-1 ) {
+ return null; // invalid escape sequence.
+ }
+ else buf.append((char)c);
+ i = end;
+ }
+ return buf.toString();
+ }
+
/** Given char x or \t or \u1234 return the char value;
* Unnecessary escapes like '\{' yield -1.
*/
public static int getCharValueFromCharInGrammarLiteral(String cstr) {
switch ( cstr.length() ) {
- case 1 :
+ case 1:
// 'x'
return cstr.charAt(0); // no escape char
- case 2 :
+ case 2:
if ( cstr.charAt(0)!='\\' ) return -1;
// '\x' (antlr lexer will catch invalid char)
if ( Character.isDigit(cstr.charAt(1)) ) return -1;
@@ -116,37 +124,22 @@ public class CharSupport {
int charVal = ANTLRLiteralEscapedCharValue[escChar];
if ( charVal==0 ) return -1;
return charVal;
- case 6 :
+ case 6:
// '\u1234'
if ( !cstr.startsWith("\\u") ) return -1;
String unicodeChars = cstr.substring(2, cstr.length());
- return Integer.parseInt(unicodeChars, 16);
- default :
+ int result = -1;
+ try {
+ result = Integer.parseInt(unicodeChars, 16);
+ }
+ catch (NumberFormatException e) {
+ }
+ return result;
+ default:
return -1;
}
}
- public static String getStringFromGrammarStringLiteral(String literal) {
- StringBuilder buf = new StringBuilder();
- int i = 1; // skip first quote
- int n = literal.length()-1; // skip last quote
- while ( i < n ) { // scan all but last quote
- int end = i+1;
- if ( literal.charAt(i) == '\\' ) {
- end = i+2;
- if ( (i+1)>=n ) break; // ignore spurious \ on end
- if ( literal.charAt(i+1) == 'u' ) end = i+6;
- }
- if ( end>n ) break;
- String esc = literal.substring(i, end);
- int c = getCharValueFromCharInGrammarLiteral(esc);
- if ( c==-1 ) { buf.append(esc); }
- else buf.append((char)c);
- i = end;
- }
- return buf.toString();
- }
-
public static String capitalize(String s) {
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
diff --git a/tool/src/org/antlr/v4/misc/FrequencySet.java b/tool/src/org/antlr/v4/misc/FrequencySet.java
index 94e467c..d3d4c73 100644
--- a/tool/src/org/antlr/v4/misc/FrequencySet.java
+++ b/tool/src/org/antlr/v4/misc/FrequencySet.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
diff --git a/tool/src/org/antlr/v4/misc/Graph.java b/tool/src/org/antlr/v4/misc/Graph.java
index a7c63d5..ec4c147 100644
--- a/tool/src/org/antlr/v4/misc/Graph.java
+++ b/tool/src/org/antlr/v4/misc/Graph.java
@@ -1,37 +1,14 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
import org.antlr.v4.runtime.misc.OrderedHashSet;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -44,13 +21,15 @@ import java.util.Set;
public class Graph<T> {
public static class Node<T> {
- T payload;
- List<Node<T>> edges; // points at which nodes?
+ public T payload;
+
+ @SuppressWarnings("unchecked")
+ public List<Node<T>> edges = Collections.EMPTY_LIST; // points at which nodes?
public Node(T payload) { this.payload = payload; }
public void addEdge(Node<T> n) {
- if ( edges==null ) edges = new ArrayList<Node<T>>();
+ if ( edges==Collections.EMPTY_LIST ) edges = new ArrayList<Node<T>>();
if ( !edges.contains(n) ) edges.add(n);
}
@@ -68,7 +47,7 @@ public class Graph<T> {
a_node.addEdge(b_node);
}
- protected Node<T> getNode(T a) {
+ public Node<T> getNode(T a) {
Node<T> existing = nodes.get(a);
if ( existing!=null ) return existing;
Node<T> n = new Node<T>(a);
diff --git a/tool/src/org/antlr/v4/misc/MutableInt.java b/tool/src/org/antlr/v4/misc/MutableInt.java
index 816a4ba..607b8f6 100644
--- a/tool/src/org/antlr/v4/misc/MutableInt.java
+++ b/tool/src/org/antlr/v4/misc/MutableInt.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
diff --git a/tool/src/org/antlr/v4/misc/OrderedHashMap.java b/tool/src/org/antlr/v4/misc/OrderedHashMap.java
index ce37b86..67f9deb 100644
--- a/tool/src/org/antlr/v4/misc/OrderedHashMap.java
+++ b/tool/src/org/antlr/v4/misc/OrderedHashMap.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
diff --git a/tool/src/org/antlr/v4/misc/Utils.java b/tool/src/org/antlr/v4/misc/Utils.java
index 6d63b7c..d9a2473 100644
--- a/tool/src/org/antlr/v4/misc/Utils.java
+++ b/tool/src/org/antlr/v4/misc/Utils.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.misc;
@@ -120,7 +96,7 @@ public class Utils {
return b;
}
- /** Find exact object type or sublass of cl in list */
+ /** Find exact object type or subclass of cl in list */
public static <T> T find(List<?> ops, Class<T> cl) {
for (Object o : ops) {
if ( cl.isInstance(o) ) return cl.cast(o);
diff --git a/tool/src/org/antlr/v4/parse/ANTLRLexer.g b/tool/src/org/antlr/v4/parse/ANTLRLexer.g
index 4768d2e..7d61c11 100644
--- a/tool/src/org/antlr/v4/parse/ANTLRLexer.g
+++ b/tool/src/org/antlr/v4/parse/ANTLRLexer.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.g b/tool/src/org/antlr/v4/parse/ANTLRParser.g
index 42946fa..3c10460 100644
--- a/tool/src/org/antlr/v4/parse/ANTLRParser.g
+++ b/tool/src/org/antlr/v4/parse/ANTLRParser.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/ATNBuilder.g b/tool/src/org/antlr/v4/parse/ATNBuilder.g
index 019f246..32cdec5 100644
--- a/tool/src/org/antlr/v4/parse/ATNBuilder.g
+++ b/tool/src/org/antlr/v4/parse/ATNBuilder.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/ActionSplitter.g b/tool/src/org/antlr/v4/parse/ActionSplitter.g
index 5feeb95..e857332 100644
--- a/tool/src/org/antlr/v4/parse/ActionSplitter.g
+++ b/tool/src/org/antlr/v4/parse/ActionSplitter.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/ActionSplitterListener.java b/tool/src/org/antlr/v4/parse/ActionSplitterListener.java
index 0e793b7..fe364f9 100644
--- a/tool/src/org/antlr/v4/parse/ActionSplitterListener.java
+++ b/tool/src/org/antlr/v4/parse/ActionSplitterListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/BlockSetTransformer.g b/tool/src/org/antlr/v4/parse/BlockSetTransformer.g
index 2233b30..d5806ab 100644
--- a/tool/src/org/antlr/v4/parse/BlockSetTransformer.g
+++ b/tool/src/org/antlr/v4/parse/BlockSetTransformer.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java b/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java
index e6a0ec3..47d6e0a 100644
--- a/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java
+++ b/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/GrammarToken.java b/tool/src/org/antlr/v4/parse/GrammarToken.java
index 3e7e190..edf75b6 100644
--- a/tool/src/org/antlr/v4/parse/GrammarToken.java
+++ b/tool/src/org/antlr/v4/parse/GrammarToken.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2014 Terence Parr
- * Copyright (c) 2014 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g b/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g
index 9c8b1be..c407aa4 100644
--- a/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g
+++ b/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g
index 774243f..0d880e3 100644
--- a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g
+++ b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g
@@ -1,7 +1,7 @@
/*
* [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
+ * Copyright (c) 2012-2016 Terence Parr
+ * Copyright (c) 2012-2016 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,7 @@ binary
prefix
: ^( ALT elementOptions?
- ({!((CommonTree)input.LT(1)).getText().equals(ruleName)}? element)+
+ element+
recurse epsilonElement*
)
{setAltAssoc((AltAST)$ALT,currentOuterAltNumber);}
diff --git a/tool/src/org/antlr/v4/parse/ResyncToEndOfRuleBlock.java b/tool/src/org/antlr/v4/parse/ResyncToEndOfRuleBlock.java
index aefff83..0564d38 100644
--- a/tool/src/org/antlr/v4/parse/ResyncToEndOfRuleBlock.java
+++ b/tool/src/org/antlr/v4/parse/ResyncToEndOfRuleBlock.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/ScopeParser.java b/tool/src/org/antlr/v4/parse/ScopeParser.java
index 743fe98..25a3f0a 100644
--- a/tool/src/org/antlr/v4/parse/ScopeParser.java
+++ b/tool/src/org/antlr/v4/parse/ScopeParser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
@@ -42,110 +18,81 @@ import org.antlr.v4.tool.ast.ActionAST;
import java.util.ArrayList;
import java.util.List;
-/** Parse args, return values, locals
- *
- * rule[arg1, arg2, ..., argN] returns [ret1, ..., retN]
- *
- * text is target language dependent. Java/C#/C/C++ would
- * use "int i" but ruby/python would use "i".
+/**
+ * Parse args, return values, locals
+ * <p>
+ * rule[arg1, arg2, ..., argN] returns [ret1, ..., retN]
+ * <p>
+ * text is target language dependent. Java/C#/C/C++ would
+ * use "int i" but ruby/python would use "i". Languages with
+ * postfix types like Go, Swift use "x : T" notation or "T x".
*/
public class ScopeParser {
- /** Given an arg or retval scope definition list like
- *
- * <code>
- * Map&lt;String, String&gt;, int[] j3, char *foo32[3]
- * </code>
- *
- * or
- *
- * <code>
- * int i=3, j=a[34]+20
- * </code>
- *
- * convert to an attribute scope.
- */
+ /**
+ * Given an arg or retval scope definition list like
+ * <p>
+ * <code>
+ * Map&lt;String, String&gt;, int[] j3, char *foo32[3]
+ * </code>
+ * <p>
+ * or
+ * <p>
+ * <code>
+ * int i=3, j=a[34]+20
+ * </code>
+ * <p>
+ * convert to an attribute scope.
+ */
public static AttributeDict parseTypedArgList(ActionAST action, String s, Grammar g) {
return parse(action, s, ',', g);
}
- public static AttributeDict parse(ActionAST action, String s, char separator, Grammar g) {
- AttributeDict dict = new AttributeDict();
+ public static AttributeDict parse(ActionAST action, String s, char separator, Grammar g) {
+ AttributeDict dict = new AttributeDict();
List<Pair<String, Integer>> decls = splitDecls(s, separator);
for (Pair<String, Integer> decl : decls) {
-// System.out.println("decl="+decl);
- if ( decl.a.trim().length()>0 ) {
- Attribute a = parseAttributeDef(action, decl, g);
- dict.add(a);
- }
+ if (decl.a.trim().length() > 0) {
+ Attribute a = parseAttributeDef(action, decl, g);
+ dict.add(a);
+ }
+ }
+ return dict;
+ }
+
+ /**
+ * For decls like "String foo" or "char *foo32[]" compute the ID
+ * and type declarations. Also handle "int x=3" and 'T t = new T("foo")'
+ * but if the separator is ',' you cannot use ',' in the initvalue
+ * unless you escape use "\," escape.
+ */
+ public static Attribute parseAttributeDef(ActionAST action, Pair<String, Integer> decl, Grammar g) {
+ if (decl.a == null) return null;
+
+ Attribute attr = new Attribute();
+ int rightEdgeOfDeclarator = decl.a.length() - 1;
+ int equalsIndex = decl.a.indexOf('=');
+ if (equalsIndex > 0) {
+ // everything after the '=' is the init value
+ attr.initValue = decl.a.substring(equalsIndex + 1, decl.a.length()).trim();
+ rightEdgeOfDeclarator = equalsIndex - 1;
+ }
+
+ String declarator = decl.a.substring(0, rightEdgeOfDeclarator + 1);
+ Pair<Integer, Integer> p;
+ String text = decl.a;
+ text = text.replaceAll("::","");
+ if ( text.contains(":") ) {
+ // declarator has type appearing after the name like "x:T"
+ p = _parsePostfixDecl(attr, declarator, action, g);
+ }
+ else {
+ // declarator has type appearing before the name like "T x"
+ p = _parsePrefixDecl(attr, declarator, action, g);
}
- return dict;
- }
-
- /** For decls like "String foo" or "char *foo32[]" compute the ID
- * and type declarations. Also handle "int x=3" and 'T t = new T("foo")'
- * but if the separator is ',' you cannot use ',' in the initvalue
- * unless you escape use "\," escape.
- */
- public static Attribute parseAttributeDef(ActionAST action, Pair<String, Integer> decl, Grammar g) {
- if ( decl.a==null ) return null;
- Attribute attr = new Attribute();
- boolean inID = false;
- int start = -1;
- int rightEdgeOfDeclarator = decl.a.length()-1;
- int equalsIndex = decl.a.indexOf('=');
- if ( equalsIndex>0 ) {
- // everything after the '=' is the init value
- attr.initValue = decl.a.substring(equalsIndex+1,decl.a.length());
- rightEdgeOfDeclarator = equalsIndex-1;
- }
- // walk backwards looking for start of an ID
- for (int i=rightEdgeOfDeclarator; i>=0; i--) {
- // if we haven't found the end yet, keep going
- if ( !inID && Character.isLetterOrDigit(decl.a.charAt(i)) ) {
- inID = true;
- }
- else if ( inID &&
- !(Character.isLetterOrDigit(decl.a.charAt(i))||
- decl.a.charAt(i)=='_') ) {
- start = i+1;
- break;
- }
- }
- if ( start<0 && inID ) {
- start = 0;
- }
- if ( start<0 ) {
- g.tool.errMgr.grammarError(ErrorType.CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL, g.fileName, action.token, decl);
- }
- // walk forwards looking for end of an ID
- int stop=-1;
- for (int i=start; i<=rightEdgeOfDeclarator; i++) {
- // if we haven't found the end yet, keep going
- if ( !(Character.isLetterOrDigit(decl.a.charAt(i))||
- decl.a.charAt(i)=='_') )
- {
- stop = i;
- break;
- }
- if ( i==rightEdgeOfDeclarator ) {
- stop = i+1;
- }
- }
-
- // the name is the last ID
- attr.name = decl.a.substring(start,stop);
-
- // the type is the decl minus the ID (could be empty)
- attr.type = decl.a.substring(0,start);
- if ( stop<=rightEdgeOfDeclarator ) {
- attr.type += decl.a.substring(stop,rightEdgeOfDeclarator+1);
- }
- attr.type = attr.type.trim();
- if ( attr.type.length()==0 ) {
- attr.type = null;
- }
-
- attr.decl = decl.a;
+ int idStart = p.a;
+ int idStop = p.b;
+
+ attr.decl = decl.a;
if (action != null) {
String actionText = action.getText();
@@ -163,6 +110,7 @@ public class ScopeParser {
int[] charIndexes = new int[actionText.length()];
for (int i = 0, j = 0; i < actionText.length(); i++, j++) {
charIndexes[j] = i;
+ // skip comments
if (i < actionText.length() - 1 && actionText.charAt(i) == '/' && actionText.charAt(i + 1) == '/') {
while (i < actionText.length() && actionText.charAt(i) != '\n') {
i++;
@@ -171,10 +119,10 @@ public class ScopeParser {
}
int declOffset = charIndexes[decl.b];
- int declLine = lines[declOffset + start];
+ int declLine = lines[declOffset + idStart];
int line = action.getToken().getLine() + declLine;
- int charPositionInLine = charPositionInLines[declOffset + start];
+ int charPositionInLine = charPositionInLines[declOffset + idStart];
if (declLine == 0) {
/* offset for the start position of the ARG_ACTION token, plus 1
* since the ARG_ACTION text had the leading '[' stripped before
@@ -183,119 +131,222 @@ public class ScopeParser {
charPositionInLine += action.getToken().getCharPositionInLine() + 1;
}
- int offset = ((CommonToken)action.getToken()).getStartIndex();
- attr.token = new CommonToken(action.getToken().getInputStream(), ANTLRParser.ID, BaseRecognizer.DEFAULT_TOKEN_CHANNEL, offset + declOffset + start + 1, offset + declOffset + stop);
+ int offset = ((CommonToken) action.getToken()).getStartIndex();
+ attr.token = new CommonToken(action.getToken().getInputStream(), ANTLRParser.ID, BaseRecognizer.DEFAULT_TOKEN_CHANNEL, offset + declOffset + idStart + 1, offset + declOffset + idStop);
attr.token.setLine(line);
attr.token.setCharPositionInLine(charPositionInLine);
assert attr.name.equals(attr.token.getText()) : "Attribute text should match the pseudo-token text at this point.";
}
- return attr;
- }
-
- /** Given an argument list like
- *
- * x, (*a).foo(21,33), 3.2+1, '\n',
- * "a,oo\nick", {bl, "fdkj"eck}, ["cat\n,", x, 43]
- *
- * convert to a list of attributes. Allow nested square brackets etc...
- * Set separatorChar to ';' or ',' or whatever you want.
- */
- public static List<Pair<String, Integer>> splitDecls(String s, int separatorChar) {
- List<Pair<String, Integer>> args = new ArrayList<Pair<String, Integer>>();
- _splitArgumentList(s, 0, -1, separatorChar, args);
- return args;
- }
-
- public static int _splitArgumentList(String actionText,
- int start,
- int targetChar,
- int separatorChar,
- List<Pair<String, Integer>> args)
- {
- if ( actionText==null ) {
- return -1;
- }
-
- actionText = actionText.replaceAll("//[^\\n]*", "");
- int n = actionText.length();
- //System.out.println("actionText@"+start+"->"+(char)targetChar+"="+actionText.substring(start,n));
- int p = start;
- int last = p;
- while ( p<n && actionText.charAt(p)!=targetChar ) {
- int c = actionText.charAt(p);
- switch ( c ) {
- case '\'' :
- p++;
- while ( p<n && actionText.charAt(p)!='\'' ) {
- if ( actionText.charAt(p)=='\\' && (p+1)<n &&
- actionText.charAt(p+1)=='\'' )
- {
- p++; // skip escaped quote
- }
- p++;
- }
- p++;
- break;
- case '"' :
- p++;
- while ( p<n && actionText.charAt(p)!='\"' ) {
- if ( actionText.charAt(p)=='\\' && (p+1)<n &&
- actionText.charAt(p+1)=='\"' )
- {
- p++; // skip escaped quote
- }
- p++;
- }
- p++;
- break;
- case '(' :
- p = _splitArgumentList(actionText,p+1,')',separatorChar,args);
- break;
- case '{' :
- p = _splitArgumentList(actionText,p+1,'}',separatorChar,args);
- break;
- case '<' :
- if ( actionText.indexOf('>',p+1)>=p ) {
- // do we see a matching '>' ahead? if so, hope it's a generic
- // and not less followed by expr with greater than
- p = _splitArgumentList(actionText,p+1,'>',separatorChar,args);
- }
- else {
- p++; // treat as normal char
- }
- break;
- case '[' :
- p = _splitArgumentList(actionText,p+1,']',separatorChar,args);
- break;
- default :
- if ( c==separatorChar && targetChar==-1 ) {
- String arg = actionText.substring(last, p);
+ return attr;
+ }
+
+ public static Pair<Integer, Integer> _parsePrefixDecl(Attribute attr, String decl, ActionAST a, Grammar g) {
+ // walk backwards looking for start of an ID
+ boolean inID = false;
+ int start = -1;
+ for (int i = decl.length() - 1; i >= 0; i--) {
+ char ch = decl.charAt(i);
+ // if we haven't found the end yet, keep going
+ if (!inID && Character.isLetterOrDigit(ch)) {
+ inID = true;
+ }
+ else if (inID && !(Character.isLetterOrDigit(ch) || ch == '_')) {
+ start = i + 1;
+ break;
+ }
+ }
+ if (start < 0 && inID) {
+ start = 0;
+ }
+ if (start < 0) {
+ g.tool.errMgr.grammarError(ErrorType.CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL, g.fileName, a.token, decl);
+ }
+
+ // walk forward looking for end of an ID
+ int stop = -1;
+ for (int i = start; i < decl.length(); i++) {
+ char ch = decl.charAt(i);
+ // if we haven't found the end yet, keep going
+ if (!(Character.isLetterOrDigit(ch) || ch == '_')) {
+ stop = i;
+ break;
+ }
+ if (i == decl.length() - 1) {
+ stop = i + 1;
+ }
+ }
+
+ // the name is the last ID
+ attr.name = decl.substring(start, stop);
+
+ // the type is the decl minus the ID (could be empty)
+ attr.type = decl.substring(0, start);
+ if (stop <= decl.length() - 1) {
+ attr.type += decl.substring(stop, decl.length());
+ }
+
+ attr.type = attr.type.trim();
+ if (attr.type.length() == 0) {
+ attr.type = null;
+ }
+ return new Pair<Integer, Integer>(start, stop);
+ }
+
+ public static Pair<Integer, Integer> _parsePostfixDecl(Attribute attr, String decl, ActionAST a, Grammar g) {
+ int start = -1;
+ int stop = -1;
+ int colon = decl.indexOf(':');
+ int namePartEnd = colon == -1 ? decl.length() : colon;
+
+ // look for start of name
+ for (int i = 0; i < namePartEnd; ++i) {
+ char ch = decl.charAt(i);
+ if (Character.isLetterOrDigit(ch) || ch == '_') {
+ start = i;
+ break;
+ }
+ }
+
+ if (start == -1) {
+ start = 0;
+ g.tool.errMgr.grammarError(ErrorType.CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL, g.fileName, a.token, decl);
+ }
+
+ // look for stop of name
+ for (int i = start; i < namePartEnd; ++i) {
+ char ch = decl.charAt(i);
+ if (!(Character.isLetterOrDigit(ch) || ch == '_')) {
+ stop = i;
+ break;
+ }
+ if (i == namePartEnd - 1) {
+ stop = namePartEnd;
+ }
+ }
+
+ if (stop == -1) {
+ stop = start;
+ }
+
+ // extract name from decl
+ attr.name = decl.substring(start, stop);
+
+ // extract type from decl (could be empty)
+ if (colon == -1) {
+ attr.type = "";
+ }
+ else {
+ attr.type = decl.substring(colon + 1, decl.length());
+ }
+ attr.type = attr.type.trim();
+
+ if (attr.type.length() == 0) {
+ attr.type = null;
+ }
+ return new Pair<Integer, Integer>(start, stop);
+ }
+
+ /**
+ * Given an argument list like
+ * <p>
+ * x, (*a).foo(21,33), 3.2+1, '\n',
+ * "a,oo\nick", {bl, "fdkj"eck}, ["cat\n,", x, 43]
+ * <p>
+ * convert to a list of attributes. Allow nested square brackets etc...
+ * Set separatorChar to ';' or ',' or whatever you want.
+ */
+ public static List<Pair<String, Integer>> splitDecls(String s, int separatorChar) {
+ List<Pair<String, Integer>> args = new ArrayList<Pair<String, Integer>>();
+ _splitArgumentList(s, 0, -1, separatorChar, args);
+ return args;
+ }
+
+ public static int _splitArgumentList(String actionText,
+ int start,
+ int targetChar,
+ int separatorChar,
+ List<Pair<String, Integer>> args) {
+ if (actionText == null) {
+ return -1;
+ }
+
+ actionText = actionText.replaceAll("//[^\\n]*", "");
+ int n = actionText.length();
+ //System.out.println("actionText@"+start+"->"+(char)targetChar+"="+actionText.substring(start,n));
+ int p = start;
+ int last = p;
+ while (p < n && actionText.charAt(p) != targetChar) {
+ int c = actionText.charAt(p);
+ switch (c) {
+ case '\'':
+ p++;
+ while (p < n && actionText.charAt(p) != '\'') {
+ if (actionText.charAt(p) == '\\' && (p + 1) < n &&
+ actionText.charAt(p + 1) == '\'') {
+ p++; // skip escaped quote
+ }
+ p++;
+ }
+ p++;
+ break;
+ case '"':
+ p++;
+ while (p < n && actionText.charAt(p) != '\"') {
+ if (actionText.charAt(p) == '\\' && (p + 1) < n &&
+ actionText.charAt(p + 1) == '\"') {
+ p++; // skip escaped quote
+ }
+ p++;
+ }
+ p++;
+ break;
+ case '(':
+ p = _splitArgumentList(actionText, p + 1, ')', separatorChar, args);
+ break;
+ case '{':
+ p = _splitArgumentList(actionText, p + 1, '}', separatorChar, args);
+ break;
+ case '<':
+ if (actionText.indexOf('>', p + 1) >= p) {
+ // do we see a matching '>' ahead? if so, hope it's a generic
+ // and not less followed by expr with greater than
+ p = _splitArgumentList(actionText, p + 1, '>', separatorChar, args);
+ } else {
+ p++; // treat as normal char
+ }
+ break;
+ case '[':
+ p = _splitArgumentList(actionText, p + 1, ']', separatorChar, args);
+ break;
+ default:
+ if (c == separatorChar && targetChar == -1) {
+ String arg = actionText.substring(last, p);
int index = last;
while (index < p && Character.isWhitespace(actionText.charAt(index))) {
index++;
}
- //System.out.println("arg="+arg);
- args.add(new Pair<String, Integer>(arg.trim(), index));
- last = p+1;
- }
- p++;
- break;
- }
- }
- if ( targetChar==-1 && p<=n ) {
- String arg = actionText.substring(last, p).trim();
+ //System.out.println("arg="+arg);
+ args.add(new Pair<String, Integer>(arg.trim(), index));
+ last = p + 1;
+ }
+ p++;
+ break;
+ }
+ }
+ if (targetChar == -1 && p <= n) {
+ String arg = actionText.substring(last, p).trim();
int index = last;
while (index < p && Character.isWhitespace(actionText.charAt(index))) {
index++;
}
- //System.out.println("arg="+arg);
- if ( arg.length()>0 ) {
- args.add(new Pair<String, Integer>(arg.trim(), index));
- }
- }
- p++;
- return p;
- }
+ //System.out.println("arg="+arg);
+ if (arg.length() > 0) {
+ args.add(new Pair<String, Integer>(arg.trim(), index));
+ }
+ }
+ p++;
+ return p;
+ }
}
diff --git a/tool/src/org/antlr/v4/parse/TokenVocabParser.java b/tool/src/org/antlr/v4/parse/TokenVocabParser.java
index 85398e6..abfa71c 100644
--- a/tool/src/org/antlr/v4/parse/TokenVocabParser.java
+++ b/tool/src/org/antlr/v4/parse/TokenVocabParser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/ToolANTLRLexer.java b/tool/src/org/antlr/v4/parse/ToolANTLRLexer.java
index 625fdd7..613c06c 100644
--- a/tool/src/org/antlr/v4/parse/ToolANTLRLexer.java
+++ b/tool/src/org/antlr/v4/parse/ToolANTLRLexer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/ToolANTLRParser.java b/tool/src/org/antlr/v4/parse/ToolANTLRParser.java
index 168b0f8..bbc4964 100644
--- a/tool/src/org/antlr/v4/parse/ToolANTLRParser.java
+++ b/tool/src/org/antlr/v4/parse/ToolANTLRParser.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/v3TreeGrammarException.java b/tool/src/org/antlr/v4/parse/v3TreeGrammarException.java
index c1fabfe..8c5c7b5 100644
--- a/tool/src/org/antlr/v4/parse/v3TreeGrammarException.java
+++ b/tool/src/org/antlr/v4/parse/v3TreeGrammarException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/parse/v4ParserException.java b/tool/src/org/antlr/v4/parse/v4ParserException.java
index 80cbb75..cdcbe30 100644
--- a/tool/src/org/antlr/v4/parse/v4ParserException.java
+++ b/tool/src/org/antlr/v4/parse/v4ParserException.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.parse;
diff --git a/tool/src/org/antlr/v4/semantics/ActionSniffer.java b/tool/src/org/antlr/v4/semantics/ActionSniffer.java
index 2d48e25..ce25233 100644
--- a/tool/src/org/antlr/v4/semantics/ActionSniffer.java
+++ b/tool/src/org/antlr/v4/semantics/ActionSniffer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/semantics/AttributeChecks.java b/tool/src/org/antlr/v4/semantics/AttributeChecks.java
index f702185..5e35e8c 100644
--- a/tool/src/org/antlr/v4/semantics/AttributeChecks.java
+++ b/tool/src/org/antlr/v4/semantics/AttributeChecks.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java
index 4853c37..4f5e792 100644
--- a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java
+++ b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
@@ -495,7 +471,7 @@ public class BasicSemanticChecks extends GrammarTreeVisitor {
protected void enterTerminal(GrammarAST tree) {
String text = tree.getText();
if (text.equals("''")) {
- g.tool.errMgr.grammarError(ErrorType.EMPTY_STRINGS_NOT_ALLOWED, g.fileName, tree.token);
+ g.tool.errMgr.grammarError(ErrorType.EMPTY_STRINGS_AND_SETS_NOT_ALLOWED, g.fileName, tree.token, "''");
}
}
diff --git a/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java b/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java
index e919890..b0c05e7 100644
--- a/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java
+++ b/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/semantics/RuleCollector.java b/tool/src/org/antlr/v4/semantics/RuleCollector.java
index fa7eb2d..94b68d2 100644
--- a/tool/src/org/antlr/v4/semantics/RuleCollector.java
+++ b/tool/src/org/antlr/v4/semantics/RuleCollector.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java
index ada4324..6f95558 100644
--- a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java
+++ b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
@@ -83,11 +59,13 @@ public class SemanticPipeline {
ruleCollector.process(g.ast);
// DO BASIC / EASY SEMANTIC CHECKS
+ int prevErrors = g.tool.errMgr.getNumErrors();
BasicSemanticChecks basics = new BasicSemanticChecks(g, ruleCollector);
basics.process();
+ if ( g.tool.errMgr.getNumErrors()>prevErrors ) return;
// TRANSFORM LEFT-RECURSIVE RULES
- int prevErrors = g.tool.errMgr.getNumErrors();
+ prevErrors = g.tool.errMgr.getNumErrors();
LeftRecursiveRuleTransformer lrtrans =
new LeftRecursiveRuleTransformer(g.ast, ruleCollector.rules.values(), g);
lrtrans.translateLeftRecursiveRules();
diff --git a/tool/src/org/antlr/v4/semantics/SymbolChecks.java b/tool/src/org/antlr/v4/semantics/SymbolChecks.java
index 999d9f0..5eccef5 100644
--- a/tool/src/org/antlr/v4/semantics/SymbolChecks.java
+++ b/tool/src/org/antlr/v4/semantics/SymbolChecks.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
@@ -43,6 +19,7 @@ import org.antlr.v4.tool.LabelElementPair;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
import org.antlr.v4.tool.ast.GrammarAST;
+import org.antlr.v4.tool.LabelType;
import java.util.Collection;
import java.util.HashMap;
@@ -94,10 +71,10 @@ public class SymbolChecks {
}
public void process() {
- // methods affect fields, but no side-effects outside this object
+ // methods affect fields, but no side-effects outside this object
// So, call order sensitive
// First collect all rules for later use in checkForLabelConflict()
- if ( g.rules!=null ) {
+ if (g.rules != null) {
for (Rule r : g.rules.values()) nameToRuleMap.put(r.name, r);
}
checkReservedNames(g.rules.values());
@@ -107,41 +84,39 @@ public class SymbolChecks {
}
public void checkActionRedefinitions(List<GrammarAST> actions) {
- if ( actions==null ) return;
+ if (actions == null) return;
String scope = g.getDefaultActionScope();
String name;
GrammarAST nameNode;
for (GrammarAST ampersandAST : actions) {
- nameNode = (GrammarAST)ampersandAST.getChild(0);
- if ( ampersandAST.getChildCount()==2 ) {
+ nameNode = (GrammarAST) ampersandAST.getChild(0);
+ if (ampersandAST.getChildCount() == 2) {
name = nameNode.getText();
- }
- else {
+ } else {
scope = nameNode.getText();
- name = ampersandAST.getChild(1).getText();
- }
- Set<String> scopeActions = actionScopeToActionNames.get(scope);
- if ( scopeActions==null ) { // init scope
- scopeActions = new HashSet<String>();
- actionScopeToActionNames.put(scope, scopeActions);
- }
- if ( !scopeActions.contains(name) ) {
- scopeActions.add(name);
- }
- else {
- errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
- g.fileName, nameNode.token, name);
- }
- }
- }
+ name = ampersandAST.getChild(1).getText();
+ }
+ Set<String> scopeActions = actionScopeToActionNames.get(scope);
+ if (scopeActions == null) { // init scope
+ scopeActions = new HashSet<String>();
+ actionScopeToActionNames.put(scope, scopeActions);
+ }
+ if (!scopeActions.contains(name)) {
+ scopeActions.add(name);
+ } else {
+ errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
+ g.fileName, nameNode.token, name);
+ }
+ }
+ }
- public void checkForTokenConflicts(List<GrammarAST> tokenIDRefs) {
+ public void checkForTokenConflicts(List<GrammarAST> tokenIDRefs) {
// for (GrammarAST a : tokenIDRefs) {
// Token t = a.token;
// String ID = t.getText();
// tokenIDs.add(ID);
// }
- }
+ }
/** Make sure a label doesn't conflict with another symbol.
* Labels must not conflict with: rules, tokens, scope names,
@@ -150,43 +125,54 @@ public class SymbolChecks {
* for repeated defs.
*/
public void checkForLabelConflicts(Collection<Rule> rules) {
- for (Rule r : rules) {
- checkForAttributeConflicts(r);
- Map<String, LabelElementPair> labelNameSpace =
- new HashMap<String, LabelElementPair>();
- for (int i=1; i<=r.numberOfAlts; i++) {
+ for (Rule r : rules) {
+ checkForAttributeConflicts(r);
+ Map<String, LabelElementPair> labelNameSpace =
+ new HashMap<String, LabelElementPair>();
+ for (int i = 1; i <= r.numberOfAlts; i++) {
if (r.hasAltSpecificContexts()) {
labelNameSpace.clear();
}
- Alternative a = r.alt[i];
- for (List<LabelElementPair> pairs : a.labelDefs.values() ) {
- for (LabelElementPair p : pairs) {
- checkForLabelConflict(r, p.label);
- String name = p.label.getText();
- LabelElementPair prev = labelNameSpace.get(name);
- if ( prev==null ) labelNameSpace.put(name, p);
- else checkForTypeMismatch(prev, p);
- }
- }
- }
- }
- }
+ Alternative a = r.alt[i];
+ for (List<LabelElementPair> pairs : a.labelDefs.values()) {
+ for (LabelElementPair p : pairs) {
+ checkForLabelConflict(r, p.label);
+ String name = p.label.getText();
+ LabelElementPair prev = labelNameSpace.get(name);
+ if (prev == null) labelNameSpace.put(name, p);
+ else checkForTypeMismatch(prev, p);
+ }
+ }
+ }
+ }
+ }
- void checkForTypeMismatch(LabelElementPair prevLabelPair,
- LabelElementPair labelPair)
- {
- // label already defined; if same type, no problem
- if ( prevLabelPair.type != labelPair.type ) {
- String typeMismatchExpr = labelPair.type+"!="+prevLabelPair.type;
- errMgr.grammarError(
- ErrorType.LABEL_TYPE_CONFLICT,
- g.fileName,
- labelPair.label.token,
- labelPair.label.getText(),
- typeMismatchExpr);
- }
- }
+ void checkForTypeMismatch(LabelElementPair prevLabelPair, LabelElementPair labelPair) {
+ // label already defined; if same type, no problem
+ if (prevLabelPair.type != labelPair.type) {
+ String typeMismatchExpr = labelPair.type + "!=" + prevLabelPair.type;
+ errMgr.grammarError(
+ ErrorType.LABEL_TYPE_CONFLICT,
+ g.fileName,
+ labelPair.label.token,
+ labelPair.label.getText(),
+ typeMismatchExpr);
+ }
+ if (!prevLabelPair.element.getText().equals(labelPair.element.getText()) &&
+ (prevLabelPair.type.equals(LabelType.RULE_LABEL) || prevLabelPair.type.equals(LabelType.RULE_LIST_LABEL)) &&
+ (labelPair.type.equals(LabelType.RULE_LABEL) || labelPair.type.equals(LabelType.RULE_LIST_LABEL))) {
+
+ String prevLabelOp = prevLabelPair.type.equals(LabelType.RULE_LIST_LABEL) ? "+=" : "=";
+ String labelOp = labelPair.type.equals(LabelType.RULE_LIST_LABEL) ? "+=" : "=";
+ errMgr.grammarError(
+ ErrorType.LABEL_TYPE_CONFLICT,
+ g.fileName,
+ labelPair.label.token,
+ labelPair.label.getText() + labelOp + labelPair.element.getText(),
+ prevLabelPair.label.getText() + prevLabelOp + prevLabelPair.element.getText());
+ }
+ }
public void checkForLabelConflict(Rule r, GrammarAST labelID) {
String name = labelID.getText();
diff --git a/tool/src/org/antlr/v4/semantics/SymbolCollector.java b/tool/src/org/antlr/v4/semantics/SymbolCollector.java
index b0c43a4..2bcf9ca 100644
--- a/tool/src/org/antlr/v4/semantics/SymbolCollector.java
+++ b/tool/src/org/antlr/v4/semantics/SymbolCollector.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java
index ac788e1..9c6f444 100644
--- a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java
+++ b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.semantics;
diff --git a/tool/src/org/antlr/v4/tool/ANTLRMessage.java b/tool/src/org/antlr/v4/tool/ANTLRMessage.java
index 36d9ab9..0ed03d6 100644
--- a/tool/src/org/antlr/v4/tool/ANTLRMessage.java
+++ b/tool/src/org/antlr/v4/tool/ANTLRMessage.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/ANTLRToolListener.java b/tool/src/org/antlr/v4/tool/ANTLRToolListener.java
index 76a73a0..5662b34 100644
--- a/tool/src/org/antlr/v4/tool/ANTLRToolListener.java
+++ b/tool/src/org/antlr/v4/tool/ANTLRToolListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/Alternative.java b/tool/src/org/antlr/v4/tool/Alternative.java
index 3d5e1cb..f47543c 100644
--- a/tool/src/org/antlr/v4/tool/Alternative.java
+++ b/tool/src/org/antlr/v4/tool/Alternative.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/Attribute.java b/tool/src/org/antlr/v4/tool/Attribute.java
index 3dc0258..94baaa6 100644
--- a/tool/src/org/antlr/v4/tool/Attribute.java
+++ b/tool/src/org/antlr/v4/tool/Attribute.java
@@ -1,42 +1,18 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
import org.antlr.runtime.Token;
-/** Track the names of attributes define in arg lists, return values,
+/** Track the names of attributes defined in arg lists, return values,
* scope blocks etc...
*/
public class Attribute {
- /** The entire declaration such as "String foo;" */
+ /** The entire declaration such as "String foo" or "x:int" */
public String decl;
/** The type; might be empty such as for Python which has no static typing */
@@ -66,8 +42,11 @@ public class Attribute {
@Override
public String toString() {
if ( initValue!=null ) {
- return type+" "+name+"="+initValue;
+ return name+":"+type+"="+initValue;
}
- return type+" "+name;
+ if ( type!=null ) {
+ return name+":"+type;
+ }
+ return name;
}
-} \ No newline at end of file
+}
diff --git a/tool/src/org/antlr/v4/tool/AttributeDict.java b/tool/src/org/antlr/v4/tool/AttributeDict.java
index e8d487f..6513f9b 100644
--- a/tool/src/org/antlr/v4/tool/AttributeDict.java
+++ b/tool/src/org/antlr/v4/tool/AttributeDict.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -65,7 +41,7 @@ public class AttributeDict {
predefinedTokenDict.add(new Attribute("int"));
}
- public static enum DictType {
+ public enum DictType {
ARG, RET, LOCAL, TOKEN,
PREDEFINED_RULE, PREDEFINED_LEXER_RULE,
}
diff --git a/tool/src/org/antlr/v4/tool/AttributeResolver.java b/tool/src/org/antlr/v4/tool/AttributeResolver.java
index ee01ee1..e581f23 100644
--- a/tool/src/org/antlr/v4/tool/AttributeResolver.java
+++ b/tool/src/org/antlr/v4/tool/AttributeResolver.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java b/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java
index 69e71b5..be48bfa 100644
--- a/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java
+++ b/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java
@@ -1,32 +1,9 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
+
package org.antlr.v4.tool;
import org.antlr.v4.Tool;
@@ -102,7 +79,10 @@ public class BuildDependencyGenerator {
List<File> files = new ArrayList<File>();
// add generated recognizer; e.g., TParser.java
- files.add(getOutputFile(generator.getRecognizerFileName()));
+ if (generator.getTarget().needsHeader()) {
+ files.add(getOutputFile(generator.getRecognizerFileName(true)));
+ }
+ files.add(getOutputFile(generator.getRecognizerFileName(false)));
// add output vocab file; e.g., T.tokens. This is always generated to
// the base output directory, which will be just . if there is no -o option
//
@@ -134,16 +114,30 @@ public class BuildDependencyGenerator {
if ( g.tool.gen_listener ) {
// add generated listener; e.g., TListener.java
- files.add(getOutputFile(generator.getListenerFileName()));
+ if (generator.getTarget().needsHeader()) {
+ files.add(getOutputFile(generator.getListenerFileName(true)));
+ }
+ files.add(getOutputFile(generator.getListenerFileName(false)));
+
// add generated base listener; e.g., TBaseListener.java
- files.add(getOutputFile(generator.getBaseListenerFileName()));
+ if (generator.getTarget().needsHeader()) {
+ files.add(getOutputFile(generator.getBaseListenerFileName(true)));
+ }
+ files.add(getOutputFile(generator.getBaseListenerFileName(false)));
}
if ( g.tool.gen_visitor ) {
// add generated visitor; e.g., TVisitor.java
- files.add(getOutputFile(generator.getVisitorFileName()));
+ if (generator.getTarget().needsHeader()) {
+ files.add(getOutputFile(generator.getVisitorFileName(true)));
+ }
+ files.add(getOutputFile(generator.getVisitorFileName(false)));
+
// add generated base visitor; e.g., TBaseVisitor.java
- files.add(getOutputFile(generator.getBaseVisitorFileName()));
+ if (generator.getTarget().needsHeader()) {
+ files.add(getOutputFile(generator.getBaseVisitorFileName(true)));
+ }
+ files.add(getOutputFile(generator.getBaseVisitorFileName(false)));
}
diff --git a/tool/src/org/antlr/v4/tool/DOTGenerator.java b/tool/src/org/antlr/v4/tool/DOTGenerator.java
index 740bfe4..6f7aaea 100644
--- a/tool/src/org/antlr/v4/tool/DOTGenerator.java
+++ b/tool/src/org/antlr/v4/tool/DOTGenerator.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/DefaultToolListener.java b/tool/src/org/antlr/v4/tool/DefaultToolListener.java
index 2005c85..0f64cd0 100644
--- a/tool/src/org/antlr/v4/tool/DefaultToolListener.java
+++ b/tool/src/org/antlr/v4/tool/DefaultToolListener.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/ErrorManager.java b/tool/src/org/antlr/v4/tool/ErrorManager.java
index 983c41b..34f0d50 100644
--- a/tool/src/org/antlr/v4/tool/ErrorManager.java
+++ b/tool/src/org/antlr/v4/tool/ErrorManager.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -157,7 +133,7 @@ public class ErrorManager {
}
/**
- * Raise a predefined message with some number of paramters for the StringTemplate but for which there
+ * Raise a predefined message with some number of parameters for the StringTemplate but for which there
* is no location information possible.
* @param errorType The Message Descriptor
* @param args The arguments to pass to the StringTemplate
diff --git a/tool/src/org/antlr/v4/tool/ErrorSeverity.java b/tool/src/org/antlr/v4/tool/ErrorSeverity.java
index f942d3e..1c527b1 100644
--- a/tool/src/org/antlr/v4/tool/ErrorSeverity.java
+++ b/tool/src/org/antlr/v4/tool/ErrorSeverity.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -61,7 +37,7 @@ public enum ErrorSeverity {
/**
* Standard constructor to build an instance of the Enum entries
*
- * @param text The human readable string representing the serverity level
+ * @param text The human readable string representing the severity level
*/
private ErrorSeverity(String text) { this.text = text; }
}
diff --git a/tool/src/org/antlr/v4/tool/ErrorType.java b/tool/src/org/antlr/v4/tool/ErrorType.java
index 32bb574..c4a3861 100644
--- a/tool/src/org/antlr/v4/tool/ErrorType.java
+++ b/tool/src/org/antlr/v4/tool/ErrorType.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -328,9 +304,9 @@ public enum ErrorType {
/**
* Compiler Error 79.
*
- * <p>missing arguments(s) on rule reference: <em>rule</em></p>
+ * <p>missing argument(s) on rule reference: <em>rule</em></p>
*/
- MISSING_RULE_ARGS(79, "missing arguments(s) on rule reference: <arg>", ErrorSeverity.ERROR),
+ MISSING_RULE_ARGS(79, "missing argument(s) on rule reference: <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 80.
*
@@ -1006,11 +982,68 @@ public enum ErrorType {
*
* <p>empty strings not allowed</p>
*
- * <pre>A: '''test''';</pre>
- * <pre>B: '';</pre>
- * <pre>C: 'test' '';</pre>
+ * <pre>
+ * A: '''test''';
+ * B: '';
+ * C: 'test' '';
+ * D: [];
+ * E: [f-a];
+ * </pre>
+ */
+ EMPTY_STRINGS_AND_SETS_NOT_ALLOWED(174, "string literals and sets cannot be empty: <arg>", ErrorSeverity.ERROR),
+ /**
+ * Compiler Error 175.
+ *
+ * <p><em>name</em> is not a recognized token name</p>
+ *
+ * <pre>TOKEN: 'a' -> type(CHANNEL1); // error 175</pre>
+ */
+ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME(175, "<arg> is not a recognized token name", ErrorSeverity.ERROR),
+ /**
+ * Compiler Error 176.
+ *
+ * <p><em>name</em>is not a recognized mode name</p>
+ *
+ * <pre>TOKEN: 'a' -> mode(MODE1); // error 176</pre>
+ */
+ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME(176, "<arg> is not a recognized mode name", ErrorSeverity.ERROR),
+ /**
+ * Compiler Error 177.
+ *
+ * <p><em>name</em> is not a recognized channel name</p>
+ *
+ * <pre>TOKEN: 'a' -> channel(TOKEN1); // error 177</pre>
+ */
+ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME(177, "<arg> is not a recognized channel name", ErrorSeverity.ERROR),
+ /*
+ * Compiler Warning 178.
+ *
+ * <p>lexer rule has a duplicated commands</p>
+ *
+ * <p>TOKEN: 'asdf' -> mode(MODE1), mode(MODE2);</p>
+ * */
+ DUPLICATED_COMMAND(178, "duplicated command <arg>", ErrorSeverity.WARNING),
+ /*
+ * Compiler Waring 179.
+ *
+ * <p>incompatible commands <em>command1</em> and <em>command2</em></p>
+ *
+ * <p>T00: 'a00' -> skip, more;</p>
+ */
+ INCOMPATIBLE_COMMANDS(179, "incompatible commands <arg> and <arg2>", ErrorSeverity.WARNING),
+ /**
+ * Compiler Warning 180.
+ *
+ * <p>chars "a-f" used multiple times in set [a-fc-m]</p>
+ *
+ * <pre>
+ * A: [aa-z]; // warning
+ * B: [a-fc-m]; // warning
+ * </pre>
+ *
+ * TODO: Does not work with fragment rules.
*/
- EMPTY_STRINGS_NOT_ALLOWED(174, "string literals cannot be empty", ErrorSeverity.ERROR),
+ CHARACTERS_COLLISION_IN_SET(180, "chars \"<arg>\" used multiple times in set <arg2>", ErrorSeverity.WARNING),
/*
* Backward incompatibility errors
diff --git a/tool/src/org/antlr/v4/tool/Grammar.java b/tool/src/org/antlr/v4/tool/Grammar.java
index 89e2a26..ea249f8 100644
--- a/tool/src/org/antlr/v4/tool/Grammar.java
+++ b/tool/src/org/antlr/v4/tool/Grammar.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -105,6 +81,7 @@ public class Grammar implements AttributeResolver {
parserOptions.add("TokenLabelType");
parserOptions.add("tokenVocab");
parserOptions.add("language");
+ parserOptions.add("exportMacro");
}
public static final Set<String> lexerOptions = parserOptions;
@@ -338,6 +315,15 @@ public class Grammar implements AttributeResolver {
this.text = grammarText;
this.fileName = fileName;
this.tool = new Tool();
+ ANTLRToolListener hush = new ANTLRToolListener() {
+ @Override
+ public void info(String msg) { }
+ @Override
+ public void error(ANTLRMessage msg) { }
+ @Override
+ public void warning(ANTLRMessage msg) { }
+ };
+ tool.addListener(hush); // we want to hush errors/warnings
this.tool.addListener(listener);
org.antlr.runtime.ANTLRStringStream in = new org.antlr.runtime.ANTLRStringStream(grammarText);
in.name = fileName;
@@ -383,6 +369,8 @@ public class Grammar implements AttributeResolver {
if ( ast==null ) return;
GrammarAST i = (GrammarAST)ast.getFirstChildWithType(ANTLRParser.IMPORT);
if ( i==null ) return;
+ Set<String> visited = new HashSet<>();
+ visited.add(this.name);
importedGrammars = new ArrayList<Grammar>();
for (Object c : i.getChildren()) {
GrammarAST t = (GrammarAST)c;
@@ -394,6 +382,9 @@ public class Grammar implements AttributeResolver {
else if ( t.getType()==ANTLRParser.ID ) {
importedGrammarName = t.getText();
}
+ if ( visited.contains(importedGrammarName) ) { // ignore circular refs
+ continue;
+ }
Grammar g;
try {
g = tool.loadImportedGrammar(this, t);
diff --git a/tool/src/org/antlr/v4/tool/GrammarInterpreterRuleContext.java b/tool/src/org/antlr/v4/tool/GrammarInterpreterRuleContext.java
index 936b8dc..78d1731 100644
--- a/tool/src/org/antlr/v4/tool/GrammarInterpreterRuleContext.java
+++ b/tool/src/org/antlr/v4/tool/GrammarInterpreterRuleContext.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java b/tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java
index 1e77d57..b8cbb77 100644
--- a/tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java
+++ b/tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -48,6 +24,7 @@ import org.antlr.v4.runtime.atn.DecisionState;
import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.atn.RuleStartState;
import org.antlr.v4.runtime.atn.StarLoopEntryState;
+import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.tree.Trees;
import java.lang.reflect.Constructor;
@@ -292,22 +269,26 @@ public class GrammarParserInterpreter extends ParserInterpreter {
* ambig input.
*/
public static List<ParserRuleContext> getAllPossibleParseTrees(Grammar g,
- Parser originalParser,
- TokenStream tokens,
- int decision,
- BitSet alts,
- int startIndex,
- int stopIndex,
- int startRuleIndex)
- throws RecognitionException
- {
+ Parser originalParser,
+ TokenStream tokens,
+ int decision,
+ BitSet alts,
+ int startIndex,
+ int stopIndex,
+ int startRuleIndex)
+ throws RecognitionException {
List<ParserRuleContext> trees = new ArrayList<ParserRuleContext>();
// Create a new parser interpreter to parse the ambiguous subphrase
ParserInterpreter parser = deriveTempParserInterpreter(g, originalParser, tokens);
+ if ( stopIndex>=(tokens.size()-1) ) { // if we are pointing at EOF token
+ // EOF is not in tree, so must be 1 less than last non-EOF token
+ stopIndex = tokens.size()-2;
+ }
+
// get ambig trees
int alt = alts.nextSetBit(0);
- while (alt >= 0) {
+ while ( alt>=0 ) {
// re-parse entire input for all ambiguous alternatives
// (don't have to do first as it's been parsed, but do again for simplicity
// using this temp parser.)
@@ -318,16 +299,15 @@ public class GrammarParserInterpreter extends ParserInterpreter {
(GrammarInterpreterRuleContext) Trees.getRootOfSubtreeEnclosingRegion(t, startIndex, stopIndex);
// Use higher of overridden decision tree or tree enclosing all tokens
if ( Trees.isAncestorOf(parser.getOverrideDecisionRoot(), ambigSubTree) ) {
- ambigSubTree = (GrammarInterpreterRuleContext)parser.getOverrideDecisionRoot();
+ ambigSubTree = (GrammarInterpreterRuleContext) parser.getOverrideDecisionRoot();
}
trees.add(ambigSubTree);
- alt = alts.nextSetBit(alt + 1);
+ alt = alts.nextSetBit(alt+1);
}
return trees;
}
-
/** Return a list of parse trees, one for each alternative in a decision
* given the same input.
*
@@ -355,25 +335,25 @@ public class GrammarParserInterpreter extends ParserInterpreter {
* @since 4.5.1
*/
public static List<ParserRuleContext> getLookaheadParseTrees(Grammar g,
- ParserInterpreter originalParser,
- TokenStream tokens,
- int startRuleIndex,
- int decision,
- int startIndex,
- int stopIndex)
- {
+ ParserInterpreter originalParser,
+ TokenStream tokens,
+ int startRuleIndex,
+ int decision,
+ int startIndex,
+ int stopIndex) {
List<ParserRuleContext> trees = new ArrayList<ParserRuleContext>();
// Create a new parser interpreter to parse the ambiguous subphrase
ParserInterpreter parser = deriveTempParserInterpreter(g, originalParser, tokens);
- BailButConsumeErrorStrategy errorHandler = new BailButConsumeErrorStrategy();
- parser.setErrorHandler(errorHandler);
DecisionState decisionState = originalParser.getATN().decisionToState.get(decision);
- for (int alt=1; alt<=decisionState.getTransitions().length; alt++) {
+ for (int alt = 1; alt<=decisionState.getTransitions().length; alt++) {
// re-parse entire input for all ambiguous alternatives
// (don't have to do first as it's been parsed, but do again for simplicity
// using this temp parser.)
+ GrammarParserInterpreter.BailButConsumeErrorStrategy errorHandler =
+ new GrammarParserInterpreter.BailButConsumeErrorStrategy();
+ parser.setErrorHandler(errorHandler);
parser.reset();
parser.addDecisionOverride(decision, startIndex, alt);
ParserRuleContext tt = parser.parse(startRuleIndex);
@@ -381,10 +361,17 @@ public class GrammarParserInterpreter extends ParserInterpreter {
if ( errorHandler.firstErrorTokenIndex>=0 ) {
stopTreeAt = errorHandler.firstErrorTokenIndex; // cut off rest at first error
}
+ Interval overallRange = tt.getSourceInterval();
+ if ( stopTreeAt>overallRange.b ) {
+ // If we try to look beyond range of tree, stopTreeAt must be EOF
+ // for which there is no EOF ref in grammar. That means tree
+ // will not have node for stopTreeAt; limit to overallRange.b
+ stopTreeAt = overallRange.b;
+ }
ParserRuleContext subtree =
Trees.getRootOfSubtreeEnclosingRegion(tt,
- startIndex,
- stopTreeAt);
+ startIndex,
+ stopTreeAt);
// Use higher of overridden decision tree or tree enclosing all tokens
if ( Trees.isAncestorOf(parser.getOverrideDecisionRoot(), subtree) ) {
subtree = parser.getOverrideDecisionRoot();
diff --git a/tool/src/org/antlr/v4/tool/GrammarSemanticsMessage.java b/tool/src/org/antlr/v4/tool/GrammarSemanticsMessage.java
index 72e7501..3be7c72 100644
--- a/tool/src/org/antlr/v4/tool/GrammarSemanticsMessage.java
+++ b/tool/src/org/antlr/v4/tool/GrammarSemanticsMessage.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/GrammarSyntaxMessage.java b/tool/src/org/antlr/v4/tool/GrammarSyntaxMessage.java
index 4648a84..6de8861 100644
--- a/tool/src/org/antlr/v4/tool/GrammarSyntaxMessage.java
+++ b/tool/src/org/antlr/v4/tool/GrammarSyntaxMessage.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java b/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java
index 9668838..fa27e7f 100644
--- a/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java
+++ b/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/LabelElementPair.java b/tool/src/org/antlr/v4/tool/LabelElementPair.java
index 835bd5f..aa2b292 100644
--- a/tool/src/org/antlr/v4/tool/LabelElementPair.java
+++ b/tool/src/org/antlr/v4/tool/LabelElementPair.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/LabelType.java b/tool/src/org/antlr/v4/tool/LabelType.java
index df92ff9..b28cee2 100644
--- a/tool/src/org/antlr/v4/tool/LabelType.java
+++ b/tool/src/org/antlr/v4/tool/LabelType.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
@@ -36,10 +12,5 @@ public enum LabelType {
TOKEN_LABEL,
RULE_LIST_LABEL,
TOKEN_LIST_LABEL,
- LEXER_STRING_LABEL, // used in lexer for x='a'
- SUBRULE_LABEL, // x=(...)
- SUBRULE_LIST_LABEL, // x+=(...)
- WILDCARD_TREE_LABEL, // Used in tree grammar x=.
- WILDCARD_TREE_LIST_LABEL // Used in tree grammar x+=.
- ;
+ LEXER_STRING_LABEL; // used in lexer for x='a'
}
diff --git a/tool/src/org/antlr/v4/tool/LeftRecursionCyclesMessage.java b/tool/src/org/antlr/v4/tool/LeftRecursionCyclesMessage.java
index 3e0740b..ca1fbc3 100644
--- a/tool/src/org/antlr/v4/tool/LeftRecursionCyclesMessage.java
+++ b/tool/src/org/antlr/v4/tool/LeftRecursionCyclesMessage.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/LeftRecursiveRule.java b/tool/src/org/antlr/v4/tool/LeftRecursiveRule.java
index ad06e34..fb07c5b 100644
--- a/tool/src/org/antlr/v4/tool/LeftRecursiveRule.java
+++ b/tool/src/org/antlr/v4/tool/LeftRecursiveRule.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/LexerGrammar.java b/tool/src/org/antlr/v4/tool/LexerGrammar.java
index 5b92a80..5c89ab8 100644
--- a/tool/src/org/antlr/v4/tool/LexerGrammar.java
+++ b/tool/src/org/antlr/v4/tool/LexerGrammar.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/Rule.java b/tool/src/org/antlr/v4/tool/Rule.java
index 38f5c88..986ea7f 100644
--- a/tool/src/org/antlr/v4/tool/Rule.java
+++ b/tool/src/org/antlr/v4/tool/Rule.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/ToolMessage.java b/tool/src/org/antlr/v4/tool/ToolMessage.java
index 422eda2..b340466 100644
--- a/tool/src/org/antlr/v4/tool/ToolMessage.java
+++ b/tool/src/org/antlr/v4/tool/ToolMessage.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool;
diff --git a/tool/src/org/antlr/v4/tool/ast/ActionAST.java b/tool/src/org/antlr/v4/tool/ast/ActionAST.java
index 8daf349..9ac97da 100644
--- a/tool/src/org/antlr/v4/tool/ast/ActionAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/ActionAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/AltAST.java b/tool/src/org/antlr/v4/tool/ast/AltAST.java
index 77e2106..38f5a6b 100644
--- a/tool/src/org/antlr/v4/tool/ast/AltAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/AltAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/BlockAST.java b/tool/src/org/antlr/v4/tool/ast/BlockAST.java
index 6e45e96..9ddf349 100644
--- a/tool/src/org/antlr/v4/tool/ast/BlockAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/BlockAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarAST.java b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java
index a794b88..cb59b83 100644
--- a/tool/src/org/antlr/v4/tool/ast/GrammarAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java
index 3b2094b..472dcf5 100644
--- a/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java
+++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java
index a11deb1..be92f85 100644
--- a/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java
+++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java
index b492c93..f6b5bca 100644
--- a/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java
+++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java
@@ -1,37 +1,14 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token;
import org.antlr.v4.misc.CharSupport;
+import org.antlr.v4.tool.ErrorType;
import java.util.Collections;
import java.util.HashMap;
@@ -65,6 +42,10 @@ public abstract class GrammarASTWithOptions extends GrammarAST {
String v = value.getText();
if ( v.startsWith("'") || v.startsWith("\"") ) {
v = CharSupport.getStringFromGrammarStringLiteral(v);
+ if (v == null) {
+ g.tool.errMgr.grammarError(ErrorType.INVALID_ESCAPE_SEQUENCE, g.fileName, value.getToken());
+ v = "";
+ }
}
return v;
}
diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java b/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java
index bf4ef96..95f5128 100644
--- a/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/NotAST.java b/tool/src/org/antlr/v4/tool/ast/NotAST.java
index 0d943e6..ecd1d5a 100644
--- a/tool/src/org/antlr/v4/tool/ast/NotAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/NotAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/OptionalBlockAST.java b/tool/src/org/antlr/v4/tool/ast/OptionalBlockAST.java
index fafdfc3..3a05d89 100644
--- a/tool/src/org/antlr/v4/tool/ast/OptionalBlockAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/OptionalBlockAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/PlusBlockAST.java b/tool/src/org/antlr/v4/tool/ast/PlusBlockAST.java
index 2bd97be..ad0ae26 100644
--- a/tool/src/org/antlr/v4/tool/ast/PlusBlockAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/PlusBlockAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/PredAST.java b/tool/src/org/antlr/v4/tool/ast/PredAST.java
index c7d0706..8069916 100644
--- a/tool/src/org/antlr/v4/tool/ast/PredAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/PredAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/QuantifierAST.java b/tool/src/org/antlr/v4/tool/ast/QuantifierAST.java
index 0869ca7..acfa942 100644
--- a/tool/src/org/antlr/v4/tool/ast/QuantifierAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/QuantifierAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/RangeAST.java b/tool/src/org/antlr/v4/tool/ast/RangeAST.java
index 54ce96a..e285ca6 100644
--- a/tool/src/org/antlr/v4/tool/ast/RangeAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/RangeAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/RuleAST.java b/tool/src/org/antlr/v4/tool/ast/RuleAST.java
index 0db780a..3600971 100644
--- a/tool/src/org/antlr/v4/tool/ast/RuleAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/RuleAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/RuleElementAST.java b/tool/src/org/antlr/v4/tool/ast/RuleElementAST.java
index e5118fa..e355604 100644
--- a/tool/src/org/antlr/v4/tool/ast/RuleElementAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/RuleElementAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/RuleRefAST.java b/tool/src/org/antlr/v4/tool/ast/RuleRefAST.java
index 822c142..be07e58 100644
--- a/tool/src/org/antlr/v4/tool/ast/RuleRefAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/RuleRefAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/SetAST.java b/tool/src/org/antlr/v4/tool/ast/SetAST.java
index 9c06b49..53c4c36 100644
--- a/tool/src/org/antlr/v4/tool/ast/SetAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/SetAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/StarBlockAST.java b/tool/src/org/antlr/v4/tool/ast/StarBlockAST.java
index 58c7b45..20b8793 100644
--- a/tool/src/org/antlr/v4/tool/ast/StarBlockAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/StarBlockAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;
diff --git a/tool/src/org/antlr/v4/tool/ast/TerminalAST.java b/tool/src/org/antlr/v4/tool/ast/TerminalAST.java
index 26114f3..fcac32d 100644
--- a/tool/src/org/antlr/v4/tool/ast/TerminalAST.java
+++ b/tool/src/org/antlr/v4/tool/ast/TerminalAST.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.tool.ast;