├── CMakeLists.txt ├── README.md ├── antlr-runtime ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── VERSION ├── cmake │ ├── Antlr4Package.md │ ├── ExternalAntlr4Cpp.cmake │ ├── FindANTLR.cmake │ ├── README.md │ ├── antlr4-generator.cmake.in │ └── antlr4-runtime.cmake.in ├── demo │ ├── CMakeLists.txt │ ├── Linux │ │ └── main.cpp │ ├── Mac │ │ ├── antlr4-cpp-demo │ │ │ └── main.cpp │ │ ├── antlrcpp Tests │ │ │ ├── Info.plist │ │ │ ├── InputHandlingTests.mm │ │ │ ├── MiscClassTests.mm │ │ │ └── antlrcpp_Tests.mm │ │ ├── antlrcpp-demo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ ├── antlr4-cpp-demo.xcscheme │ │ │ │ └── antlrcpp Tests.xcscheme │ │ └── build.sh │ ├── README.md │ ├── TLexer.g4 │ ├── TLexer.tokens │ ├── TParser.g4 │ ├── Windows │ │ ├── antlr4-cpp-demo │ │ │ ├── antlr4-cpp-demo-vs2015.vcxproj │ │ │ ├── antlr4-cpp-demo-vs2015.vcxproj.filters │ │ │ ├── antlr4-cpp-demo.vcxproj │ │ │ ├── antlr4-cpp-demo.vcxproj.filters │ │ │ └── main.cpp │ │ ├── antlr4cpp-vs2013.sln │ │ └── antlr4cpp-vs2015.sln │ ├── generate.cmd │ ├── generate.sh │ └── generated │ │ ├── TLexer.cpp │ │ ├── TLexer.h │ │ ├── TLexer.interp │ │ ├── TLexer.tokens │ │ ├── TParser.cpp │ │ ├── TParser.h │ │ ├── TParser.interp │ │ ├── TParser.tokens │ │ ├── TParserBaseListener.cpp │ │ ├── TParserBaseListener.h │ │ ├── TParserBaseVisitor.cpp │ │ ├── TParserBaseVisitor.h │ │ ├── TParserListener.cpp │ │ ├── TParserListener.h │ │ ├── TParserVisitor.cpp │ │ └── TParserVisitor.h ├── deploy-macos.sh ├── deploy-source.sh ├── deploy-windows.cmd ├── dist │ ├── libantlr4-runtime.a │ ├── libantlr4-runtime.so │ └── libantlr4-runtime.so.4.8 └── runtime │ ├── CMakeLists.txt │ ├── antlr4cpp-vs2013.vcxproj │ ├── antlr4cpp-vs2013.vcxproj.filters │ ├── antlr4cpp-vs2015.vcxproj │ ├── antlr4cpp-vs2015.vcxproj.filters │ ├── antlr4cpp-vs2017.vcxproj │ ├── antlr4cpp-vs2017.vcxproj.filters │ ├── antlr4cpp-vs2019.vcxproj │ ├── antlr4cpp-vs2019.vcxproj.filters │ ├── antlrcpp-ios │ ├── Info.plist │ └── antlrcpp_ios.h │ ├── antlrcpp.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ ├── antlr4.xcscheme │ │ ├── antlr4_ios.xcscheme │ │ └── antlr4_static.xcscheme │ ├── buil │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 3.5.1 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ └── a.out │ │ │ └── CompilerIdCXX │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ └── a.out │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeOutput.log │ │ ├── CMakeRuleHashes.txt │ │ ├── Makefile.cmake │ │ ├── Makefile2 │ │ ├── TargetDirectories.txt │ │ ├── antlr4_shared.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ └── progress.make │ │ ├── antlr4_static.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ └── progress.make │ │ ├── cmake.check_cache │ │ ├── feature_tests.bin │ │ ├── feature_tests.c │ │ ├── feature_tests.cxx │ │ ├── make_lib_output_dir.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ └── progress.make │ │ └── progress.marks │ ├── Makefile │ └── cmake_install.cmake │ ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 3.5.1 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ └── a.out │ │ │ └── CompilerIdCXX │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ └── a.out │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeOutput.log │ │ ├── CMakeRuleHashes.txt │ │ ├── Makefile.cmake │ │ ├── Makefile2 │ │ ├── TargetDirectories.txt │ │ ├── antlr4_shared.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ └── progress.make │ │ ├── antlr4_static.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ └── progress.make │ │ ├── cmake.check_cache │ │ ├── feature_tests.bin │ │ ├── feature_tests.c │ │ ├── feature_tests.cxx │ │ ├── make_lib_output_dir.dir │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ └── progress.make │ │ └── progress.marks │ ├── Makefile │ └── cmake_install.cmake │ └── src │ ├── ANTLRErrorListener.cpp │ ├── ANTLRErrorListener.h │ ├── ANTLRErrorStrategy.cpp │ ├── ANTLRErrorStrategy.h │ ├── ANTLRFileStream.cpp │ ├── ANTLRFileStream.h │ ├── ANTLRInputStream.cpp │ ├── ANTLRInputStream.h │ ├── BailErrorStrategy.cpp │ ├── BailErrorStrategy.h │ ├── BaseErrorListener.cpp │ ├── BaseErrorListener.h │ ├── BufferedTokenStream.cpp │ ├── BufferedTokenStream.h │ ├── CharStream.cpp │ ├── CharStream.h │ ├── CommonToken.cpp │ ├── CommonToken.h │ ├── CommonTokenFactory.cpp │ ├── CommonTokenFactory.h │ ├── CommonTokenStream.cpp │ ├── CommonTokenStream.h │ ├── ConsoleErrorListener.cpp │ ├── ConsoleErrorListener.h │ ├── DefaultErrorStrategy.cpp │ ├── DefaultErrorStrategy.h │ ├── DiagnosticErrorListener.cpp │ ├── DiagnosticErrorListener.h │ ├── Exceptions.cpp │ ├── Exceptions.h │ ├── FailedPredicateException.cpp │ ├── FailedPredicateException.h │ ├── InputMismatchException.cpp │ ├── InputMismatchException.h │ ├── IntStream.cpp │ ├── IntStream.h │ ├── InterpreterRuleContext.cpp │ ├── InterpreterRuleContext.h │ ├── Lexer.cpp │ ├── Lexer.h │ ├── LexerInterpreter.cpp │ ├── LexerInterpreter.h │ ├── LexerNoViableAltException.cpp │ ├── LexerNoViableAltException.h │ ├── ListTokenSource.cpp │ ├── ListTokenSource.h │ ├── NoViableAltException.cpp │ ├── NoViableAltException.h │ ├── Parser.cpp │ ├── Parser.h │ ├── ParserInterpreter.cpp │ ├── ParserInterpreter.h │ ├── ParserRuleContext.cpp │ ├── ParserRuleContext.h │ ├── ProxyErrorListener.cpp │ ├── ProxyErrorListener.h │ ├── RecognitionException.cpp │ ├── RecognitionException.h │ ├── Recognizer.cpp │ ├── Recognizer.h │ ├── RuleContext.cpp │ ├── RuleContext.h │ ├── RuleContextWithAltNum.cpp │ ├── RuleContextWithAltNum.h │ ├── RuntimeMetaData.cpp │ ├── RuntimeMetaData.h │ ├── Token.cpp │ ├── Token.h │ ├── TokenFactory.h │ ├── TokenSource.cpp │ ├── TokenSource.h │ ├── TokenStream.cpp │ ├── TokenStream.h │ ├── TokenStreamRewriter.cpp │ ├── TokenStreamRewriter.h │ ├── UnbufferedCharStream.cpp │ ├── UnbufferedCharStream.h │ ├── UnbufferedTokenStream.cpp │ ├── UnbufferedTokenStream.h │ ├── Vocabulary.cpp │ ├── Vocabulary.h │ ├── WritableToken.cpp │ ├── WritableToken.h │ ├── antlr4-common.h │ ├── antlr4-runtime.h │ ├── atn │ ├── ATN.cpp │ ├── ATN.h │ ├── ATNConfig.cpp │ ├── ATNConfig.h │ ├── ATNConfigSet.cpp │ ├── ATNConfigSet.h │ ├── ATNDeserializationOptions.cpp │ ├── ATNDeserializationOptions.h │ ├── ATNDeserializer.cpp │ ├── ATNDeserializer.h │ ├── ATNSerializer.cpp │ ├── ATNSerializer.h │ ├── ATNSimulator.cpp │ ├── ATNSimulator.h │ ├── ATNState.cpp │ ├── ATNState.h │ ├── ATNType.h │ ├── AbstractPredicateTransition.cpp │ ├── AbstractPredicateTransition.h │ ├── ActionTransition.cpp │ ├── ActionTransition.h │ ├── AmbiguityInfo.cpp │ ├── AmbiguityInfo.h │ ├── ArrayPredictionContext.cpp │ ├── ArrayPredictionContext.h │ ├── AtomTransition.cpp │ ├── AtomTransition.h │ ├── BasicBlockStartState.cpp │ ├── BasicBlockStartState.h │ ├── BasicState.cpp │ ├── BasicState.h │ ├── BlockEndState.cpp │ ├── BlockEndState.h │ ├── BlockStartState.cpp │ ├── BlockStartState.h │ ├── ContextSensitivityInfo.cpp │ ├── ContextSensitivityInfo.h │ ├── DecisionEventInfo.cpp │ ├── DecisionEventInfo.h │ ├── DecisionInfo.cpp │ ├── DecisionInfo.h │ ├── DecisionState.cpp │ ├── DecisionState.h │ ├── EmptyPredictionContext.cpp │ ├── EmptyPredictionContext.h │ ├── EpsilonTransition.cpp │ ├── EpsilonTransition.h │ ├── ErrorInfo.cpp │ ├── ErrorInfo.h │ ├── LL1Analyzer.cpp │ ├── LL1Analyzer.h │ ├── LexerATNConfig.cpp │ ├── LexerATNConfig.h │ ├── LexerATNSimulator.cpp │ ├── LexerATNSimulator.h │ ├── LexerAction.cpp │ ├── LexerAction.h │ ├── LexerActionExecutor.cpp │ ├── LexerActionExecutor.h │ ├── LexerActionType.h │ ├── LexerChannelAction.cpp │ ├── LexerChannelAction.h │ ├── LexerCustomAction.cpp │ ├── LexerCustomAction.h │ ├── LexerIndexedCustomAction.cpp │ ├── LexerIndexedCustomAction.h │ ├── LexerModeAction.cpp │ ├── LexerModeAction.h │ ├── LexerMoreAction.cpp │ ├── LexerMoreAction.h │ ├── LexerPopModeAction.cpp │ ├── LexerPopModeAction.h │ ├── LexerPushModeAction.cpp │ ├── LexerPushModeAction.h │ ├── LexerSkipAction.cpp │ ├── LexerSkipAction.h │ ├── LexerTypeAction.cpp │ ├── LexerTypeAction.h │ ├── LookaheadEventInfo.cpp │ ├── LookaheadEventInfo.h │ ├── LoopEndState.cpp │ ├── LoopEndState.h │ ├── Makefile │ ├── NotSetTransition.cpp │ ├── NotSetTransition.h │ ├── OrderedATNConfigSet.cpp │ ├── OrderedATNConfigSet.h │ ├── ParseInfo.cpp │ ├── ParseInfo.h │ ├── ParserATNSimulator.cpp │ ├── ParserATNSimulator.h │ ├── PlusBlockStartState.cpp │ ├── PlusBlockStartState.h │ ├── PlusLoopbackState.cpp │ ├── PlusLoopbackState.h │ ├── PrecedencePredicateTransition.cpp │ ├── PrecedencePredicateTransition.h │ ├── PredicateEvalInfo.cpp │ ├── PredicateEvalInfo.h │ ├── PredicateTransition.cpp │ ├── PredicateTransition.h │ ├── PredictionContext.cpp │ ├── PredictionContext.h │ ├── PredictionMode.cpp │ ├── PredictionMode.h │ ├── ProfilingATNSimulator.cpp │ ├── ProfilingATNSimulator.h │ ├── RangeTransition.cpp │ ├── RangeTransition.h │ ├── RuleStartState.cpp │ ├── RuleStartState.h │ ├── RuleStopState.cpp │ ├── RuleStopState.h │ ├── RuleTransition.cpp │ ├── RuleTransition.h │ ├── SemanticContext.cpp │ ├── SemanticContext.h │ ├── SetTransition.cpp │ ├── SetTransition.h │ ├── SingletonPredictionContext.cpp │ ├── SingletonPredictionContext.h │ ├── StarBlockStartState.cpp │ ├── StarBlockStartState.h │ ├── StarLoopEntryState.cpp │ ├── StarLoopEntryState.h │ ├── StarLoopbackState.cpp │ ├── StarLoopbackState.h │ ├── TokensStartState.cpp │ ├── TokensStartState.h │ ├── Transition.cpp │ ├── Transition.h │ ├── WildcardTransition.cpp │ └── WildcardTransition.h │ ├── dfa │ ├── DFA.cpp │ ├── DFA.h │ ├── DFASerializer.cpp │ ├── DFASerializer.h │ ├── DFAState.cpp │ ├── DFAState.h │ ├── LexerDFASerializer.cpp │ └── LexerDFASerializer.h │ ├── misc │ ├── InterpreterDataReader.cpp │ ├── InterpreterDataReader.h │ ├── Interval.cpp │ ├── Interval.h │ ├── IntervalSet.cpp │ ├── IntervalSet.h │ ├── MurmurHash.cpp │ ├── MurmurHash.h │ ├── Predicate.cpp │ └── Predicate.h │ ├── support │ ├── Any.cpp │ ├── Any.h │ ├── Arrays.cpp │ ├── Arrays.h │ ├── BitSet.h │ ├── CPPUtils.cpp │ ├── CPPUtils.h │ ├── Declarations.h │ ├── StringUtils.cpp │ ├── StringUtils.h │ ├── guid.cpp │ └── guid.h │ └── tree │ ├── AbstractParseTreeVisitor.h │ ├── ErrorNode.cpp │ ├── ErrorNode.h │ ├── ErrorNodeImpl.cpp │ ├── ErrorNodeImpl.h │ ├── IterativeParseTreeWalker.cpp │ ├── IterativeParseTreeWalker.h │ ├── ParseTree.cpp │ ├── ParseTree.h │ ├── ParseTreeListener.cpp │ ├── ParseTreeListener.h │ ├── ParseTreeProperty.h │ ├── ParseTreeVisitor.cpp │ ├── ParseTreeVisitor.h │ ├── ParseTreeWalker.cpp │ ├── ParseTreeWalker.h │ ├── TerminalNode.cpp │ ├── TerminalNode.h │ ├── TerminalNodeImpl.cpp │ ├── TerminalNodeImpl.h │ ├── Trees.cpp │ ├── Trees.h │ ├── pattern │ ├── Chunk.cpp │ ├── Chunk.h │ ├── ParseTreeMatch.cpp │ ├── ParseTreeMatch.h │ ├── ParseTreePattern.cpp │ ├── ParseTreePattern.h │ ├── ParseTreePatternMatcher.cpp │ ├── ParseTreePatternMatcher.h │ ├── RuleTagToken.cpp │ ├── RuleTagToken.h │ ├── TagChunk.cpp │ ├── TagChunk.h │ ├── TextChunk.cpp │ ├── TextChunk.h │ ├── TokenTagToken.cpp │ └── TokenTagToken.h │ └── xpath │ ├── XPath.cpp │ ├── XPath.h │ ├── XPathElement.cpp │ ├── XPathElement.h │ ├── XPathLexer.cpp │ ├── XPathLexer.g4 │ ├── XPathLexer.h │ ├── XPathLexer.tokens │ ├── XPathLexerErrorListener.cpp │ ├── XPathLexerErrorListener.h │ ├── XPathRuleAnywhereElement.cpp │ ├── XPathRuleAnywhereElement.h │ ├── XPathRuleElement.cpp │ ├── XPathRuleElement.h │ ├── XPathTokenAnywhereElement.cpp │ ├── XPathTokenAnywhereElement.h │ ├── XPathTokenElement.cpp │ ├── XPathTokenElement.h │ ├── XPathWildcardAnywhereElement.cpp │ ├── XPathWildcardAnywhereElement.h │ ├── XPathWildcardElement.cpp │ └── XPathWildcardElement.h ├── bin └── antlr-4.8-complete.jar ├── lib ├── libantlr4-runtime.a ├── libantlr4-runtime.so └── libantlr4-runtime.so.4.8 ├── rpgle └── CALCFIB.rpgle └── src ├── antlr ├── RpgLexer.g4 ├── RpgLexer.tokens └── RpgParser.g4 ├── generated ├── RpgLexer.cpp ├── RpgLexer.h ├── RpgLexer.interp ├── RpgLexer.tokens ├── RpgParser.cpp ├── RpgParser.h ├── RpgParser.interp ├── RpgParser.tokens ├── RpgParserBaseListener.cpp ├── RpgParserBaseListener.h ├── RpgParserBaseVisitor.cpp ├── RpgParserBaseVisitor.h ├── RpgParserListener.cpp ├── RpgParserListener.h ├── RpgParserVisitor.cpp └── RpgParserVisitor.h ├── main.cpp ├── rpg ├── ast.h ├── compiler.cpp ├── compiler.h ├── declaration.cpp ├── declaration.h ├── generator.cpp ├── generator.h ├── log.h ├── parser.cpp ├── parser.h ├── rpgjit.h ├── symbtab.h ├── symtab.cpp └── tags └── utils └── optionparser.h /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5.1) 2 | project(rpg) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | set(LLVM_LINK_COMPONENTS 7 | Analysis 8 | Core 9 | Support 10 | ) 11 | 12 | include_directories(include) 13 | include_directories(test/gtest) 14 | include_directories(src) 15 | include_directories(src/generated) 16 | include_directories(antlr-runtime/runtime/src) 17 | include_directories(/usr/include/llvm-11) 18 | 19 | link_directories(/usr/lib/llvm-11/lib) 20 | add_definitions(-DANTLR4CPP_STATIC) 21 | 22 | add_executable(rpg src/main.cpp 23 | src/generated/RpgLexer.cpp 24 | src/generated/RpgParser.cpp 25 | src/rpg/compiler.cpp 26 | src/rpg/symtab.cpp src/rpg/declaration.cpp src/rpg/parser.cpp src/rpg/generator.cpp src/rpg/rpgjit.h) 27 | 28 | target_link_libraries(rpg antlr4-runtime.a -lLLVM-11 -lrt -ldl -ltinfo -lpthread -lz -lm) 29 | 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A tutorial on how to write a compiler using LLVM 2 | 3 | This is the companion repository to the article at https://tomassetti.me/a-tutorial-on-how-to-write-a-compiler-using-llvm/. 4 | 5 | The project requires the LLVM librariaries installed see https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm. 6 | 7 | ## Project Structure 8 | ``` 9 | . 10 | ├── bin 11 | │ └── antlr-4.8-complete.jar // ANTLR4 tool 12 | | 13 | ├── rpgle 14 | │ └── CALCFIB.rpgle // Sample RPG file 15 | ├── src 16 | │ ├── antlr // ANTLR4 grammar files 17 | │ ├── generated // ANTLR4 generated parser/lexer 18 | │ └── rpg // C++ source code 19 | │ 20 | └── CMakeLists.txt // CMake file 21 | ``` 22 | 23 | ## Compile and run 24 | CMake 25 | ``` 26 | article-llvm-rpg$ cmake . 27 | ``` 28 | Build the project 29 | ``` 30 | article-llvm-rpg$ make -j2 31 | ``` 32 | Run the sample 33 | ``` 34 | article-llvm-rpg$ ./rpg rpgle/CALCFIB.rpgle 35 | ``` 36 | 37 | ## Generate parser and lexer 38 | The ANTLR4 lexer and parser are already included in the source code, the antlr .jar file required 39 | to is available in the bin directory. 40 | To re generate the lexer and the parser: 41 | ``` 42 | article-llvm-rpg$ java -cp ./bin/antlr-4.8-complete.jar org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o src/generated/ -Xexact-output-dir -package antlrcpprpg src/antlr/RpgLexer.g4 src/antlr/RpgParser.g4 43 | ``` 44 | -------------------------------------------------------------------------------- /antlr-runtime/VERSION: -------------------------------------------------------------------------------- 1 | 4.8 2 | -------------------------------------------------------------------------------- /antlr-runtime/cmake/antlr4-runtime.cmake.in: -------------------------------------------------------------------------------- 1 | set(ANTLR_VERSION @ANTLR_VERSION@) 2 | 3 | @PACKAGE_INIT@ 4 | 5 | set_and_check(ANTLR4_INCLUDE_DIR "@PACKAGE_ANTLR4_INCLUDE_DIR@") 6 | set_and_check(ANTLR4_LIB_DIR "@PACKAGE_ANTLR4_LIB_DIR@") 7 | 8 | include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake) 9 | 10 | check_required_components(antlr) 11 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Linux/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | // 7 | // main.cpp 8 | // antlr4-cpp-demo 9 | // 10 | // Created by Mike Lischke on 13.03.16. 11 | // 12 | 13 | #include 14 | 15 | #include "antlr4-runtime.h" 16 | #include "TLexer.h" 17 | #include "TParser.h" 18 | 19 | using namespace antlrcpptest; 20 | using namespace antlr4; 21 | 22 | int main(int , const char **) { 23 | ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);"); 24 | TLexer lexer(&input); 25 | CommonTokenStream tokens(&lexer); 26 | 27 | tokens.fill(); 28 | for (auto token : tokens.getTokens()) { 29 | std::cout << token->toString() << std::endl; 30 | } 31 | 32 | TParser parser(&tokens); 33 | tree::ParseTree* tree = parser.main(); 34 | 35 | std::cout << tree->toStringTree(&parser) << std::endl << std::endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Mac/antlr4-cpp-demo/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | // 7 | // main.cpp 8 | // antlr4-cpp-demo 9 | // 10 | // Created by Mike Lischke on 13.03.16. 11 | // 12 | 13 | #include 14 | 15 | #include "antlr4-runtime.h" 16 | #include "TLexer.h" 17 | #include "TParser.h" 18 | 19 | using namespace antlrcpptest; 20 | using namespace antlr4; 21 | 22 | int main(int , const char **) { 23 | ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);"); 24 | TLexer lexer(&input); 25 | CommonTokenStream tokens(&lexer); 26 | 27 | tokens.fill(); 28 | for (auto token : tokens.getTokens()) { 29 | std::cout << token->toString() << std::endl; 30 | } 31 | 32 | TParser parser(&tokens); 33 | tree::ParseTree *tree = parser.main(); 34 | 35 | std::cout << tree->toStringTree(&parser) << std::endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Mac/antlrcpp Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Mac/antlrcpp-demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Mac/antlrcpp-demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /antlr-runtime/demo/README.md: -------------------------------------------------------------------------------- 1 | ## Demo application for the ANTLR 4 C++ target 2 | 3 | This demo app shows how to build the ANTLR runtime both as dynamic and static library and how to use a parser generated from a simple demo grammar. 4 | 5 | A few steps are necessary to get this to work: 6 | 7 | - Download the current ANTLR jar and place it in this folder. 8 | - Open the generation script for your platform (generate.cmd for Windows, generate.sh for *nix/OSX) and update the LOCATION var to the actual name of the jar you downloaded. 9 | - Run the generation script. This will generate a test parser + lexer, along with listener + visitor classes in a subfolder named "generated". This is where the demo application looks for these files. 10 | - Open the project in the folder that matches your system. 11 | - Compile and run. 12 | 13 | Compilation is done as described in the [runtime/cpp/readme.md](../README.md) file. 14 | -------------------------------------------------------------------------------- /antlr-runtime/demo/TLexer.tokens: -------------------------------------------------------------------------------- 1 | DUMMY=1 2 | Return=2 3 | Continue=3 4 | INT=4 5 | Digit=5 6 | ID=6 7 | LessThan=7 8 | GreaterThan=8 9 | Equal=9 10 | And=10 11 | Colon=11 12 | Semicolon=12 13 | Plus=13 14 | Minus=14 15 | Star=15 16 | OpenPar=16 17 | ClosePar=17 18 | OpenCurly=18 19 | CloseCurly=19 20 | QuestionMark=20 21 | Comma=21 22 | String=22 23 | Foo=23 24 | Bar=24 25 | Any=25 26 | Comment=26 27 | WS=27 28 | Dot=28 29 | DotDot=29 30 | Dollar=30 31 | Ampersand=31 32 | 'return'=2 33 | 'continue'=3 34 | '<'=7 35 | '>'=8 36 | '='=9 37 | 'and'=10 38 | ':'=11 39 | ';'=12 40 | '+'=13 41 | '-'=14 42 | '*'=15 43 | '('=16 44 | ')'=17 45 | '{'=18 46 | '}'=19 47 | '?'=20 48 | ','=21 49 | '$'=30 50 | '&'=31 51 | '.'=28 52 | '..'=29 53 | -------------------------------------------------------------------------------- /antlr-runtime/demo/Windows/antlr4-cpp-demo/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | // 7 | // main.cpp 8 | // antlr4-cpp-demo 9 | // 10 | // Created by Mike Lischke on 13.03.16. 11 | // 12 | 13 | #include 14 | 15 | #include "antlr4-runtime.h" 16 | #include "TLexer.h" 17 | #include "TParser.h" 18 | 19 | #include 20 | 21 | #pragma execution_character_set("utf-8") 22 | 23 | using namespace antlrcpptest; 24 | using namespace antlr4; 25 | 26 | int main(int argc, const char * argv[]) { 27 | 28 | ANTLRInputStream input("🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);"); 29 | TLexer lexer(&input); 30 | CommonTokenStream tokens(&lexer); 31 | 32 | TParser parser(&tokens); 33 | tree::ParseTree *tree = parser.main(); 34 | 35 | std::wstring s = antlrcpp::s2ws(tree->toStringTree(&parser)) + L"\n"; 36 | 37 | OutputDebugString(s.data()); // Only works properly since VS 2015. 38 | //std::wcout << "Parse Tree: " << s << std::endl; Unicode output in the console is very limited. 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generate.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Created 2016, Mike Lischke (public domain) 3 | 4 | :: This script is used to generate source files from the test grammars in the same folder. The generated files are placed 5 | :: into a subfolder "generated" which the demo project uses to compile a demo binary. 6 | 7 | :: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly). 8 | 9 | set LOCATION=antlr-4.8-complete.jar 10 | java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4 11 | ::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4 12 | ::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4 13 | 14 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TLexer.tokens: -------------------------------------------------------------------------------- 1 | DUMMY=1 2 | Return=2 3 | Continue=3 4 | INT=4 5 | Digit=5 6 | ID=6 7 | LessThan=7 8 | GreaterThan=8 9 | Equal=9 10 | And=10 11 | Colon=11 12 | Semicolon=12 13 | Plus=13 14 | Minus=14 15 | Star=15 16 | OpenPar=16 17 | ClosePar=17 18 | OpenCurly=18 19 | CloseCurly=19 20 | QuestionMark=20 21 | Comma=21 22 | String=22 23 | Foo=23 24 | Bar=24 25 | Any=25 26 | Comment=26 27 | WS=27 28 | Dot=28 29 | DotDot=29 30 | Dollar=30 31 | Ampersand=31 32 | 'return'=2 33 | 'continue'=3 34 | '<'=7 35 | '>'=8 36 | '='=9 37 | 'and'=10 38 | ':'=11 39 | ';'=12 40 | '+'=13 41 | '-'=14 42 | '*'=15 43 | '('=16 44 | ')'=17 45 | '{'=18 46 | '}'=19 47 | '?'=20 48 | ','=21 49 | '$'=30 50 | '&'=31 51 | '.'=28 52 | '..'=29 53 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParser.tokens: -------------------------------------------------------------------------------- 1 | DUMMY=1 2 | Return=2 3 | Continue=3 4 | INT=4 5 | Digit=5 6 | ID=6 7 | LessThan=7 8 | GreaterThan=8 9 | Equal=9 10 | And=10 11 | Colon=11 12 | Semicolon=12 13 | Plus=13 14 | Minus=14 15 | Star=15 16 | OpenPar=16 17 | ClosePar=17 18 | OpenCurly=18 19 | CloseCurly=19 20 | QuestionMark=20 21 | Comma=21 22 | String=22 23 | Foo=23 24 | Bar=24 25 | Any=25 26 | Comment=26 27 | WS=27 28 | Dot=28 29 | DotDot=29 30 | Dollar=30 31 | Ampersand=31 32 | 'return'=2 33 | 'continue'=3 34 | '<'=7 35 | '>'=8 36 | '='=9 37 | 'and'=10 38 | ':'=11 39 | ';'=12 40 | '+'=13 41 | '-'=14 42 | '*'=15 43 | '('=16 44 | ')'=17 45 | '{'=18 46 | '}'=19 47 | '?'=20 48 | ','=21 49 | '$'=30 50 | '&'=31 51 | '.'=28 52 | '..'=29 53 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParserBaseListener.cpp: -------------------------------------------------------------------------------- 1 | /* parser/listener/visitor header section */ 2 | 3 | // Generated from TParser.g4 by ANTLR 4.8 4 | 5 | /* base listener preinclude section */ 6 | 7 | #include "TParserBaseListener.h" 8 | 9 | /* base listener postinclude section */ 10 | 11 | using namespace antlrcpptest; 12 | 13 | /* base listener definitions section */ -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParserBaseVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* parser/listener/visitor header section */ 2 | 3 | // Generated from TParser.g4 by ANTLR 4.8 4 | 5 | /* base visitor preinclude section */ 6 | 7 | #include "TParserBaseVisitor.h" 8 | 9 | /* base visitor postinclude section */ 10 | 11 | using namespace antlrcpptest; 12 | 13 | /* base visitor definitions section */ 14 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParserListener.cpp: -------------------------------------------------------------------------------- 1 | /* parser/listener/visitor header section */ 2 | 3 | // Generated from TParser.g4 by ANTLR 4.8 4 | 5 | /* listener preinclude section */ 6 | 7 | #include "TParserListener.h" 8 | 9 | /* listener postinclude section */ 10 | 11 | using namespace antlrcpptest; 12 | 13 | /* listener definitions section */ -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParserVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* parser/listener/visitor header section */ 2 | 3 | // Generated from TParser.g4 by ANTLR 4.8 4 | 5 | /* visitor preinclude section */ 6 | 7 | #include "TParserVisitor.h" 8 | 9 | /* visitor postinclude section */ 10 | 11 | using namespace antlrcpptest; 12 | 13 | /* visitor definitions section */ 14 | -------------------------------------------------------------------------------- /antlr-runtime/demo/generated/TParserVisitor.h: -------------------------------------------------------------------------------- 1 | /* parser/listener/visitor header section */ 2 | 3 | // Generated from TParser.g4 by ANTLR 4.8 4 | 5 | #pragma once 6 | 7 | /* visitor preinclude section */ 8 | 9 | #include "antlr4-runtime.h" 10 | #include "TParser.h" 11 | 12 | /* visitor postinclude section */ 13 | 14 | namespace antlrcpptest { 15 | 16 | /** 17 | * This class defines an abstract visitor for a parse tree 18 | * produced by TParser. 19 | */ 20 | class TParserVisitor : public antlr4::tree::AbstractParseTreeVisitor { 21 | public: 22 | /* visitor public declarations/members section */ 23 | 24 | /** 25 | * Visit parse trees produced by TParser. 26 | */ 27 | virtual antlrcpp::Any visitMain(TParser::MainContext *context) = 0; 28 | 29 | virtual antlrcpp::Any visitDivide(TParser::DivideContext *context) = 0; 30 | 31 | virtual antlrcpp::Any visitAnd_(TParser::And_Context *context) = 0; 32 | 33 | virtual antlrcpp::Any visitConquer(TParser::ConquerContext *context) = 0; 34 | 35 | virtual antlrcpp::Any visitUnused(TParser::UnusedContext *context) = 0; 36 | 37 | virtual antlrcpp::Any visitUnused2(TParser::Unused2Context *context) = 0; 38 | 39 | virtual antlrcpp::Any visitStat(TParser::StatContext *context) = 0; 40 | 41 | virtual antlrcpp::Any visitExpr(TParser::ExprContext *context) = 0; 42 | 43 | virtual antlrcpp::Any visitReturn(TParser::ReturnContext *context) = 0; 44 | 45 | virtual antlrcpp::Any visitContinue(TParser::ContinueContext *context) = 0; 46 | 47 | virtual antlrcpp::Any visitId(TParser::IdContext *context) = 0; 48 | 49 | virtual antlrcpp::Any visitArray(TParser::ArrayContext *context) = 0; 50 | 51 | virtual antlrcpp::Any visitIdarray(TParser::IdarrayContext *context) = 0; 52 | 53 | virtual antlrcpp::Any visitAny(TParser::AnyContext *context) = 0; 54 | 55 | 56 | private: 57 | /* visitor private declarations/members section */ 58 | }; 59 | 60 | } // namespace antlrcpptest 61 | -------------------------------------------------------------------------------- /antlr-runtime/deploy-macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean left overs from previous builds if there are any 4 | rm -f -R antlr4-runtime build lib 2> /dev/null 5 | rm antlr4-cpp-runtime-macos.zip 2> /dev/null 6 | 7 | # Binaries 8 | xcodebuild -project runtime/antlrcpp.xcodeproj -target antlr4 -configuration Release 9 | xcodebuild -project runtime/antlrcpp.xcodeproj -target antlr4_static -configuration Release 10 | rm -f -R lib 11 | mkdir lib 12 | mv runtime/build/Release/libantlr4-runtime.a lib/ 13 | mv runtime/build/Release/libantlr4-runtime.dylib lib/ 14 | 15 | # Headers 16 | rm -f -R antlr4-runtime 17 | pushd runtime/src 18 | find . -name '*.h' | cpio -pdm ../../antlr4-runtime 19 | popd 20 | 21 | # Zip up and clean up 22 | zip -r antlr4-cpp-runtime-macos.zip antlr4-runtime lib 23 | 24 | rm -f -R antlr4-runtime build lib 25 | 26 | # Deploy 27 | #cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download 28 | -------------------------------------------------------------------------------- /antlr-runtime/deploy-source.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Zip it 4 | rm -f antlr4-cpp-runtime-source.zip 5 | zip -r antlr4-cpp-runtime-source.zip "README.md" "cmake" "demo" "runtime" "CMakeLists.txt" "deploy-macos.sh" "deploy-source.sh" "deploy-windows.cmd" "VERSION" \ 6 | -X -x "*.DS_Store*" "antlrcpp.xcodeproj/xcuserdata/*" "*Build*" "*DerivedData*" "*.jar" "demo/generated/*" "*.vscode*" "runtime/build/*" 7 | 8 | # Add the license file from the ANTLR root as well. 9 | pushd ../../ 10 | zip runtime/cpp/antlr4-cpp-runtime-source.zip LICENSE.txt 11 | popd 12 | 13 | # Deploy 14 | #cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download 15 | -------------------------------------------------------------------------------- /antlr-runtime/dist/libantlr4-runtime.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/dist/libantlr4-runtime.a -------------------------------------------------------------------------------- /antlr-runtime/dist/libantlr4-runtime.so: -------------------------------------------------------------------------------- 1 | libantlr4-runtime.so.4.8 -------------------------------------------------------------------------------- /antlr-runtime/dist/libantlr4-runtime.so.4.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/dist/libantlr4-runtime.so.4.8 -------------------------------------------------------------------------------- /antlr-runtime/runtime/antlrcpp-ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/antlrcpp-ios/antlrcpp_ios.h: -------------------------------------------------------------------------------- 1 | // 2 | // antlrcpp-ios.h 3 | // antlrcpp-ios 4 | // 5 | // Created by Mike Lischke on 05.05.16. 6 | // Copyright © 2016 Mike Lischke. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for antlrcpp-ios. 12 | FOUNDATION_EXPORT double antlrcpp_iosVersionNumber; 13 | 14 | //! Project version string for antlrcpp-ios. 15 | FOUNDATION_EXPORT const unsigned char antlrcpp_iosVersionString[]; 16 | 17 | #include "antlr4-runtime.h" 18 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-4.4.0-171-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "4.4.0-171-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-4.4.0-171-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "4.4.0-171-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/buil/CMakeFiles/3.5.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.5 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/CMakeRuleHashes.txt: -------------------------------------------------------------------------------- 1 | # Hashes of file build rules. 2 | e77279d2da11bbaf2aae37dad870dbf6 CMakeFiles/make_lib_output_dir 3 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/Makefile.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.5 3 | 4 | # The generator used is: 5 | set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") 6 | 7 | # The top level Makefile was generated from the following files: 8 | set(CMAKE_MAKEFILE_DEPENDS 9 | "CMakeCache.txt" 10 | "../CMakeLists.txt" 11 | "CMakeFiles/3.5.1/CMakeCCompiler.cmake" 12 | "CMakeFiles/3.5.1/CMakeCXXCompiler.cmake" 13 | "CMakeFiles/3.5.1/CMakeSystem.cmake" 14 | "/usr/share/cmake-3.5/Modules/CMakeCInformation.cmake" 15 | "/usr/share/cmake-3.5/Modules/CMakeCXXInformation.cmake" 16 | "/usr/share/cmake-3.5/Modules/CMakeCommonLanguageInclude.cmake" 17 | "/usr/share/cmake-3.5/Modules/CMakeGenericSystem.cmake" 18 | "/usr/share/cmake-3.5/Modules/CMakeLanguageInformation.cmake" 19 | "/usr/share/cmake-3.5/Modules/CMakeSystemSpecificInformation.cmake" 20 | "/usr/share/cmake-3.5/Modules/CMakeSystemSpecificInitialize.cmake" 21 | "/usr/share/cmake-3.5/Modules/Compiler/GNU-C.cmake" 22 | "/usr/share/cmake-3.5/Modules/Compiler/GNU-CXX.cmake" 23 | "/usr/share/cmake-3.5/Modules/Compiler/GNU.cmake" 24 | "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU-C.cmake" 25 | "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU-CXX.cmake" 26 | "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU.cmake" 27 | "/usr/share/cmake-3.5/Modules/Platform/Linux.cmake" 28 | "/usr/share/cmake-3.5/Modules/Platform/UnixPaths.cmake" 29 | ) 30 | 31 | # The corresponding makefile is: 32 | set(CMAKE_MAKEFILE_OUTPUTS 33 | "Makefile" 34 | "CMakeFiles/cmake.check_cache" 35 | ) 36 | 37 | # Byproducts of CMake generate step: 38 | set(CMAKE_MAKEFILE_PRODUCTS 39 | "CMakeFiles/CMakeDirectoryInformation.cmake" 40 | ) 41 | 42 | # Dependency information for all targets: 43 | set(CMAKE_DEPEND_INFO_FILES 44 | "CMakeFiles/antlr4_shared.dir/DependInfo.cmake" 45 | "CMakeFiles/antlr4_static.dir/DependInfo.cmake" 46 | "CMakeFiles/make_lib_output_dir.dir/DependInfo.cmake" 47 | ) 48 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/edit_cache.dir 2 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/rebuild_cache.dir 3 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir 4 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/install.dir 5 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/list_install_components.dir 6 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir 7 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/install/local.dir 8 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/install/strip.dir 9 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Per-language clean rules from dependency scanning. 3 | foreach(lang ) 4 | include(CMakeFiles/antlr4_shared.dir/cmake_clean_${lang}.cmake OPTIONAL) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/depend.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_shared.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Per-language clean rules from dependency scanning. 3 | foreach(lang ) 4 | include(CMakeFiles/antlr4_static.dir/cmake_clean_${lang}.cmake OPTIONAL) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/depend.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/antlr4_static.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/buil/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "C_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/make_lib_output_dir" 3 | ) 4 | 5 | # Per-language clean rules from dependency scanning. 6 | foreach(lang ) 7 | include(CMakeFiles/make_lib_output_dir.dir/cmake_clean_${lang}.cmake OPTIONAL) 8 | endforeach() 9 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir/depend.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/make_lib_output_dir.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/buil/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/3.5.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-4.4.0-171-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "4.4.0-171-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-4.4.0-171-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "4.4.0-171-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/3.5.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/build/CMakeFiles/3.5.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/3.5.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/build/CMakeFiles/3.5.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.5 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/CMakeRuleHashes.txt: -------------------------------------------------------------------------------- 1 | # Hashes of file build rules. 2 | 627aa4a35a28bb094fd81be0a01b0613 CMakeFiles/make_lib_output_dir 3 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/edit_cache.dir 2 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/rebuild_cache.dir 3 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir 4 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/install.dir 5 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/list_install_components.dir 6 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir 7 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/install/local.dir 8 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/install/strip.dir 9 | /home/madytyoo/CLionProjects/rpg/antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Per-language clean rules from dependency scanning. 3 | foreach(lang ) 4 | include(CMakeFiles/antlr4_shared.dir/cmake_clean_${lang}.cmake OPTIONAL) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/depend.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_shared.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Per-language clean rules from dependency scanning. 3 | foreach(lang ) 4 | include(CMakeFiles/antlr4_static.dir/cmake_clean_${lang}.cmake OPTIONAL) 5 | endforeach() 6 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for antlr4_static. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/antlr4_static.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/antlr-runtime/runtime/build/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "C_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | # The set of languages for which implicit dependencies are needed: 2 | set(CMAKE_DEPENDS_LANGUAGES 3 | ) 4 | # The set of files for implicit dependencies of each language: 5 | 6 | # Targets to which this target links. 7 | set(CMAKE_TARGET_LINKED_INFO_FILES 8 | ) 9 | 10 | # Fortran module output directory. 11 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/make_lib_output_dir" 3 | ) 4 | 5 | # Per-language clean rules from dependency scanning. 6 | foreach(lang ) 7 | include(CMakeFiles/make_lib_output_dir.dir/cmake_clean_${lang}.cmake OPTIONAL) 8 | endforeach() 9 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir/depend.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" GeneratorLLVM, CMake Version 3.5 3 | 4 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/make_lib_output_dir.dir/progress.make: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/build/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ANTLRErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorListener.h" 7 | 8 | antlr4::ANTLRErrorListener::~ANTLRErrorListener() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ANTLRErrorStrategy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorStrategy.h" 7 | 8 | antlr4::ANTLRErrorStrategy::~ANTLRErrorStrategy() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ANTLRFileStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/StringUtils.h" 7 | 8 | #include "ANTLRFileStream.h" 9 | 10 | using namespace antlr4; 11 | 12 | ANTLRFileStream::ANTLRFileStream(const std::string &fileName) { 13 | _fileName = fileName; 14 | loadFromFile(fileName); 15 | } 16 | 17 | void ANTLRFileStream::loadFromFile(const std::string &fileName) { 18 | _fileName = fileName; 19 | if (_fileName.empty()) { 20 | return; 21 | } 22 | 23 | #ifdef _MSC_VER 24 | std::ifstream stream(antlrcpp::s2ws(fileName), std::ios::binary); 25 | #else 26 | std::ifstream stream(fileName, std::ios::binary); 27 | #endif 28 | 29 | ANTLRInputStream::load(stream); 30 | } 31 | 32 | std::string ANTLRFileStream::getSourceName() const { 33 | return _fileName; 34 | } 35 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ANTLRFileStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRInputStream.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// This is an ANTLRInputStream that is loaded from a file all at once 13 | /// when you construct the object (or call load()). 14 | // TODO: this class needs testing. 15 | class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream { 16 | protected: 17 | std::string _fileName; // UTF-8 encoded file name. 18 | 19 | public: 20 | // Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM). 21 | ANTLRFileStream(const std::string &fileName); 22 | 23 | virtual void loadFromFile(const std::string &fileName); 24 | virtual std::string getSourceName() const override; 25 | }; 26 | 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/BaseErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "BaseErrorListener.h" 7 | #include "RecognitionException.h" 8 | 9 | using namespace antlr4; 10 | 11 | void BaseErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, size_t /*line*/, 12 | size_t /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) { 13 | } 14 | 15 | void BaseErrorListener::reportAmbiguity(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 16 | size_t /*stopIndex*/, bool /*exact*/, const antlrcpp::BitSet &/*ambigAlts*/, atn::ATNConfigSet * /*configs*/) { 17 | } 18 | 19 | void BaseErrorListener::reportAttemptingFullContext(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 20 | size_t /*stopIndex*/, const antlrcpp::BitSet &/*conflictingAlts*/, atn::ATNConfigSet * /*configs*/) { 21 | } 22 | 23 | void BaseErrorListener::reportContextSensitivity(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 24 | size_t /*stopIndex*/, size_t /*prediction*/, atn::ATNConfigSet * /*configs*/) { 25 | } 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/BaseErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRErrorListener.h" 9 | 10 | namespace antlrcpp { 11 | class BitSet; 12 | } 13 | 14 | namespace antlr4 { 15 | 16 | /** 17 | * Provides an empty default implementation of {@link ANTLRErrorListener}. The 18 | * default implementation of each method does nothing, but can be overridden as 19 | * necessary. 20 | */ 21 | class ANTLR4CPP_PUBLIC BaseErrorListener : public ANTLRErrorListener { 22 | 23 | virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine, 24 | const std::string &msg, std::exception_ptr e) override; 25 | 26 | virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact, 27 | const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override; 28 | 29 | virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 30 | const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override; 31 | 32 | virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 33 | size_t prediction, atn::ATNConfigSet *configs) override; 34 | }; 35 | 36 | } // namespace antlr4 37 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/CharStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "CharStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | CharStream::~CharStream() { 11 | } 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/CharStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "IntStream.h" 9 | #include "misc/Interval.h" 10 | 11 | namespace antlr4 { 12 | 13 | /// A source of characters for an ANTLR lexer. 14 | class ANTLR4CPP_PUBLIC CharStream : public IntStream { 15 | public: 16 | virtual ~CharStream(); 17 | 18 | /// This method returns the text for a range of characters within this input 19 | /// stream. This method is guaranteed to not throw an exception if the 20 | /// specified interval lies entirely within a marked range. For more 21 | /// information about marked ranges, see IntStream::mark. 22 | /// 23 | /// an interval within the stream 24 | /// the text of the specified interval 25 | /// 26 | /// if {@code interval} is {@code null} 27 | /// if {@code interval.a < 0}, or if 28 | /// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or 29 | /// past the end of the stream 30 | /// if the stream does not support 31 | /// getting the text of the specified interval 32 | virtual std::string getText(const misc::Interval &interval) = 0; 33 | 34 | virtual std::string toString() const = 0; 35 | }; 36 | 37 | } // namespace antlr4 38 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/CommonTokenFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "CommonToken.h" 8 | #include "CharStream.h" 9 | 10 | #include "CommonTokenFactory.h" 11 | 12 | using namespace antlr4; 13 | 14 | const Ref> CommonTokenFactory::DEFAULT = std::make_shared(); 15 | 16 | CommonTokenFactory::CommonTokenFactory(bool copyText_) : copyText(copyText_) { 17 | } 18 | 19 | CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) { 20 | } 21 | 22 | std::unique_ptr CommonTokenFactory::create(std::pair source, size_t type, 23 | const std::string &text, size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) { 24 | 25 | std::unique_ptr t(new CommonToken(source, type, channel, start, stop)); 26 | t->setLine(line); 27 | t->setCharPositionInLine(charPositionInLine); 28 | if (text != "") { 29 | t->setText(text); 30 | } else if (copyText && source.second != nullptr) { 31 | t->setText(source.second->getText(misc::Interval(start, stop))); 32 | } 33 | 34 | return t; 35 | } 36 | 37 | std::unique_ptr CommonTokenFactory::create(size_t type, const std::string &text) { 38 | return std::unique_ptr(new CommonToken(type, text)); 39 | } 40 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ConsoleErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ConsoleErrorListener.h" 7 | 8 | using namespace antlr4; 9 | 10 | ConsoleErrorListener ConsoleErrorListener::INSTANCE; 11 | 12 | void ConsoleErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 13 | size_t line, size_t charPositionInLine, const std::string &msg, std::exception_ptr /*e*/) { 14 | std::cerr << "line " << line << ":" << charPositionInLine << " " << msg << std::endl; 15 | } 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ConsoleErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "BaseErrorListener.h" 9 | 10 | namespace antlr4 { 11 | 12 | class ANTLR4CPP_PUBLIC ConsoleErrorListener : public BaseErrorListener { 13 | public: 14 | /** 15 | * Provides a default instance of {@link ConsoleErrorListener}. 16 | */ 17 | static ConsoleErrorListener INSTANCE; 18 | 19 | /** 20 | * {@inheritDoc} 21 | * 22 | *

23 | * This implementation prints messages to {@link System#err} containing the 24 | * values of {@code line}, {@code charPositionInLine}, and {@code msg} using 25 | * the following format.

26 | * 27 | *
28 |      * line line:charPositionInLine msg
29 |      * 
30 | */ 31 | virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine, 32 | const std::string &msg, std::exception_ptr e) override; 33 | }; 34 | 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/FailedPredicateException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// A semantic predicate failed during validation. Validation of predicates 13 | /// occurs when normally parsing the alternative just like matching a token. 14 | /// Disambiguating predicate evaluation occurs when we test a predicate during 15 | /// prediction. 16 | class ANTLR4CPP_PUBLIC FailedPredicateException : public RecognitionException { 17 | public: 18 | FailedPredicateException(Parser *recognizer); 19 | FailedPredicateException(Parser *recognizer, const std::string &predicate); 20 | FailedPredicateException(Parser *recognizer, const std::string &predicate, const std::string &message); 21 | 22 | virtual size_t getRuleIndex(); 23 | virtual size_t getPredIndex(); 24 | virtual std::string getPredicate(); 25 | 26 | private: 27 | size_t _ruleIndex; 28 | size_t _predicateIndex; 29 | std::string _predicate; 30 | }; 31 | 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/InputMismatchException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Parser.h" 7 | 8 | #include "InputMismatchException.h" 9 | 10 | using namespace antlr4; 11 | 12 | InputMismatchException::InputMismatchException(Parser *recognizer) 13 | : RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(), 14 | recognizer->getCurrentToken()) { 15 | } 16 | 17 | InputMismatchException::~InputMismatchException() { 18 | } 19 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/InputMismatchException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// 13 | /// This signifies any kind of mismatched input exceptions such as 14 | /// when the current input does not match the expected token. 15 | /// 16 | class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException { 17 | public: 18 | InputMismatchException(Parser *recognizer); 19 | InputMismatchException(InputMismatchException const&) = default; 20 | ~InputMismatchException(); 21 | InputMismatchException& operator=(InputMismatchException const&) = default; 22 | }; 23 | 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/IntStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "IntStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | const std::string IntStream::UNKNOWN_SOURCE_NAME = ""; 11 | 12 | IntStream::~IntStream() = default; 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/InterpreterRuleContext.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "InterpreterRuleContext.h" 7 | 8 | using namespace antlr4; 9 | 10 | InterpreterRuleContext::InterpreterRuleContext() : ParserRuleContext() { 11 | } 12 | 13 | InterpreterRuleContext::InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex) 14 | : ParserRuleContext(parent, invokingStateNumber), _ruleIndex(ruleIndex) { 15 | } 16 | 17 | size_t InterpreterRuleContext::getRuleIndex() const { 18 | return _ruleIndex; 19 | } 20 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/InterpreterRuleContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ParserRuleContext.h" 9 | 10 | namespace antlr4 { 11 | 12 | /** 13 | * This class extends {@link ParserRuleContext} by allowing the value of 14 | * {@link #getRuleIndex} to be explicitly set for the context. 15 | * 16 | *

17 | * {@link ParserRuleContext} does not include field storage for the rule index 18 | * since the context classes created by the code generator override the 19 | * {@link #getRuleIndex} method to return the correct value for that context. 20 | * Since the parser interpreter does not use the context classes generated for a 21 | * parser, this class (with slightly more memory overhead per node) is used to 22 | * provide equivalent functionality.

23 | */ 24 | class ANTLR4CPP_PUBLIC InterpreterRuleContext : public ParserRuleContext { 25 | public: 26 | InterpreterRuleContext(); 27 | 28 | /** 29 | * Constructs a new {@link InterpreterRuleContext} with the specified 30 | * parent, invoking state, and rule index. 31 | * 32 | * @param parent The parent context. 33 | * @param invokingStateNumber The invoking state number. 34 | * @param ruleIndex The rule index for the current context. 35 | */ 36 | InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex); 37 | 38 | virtual size_t getRuleIndex() const override; 39 | 40 | protected: 41 | /** This is the backing field for {@link #getRuleIndex}. */ 42 | const size_t _ruleIndex = INVALID_INDEX; 43 | }; 44 | 45 | } // namespace antlr4 46 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/LexerNoViableAltException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "support/CPPUtils.h" 8 | #include "CharStream.h" 9 | #include "Lexer.h" 10 | 11 | #include "LexerNoViableAltException.h" 12 | 13 | using namespace antlr4; 14 | 15 | LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex, 16 | atn::ATNConfigSet *deadEndConfigs) 17 | : RecognitionException(lexer, input, nullptr, nullptr), _startIndex(startIndex), _deadEndConfigs(deadEndConfigs) { 18 | } 19 | 20 | size_t LexerNoViableAltException::getStartIndex() { 21 | return _startIndex; 22 | } 23 | 24 | atn::ATNConfigSet* LexerNoViableAltException::getDeadEndConfigs() { 25 | return _deadEndConfigs; 26 | } 27 | 28 | std::string LexerNoViableAltException::toString() { 29 | std::string symbol; 30 | if (_startIndex < getInputStream()->size()) { 31 | symbol = static_cast(getInputStream())->getText(misc::Interval(_startIndex, _startIndex)); 32 | symbol = antlrcpp::escapeWhitespace(symbol, false); 33 | } 34 | std::string format = "LexerNoViableAltException('" + symbol + "')"; 35 | return format; 36 | } 37 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/LexerNoViableAltException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | #include "atn/ATNConfigSet.h" 10 | 11 | namespace antlr4 { 12 | 13 | class ANTLR4CPP_PUBLIC LexerNoViableAltException : public RecognitionException { 14 | public: 15 | LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex, 16 | atn::ATNConfigSet *deadEndConfigs); 17 | 18 | virtual size_t getStartIndex(); 19 | virtual atn::ATNConfigSet* getDeadEndConfigs(); 20 | virtual std::string toString(); 21 | 22 | private: 23 | /// Matching attempted at what input index? 24 | const size_t _startIndex; 25 | 26 | /// Which configurations did we try at input.index() that couldn't match input.LA(1)? 27 | atn::ATNConfigSet *_deadEndConfigs; 28 | 29 | }; 30 | 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/NoViableAltException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Parser.h" 7 | 8 | #include "NoViableAltException.h" 9 | 10 | using namespace antlr4; 11 | 12 | namespace { 13 | 14 | // Create a normal shared pointer if the configurations are to be deleted. If not, then 15 | // the shared pointer is created with a deleter that does nothing. 16 | Ref buildConfigsRef(atn::ATNConfigSet *configs, bool deleteConfigs) { 17 | if (deleteConfigs) { 18 | return Ref(configs); 19 | } else { 20 | return Ref(configs, [](atn::ATNConfigSet *){}); 21 | } 22 | } 23 | 24 | } 25 | 26 | NoViableAltException::NoViableAltException(Parser *recognizer) 27 | : NoViableAltException(recognizer, recognizer->getTokenStream(), recognizer->getCurrentToken(), 28 | recognizer->getCurrentToken(), nullptr, recognizer->getContext(), false) { 29 | } 30 | 31 | NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *input,Token *startToken, 32 | Token *offendingToken, atn::ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx, bool deleteConfigs) 33 | : RecognitionException("No viable alternative", recognizer, input, ctx, offendingToken), 34 | _deadEndConfigs(buildConfigsRef(deadEndConfigs, deleteConfigs)), _startToken(startToken) { 35 | } 36 | 37 | NoViableAltException::~NoViableAltException() { 38 | } 39 | 40 | Token* NoViableAltException::getStartToken() const { 41 | return _startToken; 42 | } 43 | 44 | atn::ATNConfigSet* NoViableAltException::getDeadEndConfigs() const { 45 | return _deadEndConfigs.get(); 46 | } 47 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/NoViableAltException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | #include "Token.h" 10 | #include "atn/ATNConfigSet.h" 11 | 12 | namespace antlr4 { 13 | 14 | /// Indicates that the parser could not decide which of two or more paths 15 | /// to take based upon the remaining input. It tracks the starting token 16 | /// of the offending input and also knows where the parser was 17 | /// in the various paths when the error. Reported by reportNoViableAlternative() 18 | class ANTLR4CPP_PUBLIC NoViableAltException : public RecognitionException { 19 | public: 20 | NoViableAltException(Parser *recognizer); // LL(1) error 21 | NoViableAltException(Parser *recognizer, TokenStream *input,Token *startToken, 22 | Token *offendingToken, atn::ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx, bool deleteConfigs); 23 | ~NoViableAltException(); 24 | 25 | virtual Token* getStartToken() const; 26 | virtual atn::ATNConfigSet* getDeadEndConfigs() const; 27 | 28 | private: 29 | /// Which configurations did we try at input.index() that couldn't match input.LT(1)? 30 | /// Shared pointer that conditionally deletes the configurations (based on flag 31 | /// passed during construction) 32 | Ref _deadEndConfigs; 33 | 34 | /// The token object at the start index; the input stream might 35 | /// not be buffering tokens so get a reference to it. (At the 36 | /// time the error occurred, of course the stream needs to keep a 37 | /// buffer all of the tokens but later we might not have access to those.) 38 | Token *_startToken; 39 | 40 | }; 41 | 42 | } // namespace antlr4 43 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/ProxyErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRErrorListener.h" 9 | #include "Exceptions.h" 10 | 11 | namespace antlr4 { 12 | 13 | /// This implementation of ANTLRErrorListener dispatches all calls to a 14 | /// collection of delegate listeners. This reduces the effort required to support multiple 15 | /// listeners. 16 | class ANTLR4CPP_PUBLIC ProxyErrorListener : public ANTLRErrorListener { 17 | private: 18 | std::set _delegates; // Not owned. 19 | 20 | public: 21 | void addErrorListener(ANTLRErrorListener *listener); 22 | void removeErrorListener(ANTLRErrorListener *listener); 23 | void removeErrorListeners(); 24 | 25 | void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line, size_t charPositionInLine, 26 | const std::string &msg, std::exception_ptr e) override; 27 | 28 | virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact, 29 | const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override; 30 | 31 | virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 32 | const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override; 33 | 34 | virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 35 | size_t prediction, atn::ATNConfigSet *configs) override; 36 | }; 37 | 38 | } // namespace antlr4 39 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/RuleContextWithAltNum.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATN.h" 7 | 8 | #include "RuleContextWithAltNum.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RuleContextWithAltNum::RuleContextWithAltNum() : ParserRuleContext() { 14 | altNum = ATN::INVALID_ALT_NUMBER; 15 | } 16 | 17 | RuleContextWithAltNum::RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber) 18 | : ParserRuleContext(parent, invokingStateNumber) { 19 | } 20 | 21 | size_t RuleContextWithAltNum::getAltNumber() const { 22 | return altNum; 23 | } 24 | 25 | void RuleContextWithAltNum::setAltNumber(size_t number) { 26 | altNum = number; 27 | } 28 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/RuleContextWithAltNum.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ParserRuleContext.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// A handy class for use with 13 | /// 14 | /// options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} 15 | /// 16 | /// that provides a backing field / impl for the outer alternative number 17 | /// matched for an internal parse tree node. 18 | /// 19 | /// I'm only putting into Java runtime as I'm certain I'm the only one that 20 | /// will really every use this. 21 | class ANTLR4CPP_PUBLIC RuleContextWithAltNum : public ParserRuleContext { 22 | public: 23 | size_t altNum = 0; 24 | 25 | RuleContextWithAltNum(); 26 | RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber); 27 | 28 | virtual size_t getAltNumber() const override; 29 | virtual void setAltNumber(size_t altNum) override; 30 | }; 31 | 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/Token.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | 8 | antlr4::Token::~Token() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/TokenFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// The default mechanism for creating tokens. It's used by default in Lexer and 13 | /// the error handling strategy (to create missing tokens). Notifying the parser 14 | /// of a new factory means that it notifies it's token source and error strategy. 15 | template 16 | class ANTLR4CPP_PUBLIC TokenFactory { 17 | public: 18 | virtual ~TokenFactory() {} 19 | 20 | /// This is the method used to create tokens in the lexer and in the 21 | /// error handling strategy. If text!=null, than the start and stop positions 22 | /// are wiped to -1 in the text override is set in the CommonToken. 23 | virtual std::unique_ptr create(std::pair source, size_t type, const std::string &text, 24 | size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) = 0; 25 | 26 | /// Generically useful 27 | virtual std::unique_ptr create(size_t type, const std::string &text) = 0; 28 | }; 29 | 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/TokenSource.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenSource.h" 7 | 8 | antlr4::TokenSource::~TokenSource() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/TokenStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | TokenStream::~TokenStream() { 11 | } 12 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/WritableToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "WritableToken.h" 7 | 8 | antlr4::WritableToken::~WritableToken() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/WritableToken.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Token.h" 9 | 10 | namespace antlr4 { 11 | 12 | class ANTLR4CPP_PUBLIC WritableToken : public Token { 13 | public: 14 | virtual ~WritableToken(); 15 | virtual void setText(const std::string &text) = 0; 16 | virtual void setType(size_t ttype) = 0; 17 | virtual void setLine(size_t line) = 0; 18 | virtual void setCharPositionInLine(size_t pos) = 0; 19 | virtual void setChannel(size_t channel) = 0; 20 | virtual void setTokenIndex(size_t index) = 0; 21 | }; 22 | 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ATNDeserializationOptions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNDeserializationOptions.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | ATNDeserializationOptions ATNDeserializationOptions::defaultOptions; 11 | 12 | ATNDeserializationOptions::ATNDeserializationOptions() { 13 | InitializeInstanceFields(); 14 | } 15 | 16 | ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *options) : ATNDeserializationOptions() { 17 | this->verifyATN = options->verifyATN; 18 | this->generateRuleBypassTransitions = options->generateRuleBypassTransitions; 19 | } 20 | 21 | ATNDeserializationOptions::~ATNDeserializationOptions() { 22 | } 23 | 24 | const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() { 25 | return defaultOptions; 26 | } 27 | 28 | bool ATNDeserializationOptions::isReadOnly() { 29 | return readOnly; 30 | } 31 | 32 | void ATNDeserializationOptions::makeReadOnly() { 33 | readOnly = true; 34 | } 35 | 36 | bool ATNDeserializationOptions::isVerifyATN() { 37 | return verifyATN; 38 | } 39 | 40 | void ATNDeserializationOptions::setVerifyATN(bool verify) { 41 | throwIfReadOnly(); 42 | verifyATN = verify; 43 | } 44 | 45 | bool ATNDeserializationOptions::isGenerateRuleBypassTransitions() { 46 | return generateRuleBypassTransitions; 47 | } 48 | 49 | void ATNDeserializationOptions::setGenerateRuleBypassTransitions(bool generate) { 50 | throwIfReadOnly(); 51 | generateRuleBypassTransitions = generate; 52 | } 53 | 54 | void ATNDeserializationOptions::throwIfReadOnly() { 55 | if (isReadOnly()) { 56 | throw "The object is read only."; 57 | } 58 | } 59 | 60 | void ATNDeserializationOptions::InitializeInstanceFields() { 61 | readOnly = false; 62 | verifyATN = true; 63 | generateRuleBypassTransitions = false; 64 | } 65 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ATNDeserializationOptions.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC ATNDeserializationOptions { 14 | private: 15 | static ATNDeserializationOptions defaultOptions; 16 | 17 | bool readOnly; 18 | bool verifyATN; 19 | bool generateRuleBypassTransitions; 20 | 21 | public: 22 | ATNDeserializationOptions(); 23 | ATNDeserializationOptions(ATNDeserializationOptions *options); 24 | ATNDeserializationOptions(ATNDeserializationOptions const&) = default; 25 | virtual ~ATNDeserializationOptions(); 26 | ATNDeserializationOptions& operator=(ATNDeserializationOptions const&) = default; 27 | 28 | static const ATNDeserializationOptions& getDefaultOptions(); 29 | 30 | bool isReadOnly(); 31 | 32 | void makeReadOnly(); 33 | 34 | bool isVerifyATN(); 35 | 36 | void setVerifyATN(bool verify); 37 | 38 | bool isGenerateRuleBypassTransitions(); 39 | 40 | void setGenerateRuleBypassTransitions(bool generate); 41 | 42 | protected: 43 | virtual void throwIfReadOnly(); 44 | 45 | private: 46 | void InitializeInstanceFields(); 47 | }; 48 | 49 | } // namespace atn 50 | } // namespace antlr4 51 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ATNType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Represents the type of recognizer an ATN applies to. 14 | enum class ATNType { 15 | LEXER = 0, 16 | PARSER = 1, 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/AbstractPredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/AbstractPredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | AbstractPredicateTransition::AbstractPredicateTransition(ATNState *target) : Transition(target) { 11 | } 12 | 13 | AbstractPredicateTransition::~AbstractPredicateTransition() { 14 | } 15 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/AbstractPredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTState; 14 | 15 | class ANTLR4CPP_PUBLIC AbstractPredicateTransition : public Transition { 16 | 17 | public: 18 | AbstractPredicateTransition(ATNState *target); 19 | ~AbstractPredicateTransition(); 20 | 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ActionTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ActionTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | ActionTransition::ActionTransition(ATNState *target, size_t ruleIndex) 11 | : Transition(target), ruleIndex(ruleIndex), actionIndex(INVALID_INDEX), isCtxDependent(false) { 12 | } 13 | 14 | ActionTransition::ActionTransition(ATNState *target, size_t ruleIndex, size_t actionIndex, bool isCtxDependent) 15 | : Transition(target), ruleIndex(ruleIndex), actionIndex(actionIndex), isCtxDependent(isCtxDependent) { 16 | } 17 | 18 | Transition::SerializationType ActionTransition::getSerializationType() const { 19 | return ACTION; 20 | } 21 | 22 | bool ActionTransition::isEpsilon() const { 23 | return true; // we are to be ignored by analysis 'cept for predicates 24 | } 25 | 26 | bool ActionTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 27 | return false; 28 | } 29 | 30 | std::string ActionTransition::toString() const { 31 | return " ACTION " + Transition::toString() + " { ruleIndex: " + std::to_string(ruleIndex) + ", actionIndex: " + 32 | std::to_string(actionIndex) + ", isCtxDependent: " + std::to_string(isCtxDependent) + " }"; 33 | } 34 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ActionTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC ActionTransition final : public Transition { 14 | public: 15 | const size_t ruleIndex; 16 | const size_t actionIndex; 17 | const bool isCtxDependent; // e.g., $i ref in action 18 | 19 | ActionTransition(ATNState *target, size_t ruleIndex); 20 | 21 | ActionTransition(ATNState *target, size_t ruleIndex, size_t actionIndex, bool isCtxDependent); 22 | 23 | virtual SerializationType getSerializationType() const override; 24 | 25 | virtual bool isEpsilon() const override; 26 | 27 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 28 | 29 | virtual std::string toString() const override; 30 | }; 31 | 32 | } // namespace atn 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/AmbiguityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/AmbiguityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | AmbiguityInfo::AmbiguityInfo(size_t decision, ATNConfigSet *configs, const antlrcpp::BitSet &ambigAlts, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->ambigAlts = ambigAlts; 16 | } 17 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ArrayPredictionContext.h: -------------------------------------------------------------------------------- 1 |  2 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "atn/PredictionContext.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class SingletonPredictionContext; 15 | 16 | class ANTLR4CPP_PUBLIC ArrayPredictionContext : public PredictionContext { 17 | public: 18 | /// Parent can be empty only if full ctx mode and we make an array 19 | /// from EMPTY and non-empty. We merge EMPTY by using null parent and 20 | /// returnState == EMPTY_RETURN_STATE. 21 | // Also here: we use a strong reference to our parents to avoid having them freed prematurely. 22 | // See also SinglePredictionContext. 23 | const std::vector> parents; 24 | 25 | /// Sorted for merge, no duplicates; if present, EMPTY_RETURN_STATE is always last. 26 | const std::vector returnStates; 27 | 28 | ArrayPredictionContext(Ref const& a); 29 | ArrayPredictionContext(std::vector> const& parents_, std::vector const& returnStates); 30 | virtual ~ArrayPredictionContext(); 31 | 32 | virtual bool isEmpty() const override; 33 | virtual size_t size() const override; 34 | virtual Ref getParent(size_t index) const override; 35 | virtual size_t getReturnState(size_t index) const override; 36 | bool operator == (const PredictionContext &o) const override; 37 | 38 | virtual std::string toString() const override; 39 | }; 40 | 41 | } // namespace atn 42 | } // namespace antlr4 43 | 44 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/AtomTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | #include "atn/Transition.h" 8 | 9 | #include "atn/AtomTransition.h" 10 | 11 | using namespace antlr4::misc; 12 | using namespace antlr4::atn; 13 | 14 | AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(target), _label(label) { 15 | } 16 | 17 | Transition::SerializationType AtomTransition::getSerializationType() const { 18 | return ATOM; 19 | } 20 | 21 | IntervalSet AtomTransition::label() const { 22 | return IntervalSet::of((int)_label); 23 | } 24 | 25 | bool AtomTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 26 | return _label == symbol; 27 | } 28 | 29 | std::string AtomTransition::toString() const { 30 | return "ATOM " + Transition::toString() + " { label: " + std::to_string(_label) + " }"; 31 | } 32 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/AtomTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// TODO: make all transitions sets? no, should remove set edges. 14 | class ANTLR4CPP_PUBLIC AtomTransition final : public Transition { 15 | public: 16 | /// The token type or character value; or, signifies special label. 17 | const size_t _label; 18 | 19 | AtomTransition(ATNState *target, size_t label); 20 | 21 | virtual SerializationType getSerializationType() const override; 22 | 23 | virtual misc::IntervalSet label() const override; 24 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BasicBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BasicBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t BasicBlockStartState::getStateType() { 11 | return BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BasicBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | #include "atn/BlockStartState.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC BasicBlockStartState final : public BlockStartState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BasicState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BasicState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t BasicState::getStateType() { 11 | return BASIC; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BasicState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC BasicState final : public ATNState { 14 | 15 | public: 16 | virtual size_t getStateType() override; 17 | 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BlockEndState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BlockEndState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | BlockEndState::BlockEndState() : startState(nullptr) { 11 | } 12 | 13 | size_t BlockEndState::getStateType() { 14 | return BLOCK_END; 15 | } 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BlockEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Terminal node of a simple {@code (a|b|c)} block. 14 | class ANTLR4CPP_PUBLIC BlockEndState final : public ATNState { 15 | public: 16 | BlockStartState *startState = nullptr; 17 | 18 | BlockEndState(); 19 | 20 | virtual size_t getStateType() override; 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "BlockStartState.h" 7 | 8 | antlr4::atn::BlockStartState::~BlockStartState() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/BlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The start of a regular {@code (...)} block. 14 | class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState { 15 | public: 16 | ~BlockStartState(); 17 | BlockEndState *endState = nullptr; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ContextSensitivityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ContextSensitivityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | ContextSensitivityInfo::ContextSensitivityInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, 12 | size_t startIndex, size_t stopIndex) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, true) { 14 | } 15 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/DecisionEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | DecisionEventInfo::DecisionEventInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, 12 | size_t stopIndex, bool fullCtx) 13 | : decision(decision), configs(configs), input(input), startIndex(startIndex), stopIndex(stopIndex), fullCtx(fullCtx) { 14 | } 15 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/DecisionInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ErrorInfo.h" 7 | #include "atn/LookaheadEventInfo.h" 8 | 9 | #include "atn/DecisionInfo.h" 10 | 11 | using namespace antlr4::atn; 12 | 13 | DecisionInfo::DecisionInfo(size_t decision) : decision(decision) { 14 | } 15 | 16 | std::string DecisionInfo::toString() const { 17 | std::stringstream ss; 18 | 19 | ss << "{decision=" << decision << ", contextSensitivities=" << contextSensitivities.size() << ", errors="; 20 | ss << errors.size() << ", ambiguities=" << ambiguities.size() << ", SLL_lookahead=" << SLL_TotalLook; 21 | ss << ", SLL_ATNTransitions=" << SLL_ATNTransitions << ", SLL_DFATransitions=" << SLL_DFATransitions; 22 | ss << ", LL_Fallback=" << LL_Fallback << ", LL_lookahead=" << LL_TotalLook << ", LL_ATNTransitions=" << LL_ATNTransitions << '}'; 23 | 24 | return ss.str(); 25 | } 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/DecisionState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | void DecisionState::InitializeInstanceFields() { 11 | decision = -1; 12 | nonGreedy = false; 13 | } 14 | 15 | std::string DecisionState::toString() const { 16 | return "DECISION " + ATNState::toString(); 17 | } 18 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/DecisionState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC DecisionState : public ATNState { 14 | public: 15 | int decision; 16 | bool nonGreedy; 17 | 18 | private: 19 | void InitializeInstanceFields(); 20 | 21 | public: 22 | DecisionState() { 23 | InitializeInstanceFields(); 24 | } 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/EmptyPredictionContext.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/EmptyPredictionContext.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | EmptyPredictionContext::EmptyPredictionContext() : SingletonPredictionContext(nullptr, EMPTY_RETURN_STATE) { 11 | } 12 | 13 | bool EmptyPredictionContext::isEmpty() const { 14 | return true; 15 | } 16 | 17 | size_t EmptyPredictionContext::size() const { 18 | return 1; 19 | } 20 | 21 | Ref EmptyPredictionContext::getParent(size_t /*index*/) const { 22 | return nullptr; 23 | } 24 | 25 | size_t EmptyPredictionContext::getReturnState(size_t /*index*/) const { 26 | return returnState; 27 | } 28 | 29 | bool EmptyPredictionContext::operator == (const PredictionContext &o) const { 30 | return this == &o; 31 | } 32 | 33 | std::string EmptyPredictionContext::toString() const { 34 | return "$"; 35 | } 36 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/EmptyPredictionContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/SingletonPredictionContext.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC EmptyPredictionContext : public SingletonPredictionContext { 14 | public: 15 | EmptyPredictionContext(); 16 | 17 | virtual bool isEmpty() const override; 18 | virtual size_t size() const override; 19 | virtual Ref getParent(size_t index) const override; 20 | virtual size_t getReturnState(size_t index) const override; 21 | virtual std::string toString() const override; 22 | 23 | virtual bool operator == (const PredictionContext &o) const override; 24 | }; 25 | 26 | } // namespace atn 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/EpsilonTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/EpsilonTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | EpsilonTransition::EpsilonTransition(ATNState *target) : EpsilonTransition(target, INVALID_INDEX) { 11 | } 12 | 13 | EpsilonTransition::EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn) 14 | : Transition(target), _outermostPrecedenceReturn(outermostPrecedenceReturn) { 15 | } 16 | 17 | size_t EpsilonTransition::outermostPrecedenceReturn() { 18 | return _outermostPrecedenceReturn; 19 | } 20 | 21 | Transition::SerializationType EpsilonTransition::getSerializationType() const { 22 | return EPSILON; 23 | } 24 | 25 | bool EpsilonTransition::isEpsilon() const { 26 | return true; 27 | } 28 | 29 | bool EpsilonTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 30 | return false; 31 | } 32 | 33 | std::string EpsilonTransition::toString() const { 34 | return "EPSILON " + Transition::toString() + " {}"; 35 | } 36 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/EpsilonTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC EpsilonTransition final : public Transition { 14 | public: 15 | EpsilonTransition(ATNState *target); 16 | EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn); 17 | 18 | /** 19 | * @return the rule index of a precedence rule for which this transition is 20 | * returning from, where the precedence value is 0; otherwise, INVALID_INDEX. 21 | * 22 | * @see ATNConfig#isPrecedenceFilterSuppressed() 23 | * @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet) 24 | * @since 4.4.1 25 | */ 26 | size_t outermostPrecedenceReturn(); 27 | virtual SerializationType getSerializationType() const override; 28 | 29 | virtual bool isEpsilon() const override; 30 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 31 | 32 | virtual std::string toString() const override; 33 | 34 | private: 35 | const size_t _outermostPrecedenceReturn; // A rule index. 36 | }; 37 | 38 | } // namespace atn 39 | } // namespace antlr4 40 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/ErrorInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNConfigSet.h" 7 | 8 | #include "atn/ErrorInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | ErrorInfo::ErrorInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 14 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 15 | } 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerATNConfig.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNConfig.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC LexerATNConfig : public ATNConfig { 14 | public: 15 | LexerATNConfig(ATNState *state, int alt, Ref const& context); 16 | LexerATNConfig(ATNState *state, int alt, Ref const& context, Ref const& lexerActionExecutor); 17 | 18 | LexerATNConfig(Ref const& c, ATNState *state); 19 | LexerATNConfig(Ref const& c, ATNState *state, Ref const& lexerActionExecutor); 20 | LexerATNConfig(Ref const& c, ATNState *state, Ref const& context); 21 | 22 | /** 23 | * Gets the {@link LexerActionExecutor} capable of executing the embedded 24 | * action(s) for the current configuration. 25 | */ 26 | Ref getLexerActionExecutor() const; 27 | bool hasPassedThroughNonGreedyDecision(); 28 | 29 | virtual size_t hashCode() const override; 30 | 31 | bool operator == (const LexerATNConfig& other) const; 32 | 33 | private: 34 | /** 35 | * This is the backing field for {@link #getLexerActionExecutor}. 36 | */ 37 | const Ref _lexerActionExecutor; 38 | const bool _passedThroughNonGreedyDecision; 39 | 40 | static bool checkNonGreedyDecision(Ref const& source, ATNState *target); 41 | }; 42 | 43 | } // namespace atn 44 | } // namespace antlr4 45 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "LexerAction.h" 7 | 8 | antlr4::atn::LexerAction::~LexerAction() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerActionType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// Represents the serialization type of a . 15 | /// 16 | /// @author Sam Harwell 17 | /// @since 4.2 18 | /// 19 | enum class LexerActionType : size_t { 20 | /// 21 | /// The type of a action. 22 | /// 23 | CHANNEL, 24 | /// 25 | /// The type of a action. 26 | /// 27 | CUSTOM, 28 | /// 29 | /// The type of a action. 30 | /// 31 | MODE, 32 | /// 33 | /// The type of a action. 34 | /// 35 | MORE, 36 | /// 37 | /// The type of a action. 38 | /// 39 | POP_MODE, 40 | /// 41 | /// The type of a action. 42 | /// 43 | PUSH_MODE, 44 | /// 45 | /// The type of a action. 46 | /// 47 | SKIP, 48 | /// 49 | /// The type of a action. 50 | /// 51 | TYPE, 52 | }; 53 | 54 | } // namespace atn 55 | } // namespace antlr4 56 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerChannelAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerChannelAction.h" 10 | 11 | using namespace antlr4::atn; 12 | using namespace antlr4::misc; 13 | 14 | LexerChannelAction::LexerChannelAction(int channel) : _channel(channel) { 15 | } 16 | 17 | int LexerChannelAction::getChannel() const { 18 | return _channel; 19 | } 20 | 21 | LexerActionType LexerChannelAction::getActionType() const { 22 | return LexerActionType::CHANNEL; 23 | } 24 | 25 | bool LexerChannelAction::isPositionDependent() const { 26 | return false; 27 | } 28 | 29 | void LexerChannelAction::execute(Lexer *lexer) { 30 | lexer->setChannel(_channel); 31 | } 32 | 33 | size_t LexerChannelAction::hashCode() const { 34 | size_t hash = MurmurHash::initialize(); 35 | hash = MurmurHash::update(hash, static_cast(getActionType())); 36 | hash = MurmurHash::update(hash, _channel); 37 | return MurmurHash::finish(hash, 2); 38 | } 39 | 40 | bool LexerChannelAction::operator == (const LexerAction &obj) const { 41 | if (&obj == this) { 42 | return true; 43 | } 44 | 45 | const LexerChannelAction *action = dynamic_cast(&obj); 46 | if (action == nullptr) { 47 | return false; 48 | } 49 | 50 | return _channel == action->_channel; 51 | } 52 | 53 | std::string LexerChannelAction::toString() const { 54 | return "channel(" + std::to_string(_channel) + ")"; 55 | } 56 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerCustomAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "support/CPPUtils.h" 8 | #include "Lexer.h" 9 | 10 | #include "atn/LexerCustomAction.h" 11 | 12 | using namespace antlr4; 13 | using namespace antlr4::atn; 14 | using namespace antlr4::misc; 15 | 16 | LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex) : _ruleIndex(ruleIndex), _actionIndex(actionIndex) { 17 | } 18 | 19 | size_t LexerCustomAction::getRuleIndex() const { 20 | return _ruleIndex; 21 | } 22 | 23 | size_t LexerCustomAction::getActionIndex() const { 24 | return _actionIndex; 25 | } 26 | 27 | LexerActionType LexerCustomAction::getActionType() const { 28 | return LexerActionType::CUSTOM; 29 | } 30 | 31 | bool LexerCustomAction::isPositionDependent() const { 32 | return true; 33 | } 34 | 35 | void LexerCustomAction::execute(Lexer *lexer) { 36 | lexer->action(nullptr, _ruleIndex, _actionIndex); 37 | } 38 | 39 | size_t LexerCustomAction::hashCode() const { 40 | size_t hash = MurmurHash::initialize(); 41 | hash = MurmurHash::update(hash, static_cast(getActionType())); 42 | hash = MurmurHash::update(hash, _ruleIndex); 43 | hash = MurmurHash::update(hash, _actionIndex); 44 | return MurmurHash::finish(hash, 3); 45 | } 46 | 47 | bool LexerCustomAction::operator == (const LexerAction &obj) const { 48 | if (&obj == this) { 49 | return true; 50 | } 51 | 52 | const LexerCustomAction *action = dynamic_cast(&obj); 53 | if (action == nullptr) { 54 | return false; 55 | } 56 | 57 | return _ruleIndex == action->_ruleIndex && _actionIndex == action->_actionIndex; 58 | } 59 | 60 | std::string LexerCustomAction::toString() const { 61 | return antlrcpp::toString(this); 62 | } 63 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerIndexedCustomAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | #include "support/CPPUtils.h" 9 | 10 | #include "atn/LexerIndexedCustomAction.h" 11 | 12 | using namespace antlr4; 13 | using namespace antlr4::atn; 14 | using namespace antlr4::misc; 15 | 16 | LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref const& action) 17 | : _offset(offset), _action(action) { 18 | } 19 | 20 | int LexerIndexedCustomAction::getOffset() const { 21 | return _offset; 22 | } 23 | 24 | Ref LexerIndexedCustomAction::getAction() const { 25 | return _action; 26 | } 27 | 28 | LexerActionType LexerIndexedCustomAction::getActionType() const { 29 | return _action->getActionType(); 30 | } 31 | 32 | bool LexerIndexedCustomAction::isPositionDependent() const { 33 | return true; 34 | } 35 | 36 | void LexerIndexedCustomAction::execute(Lexer *lexer) { 37 | // assume the input stream position was properly set by the calling code 38 | _action->execute(lexer); 39 | } 40 | 41 | size_t LexerIndexedCustomAction::hashCode() const { 42 | size_t hash = MurmurHash::initialize(); 43 | hash = MurmurHash::update(hash, _offset); 44 | hash = MurmurHash::update(hash, _action); 45 | return MurmurHash::finish(hash, 2); 46 | } 47 | 48 | bool LexerIndexedCustomAction::operator == (const LexerAction &obj) const { 49 | if (&obj == this) { 50 | return true; 51 | } 52 | 53 | const LexerIndexedCustomAction *action = dynamic_cast(&obj); 54 | if (action == nullptr) { 55 | return false; 56 | } 57 | 58 | return _offset == action->_offset && *_action == *action->_action; 59 | } 60 | 61 | std::string LexerIndexedCustomAction::toString() const { 62 | return antlrcpp::toString(this); 63 | } 64 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerModeAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | LexerModeAction::LexerModeAction(int mode) : _mode(mode) { 16 | } 17 | 18 | int LexerModeAction::getMode() { 19 | return _mode; 20 | } 21 | 22 | LexerActionType LexerModeAction::getActionType() const { 23 | return LexerActionType::MODE; 24 | } 25 | 26 | bool LexerModeAction::isPositionDependent() const { 27 | return false; 28 | } 29 | 30 | void LexerModeAction::execute(Lexer *lexer) { 31 | lexer->setMode(_mode); 32 | } 33 | 34 | size_t LexerModeAction::hashCode() const { 35 | size_t hash = MurmurHash::initialize(); 36 | hash = MurmurHash::update(hash, static_cast(getActionType())); 37 | hash = MurmurHash::update(hash, _mode); 38 | return MurmurHash::finish(hash, 2); 39 | } 40 | 41 | bool LexerModeAction::operator == (const LexerAction &obj) const { 42 | if (&obj == this) { 43 | return true; 44 | } 45 | 46 | const LexerModeAction *action = dynamic_cast(&obj); 47 | if (action == nullptr) { 48 | return false; 49 | } 50 | 51 | return _mode == action->_mode; 52 | } 53 | 54 | std::string LexerModeAction::toString() const { 55 | return "mode(" + std::to_string(_mode) + ")"; 56 | } 57 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerMoreAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerMoreAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref LexerMoreAction::getInstance() { 16 | static Ref instance(new LexerMoreAction()); 17 | return instance; 18 | } 19 | 20 | LexerMoreAction::LexerMoreAction() { 21 | } 22 | 23 | LexerActionType LexerMoreAction::getActionType() const { 24 | return LexerActionType::MORE; 25 | } 26 | 27 | bool LexerMoreAction::isPositionDependent() const { 28 | return false; 29 | } 30 | 31 | void LexerMoreAction::execute(Lexer *lexer) { 32 | lexer->more(); 33 | } 34 | 35 | size_t LexerMoreAction::hashCode() const { 36 | size_t hash = MurmurHash::initialize(); 37 | hash = MurmurHash::update(hash, static_cast(getActionType())); 38 | return MurmurHash::finish(hash, 1); 39 | } 40 | 41 | bool LexerMoreAction::operator == (const LexerAction &obj) const { 42 | return &obj == this; 43 | } 44 | 45 | std::string LexerMoreAction::toString() const { 46 | return "more"; 47 | } 48 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerPopModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerPopModeAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref LexerPopModeAction::getInstance() { 16 | static Ref instance(new LexerPopModeAction()); 17 | return instance; 18 | } 19 | 20 | LexerPopModeAction::LexerPopModeAction() { 21 | } 22 | 23 | LexerActionType LexerPopModeAction::getActionType() const { 24 | return LexerActionType::POP_MODE; 25 | } 26 | 27 | bool LexerPopModeAction::isPositionDependent() const { 28 | return false; 29 | } 30 | 31 | void LexerPopModeAction::execute(Lexer *lexer) { 32 | lexer->popMode(); 33 | } 34 | 35 | size_t LexerPopModeAction::hashCode() const { 36 | size_t hash = MurmurHash::initialize(); 37 | hash = MurmurHash::update(hash, static_cast(getActionType())); 38 | return MurmurHash::finish(hash, 1); 39 | } 40 | 41 | bool LexerPopModeAction::operator == (const LexerAction &obj) const { 42 | return &obj == this; 43 | } 44 | 45 | std::string LexerPopModeAction::toString() const { 46 | return "popMode"; 47 | } 48 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerPushModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerPushModeAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | LexerPushModeAction::LexerPushModeAction(int mode) : _mode(mode) { 16 | } 17 | 18 | int LexerPushModeAction::getMode() const { 19 | return _mode; 20 | } 21 | 22 | LexerActionType LexerPushModeAction::getActionType() const { 23 | return LexerActionType::PUSH_MODE; 24 | } 25 | 26 | bool LexerPushModeAction::isPositionDependent() const { 27 | return false; 28 | } 29 | 30 | void LexerPushModeAction::execute(Lexer *lexer) { 31 | lexer->pushMode(_mode); 32 | } 33 | 34 | size_t LexerPushModeAction::hashCode() const { 35 | size_t hash = MurmurHash::initialize(); 36 | hash = MurmurHash::update(hash, static_cast(getActionType())); 37 | hash = MurmurHash::update(hash, _mode); 38 | return MurmurHash::finish(hash, 2); 39 | } 40 | 41 | bool LexerPushModeAction::operator == (const LexerAction &obj) const { 42 | if (&obj == this) { 43 | return true; 44 | } 45 | 46 | const LexerPushModeAction *action = dynamic_cast(&obj); 47 | if (action == nullptr) { 48 | return false; 49 | } 50 | 51 | return _mode == action->_mode; 52 | } 53 | 54 | std::string LexerPushModeAction::toString() const { 55 | return "pushMode(" + std::to_string(_mode) + ")"; 56 | } 57 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerSkipAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerSkipAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref LexerSkipAction::getInstance() { 16 | static Ref instance(new LexerSkipAction()); 17 | return instance; 18 | } 19 | 20 | LexerSkipAction::LexerSkipAction() { 21 | } 22 | 23 | LexerActionType LexerSkipAction::getActionType() const { 24 | return LexerActionType::SKIP; 25 | } 26 | 27 | bool LexerSkipAction::isPositionDependent() const { 28 | return false; 29 | } 30 | 31 | void LexerSkipAction::execute(Lexer *lexer) { 32 | lexer->skip(); 33 | } 34 | 35 | size_t LexerSkipAction::hashCode() const { 36 | size_t hash = MurmurHash::initialize(); 37 | hash = MurmurHash::update(hash, static_cast(getActionType())); 38 | return MurmurHash::finish(hash, 1); 39 | } 40 | 41 | bool LexerSkipAction::operator == (const LexerAction &obj) const { 42 | return &obj == this; 43 | } 44 | 45 | std::string LexerSkipAction::toString() const { 46 | return "skip"; 47 | } 48 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LexerTypeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerTypeAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | LexerTypeAction::LexerTypeAction(int type) : _type(type) { 16 | } 17 | 18 | int LexerTypeAction::getType() const { 19 | return _type; 20 | } 21 | 22 | LexerActionType LexerTypeAction::getActionType() const { 23 | return LexerActionType::TYPE; 24 | } 25 | 26 | bool LexerTypeAction::isPositionDependent() const { 27 | return false; 28 | } 29 | 30 | void LexerTypeAction::execute(Lexer *lexer) { 31 | lexer->setType(_type); 32 | } 33 | 34 | size_t LexerTypeAction::hashCode() const { 35 | size_t hash = MurmurHash::initialize(); 36 | hash = MurmurHash::update(hash, static_cast(getActionType())); 37 | hash = MurmurHash::update(hash, _type); 38 | return MurmurHash::finish(hash, 2); 39 | } 40 | 41 | bool LexerTypeAction::operator == (const LexerAction &obj) const { 42 | if (&obj == this) { 43 | return true; 44 | } 45 | 46 | const LexerTypeAction *action = dynamic_cast(&obj); 47 | if (action == nullptr) { 48 | return false; 49 | } 50 | 51 | return _type == action->_type; 52 | } 53 | 54 | std::string LexerTypeAction::toString() const { 55 | return "type(" + std::to_string(_type) + ")"; 56 | } 57 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LookaheadEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/LookaheadEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | LookaheadEventInfo::LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->predictedAlt = predictedAlt; 16 | } 17 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LoopEndState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/LoopEndState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t LoopEndState::getStateType() { 11 | return LOOP_END; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/LoopEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Mark the end of a * or + loop. 14 | class ANTLR4CPP_PUBLIC LoopEndState final : public ATNState { 15 | public: 16 | ATNState *loopBackState = nullptr; 17 | 18 | virtual size_t getStateType() override; 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS += -g -std=c++0x -Wall #-Wextra 3 | CXXFLAGS += -I. -I../ -I../misc/ -I../tree/ -I../dfa/ \ 4 | -I../../../../../antlrcpp/ 5 | 6 | #TODO LDFLAGS += ? 7 | 8 | ALL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS) 9 | ALL_LDFLAGS = $(LDFLAGS) 10 | 11 | # Escote's files 12 | SRCS = \ 13 | AbstractPredicateTransition.cpp \ 14 | ActionTransition.cpp \ 15 | ArrayPredictionContext.cpp \ 16 | ATNDeserializationOptions.cpp \ 17 | ATNDeserializer.cpp \ 18 | ATNState.cpp \ 19 | ATNType.cpp \ 20 | AtomTransition.cpp \ 21 | BasicBlockStartState.cpp \ 22 | BasicState.cpp \ 23 | BlockEndState.cpp \ 24 | BlockStartState.cpp \ 25 | DecisionState.cpp \ 26 | EmptyPredictionContext.cpp \ 27 | EpsilonTransition.cpp \ 28 | LexerATNConfig.cpp \ 29 | LoopEndState.cpp 30 | # Escote's TODO: LL1Analyzer.cpp LexerATNSimulator.cpp ATNSimulator.cpp \ 31 | ATNSerializer.cpp ATNConfigSet.cpp ATNConfig.cpp \ 32 | ATN.cpp 33 | 34 | # Alejandro's files 35 | SRCS += \ 36 | NotSetTransition.cpp \ 37 | OrderedATNConfigSet.cpp \ 38 | PlusBlockStartState.cpp \ 39 | PlusLoopbackState.cpp \ 40 | PredicateTransition.cpp \ 41 | PredictionMode.cpp \ 42 | RangeTransition.cpp \ 43 | RuleStartState.cpp \ 44 | RuleStopState.cpp \ 45 | RuleTransition.cpp \ 46 | SemanticContext.cpp \ 47 | SetTransition.cpp \ 48 | SingletonPredictionContext.cpp \ 49 | StarBlockStartState.cpp \ 50 | StarLoopbackState.cpp \ 51 | StarLoopEntryState.cpp \ 52 | TokensStartState.cpp \ 53 | Transition.cpp \ 54 | WildcardTransition.cpp 55 | # Alejandro's TODO: PredictionContext.cpp PredictionContextCache.cpp \ 56 | PrecedencePredicateTransition.cpp ParserATNSimulator.cpp 57 | 58 | OBJS = $(SRCS:.cpp=.o) 59 | 60 | all: $(OBJS) 61 | 62 | %.o: %.cpp 63 | $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ 64 | 65 | clean: 66 | $(RM) $(OBJS) 67 | 68 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/NotSetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/NotSetTransition.h" 7 | #include "atn/ATNState.h" 8 | #include "misc/IntervalSet.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | NotSetTransition::NotSetTransition(ATNState *target, const misc::IntervalSet &set) : SetTransition(target, set) { 14 | } 15 | 16 | Transition::SerializationType NotSetTransition::getSerializationType() const { 17 | return NOT_SET; 18 | } 19 | 20 | bool NotSetTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 21 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol 22 | && !SetTransition::matches(symbol, minVocabSymbol, maxVocabSymbol); 23 | } 24 | 25 | std::string NotSetTransition::toString() const { 26 | return "NOT_SET " + Transition::toString() + " { " + SetTransition::toString() + " }"; 27 | } 28 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/NotSetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/SetTransition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC NotSetTransition final : public SetTransition { 14 | public: 15 | NotSetTransition(ATNState *target, const misc::IntervalSet &set); 16 | 17 | virtual SerializationType getSerializationType() const override; 18 | 19 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 20 | 21 | virtual std::string toString() const override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/OrderedATNConfigSet.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/OrderedATNConfigSet.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t OrderedATNConfigSet::getHash(ATNConfig *c) { 11 | return c->hashCode(); 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/OrderedATNConfigSet.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNConfigSet.h" 9 | #include "atn/ATNConfig.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC OrderedATNConfigSet : public ATNConfigSet { 15 | protected: 16 | virtual size_t getHash(ATNConfig *c) override; 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PlusBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PlusBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t PlusBlockStartState::getStateType() { 11 | return PLUS_BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PlusBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Start of {@code (A|B|...)+} loop. Technically a decision state, but 14 | /// we don't use for code generation; somebody might need it, so I'm defining 15 | /// it for completeness. In reality, the node is the 16 | /// real decision-making note for {@code A+}. 17 | class ANTLR4CPP_PUBLIC PlusBlockStartState final : public BlockStartState { 18 | public: 19 | PlusLoopbackState *loopBackState = nullptr; 20 | 21 | virtual size_t getStateType() override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PlusLoopbackState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PlusLoopbackState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t PlusLoopbackState::getStateType() { 11 | return PLUS_LOOP_BACK; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PlusLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: 14 | /// one to the loop back to start of the block and one to exit. 15 | class ANTLR4CPP_PUBLIC PlusLoopbackState final : public DecisionState { 16 | 17 | public: 18 | virtual size_t getStateType() override; 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PrecedencePredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PrecedencePredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | PrecedencePredicateTransition::PrecedencePredicateTransition(ATNState *target, int precedence) 11 | : AbstractPredicateTransition(target), precedence(precedence) { 12 | } 13 | 14 | Transition::SerializationType PrecedencePredicateTransition::getSerializationType() const { 15 | return PRECEDENCE; 16 | } 17 | 18 | bool PrecedencePredicateTransition::isEpsilon() const { 19 | return true; 20 | } 21 | 22 | bool PrecedencePredicateTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 23 | return false; 24 | } 25 | 26 | Ref PrecedencePredicateTransition::getPredicate() const { 27 | return std::make_shared(precedence); 28 | } 29 | 30 | std::string PrecedencePredicateTransition::toString() const { 31 | return "PRECEDENCE " + Transition::toString() + " { precedence: " + std::to_string(precedence) + " }"; 32 | } 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PrecedencePredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/AbstractPredicateTransition.h" 9 | #include "SemanticContext.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC PrecedencePredicateTransition final : public AbstractPredicateTransition { 15 | public: 16 | const int precedence; 17 | 18 | PrecedencePredicateTransition(ATNState *target, int precedence); 19 | 20 | virtual SerializationType getSerializationType() const override; 21 | virtual bool isEpsilon() const override; 22 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 23 | Ref getPredicate() const; 24 | virtual std::string toString() const override; 25 | 26 | }; 27 | 28 | } // namespace atn 29 | } // namespace antlr4 30 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PredicateEvalInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "SemanticContext.h" 7 | 8 | #include "atn/PredicateEvalInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | PredicateEvalInfo::PredicateEvalInfo(size_t decision, TokenStream *input, size_t startIndex, size_t stopIndex, 14 | Ref const& semctx, bool evalResult, size_t predictedAlt, bool fullCtx) 15 | : DecisionEventInfo(decision, nullptr, input, startIndex, stopIndex, fullCtx), 16 | semctx(semctx), predictedAlt(predictedAlt), evalResult(evalResult) { 17 | } 18 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | PredicateTransition::PredicateTransition(ATNState *target, size_t ruleIndex, size_t predIndex, bool isCtxDependent) : AbstractPredicateTransition(target), ruleIndex(ruleIndex), predIndex(predIndex), isCtxDependent(isCtxDependent) { 11 | } 12 | 13 | Transition::SerializationType PredicateTransition::getSerializationType() const { 14 | return PREDICATE; 15 | } 16 | 17 | bool PredicateTransition::isEpsilon() const { 18 | return true; 19 | } 20 | 21 | bool PredicateTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 22 | return false; 23 | } 24 | 25 | Ref PredicateTransition::getPredicate() const { 26 | return std::make_shared(ruleIndex, predIndex, isCtxDependent); 27 | } 28 | 29 | std::string PredicateTransition::toString() const { 30 | return "PREDICATE " + Transition::toString() + " { ruleIndex: " + std::to_string(ruleIndex) + 31 | ", predIndex: " + std::to_string(predIndex) + ", isCtxDependent: " + std::to_string(isCtxDependent) + " }"; 32 | 33 | // Generate and add a predicate context here? 34 | } 35 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/PredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/AbstractPredicateTransition.h" 9 | #include "SemanticContext.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// TODO: this is old comment: 15 | /// A tree of semantic predicates from the grammar AST if label==SEMPRED. 16 | /// In the ATN, labels will always be exactly one predicate, but the DFA 17 | /// may have to combine a bunch of them as it collects predicates from 18 | /// multiple ATN configurations into a single DFA state. 19 | class ANTLR4CPP_PUBLIC PredicateTransition final : public AbstractPredicateTransition { 20 | public: 21 | const size_t ruleIndex; 22 | const size_t predIndex; 23 | const bool isCtxDependent; // e.g., $i ref in pred 24 | 25 | PredicateTransition(ATNState *target, size_t ruleIndex, size_t predIndex, bool isCtxDependent); 26 | 27 | virtual SerializationType getSerializationType() const override; 28 | 29 | virtual bool isEpsilon() const override; 30 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 31 | 32 | Ref getPredicate() const; 33 | 34 | virtual std::string toString() const override; 35 | 36 | }; 37 | 38 | } // namespace atn 39 | } // namespace antlr4 40 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RangeTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | 8 | #include "atn/RangeTransition.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RangeTransition::RangeTransition(ATNState *target, size_t from, size_t to) : Transition(target), from(from), to(to) { 14 | } 15 | 16 | Transition::SerializationType RangeTransition::getSerializationType() const { 17 | return RANGE; 18 | } 19 | 20 | misc::IntervalSet RangeTransition::label() const { 21 | return misc::IntervalSet::of((int)from, (int)to); 22 | } 23 | 24 | bool RangeTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 25 | return symbol >= from && symbol <= to; 26 | } 27 | 28 | std::string RangeTransition::toString() const { 29 | return "RANGE " + Transition::toString() + " { from: " + std::to_string(from) + ", to: " + std::to_string(to) + " }"; 30 | } 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RangeTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RangeTransition final : public Transition { 14 | public: 15 | const size_t from; 16 | const size_t to; 17 | 18 | RangeTransition(ATNState *target, size_t from, size_t to); 19 | 20 | virtual SerializationType getSerializationType() const override; 21 | 22 | virtual misc::IntervalSet label() const override; 23 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 24 | 25 | virtual std::string toString() const override; 26 | }; 27 | 28 | } // namespace atn 29 | } // namespace antlr4 30 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | RuleStartState::RuleStartState() { 11 | isLeftRecursiveRule = false; 12 | } 13 | 14 | size_t RuleStartState::getStateType() { 15 | return RULE_START; 16 | } 17 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RuleStartState final : public ATNState { 14 | public: 15 | RuleStartState(); 16 | 17 | RuleStopState *stopState = nullptr; 18 | bool isLeftRecursiveRule = false; 19 | 20 | virtual size_t getStateType() override; 21 | 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleStopState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStopState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t RuleStopState::getStateType() { 11 | return RULE_STOP; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleStopState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The last node in the ATN for a rule, unless that rule is the start symbol. 14 | /// In that case, there is one transition to EOF. Later, we might encode 15 | /// references to all calls to this rule to compute FOLLOW sets for 16 | /// error handling. 17 | class ANTLR4CPP_PUBLIC RuleStopState final : public ATNState { 18 | 19 | public: 20 | virtual size_t getStateType() override; 21 | 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStartState.h" 7 | #include "atn/RuleTransition.h" 8 | 9 | using namespace antlr4::atn; 10 | 11 | RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState) 12 | : RuleTransition(ruleStart, ruleIndex, 0, followState) { 13 | } 14 | 15 | RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState) 16 | : Transition(ruleStart), ruleIndex(ruleIndex), precedence(precedence) { 17 | this->followState = followState; 18 | } 19 | 20 | Transition::SerializationType RuleTransition::getSerializationType() const { 21 | return RULE; 22 | } 23 | 24 | bool RuleTransition::isEpsilon() const { 25 | return true; 26 | } 27 | 28 | bool RuleTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 29 | return false; 30 | } 31 | 32 | std::string RuleTransition::toString() const { 33 | std::stringstream ss; 34 | ss << "RULE " << Transition::toString() << " { ruleIndex: " << ruleIndex << ", precedence: " << precedence << 35 | ", followState: " << std::hex << followState << " }"; 36 | return ss.str(); 37 | } 38 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/RuleTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RuleTransition : public Transition { 14 | public: 15 | /// Ptr to the rule definition object for this rule ref. 16 | const size_t ruleIndex; // no Rule object at runtime 17 | 18 | const int precedence; 19 | 20 | /// What node to begin computations following ref to rule. 21 | ATNState *followState; 22 | 23 | /// @deprecated Use 24 | /// instead. 25 | RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState); 26 | 27 | RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState); 28 | RuleTransition(RuleTransition const&) = delete; 29 | RuleTransition& operator=(RuleTransition const&) = delete; 30 | 31 | virtual SerializationType getSerializationType() const override; 32 | 33 | virtual bool isEpsilon() const override; 34 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 35 | 36 | virtual std::string toString() const override; 37 | }; 38 | 39 | } // namespace atn 40 | } // namespace antlr4 41 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/SetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | #include "misc/IntervalSet.h" 8 | 9 | #include "atn/SetTransition.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | 14 | SetTransition::SetTransition(ATNState *target, const misc::IntervalSet &aSet) 15 | : Transition(target), set(aSet.isEmpty() ? misc::IntervalSet::of(Token::INVALID_TYPE) : aSet) { 16 | } 17 | 18 | Transition::SerializationType SetTransition::getSerializationType() const { 19 | return SET; 20 | } 21 | 22 | misc::IntervalSet SetTransition::label() const { 23 | return set; 24 | } 25 | 26 | bool SetTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 27 | return set.contains(symbol); 28 | } 29 | 30 | std::string SetTransition::toString() const { 31 | return "SET " + Transition::toString() + " { set: " + set.toString() + "}"; 32 | } 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/SetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// A transition containing a set of values. 15 | class ANTLR4CPP_PUBLIC SetTransition : public Transition { 16 | public: 17 | const misc::IntervalSet set; 18 | 19 | SetTransition(ATNState *target, const misc::IntervalSet &set); 20 | 21 | virtual SerializationType getSerializationType() const override; 22 | 23 | virtual misc::IntervalSet label() const override; 24 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/SingletonPredictionContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/PredictionContext.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC SingletonPredictionContext : public PredictionContext { 14 | public: 15 | // Usually a parent is linked via a weak ptr. Not so here as we have kinda reverse reference chain. 16 | // There are no child contexts stored here and often the parent context is left dangling when it's 17 | // owning ATNState is released. In order to avoid having this context released as well (leaving all other contexts 18 | // which got this one as parent with a null reference) we use a shared_ptr here instead, to keep those left alone 19 | // parent contexts alive. 20 | const Ref parent; 21 | const size_t returnState; 22 | 23 | SingletonPredictionContext(Ref const& parent, size_t returnState); 24 | virtual ~SingletonPredictionContext(); 25 | 26 | static Ref create(Ref const& parent, size_t returnState); 27 | 28 | virtual size_t size() const override; 29 | virtual Ref getParent(size_t index) const override; 30 | virtual size_t getReturnState(size_t index) const override; 31 | virtual bool operator == (const PredictionContext &o) const override; 32 | virtual std::string toString() const override; 33 | }; 34 | 35 | } // namespace atn 36 | } // namespace antlr4 37 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t StarBlockStartState::getStateType() { 11 | return STAR_BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The block that begins a closure loop. 14 | class ANTLR4CPP_PUBLIC StarBlockStartState final : public BlockStartState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarLoopEntryState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarLoopEntryState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | StarLoopEntryState::StarLoopEntryState() : DecisionState(), isPrecedenceDecision(false) { 11 | } 12 | 13 | size_t StarLoopEntryState::getStateType() { 14 | return STAR_LOOP_ENTRY; 15 | } 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarLoopEntryState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopEntryState final : public DecisionState { 14 | public: 15 | StarLoopEntryState(); 16 | 17 | /** 18 | * Indicates whether this state can benefit from a precedence DFA during SLL 19 | * decision making. 20 | * 21 | *

This is a computed property that is calculated during ATN deserialization 22 | * and stored for use in {@link ParserATNSimulator} and 23 | * {@link ParserInterpreter}.

24 | * 25 | * @see DFA#isPrecedenceDfa() 26 | */ 27 | bool isPrecedenceDecision = false; 28 | 29 | StarLoopbackState *loopBackState = nullptr; 30 | 31 | virtual size_t getStateType() override; 32 | }; 33 | 34 | } // namespace atn 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarLoopbackState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarLoopEntryState.h" 7 | #include "atn/Transition.h" 8 | 9 | #include "atn/StarLoopbackState.h" 10 | 11 | using namespace antlr4::atn; 12 | 13 | StarLoopEntryState *StarLoopbackState::getLoopEntryState() { 14 | return dynamic_cast(transitions[0]->target); 15 | } 16 | 17 | size_t StarLoopbackState::getStateType() { 18 | return STAR_LOOP_BACK; 19 | } 20 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/StarLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopbackState final : public ATNState { 14 | public: 15 | StarLoopEntryState *getLoopEntryState(); 16 | 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/TokensStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/TokensStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t TokensStartState::getStateType() { 11 | return TOKEN_START; 12 | } 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/TokensStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The Tokens rule start state linking to each lexer rule start state. 14 | class ANTLR4CPP_PUBLIC TokensStartState final : public DecisionState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/Transition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | #include "support/Arrays.h" 8 | 9 | #include "atn/Transition.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | 14 | using namespace antlrcpp; 15 | 16 | const std::vector Transition::serializationNames = { 17 | "INVALID", "EPSILON", "RANGE", "RULE", "PREDICATE", "ATOM", "ACTION", "SET", "NOT_SET", "WILDCARD", "PRECEDENCE" 18 | }; 19 | 20 | Transition::Transition(ATNState *target) { 21 | if (target == nullptr) { 22 | throw NullPointerException("target cannot be null."); 23 | } 24 | 25 | this->target = target; 26 | } 27 | 28 | Transition::~Transition() { 29 | } 30 | 31 | bool Transition::isEpsilon() const { 32 | return false; 33 | } 34 | 35 | misc::IntervalSet Transition::label() const { 36 | return misc::IntervalSet::EMPTY_SET; 37 | } 38 | 39 | std::string Transition::toString() const { 40 | std::stringstream ss; 41 | ss << "(Transition " << std::hex << this << ", target: " << std::hex << target << ')'; 42 | 43 | return ss.str(); 44 | } 45 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/WildcardTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNState.h" 7 | 8 | #include "atn/WildcardTransition.h" 9 | 10 | using namespace antlr4::atn; 11 | 12 | WildcardTransition::WildcardTransition(ATNState *target) : Transition(target) { 13 | } 14 | 15 | Transition::SerializationType WildcardTransition::getSerializationType() const { 16 | return WILDCARD; 17 | } 18 | 19 | bool WildcardTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 20 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; 21 | } 22 | 23 | std::string WildcardTransition::toString() const { 24 | return "WILDCARD " + Transition::toString() + " {}"; 25 | } 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/atn/WildcardTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC WildcardTransition final : public Transition { 14 | public: 15 | WildcardTransition(ATNState *target); 16 | 17 | virtual SerializationType getSerializationType() const override; 18 | 19 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 20 | 21 | virtual std::string toString() const override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/dfa/DFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Vocabulary.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | /// A DFA walker that knows how to dump them to serialized strings. 14 | class ANTLR4CPP_PUBLIC DFASerializer { 15 | public: 16 | DFASerializer(const DFA *dfa, const std::vector& tnames); 17 | DFASerializer(const DFA *dfa, const Vocabulary &vocabulary); 18 | virtual ~DFASerializer(); 19 | 20 | virtual std::string toString() const; 21 | 22 | protected: 23 | virtual std::string getEdgeLabel(size_t i) const; 24 | virtual std::string getStateString(DFAState *s) const; 25 | 26 | private: 27 | const DFA *_dfa; 28 | const Vocabulary &_vocabulary; 29 | }; 30 | 31 | } // namespace atn 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/dfa/LexerDFASerializer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Vocabulary.h" 7 | 8 | #include "dfa/LexerDFASerializer.h" 9 | 10 | using namespace antlr4::dfa; 11 | 12 | LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary::EMPTY_VOCABULARY) { 13 | } 14 | 15 | LexerDFASerializer::~LexerDFASerializer() { 16 | } 17 | 18 | std::string LexerDFASerializer::getEdgeLabel(size_t i) const { 19 | return std::string("'") + static_cast(i) + "'"; 20 | } 21 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/dfa/LexerDFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "dfa/DFASerializer.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer { 14 | public: 15 | LexerDFASerializer(DFA *dfa); 16 | virtual ~LexerDFASerializer(); 17 | 18 | protected: 19 | virtual std::string getEdgeLabel(size_t i) const override; 20 | }; 21 | 22 | } // namespace atn 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/misc/InterpreterDataReader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace misc { 12 | 13 | struct InterpreterData { 14 | atn::ATN atn; 15 | dfa::Vocabulary vocabulary; 16 | std::vector ruleNames; 17 | std::vector channels; // Only valid for lexer grammars. 18 | std::vector modes; // ditto 19 | 20 | InterpreterData() {}; // For invalid content. 21 | InterpreterData(std::vector const& literalNames, std::vector const& symbolicNames); 22 | }; 23 | 24 | // A class to read plain text interpreter data produced by ANTLR. 25 | class ANTLR4CPP_PUBLIC InterpreterDataReader { 26 | public: 27 | static InterpreterData parseFile(std::string const& fileName); 28 | }; 29 | 30 | } // namespace atn 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/misc/Predicate.cpp: -------------------------------------------------------------------------------- 1 | #include "misc/Predicate.h" 2 | 3 | antlr4::misc::Predicate::~Predicate() { 4 | } 5 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/misc/Predicate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace misc { 12 | 13 | class ANTLR4CPP_PUBLIC Predicate { 14 | public: 15 | virtual ~Predicate(); 16 | 17 | virtual bool test(tree::ParseTree *t) = 0; 18 | }; 19 | 20 | } // namespace tree 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/support/Any.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Any.h" 7 | 8 | using namespace antlrcpp; 9 | 10 | Any::~Any() 11 | { 12 | delete _ptr; 13 | } 14 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/support/Arrays.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "Exceptions.h" 8 | 9 | #include "support/Arrays.h" 10 | 11 | using namespace antlrcpp; 12 | 13 | std::string Arrays::listToString(const std::vector &list, const std::string &separator) 14 | { 15 | std::stringstream ss; 16 | bool firstEntry = true; 17 | 18 | ss << '['; 19 | for (auto &entry : list) { 20 | ss << entry; 21 | if (firstEntry) { 22 | ss << separator; 23 | firstEntry = false; 24 | } 25 | } 26 | 27 | ss << ']'; 28 | return ss.str(); 29 | } 30 | 31 | template <> 32 | std::string Arrays::toString(const std::vector &source) { 33 | std::string result = "["; 34 | bool firstEntry = true; 35 | for (auto value : source) { 36 | result += value->toStringTree(); 37 | if (firstEntry) { 38 | result += ", "; 39 | firstEntry = false; 40 | } 41 | } 42 | return result + "]"; 43 | } 44 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/support/StringUtils.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/StringUtils.h" 7 | 8 | namespace antlrcpp { 9 | 10 | void replaceAll(std::string& str, std::string const& from, std::string const& to) 11 | { 12 | if (from.empty()) 13 | return; 14 | 15 | size_t start_pos = 0; 16 | while ((start_pos = str.find(from, start_pos)) != std::string::npos) { 17 | str.replace(start_pos, from.length(), to); 18 | start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'. 19 | } 20 | } 21 | 22 | std::string ws2s(std::wstring const& wstr) { 23 | std::wstring_convert> converter; 24 | std::string narrow = converter.to_bytes(wstr); 25 | 26 | return narrow; 27 | } 28 | 29 | std::wstring s2ws(const std::string &str) { 30 | std::wstring_convert> converter; 31 | std::wstring wide = converter.from_bytes(str); 32 | 33 | return wide; 34 | } 35 | 36 | } // namespace antrlcpp 37 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ErrorNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ErrorNode.h" 7 | 8 | antlr4::tree::ErrorNode::~ErrorNode() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ErrorNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC ErrorNode : public virtual TerminalNode { 14 | public: 15 | ~ErrorNode() override; 16 | }; 17 | 18 | } // namespace tree 19 | } // namespace antlr4 20 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ErrorNodeImpl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | #include "tree/ParseTreeVisitor.h" 8 | 9 | #include "tree/ErrorNodeImpl.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::misc; 13 | using namespace antlr4::tree; 14 | 15 | ErrorNodeImpl::ErrorNodeImpl(Token *token) : TerminalNodeImpl(token) { 16 | } 17 | 18 | ErrorNodeImpl::~ErrorNodeImpl() { 19 | } 20 | 21 | antlrcpp::Any ErrorNodeImpl::accept(ParseTreeVisitor *visitor) { 22 | return visitor->visitErrorNode(this); 23 | } 24 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ErrorNodeImpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/ErrorNode.h" 9 | #include "tree/TerminalNodeImpl.h" 10 | #include "misc/Interval.h" 11 | 12 | #include "support/Any.h" 13 | 14 | namespace antlr4 { 15 | namespace tree { 16 | 17 | /// 18 | /// Represents a token that was consumed during resynchronization 19 | /// rather than during a valid match operation. For example, 20 | /// we will create this kind of a node during single token insertion 21 | /// and deletion as well as during "consume until error recovery set" 22 | /// upon no viable alternative exceptions. 23 | /// 24 | class ANTLR4CPP_PUBLIC ErrorNodeImpl : public virtual TerminalNodeImpl, public virtual ErrorNode { 25 | public: 26 | ErrorNodeImpl(Token *token); 27 | ~ErrorNodeImpl() override; 28 | 29 | virtual antlrcpp::Any accept(ParseTreeVisitor *visitor) override; 30 | }; 31 | 32 | } // namespace tree 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTree.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | 8 | using namespace antlr4::tree; 9 | 10 | ParseTree::ParseTree() : parent(nullptr) { 11 | } 12 | 13 | bool ParseTree::operator == (const ParseTree &other) const { 14 | return &other == this; 15 | } 16 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeListener.h" 7 | 8 | antlr4::tree::ParseTreeListener::~ParseTreeListener() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | /** This interface describes the minimal core of methods triggered 14 | * by {@link ParseTreeWalker}. E.g., 15 | * 16 | * ParseTreeWalker walker = new ParseTreeWalker(); 17 | * walker.walk(myParseTreeListener, myParseTree); <-- triggers events in your listener 18 | * 19 | * If you want to trigger events in multiple listeners during a single 20 | * tree walk, you can use the ParseTreeDispatcher object available at 21 | * 22 | * https://github.com/antlr/antlr4/issues/841 23 | */ 24 | class ANTLR4CPP_PUBLIC ParseTreeListener { 25 | public: 26 | virtual ~ParseTreeListener(); 27 | 28 | virtual void visitTerminal(TerminalNode *node) = 0; 29 | virtual void visitErrorNode(ErrorNode *node) = 0; 30 | virtual void enterEveryRule(ParserRuleContext *ctx) = 0; 31 | virtual void exitEveryRule(ParserRuleContext *ctx) = 0; 32 | 33 | bool operator == (const ParseTreeListener &other) { 34 | return this == &other; 35 | } 36 | }; 37 | 38 | } // namespace tree 39 | } // namespace antlr4 40 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeProperty.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | /// 14 | /// Associate a property with a parse tree node. Useful with parse tree listeners 15 | /// that need to associate values with particular tree nodes, kind of like 16 | /// specifying a return value for the listener event method that visited a 17 | /// particular node. Example: 18 | /// 19 | ///
20 |   /// ParseTreeProperty<Integer> values = new ParseTreeProperty<Integer>();
21 |   /// values.put(tree, 36);
22 |   /// int x = values.get(tree);
23 |   /// values.removeFrom(tree);
24 |   /// 
25 | /// 26 | /// You would make one decl (values here) in the listener and use lots of times 27 | /// in your event methods. 28 | ///
29 | template 30 | class ANTLR4CPP_PUBLIC ParseTreeProperty { 31 | public: 32 | virtual ~ParseTreeProperty() {} 33 | virtual V get(ParseTree *node) { 34 | return _annotations[node]; 35 | } 36 | virtual void put(ParseTree *node, V value) { 37 | _annotations[node] = value; 38 | } 39 | virtual V removeFrom(ParseTree *node) { 40 | auto value = _annotations[node]; 41 | _annotations.erase(node); 42 | return value; 43 | } 44 | 45 | protected: 46 | std::map _annotations; 47 | }; 48 | 49 | } // namespace tree 50 | } // namespace antlr4 51 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeVisitor.h" 7 | 8 | antlr4::tree::ParseTreeVisitor::~ParseTreeVisitor() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeWalker.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ErrorNode.h" 7 | #include "ParserRuleContext.h" 8 | #include "tree/ParseTreeListener.h" 9 | #include "support/CPPUtils.h" 10 | 11 | #include "tree/IterativeParseTreeWalker.h" 12 | #include "tree/ParseTreeWalker.h" 13 | 14 | using namespace antlr4::tree; 15 | using namespace antlrcpp; 16 | 17 | static IterativeParseTreeWalker defaultWalker; 18 | ParseTreeWalker &ParseTreeWalker::DEFAULT = defaultWalker; 19 | 20 | ParseTreeWalker::~ParseTreeWalker() { 21 | } 22 | 23 | void ParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) const { 24 | if (is(t)) { 25 | listener->visitErrorNode(dynamic_cast(t)); 26 | return; 27 | } else if (is(t)) { 28 | listener->visitTerminal(dynamic_cast(t)); 29 | return; 30 | } 31 | 32 | enterRule(listener, t); 33 | for (auto &child : t->children) { 34 | walk(listener, child); 35 | } 36 | exitRule(listener, t); 37 | } 38 | 39 | void ParseTreeWalker::enterRule(ParseTreeListener *listener, ParseTree *r) const { 40 | ParserRuleContext *ctx = dynamic_cast(r); 41 | listener->enterEveryRule(ctx); 42 | ctx->enterRule(listener); 43 | } 44 | 45 | void ParseTreeWalker::exitRule(ParseTreeListener *listener, ParseTree *r) const { 46 | ParserRuleContext *ctx = dynamic_cast(r); 47 | ctx->exitRule(listener); 48 | listener->exitEveryRule(ctx); 49 | } 50 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/ParseTreeWalker.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC ParseTreeWalker { 14 | public: 15 | static ParseTreeWalker &DEFAULT; 16 | 17 | virtual ~ParseTreeWalker(); 18 | 19 | virtual void walk(ParseTreeListener *listener, ParseTree *t) const; 20 | 21 | protected: 22 | /// The discovery of a rule node, involves sending two events: the generic 23 | /// and a 24 | /// -specific event. First we trigger the generic and then 25 | /// the rule specific. We do them in reverse order upon finishing the node. 26 | virtual void enterRule(ParseTreeListener *listener, ParseTree *r) const; 27 | virtual void exitRule(ParseTreeListener *listener, ParseTree *r) const; 28 | }; 29 | 30 | } // namespace tree 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/TerminalNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/TerminalNode.h" 7 | 8 | antlr4::tree::TerminalNode::~TerminalNode() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/TerminalNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/ParseTree.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNode : public ParseTree { 14 | public: 15 | ~TerminalNode() override; 16 | 17 | virtual Token* getSymbol() = 0; 18 | 19 | /** Set the parent for this leaf node. 20 | * 21 | * Technically, this is not backward compatible as it changes 22 | * the interface but no one was able to create custom 23 | * TerminalNodes anyway so I'm adding as it improves internal 24 | * code quality. 25 | * 26 | * @since 4.7 27 | */ 28 | virtual void setParent(RuleContext *parent) = 0; 29 | }; 30 | 31 | } // namespace tree 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/TerminalNodeImpl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "Token.h" 8 | #include "RuleContext.h" 9 | #include "tree/ParseTreeVisitor.h" 10 | 11 | #include "tree/TerminalNodeImpl.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::tree; 15 | 16 | TerminalNodeImpl::TerminalNodeImpl(Token *symbol_) : symbol(symbol_) { 17 | } 18 | 19 | Token* TerminalNodeImpl::getSymbol() { 20 | return symbol; 21 | } 22 | 23 | void TerminalNodeImpl::setParent(RuleContext *parent_) { 24 | this->parent = parent_; 25 | } 26 | 27 | misc::Interval TerminalNodeImpl::getSourceInterval() { 28 | if (symbol == nullptr) { 29 | return misc::Interval::INVALID; 30 | } 31 | 32 | size_t tokenIndex = symbol->getTokenIndex(); 33 | return misc::Interval(tokenIndex, tokenIndex); 34 | } 35 | 36 | antlrcpp::Any TerminalNodeImpl::accept(ParseTreeVisitor *visitor) { 37 | return visitor->visitTerminal(this); 38 | } 39 | 40 | std::string TerminalNodeImpl::getText() { 41 | return symbol->getText(); 42 | } 43 | 44 | std::string TerminalNodeImpl::toStringTree(Parser * /*parser*/, bool /*pretty*/) { 45 | return toString(); 46 | } 47 | 48 | std::string TerminalNodeImpl::toString() { 49 | if (symbol->getType() == Token::EOF) { 50 | return ""; 51 | } 52 | return symbol->getText(); 53 | } 54 | 55 | std::string TerminalNodeImpl::toStringTree(bool /*pretty*/) { 56 | return toString(); 57 | } 58 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/TerminalNodeImpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNodeImpl : public virtual TerminalNode { 14 | public: 15 | Token *symbol; 16 | 17 | TerminalNodeImpl(Token *symbol); 18 | 19 | virtual Token* getSymbol() override; 20 | virtual void setParent(RuleContext *parent) override; 21 | virtual misc::Interval getSourceInterval() override; 22 | 23 | virtual antlrcpp::Any accept(ParseTreeVisitor *visitor) override; 24 | 25 | virtual std::string getText() override; 26 | virtual std::string toStringTree(Parser *parser, bool pretty = false) override; 27 | virtual std::string toString() override; 28 | virtual std::string toStringTree(bool pretty = false) override; 29 | 30 | }; 31 | 32 | } // namespace tree 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/Chunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/Chunk.h" 7 | 8 | antlr4::tree::pattern::Chunk::~Chunk() { 9 | } 10 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/Chunk.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace pattern { 13 | 14 | /// 15 | /// A chunk is either a token tag, a rule tag, or a span of literal text within a 16 | /// tree pattern. 17 | ///

18 | /// The method returns a list of 19 | /// chunks in preparation for creating a token stream by 20 | /// . From there, we get a parse 21 | /// tree from with . These 22 | /// chunks are converted to , , or the 23 | /// regular tokens of the text surrounding the tags. 24 | ///

25 | class ANTLR4CPP_PUBLIC Chunk { 26 | public: 27 | Chunk() = default; 28 | Chunk(Chunk const&) = default; 29 | virtual ~Chunk(); 30 | 31 | Chunk& operator=(Chunk const&) = default; 32 | 33 | /// This method returns a text representation of the tag chunk. Labeled tags 34 | /// are returned in the form {@code label:tag}, and unlabeled tags are 35 | /// returned as just the tag name. 36 | virtual std::string toString() { 37 | std::string str; 38 | return str; 39 | } 40 | }; 41 | 42 | } // namespace pattern 43 | } // namespace tree 44 | } // namespace antlr4 45 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/TagChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TagChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TagChunk::TagChunk(const std::string &tag) : TagChunk("", tag) { 13 | } 14 | 15 | TagChunk::TagChunk(const std::string &label, const std::string &tag) : _tag(tag), _label(label) { 16 | if (tag.empty()) { 17 | throw IllegalArgumentException("tag cannot be null or empty"); 18 | } 19 | 20 | } 21 | 22 | TagChunk::~TagChunk() { 23 | } 24 | 25 | std::string TagChunk::getTag() { 26 | return _tag; 27 | } 28 | 29 | std::string TagChunk::getLabel() { 30 | return _label; 31 | } 32 | 33 | std::string TagChunk::toString() { 34 | if (!_label.empty()) { 35 | return _label + ":" + _tag; 36 | } 37 | 38 | return _tag; 39 | } 40 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/TextChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TextChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TextChunk::TextChunk(const std::string &text) : text(text) { 13 | if (text == "") { 14 | throw IllegalArgumentException("text cannot be nul"); 15 | } 16 | 17 | } 18 | 19 | TextChunk::~TextChunk() { 20 | } 21 | 22 | std::string TextChunk::getText() { 23 | return text; 24 | } 25 | 26 | std::string TextChunk::toString() { 27 | return std::string("'") + text + std::string("'"); 28 | } 29 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/TextChunk.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Chunk.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace pattern { 13 | 14 | /// 15 | /// Represents a span of raw text (concrete syntax) between tags in a tree 16 | /// pattern string. 17 | /// 18 | class ANTLR4CPP_PUBLIC TextChunk : public Chunk { 19 | private: 20 | /// 21 | /// This is the backing field for . 22 | /// 23 | const std::string text; 24 | 25 | /// 26 | /// Constructs a new instance of with the specified text. 27 | /// 28 | /// The text of this chunk. 29 | /// if {@code text} is {@code null}. 30 | public: 31 | TextChunk(const std::string &text); 32 | virtual ~TextChunk(); 33 | 34 | /// 35 | /// Gets the raw text of this chunk. 36 | /// 37 | /// The text of the chunk. 38 | std::string getText(); 39 | 40 | /// 41 | /// {@inheritDoc} 42 | ///

43 | /// The implementation for returns the result of 44 | /// in single quotes. 45 | ///

46 | virtual std::string toString() override; 47 | }; 48 | 49 | } // namespace pattern 50 | } // namespace tree 51 | } // namespace antlr4 52 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/pattern/TokenTagToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/TokenTagToken.h" 7 | 8 | using namespace antlr4::tree::pattern; 9 | 10 | TokenTagToken::TokenTagToken(const std::string &/*tokenName*/, int type) 11 | : CommonToken(type), tokenName(""), label("") { 12 | } 13 | 14 | TokenTagToken::TokenTagToken(const std::string &tokenName, int type, const std::string &label) 15 | : CommonToken(type), tokenName(tokenName), label(label) { 16 | } 17 | 18 | std::string TokenTagToken::getTokenName() const { 19 | return tokenName; 20 | } 21 | 22 | std::string TokenTagToken::getLabel() const { 23 | return label; 24 | } 25 | 26 | std::string TokenTagToken::getText() const { 27 | if (!label.empty()) { 28 | return "<" + label + ":" + tokenName + ">"; 29 | } 30 | 31 | return "<" + tokenName + ">"; 32 | } 33 | 34 | std::string TokenTagToken::toString() const { 35 | return tokenName + ":" + std::to_string(_type); 36 | } 37 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/CPPUtils.h" 7 | 8 | #include "XPathElement.h" 9 | 10 | using namespace antlr4::tree; 11 | using namespace antlr4::tree::xpath; 12 | 13 | XPathElement::XPathElement(const std::string &nodeName) { 14 | _nodeName = nodeName; 15 | } 16 | 17 | XPathElement::~XPathElement() { 18 | } 19 | 20 | std::vector XPathElement::evaluate(ParseTree * /*t*/) { 21 | return {}; 22 | } 23 | 24 | std::string XPathElement::toString() const { 25 | std::string inv = _invert ? "!" : ""; 26 | return antlrcpp::toString(*this) + "[" + inv + _nodeName + "]"; 27 | } 28 | 29 | void XPathElement::setInvert(bool value) { 30 | _invert = value; 31 | } 32 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | class ParseTree; 13 | 14 | namespace xpath { 15 | 16 | class ANTLR4CPP_PUBLIC XPathElement { 17 | public: 18 | /// Construct element like {@code /ID} or {@code ID} or {@code /*} etc... 19 | /// op is null if just node 20 | XPathElement(const std::string &nodeName); 21 | XPathElement(XPathElement const&) = default; 22 | virtual ~XPathElement(); 23 | 24 | XPathElement& operator=(XPathElement const&) = default; 25 | 26 | /// Given tree rooted at {@code t} return all nodes matched by this path 27 | /// element. 28 | virtual std::vector evaluate(ParseTree *t); 29 | virtual std::string toString() const; 30 | 31 | void setInvert(bool value); 32 | 33 | protected: 34 | std::string _nodeName; 35 | bool _invert = false; 36 | }; 37 | 38 | } // namespace xpath 39 | } // namespace tree 40 | } // namespace antlr4 41 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar XPathLexer; 2 | 3 | tokens { TOKEN_REF, RULE_REF } 4 | 5 | /* 6 | path : separator? word (separator word)* EOF ; 7 | 8 | separator 9 | : '/' '!' 10 | | '//' '!' 11 | | '/' 12 | | '//' 13 | ; 14 | 15 | word: TOKEN_REF 16 | | RULE_REF 17 | | STRING 18 | | '*' 19 | ; 20 | */ 21 | 22 | ANYWHERE : '//' ; 23 | ROOT : '/' ; 24 | WILDCARD : '*' ; 25 | BANG : '!' ; 26 | 27 | ID : NameStartChar NameChar* 28 | { 29 | if (isupper(getText()[0])) 30 | setType(TOKEN_REF); 31 | else 32 | setType(RULE_REF); 33 | } 34 | ; 35 | 36 | fragment 37 | NameChar : NameStartChar 38 | | '0'..'9' 39 | | '_' 40 | | '\u00B7' 41 | | '\u0300'..'\u036F' 42 | | '\u203F'..'\u2040' 43 | ; 44 | 45 | fragment 46 | NameStartChar 47 | : 'A'..'Z' | 'a'..'z' 48 | | '\u00C0'..'\u00D6' 49 | | '\u00D8'..'\u00F6' 50 | | '\u00F8'..'\u02FF' 51 | | '\u0370'..'\u037D' 52 | | '\u037F'..'\u1FFF' 53 | | '\u200C'..'\u200D' 54 | | '\u2070'..'\u218F' 55 | | '\u2C00'..'\u2FEF' 56 | | '\u3001'..'\uD7FF' 57 | | '\uF900'..'\uFDCF' 58 | | '\uFDF0'..'\uFFFF' // implicitly includes ['\u10000-'\uEFFFF] 59 | ; 60 | 61 | STRING : '\'' .*? '\''; 62 | 63 | //WS : [ \t\r\n]+ -> skip ; 64 | 65 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathLexer.tokens: -------------------------------------------------------------------------------- 1 | TOKEN_REF=1 2 | RULE_REF=2 3 | ANYWHERE=3 4 | ROOT=4 5 | WILDCARD=5 6 | BANG=6 7 | ID=7 8 | STRING=8 9 | '//'=3 10 | '/'=4 11 | '*'=5 12 | '!'=6 13 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathLexerErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPathLexerErrorListener.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::tree::xpath; 10 | 11 | void XPathLexerErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 12 | size_t /*line*/, size_t /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) { 13 | } 14 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathLexerErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "BaseErrorListener.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathLexerErrorListener : public BaseErrorListener { 15 | public: 16 | virtual void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line, 17 | size_t charPositionInLine, const std::string &msg, std::exception_ptr e) override; 18 | }; 19 | 20 | } // namespace xpath 21 | } // namespace tree 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "tree/xpath/XPathRuleAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleAnywhereElement::XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllRuleNodes(t, _ruleIndex); 20 | } 21 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathRuleAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | /// Either {@code ID} at start of path or {@code ...//ID} in middle of path. 15 | class ANTLR4CPP_PUBLIC XPathRuleAnywhereElement : public XPathElement { 16 | public: 17 | XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex); 18 | 19 | virtual std::vector evaluate(ParseTree *t) override; 20 | 21 | protected: 22 | int _ruleIndex = 0; 23 | }; 24 | 25 | } // namespace xpath 26 | } // namespace tree 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathRuleElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathRuleElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleElement::XPathRuleElement(const std::string &ruleName, size_t ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleElement::evaluate(ParseTree *t) { 19 | // return all children of t that match nodeName 20 | std::vector nodes; 21 | for (auto c : t->children) { 22 | if (antlrcpp::is(c)) { 23 | ParserRuleContext *ctx = dynamic_cast(c); 24 | if ((ctx->getRuleIndex() == _ruleIndex && !_invert) || (ctx->getRuleIndex() != _ruleIndex && _invert)) { 25 | nodes.push_back(ctx); 26 | } 27 | } 28 | } 29 | return nodes; 30 | } 31 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathRuleElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathRuleElement : public XPathElement { 15 | public: 16 | XPathRuleElement(const std::string &ruleName, size_t ruleIndex); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _ruleIndex = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathTokenAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathTokenAnywhereElement::XPathTokenAnywhereElement(const std::string &tokenName, int tokenType) : XPathElement(tokenName) { 15 | this->tokenType = tokenType; 16 | } 17 | 18 | std::vector XPathTokenAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllTokenNodes(t, tokenType); 20 | } 21 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathTokenAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenAnywhereElement : public XPathElement { 15 | protected: 16 | int tokenType = 0; 17 | public: 18 | XPathTokenAnywhereElement(const std::string &tokenName, int tokenType); 19 | 20 | virtual std::vector evaluate(ParseTree *t) override; 21 | }; 22 | 23 | } // namespace xpath 24 | } // namespace tree 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathTokenElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | #include "support/CPPUtils.h" 9 | #include "Token.h" 10 | 11 | #include "XPathTokenElement.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::tree; 15 | using namespace antlr4::tree::xpath; 16 | 17 | XPathTokenElement::XPathTokenElement(const std::string &tokenName, size_t tokenType) : XPathElement(tokenName) { 18 | _tokenType = tokenType; 19 | } 20 | 21 | std::vector XPathTokenElement::evaluate(ParseTree *t) { 22 | // return all children of t that match nodeName 23 | std::vector nodes; 24 | for (auto c : t->children) { 25 | if (antlrcpp::is(c)) { 26 | TerminalNode *tnode = dynamic_cast(c); 27 | if ((tnode->getSymbol()->getType() == _tokenType && !_invert) || (tnode->getSymbol()->getType() != _tokenType && _invert)) { 28 | nodes.push_back(tnode); 29 | } 30 | } 31 | } 32 | return nodes; 33 | } 34 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathTokenElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenElement : public XPathElement { 15 | public: 16 | XPathTokenElement(const std::string &tokenName, size_t tokenType); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _tokenType = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardAnywhereElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardAnywhereElement::XPathWildcardAnywhereElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardAnywhereElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | return Trees::getDescendants(t); 23 | } 24 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardAnywhereElement : public XPathElement { 15 | public: 16 | XPathWildcardAnywhereElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathWildcardElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardElement::XPathWildcardElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | 23 | return t->children; 24 | } 25 | -------------------------------------------------------------------------------- /antlr-runtime/runtime/src/tree/xpath/XPathWildcardElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardElement : public XPathElement { 15 | public: 16 | XPathWildcardElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /bin/antlr-4.8-complete.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/bin/antlr-4.8-complete.jar -------------------------------------------------------------------------------- /lib/libantlr4-runtime.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/lib/libantlr4-runtime.a -------------------------------------------------------------------------------- /lib/libantlr4-runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/lib/libantlr4-runtime.so -------------------------------------------------------------------------------- /lib/libantlr4-runtime.so.4.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strumenta/article-llvm-rpg/8c9fc77b818db62f335d270e38272a1d31960f97/lib/libantlr4-runtime.so.4.8 -------------------------------------------------------------------------------- /rpgle/CALCFIB.rpgle: -------------------------------------------------------------------------------- 1 | * Calculates number of Fibonacci in an iterative way 2 | D NBR S 8 0 3 | D RESULT S 8 0 INZ(0) 4 | D COUNT S 8 0 5 | D A S 8 0 INZ(0) 6 | D B S 8 0 INZ((A + 1)) 7 | C *entry plist 8 | C parm ppdat 9 | * 10 | C EVAL NBR = 55 11 | C EXSR FIB 12 | C DSPLY RESULT 13 | *--------------------------------------------------------------* 14 | C FIB BEGSR 15 | C EVAL COUNT = 0 16 | C SELECT 17 | C WHEN NBR = 0 18 | C EVAL RESULT = 0 19 | C WHEN NBR = 1 20 | C EVAL RESULT = 1 21 | C OTHER 22 | C FOR COUNT = 2 TO NBR 23 | C EVAL RESULT = A + B 24 | C EVAL A = B 25 | C EVAL B = RESULT 26 | C DSPLY RESULT 27 | C ENDFOR 28 | C ENDSL 29 | C ENDSR 30 | C SETON -------------------------------------------------------------------------------- /src/generated/RpgParserBaseListener.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from src/antlr/RpgParser.g4 by ANTLR 4.8 3 | 4 | 5 | #include "RpgParserBaseListener.h" 6 | 7 | 8 | using namespace antlrcpprpg; 9 | 10 | -------------------------------------------------------------------------------- /src/generated/RpgParserBaseVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from src/antlr/RpgParser.g4 by ANTLR 4.8 3 | 4 | 5 | #include "RpgParserBaseVisitor.h" 6 | 7 | 8 | using namespace antlrcpprpg; 9 | 10 | -------------------------------------------------------------------------------- /src/generated/RpgParserListener.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from src/antlr/RpgParser.g4 by ANTLR 4.8 3 | 4 | 5 | #include "RpgParserListener.h" 6 | 7 | 8 | using namespace antlrcpprpg; 9 | 10 | -------------------------------------------------------------------------------- /src/generated/RpgParserVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from src/antlr/RpgParser.g4 by ANTLR 4.8 3 | 4 | 5 | #include "RpgParserVisitor.h" 6 | 7 | 8 | using namespace antlrcpprpg; 9 | 10 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #include "rpg/compiler.h" 7 | #include "utils/optionparser.h" 8 | enum optionIndex { UNKNOWN, HELP, DEBUG, LOG }; 9 | const option::Descriptor usage[] = 10 | { 11 | {UNKNOWN, 0, "", "",option::Arg::None, "USAGE: rpg [options]\n\n" 12 | "Options:" }, 13 | {HELP, 0,"", "help",option::Arg::None, " --help \tPrint usage and exit." }, 14 | {DEBUG, 0,"", "debug",option::Arg::None, " --debug \tGenerate debug info" }, 15 | {LOG , 0,"", "log",option::Arg::Optional, " --log \tGenerate log information" }, 16 | {UNKNOWN, 0, "", "",option::Arg::None, "\nExamples:\n" 17 | 18 | " rpg file.rpgle\n" }, 19 | {0,0,0,0,0,0} 20 | }; 21 | 22 | 23 | bool LogMessage::enable = false; 24 | int main(int argc, char *argv[]) { 25 | Compiler rpg; 26 | 27 | // skip program name argv[0] if present 28 | argc-=(argc>0); argv+=(argc>0); 29 | option::Stats stats(usage, argc, argv); 30 | std::vector options(stats.options_max); 31 | std::vector buffer(stats.buffer_max); 32 | option::Parser parse(usage, argc, argv, &options[0], &buffer[0]); 33 | 34 | if (parse.error()) 35 | return 1; 36 | 37 | if (options[HELP] || argc == 0) { 38 | option::printUsage(std::cout, usage); 39 | return 0; 40 | } 41 | 42 | if(options[DEBUG]) { 43 | rpg.setEmitDebugInfo(true); 44 | } 45 | if(options[LOG]) { 46 | rpg.setEmitLogInfo(true); 47 | } 48 | for (int i = 0; i < parse.nonOptionsCount(); ++i) { 49 | rpg.addSource(parse.nonOption(i)); 50 | } 51 | 52 | int exit_code = rpg.compile(); 53 | 54 | exit(exit_code); 55 | } 56 | -------------------------------------------------------------------------------- /src/rpg/log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by madytyoo on 3/2/20. 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | struct nullstream : std::ostream { 14 | nullstream() : std::ostream(0) {} 15 | }; 16 | 17 | template 18 | nullstream &operator<<(nullstream &o, T const &x) { return o; } 19 | 20 | 21 | class LogMessage { 22 | std::string level; 23 | std::ostream &ofs; 24 | nullstream __nullstream; 25 | static bool enable; 26 | public: 27 | static void setEnable(bool en) { 28 | LogMessage::enable = en; 29 | } 30 | LogMessage(const std::string &l) 31 | : level(l), ofs(LogMessage::enable ? std::cout : __nullstream) { 32 | stream() << "[" << level << "]\t"; 33 | //stream() << ""; 34 | } 35 | 36 | LogMessage(std::ostream &o) 37 | : level("ERROR"), ofs(o) { 38 | stream() << "[" << level << "]\t"; 39 | } 40 | 41 | inline std::ostream &stream() { 42 | return ofs; 43 | } 44 | 45 | ~LogMessage() { 46 | stream() << std::endl; 47 | } 48 | }; 49 | 50 | 51 | #define LOG(type) LogMessage(#type).stream() 52 | 53 | -------------------------------------------------------------------------------- /src/rpg/parser.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by madytyoo on 2/23/20. 3 | // 4 | 5 | #pragma once 6 | #include "antlr4-runtime.h" 7 | #include "RpgParserBaseVisitor.h" 8 | 9 | #include "ast.h" 10 | #include "compiler.h" 11 | 12 | 13 | 14 | class RpgCodeVisitor : public RpgVisitor { 15 | public: 16 | RpgCodeVisitor(const std::string &filename, const Compiler *compiler); 17 | 18 | antlrcpp::Any visitR(antlrcpprpg::RpgParser::RContext *ctx) override; 19 | 20 | antlrcpp::Any visitCsEXSR(antlrcpprpg::RpgParser::CsEXSRContext *ctx) override; 21 | 22 | antlrcpp::Any visitCsBEGSR(antlrcpprpg::RpgParser::CsBEGSRContext *ctx) override; 23 | antlrcpp::Any visitCsENDSR(antlrcpprpg::RpgParser::CsENDSRContext *ctx) override; 24 | 25 | antlrcpp::Any visitCsEVAL(antlrcpprpg::RpgParser::CsEVALContext *ctx) override; 26 | 27 | antlrcpp::Any visitBeginselect(antlrcpprpg::RpgParser::BeginselectContext *ctx) override; 28 | antlrcpp::Any visitWhenstatement(antlrcpprpg::RpgParser::WhenstatementContext *ctx) override; 29 | antlrcpp::Any visitCsOTHER(antlrcpprpg::RpgParser::CsOTHERContext *ctx) override; 30 | antlrcpp::Any visitEndselect(antlrcpprpg::RpgParser::EndselectContext *ctx) override; 31 | 32 | antlrcpp::Any visitCsFOR(antlrcpprpg::RpgParser::CsFORContext *ctx) override; 33 | antlrcpp::Any visitEndfor(antlrcpprpg::RpgParser::EndforContext *ctx) override; 34 | 35 | void addNode(std::shared_ptr node) { 36 | if(scope.size() > 0) { 37 | std::shared_ptr current = scope.top(); 38 | current.get()->addNode(node); 39 | } else { 40 | compiler->ast->add(node); 41 | } 42 | } 43 | std::shared_ptr parseExpression(antlrcpprpg::RpgParser::ExpressionContext *ctx); 44 | 45 | void dump() { } 46 | 47 | antlrcpp::Any visitCsDSPLY(antlrcpprpg::RpgParser::CsDSPLYContext *ctx) override; 48 | 49 | 50 | private: 51 | std::stack> scope; 52 | 53 | 54 | }; 55 | --------------------------------------------------------------------------------