├── .github └── workflows │ └── main.yml ├── .gitignore ├── Makefile ├── README.md ├── antlr-4.7-complete.jar ├── example2.png ├── example2.txt ├── hello.cpp ├── modelica.g4 ├── run.sh └── runtime-osx ├── antlr4-runtime ├── ANTLRErrorListener.h ├── ANTLRErrorStrategy.h ├── ANTLRFileStream.h ├── ANTLRInputStream.h ├── BailErrorStrategy.h ├── BaseErrorListener.h ├── BufferedTokenStream.h ├── CharStream.h ├── CommonToken.h ├── CommonTokenFactory.h ├── CommonTokenStream.h ├── ConsoleErrorListener.h ├── DefaultErrorStrategy.h ├── DiagnosticErrorListener.h ├── Exceptions.h ├── FailedPredicateException.h ├── InputMismatchException.h ├── IntStream.h ├── InterpreterRuleContext.h ├── Lexer.h ├── LexerInterpreter.h ├── LexerNoViableAltException.h ├── ListTokenSource.h ├── NoViableAltException.h ├── Parser.h ├── ParserInterpreter.h ├── ParserRuleContext.h ├── ProxyErrorListener.h ├── RecognitionException.h ├── Recognizer.h ├── RuleContext.h ├── RuleContextWithAltNum.h ├── RuntimeMetaData.h ├── Token.h ├── TokenFactory.h ├── TokenSource.h ├── TokenStream.h ├── TokenStreamRewriter.h ├── UnbufferedCharStream.h ├── UnbufferedTokenStream.h ├── Vocabulary.h ├── WritableToken.h ├── antlr4-common.h ├── antlr4-runtime.h ├── atn │ ├── ATN.h │ ├── ATNConfig.h │ ├── ATNConfigSet.h │ ├── ATNDeserializationOptions.h │ ├── ATNDeserializer.h │ ├── ATNSerializer.h │ ├── ATNSimulator.h │ ├── ATNState.h │ ├── ATNType.h │ ├── AbstractPredicateTransition.h │ ├── ActionTransition.h │ ├── AmbiguityInfo.h │ ├── ArrayPredictionContext.h │ ├── AtomTransition.h │ ├── BasicBlockStartState.h │ ├── BasicState.h │ ├── BlockEndState.h │ ├── BlockStartState.h │ ├── ContextSensitivityInfo.h │ ├── DecisionEventInfo.h │ ├── DecisionInfo.h │ ├── DecisionState.h │ ├── EmptyPredictionContext.h │ ├── EpsilonTransition.h │ ├── ErrorInfo.h │ ├── LL1Analyzer.h │ ├── LexerATNConfig.h │ ├── LexerATNSimulator.h │ ├── LexerAction.h │ ├── LexerActionExecutor.h │ ├── LexerActionType.h │ ├── LexerChannelAction.h │ ├── LexerCustomAction.h │ ├── LexerIndexedCustomAction.h │ ├── LexerModeAction.h │ ├── LexerMoreAction.h │ ├── LexerPopModeAction.h │ ├── LexerPushModeAction.h │ ├── LexerSkipAction.h │ ├── LexerTypeAction.h │ ├── LookaheadEventInfo.h │ ├── LoopEndState.h │ ├── NotSetTransition.h │ ├── OrderedATNConfigSet.h │ ├── ParseInfo.h │ ├── ParserATNSimulator.h │ ├── PlusBlockStartState.h │ ├── PlusLoopbackState.h │ ├── PrecedencePredicateTransition.h │ ├── PredicateEvalInfo.h │ ├── PredicateTransition.h │ ├── PredictionContext.h │ ├── PredictionMode.h │ ├── ProfilingATNSimulator.h │ ├── RangeTransition.h │ ├── RuleStartState.h │ ├── RuleStopState.h │ ├── RuleTransition.h │ ├── SemanticContext.h │ ├── SetTransition.h │ ├── SingletonPredictionContext.h │ ├── StarBlockStartState.h │ ├── StarLoopEntryState.h │ ├── StarLoopbackState.h │ ├── TokensStartState.h │ ├── Transition.h │ └── WildcardTransition.h ├── dfa │ ├── DFA.h │ ├── DFASerializer.h │ ├── DFAState.h │ └── LexerDFASerializer.h ├── misc │ ├── Interval.h │ ├── IntervalSet.h │ ├── MurmurHash.h │ └── Predicate.h ├── support │ ├── Any.h │ ├── Arrays.h │ ├── BitSet.h │ ├── CPPUtils.h │ ├── Declarations.h │ ├── StringUtils.h │ └── guid.h └── tree │ ├── AbstractParseTreeVisitor.h │ ├── ErrorNode.h │ ├── ErrorNodeImpl.h │ ├── IterativeParseTreeWalker.h │ ├── ParseTree.h │ ├── ParseTreeListener.h │ ├── ParseTreeProperty.h │ ├── ParseTreeVisitor.h │ ├── ParseTreeWalker.h │ ├── TerminalNode.h │ ├── TerminalNodeImpl.h │ ├── Trees.h │ ├── pattern │ ├── Chunk.h │ ├── ParseTreeMatch.h │ ├── ParseTreePattern.h │ ├── ParseTreePatternMatcher.h │ ├── RuleTagToken.h │ ├── TagChunk.h │ ├── TextChunk.h │ └── TokenTagToken.h │ └── xpath │ ├── XPath.h │ ├── XPathElement.h │ ├── XPathLexer.h │ ├── XPathLexerErrorListener.h │ ├── XPathRuleAnywhereElement.h │ ├── XPathRuleElement.h │ ├── XPathTokenAnywhereElement.h │ ├── XPathTokenElement.h │ ├── XPathWildcardAnywhereElement.h │ └── XPathWildcardElement.h └── lib ├── libantlr4-runtime.a └── libantlr4-runtime.dylib /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | jobs: 9 | build: 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | matrix: 13 | os: [ macos-latest] 14 | fail-fast: false 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: build 20 | run: make clean;make 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /output 2 | /generated 3 | /hello 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | JAVA=/usr/bin/java 3 | OUTPUT=output 4 | GENERATED=generated 5 | GRAMMAR=modelica.g4 6 | 7 | # here is where you plug in the runtime for your OS 8 | RUNTIME=runtime-osx 9 | CC=g++ 10 | CCARGS=-c -I $(RUNTIME)/antlr4-runtime/ -I $(GENERATED) -std=c++11 11 | LDARGS=-g 12 | LIBS=$(RUNTIME)/lib/libantlr4-runtime.a 13 | 14 | all: hello 15 | 16 | hello: dirs antlr4 hello.cpp 17 | $(CC) $(CCARGS) hello.cpp -o $(OUTPUT)/hello.o 18 | $(CC) $(CCARGS) $(GENERATED)/modelicaBaseListener.cpp -o $(OUTPUT)/modelicaBaseListener.o 19 | $(CC) $(CCARGS) $(GENERATED)/modelicaLexer.cpp -o $(OUTPUT)/modelicaLexer.o 20 | $(CC) $(CCARGS) $(GENERATED)/modelicaListener.cpp -o $(OUTPUT)/modelicaListener.o 21 | $(CC) $(CCARGS) $(GENERATED)/modelicaParser.cpp -o $(OUTPUT)/modelicaParser.o 22 | $(CC) $(LDARGS) $(OUTPUT)/hello.o $(OUTPUT)/modelicaBaseListener.o $(OUTPUT)/modelicaLexer.o $(OUTPUT)/modelicaListener.o $(OUTPUT)/modelicaParser.o $(LIBS) -o hello 23 | 24 | antlr4: $(GRAMMAR) 25 | $(JAVA) -jar antlr-4.7-complete.jar -Dlanguage=Cpp -o $(GENERATED) $(GRAMMAR) 26 | 27 | dirs: 28 | mkdir -p $(OUTPUT) 29 | mkdir -p $(GENERATED) 30 | 31 | clean: 32 | rm -rf $(OUTPUT) 33 | rm -rf $(GENERATED) 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![CI](https://github.com/teverett/antlr4-cpp-example/workflows/CI/badge.svg) 2 | 3 | # Antlr4 C++ Example 4 | 5 | A simple example of using [Antlr4](http://www.antlr.org/) to generate a C++ Parser / Lexer, for [Modelica](https://www.modelica.org/). The Modelica grammar for Antlr4 is from [here](https://github.com/antlr/grammars-v4/tree/master/modelica). 6 | 7 | To run the example, simply run `./run.sh` or `make` 8 | 9 | The example presumes that the java executable is on your path. 10 | 11 | The output includes 12 | 13 | `modelicaLexer.*`: Antlr4 Lexer for Modelica 14 | 15 | `modelicaParser.*`: Antlr4 Parser for Modelica 16 | 17 | `modelicaListener.*`: Antlr4 Listener implementation for Modelica 18 | 19 | Note that the Listener classes are optional: not every application of Antlr4 requires a listener. 20 | 21 | 22 | -------------------------------------------------------------------------------- /antlr-4.7-complete.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teverett/antlr4-cpp-example/a43d0910caaef189a08602fb529718a1fcc5ec9c/antlr-4.7-complete.jar -------------------------------------------------------------------------------- /example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teverett/antlr4-cpp-example/a43d0910caaef189a08602fb529718a1fcc5ec9c/example2.png -------------------------------------------------------------------------------- /example2.txt: -------------------------------------------------------------------------------- 1 | model Capacitor 2 | parameter Capacitance C; 3 | Voltage u "Voltage drop between pin_p and pin_n"; 4 | Pin pin_p, pin_n; 5 | equation 6 | 0 = pin_p.i + pin_n.i; 7 | u = pin_p.v - pin_n.v; 8 | C * der(u) = pin_p.i; 9 | end Capacitor; 10 | -------------------------------------------------------------------------------- /hello.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "antlr4-runtime.h" 6 | #include "modelicaLexer.h" 7 | #include "modelicaParser.h" 8 | 9 | using namespace antlr4; 10 | using namespace std; 11 | 12 | int main(int argc, char *argv[]) { 13 | string line; 14 | ifstream modelicaFile ("example2.txt"); 15 | if (modelicaFile.is_open()) { 16 | ANTLRInputStream input(modelicaFile); 17 | modelicaLexer lexer(&input); 18 | CommonTokenStream tokens(&lexer); 19 | 20 | tokens.fill(); 21 | for (auto token : tokens.getTokens()) { 22 | std::cout << token->toString() << std::endl; 23 | } 24 | 25 | modelicaParser parser(&tokens); 26 | tree::ParseTree *tree = parser.stored_definition(); 27 | 28 | std::cout << tree->toStringTree(&parser) << std::endl; 29 | modelicaFile.close(); 30 | } 31 | } -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | java -jar antlr-4.7-complete.jar -Dlanguage=Cpp -o generated/ modelica.g4 2 | 3 | 4 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/ANTLRInputStream.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 "CharStream.h" 9 | 10 | namespace antlr4 { 11 | 12 | // Vacuum all input from a stream and then treat it 13 | // like a string. Can also pass in a string or char[] to use. 14 | // Input is expected to be encoded in UTF-8 and converted to UTF-32 internally. 15 | class ANTLR4CPP_PUBLIC ANTLRInputStream : public CharStream { 16 | protected: 17 | /// The data being scanned. 18 | // UTF-32 19 | #if defined(_MSC_VER) && _MSC_VER == 1900 20 | i32string _data; // Custom type for VS 2015. 21 | #else 22 | std::u32string _data; 23 | #endif 24 | 25 | /// 0..n-1 index into string of next char 26 | size_t p; 27 | 28 | public: 29 | /// What is name or source of this char stream? 30 | std::string name; 31 | 32 | ANTLRInputStream(const std::string &input = ""); 33 | ANTLRInputStream(const char data_[], size_t numberOfActualCharsInArray); 34 | ANTLRInputStream(std::istream &stream); 35 | 36 | virtual void load(const std::string &input); 37 | virtual void load(std::istream &stream); 38 | 39 | /// Reset the stream so that it's in the same state it was 40 | /// when the object was created *except* the data array is not 41 | /// touched. 42 | virtual void reset(); 43 | virtual void consume() override; 44 | virtual size_t LA(ssize_t i) override; 45 | virtual size_t LT(ssize_t i); 46 | 47 | /// 48 | /// Return the current input symbol index 0..n where n indicates the 49 | /// last symbol has been read. The index is the index of char to 50 | /// be returned from LA(1). 51 | /// 52 | virtual size_t index() override; 53 | virtual size_t size() override; 54 | 55 | /// 56 | /// mark/release do nothing; we have entire buffer 57 | virtual ssize_t mark() override; 58 | virtual void release(ssize_t marker) override; 59 | 60 | /// 61 | /// consume() ahead until p==index; can't just set p=index as we must 62 | /// update line and charPositionInLine. If we seek backwards, just set p 63 | /// 64 | virtual void seek(size_t index) override; 65 | virtual std::string getText(const misc::Interval &interval) override; 66 | virtual std::string getSourceName() const override; 67 | virtual std::string toString() const override; 68 | 69 | private: 70 | void InitializeInstanceFields(); 71 | }; 72 | 73 | } // namespace antlr4 74 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/BailErrorStrategy.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 "DefaultErrorStrategy.h" 9 | 10 | namespace antlr4 { 11 | 12 | /** 13 | * This implementation of {@link ANTLRErrorStrategy} responds to syntax errors 14 | * by immediately canceling the parse operation with a 15 | * {@link ParseCancellationException}. The implementation ensures that the 16 | * {@link ParserRuleContext#exception} field is set for all parse tree nodes 17 | * that were not completed prior to encountering the error. 18 | * 19 | *

20 | * This error strategy is useful in the following scenarios.

21 | * 22 | *
    23 | *
  • Two-stage parsing: This error strategy allows the first 24 | * stage of two-stage parsing to immediately terminate if an error is 25 | * encountered, and immediately fall back to the second stage. In addition to 26 | * avoiding wasted work by attempting to recover from errors here, the empty 27 | * implementation of {@link BailErrorStrategy#sync} improves the performance of 28 | * the first stage.
  • 29 | *
  • Silent validation: When syntax errors are not being 30 | * reported or logged, and the parse result is simply ignored if errors occur, 31 | * the {@link BailErrorStrategy} avoids wasting work on recovering from errors 32 | * when the result will be ignored either way.
  • 33 | *
34 | * 35 | *

36 | * {@code myparser.setErrorHandler(new BailErrorStrategy());}

37 | * 38 | * @see Parser#setErrorHandler(ANTLRErrorStrategy) 39 | */ 40 | class ANTLR4CPP_PUBLIC BailErrorStrategy : public DefaultErrorStrategy { 41 | /// 42 | /// Instead of recovering from exception {@code e}, re-throw it wrapped 43 | /// in a so it is not caught by the 44 | /// rule function catches. Use to get the 45 | /// original . 46 | /// 47 | public: 48 | virtual void recover(Parser *recognizer, std::exception_ptr e) override; 49 | 50 | /// Make sure we don't attempt to recover inline; if the parser 51 | /// successfully recovers, it won't throw an exception. 52 | virtual Token* recoverInline(Parser *recognizer) override; 53 | 54 | /// 55 | /// Make sure we don't attempt to recover from problems in subrules. 56 | virtual void sync(Parser *recognizer) override; 57 | }; 58 | 59 | } // namespace antlr4 60 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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() = 0; 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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/CommonTokenFactory.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 "TokenFactory.h" 9 | 10 | namespace antlr4 { 11 | 12 | /** 13 | * This default implementation of {@link TokenFactory} creates 14 | * {@link CommonToken} objects. 15 | */ 16 | class ANTLR4CPP_PUBLIC CommonTokenFactory : public TokenFactory { 17 | public: 18 | /** 19 | * The default {@link CommonTokenFactory} instance. 20 | * 21 | *

22 | * This token factory does not explicitly copy token text when constructing 23 | * tokens.

24 | */ 25 | static const Ref> DEFAULT; 26 | 27 | protected: 28 | /** 29 | * Indicates whether {@link CommonToken#setText} should be called after 30 | * constructing tokens to explicitly set the text. This is useful for cases 31 | * where the input stream might not be able to provide arbitrary substrings 32 | * of text from the input after the lexer creates a token (e.g. the 33 | * implementation of {@link CharStream#getText} in 34 | * {@link UnbufferedCharStream} throws an 35 | * {@link UnsupportedOperationException}). Explicitly setting the token text 36 | * allows {@link Token#getText} to be called at any time regardless of the 37 | * input stream implementation. 38 | * 39 | *

40 | * The default value is {@code false} to avoid the performance and memory 41 | * overhead of copying text for every token unless explicitly requested.

42 | */ 43 | const bool copyText; 44 | 45 | public: 46 | /** 47 | * Constructs a {@link CommonTokenFactory} with the specified value for 48 | * {@link #copyText}. 49 | * 50 | *

51 | * When {@code copyText} is {@code false}, the {@link #DEFAULT} instance 52 | * should be used instead of constructing a new instance.

53 | * 54 | * @param copyText The value for {@link #copyText}. 55 | */ 56 | CommonTokenFactory(bool copyText); 57 | 58 | /** 59 | * Constructs a {@link CommonTokenFactory} with {@link #copyText} set to 60 | * {@code false}. 61 | * 62 | *

63 | * The {@link #DEFAULT} instance should be used instead of calling this 64 | * directly.

65 | */ 66 | CommonTokenFactory(); 67 | 68 | virtual std::unique_ptr create(std::pair source, size_t type, 69 | const std::string &text, size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) override; 70 | 71 | virtual std::unique_ptr create(size_t type, const std::string &text) override; 72 | }; 73 | 74 | } // namespace antlr4 75 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/CommonTokenStream.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 "BufferedTokenStream.h" 9 | 10 | namespace antlr4 { 11 | 12 | /** 13 | * This class extends {@link BufferedTokenStream} with functionality to filter 14 | * token streams to tokens on a particular channel (tokens where 15 | * {@link Token#getChannel} returns a particular value). 16 | * 17 | *

18 | * This token stream provides access to all tokens by index or when calling 19 | * methods like {@link #getText}. The channel filtering is only used for code 20 | * accessing tokens via the lookahead methods {@link #LA}, {@link #LT}, and 21 | * {@link #LB}.

22 | * 23 | *

24 | * By default, tokens are placed on the default channel 25 | * ({@link Token#DEFAULT_CHANNEL}), but may be reassigned by using the 26 | * {@code ->channel(HIDDEN)} lexer command, or by using an embedded action to 27 | * call {@link Lexer#setChannel}. 28 | *

29 | * 30 | *

31 | * Note: lexer rules which use the {@code ->skip} lexer command or call 32 | * {@link Lexer#skip} do not produce tokens at all, so input text matched by 33 | * such a rule will not be available as part of the token stream, regardless of 34 | * channel.

35 | */ 36 | class ANTLR4CPP_PUBLIC CommonTokenStream : public BufferedTokenStream { 37 | protected: 38 | /** 39 | * Specifies the channel to use for filtering tokens. 40 | * 41 | *

42 | * The default value is {@link Token#DEFAULT_CHANNEL}, which matches the 43 | * default channel assigned to tokens created by the lexer.

44 | */ 45 | size_t channel; 46 | 47 | public: 48 | /** 49 | * Constructs a new {@link CommonTokenStream} using the specified token 50 | * source and the default token channel ({@link Token#DEFAULT_CHANNEL}). 51 | * 52 | * @param tokenSource The token source. 53 | */ 54 | CommonTokenStream(TokenSource *tokenSource); 55 | 56 | /** 57 | * Constructs a new {@link CommonTokenStream} using the specified token 58 | * source and filtering tokens to the specified channel. Only tokens whose 59 | * {@link Token#getChannel} matches {@code channel} or have the 60 | * {@link Token#getType} equal to {@link Token#EOF} will be returned by the 61 | * token stream lookahead methods. 62 | * 63 | * @param tokenSource The token source. 64 | * @param channel The channel to use for filtering tokens. 65 | */ 66 | CommonTokenStream(TokenSource *tokenSource, int channel); 67 | 68 | protected: 69 | virtual ssize_t adjustSeekIndex(size_t i) override; 70 | 71 | virtual Token* LB(size_t k) override; 72 | 73 | public: 74 | virtual Token* LT(ssize_t k) override; 75 | 76 | /// Count EOF just once. 77 | virtual int getNumberOfOnChannelTokens(); 78 | 79 | private: 80 | void InitializeInstanceFields(); 81 | }; 82 | 83 | } // namespace antlr4 84 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/DiagnosticErrorListener.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 | /// 13 | /// This implementation of can be used to identify 14 | /// certain potential correctness and performance problems in grammars. "Reports" 15 | /// are made by calling with the appropriate 16 | /// message. 17 | /// 18 | ///
    19 | ///
  • Ambiguities: These are cases where more than one path through the 20 | /// grammar can match the input.
  • 21 | ///
  • Weak context sensitivity: These are cases where full-context 22 | /// prediction resolved an SLL conflict to a unique alternative which equaled the 23 | /// minimum alternative of the SLL conflict.
  • 24 | ///
  • Strong (forced) context sensitivity: These are cases where the 25 | /// full-context prediction resolved an SLL conflict to a unique alternative, 26 | /// and the minimum alternative of the SLL conflict was found to not be 27 | /// a truly viable alternative. Two-stage parsing cannot be used for inputs where 28 | /// this situation occurs.
  • 29 | ///
30 | /// 31 | /// @author Sam Harwell 32 | ///
33 | class ANTLR4CPP_PUBLIC DiagnosticErrorListener : public BaseErrorListener { 34 | /// 35 | /// When {@code true}, only exactly known ambiguities are reported. 36 | /// 37 | protected: 38 | const bool exactOnly; 39 | 40 | /// 41 | /// Initializes a new instance of which only 42 | /// reports exact ambiguities. 43 | /// 44 | public: 45 | DiagnosticErrorListener(); 46 | 47 | /// 48 | /// Initializes a new instance of , specifying 49 | /// whether all ambiguities or only exact ambiguities are reported. 50 | /// 51 | /// {@code true} to report only exact ambiguities, otherwise 52 | /// {@code false} to report all ambiguities. 53 | DiagnosticErrorListener(bool exactOnly); 54 | 55 | virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact, 56 | const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override; 57 | 58 | virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 59 | const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override; 60 | 61 | virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 62 | size_t prediction, atn::ATNConfigSet *configs) override; 63 | 64 | protected: 65 | virtual std::string getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa); 66 | 67 | /// 68 | /// Computes the set of conflicting or ambiguous alternatives from a 69 | /// configuration set, if that information was not already provided by the 70 | /// parser. 71 | /// 72 | /// The set of conflicting or ambiguous alternatives, as 73 | /// reported by the parser. 74 | /// The conflicting or ambiguous configuration set. 75 | /// Returns {@code reportedAlts} if it is not {@code null}, otherwise 76 | /// returns the set of alternatives represented in {@code configs}. 77 | virtual antlrcpp::BitSet getConflictingAlts(const antlrcpp::BitSet &reportedAlts, atn::ATNConfigSet *configs); 78 | }; 79 | 80 | } // namespace antlr4 81 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/Exceptions.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 | // An exception hierarchy modelled loosely after java.lang.* exceptions. 13 | class ANTLR4CPP_PUBLIC RuntimeException : public std::exception { 14 | private: 15 | std::string _message; 16 | public: 17 | RuntimeException(const std::string &msg = ""); 18 | 19 | virtual const char* what() const NOEXCEPT override; 20 | }; 21 | 22 | class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException { 23 | public: 24 | IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {}; 25 | }; 26 | 27 | class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException { 28 | public: 29 | IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {}; 30 | }; 31 | 32 | class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException { 33 | public: 34 | NullPointerException(const std::string &msg = "") : RuntimeException(msg) {}; 35 | }; 36 | 37 | class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException { 38 | public: 39 | IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {}; 40 | }; 41 | 42 | class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException { 43 | public: 44 | UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {}; 45 | }; 46 | 47 | class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException { 48 | public: 49 | EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {}; 50 | }; 51 | 52 | // IOException is not a runtime exception (in the java hierarchy). 53 | // Hence we have to duplicate the RuntimeException implementation. 54 | class ANTLR4CPP_PUBLIC IOException : public std::exception { 55 | private: 56 | std::string _message; 57 | 58 | public: 59 | IOException(const std::string &msg = ""); 60 | 61 | virtual const char* what() const NOEXCEPT override; 62 | }; 63 | 64 | class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException { 65 | public: 66 | CancellationException(const std::string &msg = "") : IllegalStateException(msg) {}; 67 | }; 68 | 69 | class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException { 70 | public: 71 | ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {}; 72 | }; 73 | 74 | } // namespace antlr4 75 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | }; 20 | 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/LexerInterpreter.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 "Lexer.h" 9 | #include "atn/PredictionContext.h" 10 | #include "Vocabulary.h" 11 | 12 | namespace antlr4 { 13 | 14 | class ANTLR4CPP_PUBLIC LexerInterpreter : public Lexer { 15 | public: 16 | // @deprecated 17 | LexerInterpreter(const std::string &grammarFileName, const std::vector &tokenNames, 18 | const std::vector &ruleNames, const std::vector &channelNames, 19 | const std::vector &modeNames, const atn::ATN &atn, CharStream *input); 20 | LexerInterpreter(const std::string &grammarFileName, const dfa::Vocabulary &vocabulary, 21 | const std::vector &ruleNames, const std::vector &channelNames, 22 | const std::vector &modeNames, const atn::ATN &atn, CharStream *input); 23 | 24 | ~LexerInterpreter(); 25 | 26 | virtual const atn::ATN& getATN() const override; 27 | virtual std::string getGrammarFileName() const override; 28 | virtual const std::vector& getTokenNames() const override; 29 | virtual const std::vector& getRuleNames() const override; 30 | virtual const std::vector& getChannelNames() const override; 31 | virtual const std::vector& getModeNames() const override; 32 | 33 | virtual const dfa::Vocabulary& getVocabulary() const override; 34 | 35 | protected: 36 | const std::string _grammarFileName; 37 | const atn::ATN &_atn; 38 | 39 | // @deprecated 40 | std::vector _tokenNames; 41 | const std::vector &_ruleNames; 42 | const std::vector &_channelNames; 43 | const std::vector &_modeNames; 44 | std::vector _decisionToDFA; 45 | 46 | atn::PredictionContextCache _sharedContextCache; 47 | 48 | private: 49 | dfa::Vocabulary _vocabulary; 50 | }; 51 | 52 | } // namespace antlr4 53 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/ListTokenSource.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 "TokenSource.h" 9 | #include "CommonTokenFactory.h" 10 | 11 | namespace antlr4 { 12 | 13 | /// Provides an implementation of as a wrapper around a list 14 | /// of objects. 15 | /// 16 | /// If the final token in the list is an token, it will be used 17 | /// as the EOF token for every call to after the end of the 18 | /// list is reached. Otherwise, an EOF token will be created. 19 | class ANTLR4CPP_PUBLIC ListTokenSource : public TokenSource { 20 | protected: 21 | // This list will be emptied token by token as we call nextToken(). 22 | // Token streams can be used to buffer tokens for a while. 23 | std::vector> tokens; 24 | 25 | private: 26 | /// 27 | /// The name of the input source. If this value is {@code null}, a call to 28 | /// should return the source name used to create the 29 | /// the next token in (or the previous token if the end of 30 | /// the input has been reached). 31 | /// 32 | const std::string sourceName; 33 | 34 | protected: 35 | /// The index into of token to return by the next call to 36 | /// . The end of the input is indicated by this value 37 | /// being greater than or equal to the number of items in . 38 | size_t i; 39 | 40 | private: 41 | /// This is the backing field for and 42 | /// . 43 | Ref> _factory = CommonTokenFactory::DEFAULT; 44 | 45 | public: 46 | /// Constructs a new instance from the specified 47 | /// collection of objects. 48 | /// 49 | /// The collection of objects to provide as a 50 | /// . 51 | /// if {@code tokens} is {@code null} 52 | ListTokenSource(std::vector> tokens); 53 | ListTokenSource(const ListTokenSource& other) = delete; 54 | 55 | ListTokenSource& operator = (const ListTokenSource& other) = delete; 56 | 57 | /// 58 | /// Constructs a new instance from the specified 59 | /// collection of objects and source name. 60 | /// 61 | /// The collection of objects to provide as a 62 | /// . 63 | /// The name of the . If this value is 64 | /// {@code null}, will attempt to infer the name from 65 | /// the next (or the previous token if the end of the input has 66 | /// been reached). 67 | /// 68 | /// if {@code tokens} is {@code null} 69 | ListTokenSource(std::vector> tokens_, const std::string &sourceName_); 70 | 71 | virtual size_t getCharPositionInLine() override; 72 | virtual std::unique_ptr nextToken() override; 73 | virtual size_t getLine() const override; 74 | virtual CharStream* getInputStream() override; 75 | virtual std::string getSourceName() override; 76 | 77 | template 78 | void setTokenFactory(TokenFactory *factory) { 79 | this->_factory = factory; 80 | } 81 | 82 | virtual Ref> getTokenFactory() override; 83 | 84 | private: 85 | void InitializeInstanceFields(); 86 | }; 87 | 88 | } // namespace antlr4 89 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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); 23 | 24 | virtual Token* getStartToken() const; 25 | virtual atn::ATNConfigSet* getDeadEndConfigs() const; 26 | 27 | private: 28 | /// Which configurations did we try at input.index() that couldn't match input.LT(1)? 29 | atn::ATNConfigSet* _deadEndConfigs; 30 | 31 | /// The token object at the start index; the input stream might 32 | /// not be buffering tokens so get a reference to it. (At the 33 | /// time the error occurred, of course the stream needs to keep a 34 | /// buffer all of the tokens but later we might not have access to those.) 35 | Token *_startToken; 36 | 37 | }; 38 | 39 | } // namespace antlr4 40 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/Token.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 | 10 | namespace antlr4 { 11 | 12 | /// A token has properties: text, type, line, character position in the line 13 | /// (so we can ignore tabs), token channel, index, and source from which 14 | /// we obtained this token. 15 | class ANTLR4CPP_PUBLIC Token { 16 | public: 17 | static const size_t INVALID_TYPE = 0; 18 | 19 | /// During lookahead operations, this "token" signifies we hit rule end ATN state 20 | /// and did not follow it despite needing to. 21 | static const size_t EPSILON = (size_t)-2; 22 | static const size_t MIN_USER_TOKEN_TYPE = 1; 23 | static const size_t EOF = IntStream::EOF; 24 | 25 | virtual ~Token() {}; 26 | 27 | /// All tokens go to the parser (unless skip() is called in that rule) 28 | /// on a particular "channel". The parser tunes to a particular channel 29 | /// so that whitespace etc... can go to the parser on a "hidden" channel. 30 | static const size_t DEFAULT_CHANNEL = 0; 31 | 32 | /// Anything on different channel than DEFAULT_CHANNEL is not parsed 33 | /// by parser. 34 | static const size_t HIDDEN_CHANNEL = 1; 35 | 36 | /** 37 | * This is the minimum constant value which can be assigned to a 38 | * user-defined token channel. 39 | * 40 | *

41 | * The non-negative numbers less than {@link #MIN_USER_CHANNEL_VALUE} are 42 | * assigned to the predefined channels {@link #DEFAULT_CHANNEL} and 43 | * {@link #HIDDEN_CHANNEL}.

44 | * 45 | * @see Token#getChannel() 46 | */ 47 | static const size_t MIN_USER_CHANNEL_VALUE = 2; 48 | 49 | /// Get the text of the token. 50 | virtual std::string getText() const = 0; 51 | 52 | /// Get the token type of the token 53 | virtual size_t getType() const = 0; 54 | 55 | /// The line number on which the 1st character of this token was matched, line=1..n 56 | virtual size_t getLine() const = 0; 57 | 58 | /// The index of the first character of this token relative to the 59 | /// beginning of the line at which it occurs, 0..n-1 60 | virtual size_t getCharPositionInLine() const = 0; 61 | 62 | /// Return the channel this token. Each token can arrive at the parser 63 | /// on a different channel, but the parser only "tunes" to a single channel. 64 | /// The parser ignores everything not on DEFAULT_CHANNEL. 65 | virtual size_t getChannel() const = 0; 66 | 67 | /// An index from 0..n-1 of the token object in the input stream. 68 | /// This must be valid in order to print token streams and 69 | /// use TokenRewriteStream. 70 | /// 71 | /// Return INVALID_INDEX to indicate that this token was conjured up since 72 | /// it doesn't have a valid index. 73 | virtual size_t getTokenIndex() const = 0; 74 | 75 | /// The starting character index of the token 76 | /// This method is optional; return INVALID_INDEX if not implemented. 77 | virtual size_t getStartIndex() const = 0; 78 | 79 | /// The last character index of the token. 80 | /// This method is optional; return INVALID_INDEX if not implemented. 81 | virtual size_t getStopIndex() const = 0; 82 | 83 | /// Gets the which created this token. 84 | virtual TokenSource *getTokenSource() const = 0; 85 | 86 | /// Gets the from which this token was derived. 87 | virtual CharStream *getInputStream() const = 0; 88 | 89 | virtual std::string toString() const = 0; 90 | }; 91 | 92 | } // namespace antlr4 93 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/TokenSource.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 "TokenFactory.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// 13 | /// A source of tokens must provide a sequence of tokens via 14 | /// and also must reveal it's source of characters; 's text is 15 | /// computed from a ; it only store indices into the char 16 | /// stream. 17 | ///

18 | /// Errors from the lexer are never passed to the parser. Either you want to keep 19 | /// going or you do not upon token recognition error. If you do not want to 20 | /// continue lexing then you do not want to continue parsing. Just throw an 21 | /// exception not under and Java will naturally toss 22 | /// you all the way out of the recognizers. If you want to continue lexing then 23 | /// you should not throw an exception to the parser--it has already requested a 24 | /// token. Keep lexing until you get a valid one. Just report errors and keep 25 | /// going, looking for a valid token. 26 | ///

27 | class ANTLR4CPP_PUBLIC TokenSource { 28 | public: 29 | virtual ~TokenSource() {}; 30 | 31 | /// Return a object from your input stream (usually a 32 | /// ). Do not fail/return upon lexing error; keep chewing 33 | /// on the characters until you get a good one; errors are not passed through 34 | /// to the parser. 35 | virtual std::unique_ptr nextToken() = 0; 36 | 37 | /// 38 | /// Get the line number for the current position in the input stream. The 39 | /// first line in the input is line 1. 40 | /// 41 | /// The line number for the current position in the input stream, or 42 | /// 0 if the current token source does not track line numbers. 43 | virtual size_t getLine() const = 0; 44 | 45 | /// 46 | /// Get the index into the current line for the current position in the input 47 | /// stream. The first character on a line has position 0. 48 | /// 49 | /// The line number for the current position in the input stream, or 50 | /// (sze_t)-1 if the current token source does not track character positions. 51 | virtual size_t getCharPositionInLine() = 0; 52 | 53 | /// 54 | /// Get the from which this token source is currently 55 | /// providing tokens. 56 | /// 57 | /// The associated with the current position in 58 | /// the input, or {@code null} if no input stream is available for the token 59 | /// source. 60 | virtual CharStream* getInputStream() = 0; 61 | 62 | /// 63 | /// Gets the name of the underlying input source. This method returns a 64 | /// non-null, non-empty string. If such a name is not known, this method 65 | /// returns . 66 | /// 67 | virtual std::string getSourceName() = 0; 68 | 69 | /// 70 | /// Set the this token source should use for creating 71 | /// objects from the input. 72 | /// 73 | /// The to use for creating tokens. 74 | template 75 | void setTokenFactory(TokenFactory * /*factory*/) {} 76 | 77 | /// 78 | /// Gets the this token source is currently using for 79 | /// creating objects from the input. 80 | /// 81 | /// The currently used by this token source. 82 | virtual Ref> getTokenFactory() = 0; 83 | }; 84 | 85 | } // namespace antlr4 86 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 void setText(const std::string &text) = 0; 15 | virtual void setType(size_t ttype) = 0; 16 | virtual void setLine(size_t line) = 0; 17 | virtual void setCharPositionInLine(size_t pos) = 0; 18 | virtual void setChannel(size_t channel) = 0; 19 | virtual void setTokenIndex(size_t index) = 0; 20 | }; 21 | 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/antlr4-common.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 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | // Defines for the Guid class and other platform dependent stuff. 39 | #ifdef _WIN32 40 | #ifdef _MSC_VER 41 | #pragma warning (disable: 4250) // Class inherits by dominance. 42 | #pragma warning (disable: 4512) // assignment operator could not be generated 43 | 44 | #if _MSC_VER < 1900 45 | // Before VS 2015 code like "while (true)" will create a (useless) warning in level 4. 46 | #pragma warning (disable: 4127) // conditional expression is constant 47 | #endif 48 | #endif 49 | 50 | #define GUID_WINDOWS 51 | 52 | #ifdef _WIN64 53 | typedef __int64 ssize_t; 54 | #else 55 | typedef __int32 ssize_t; 56 | #endif 57 | 58 | #if _MSC_VER == 1900 59 | // VS 2015 has a known bug when using std::codecvt_utf8 60 | // so we have to temporarily use __int32 instead. 61 | // https://connect.microsoft.com/VisualStudio/feedback/details/1403302/unresolved-external-when-using-codecvt-utf8 62 | typedef std::basic_string<__int32> i32string; 63 | #endif 64 | 65 | #ifdef ANTLR4CPP_EXPORTS 66 | #define ANTLR4CPP_PUBLIC __declspec(dllexport) 67 | #else 68 | #ifdef ANTLR4CPP_STATIC 69 | #define ANTLR4CPP_PUBLIC 70 | #else 71 | #define ANTLR4CPP_PUBLIC __declspec(dllimport) 72 | #endif 73 | #endif 74 | 75 | #ifdef _MSC_VER 76 | class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015. 77 | #endif 78 | 79 | #elif __APPLE__ 80 | #define GUID_CFUUID 81 | #if __GNUC__ >= 4 82 | #define ANTLR4CPP_PUBLIC __attribute__ ((visibility ("default"))) 83 | #else 84 | #define ANTLR4CPP_PUBLIC 85 | #endif 86 | #else 87 | #define GUID_LIBUUID 88 | #if __GNUC__ >= 6 89 | #define ANTLR4CPP_PUBLIC __attribute__ ((visibility ("default"))) 90 | #else 91 | #define ANTLR4CPP_PUBLIC 92 | #endif 93 | #endif 94 | 95 | #include "support/guid.h" 96 | #include "support/Declarations.h" 97 | 98 | #if !defined(HAS_NOEXCEPT) 99 | #if defined(__clang__) 100 | #if __has_feature(cxx_noexcept) 101 | #define HAS_NOEXCEPT 102 | #endif 103 | #else 104 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \ 105 | defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 106 | #define HAS_NOEXCEPT 107 | #endif 108 | #endif 109 | 110 | #ifdef HAS_NOEXCEPT 111 | #define NOEXCEPT noexcept 112 | #else 113 | #define NOEXCEPT 114 | #endif 115 | #endif 116 | 117 | // We have to undefine this symbol as ANTLR will use this name for own members and even 118 | // generated functions. Because EOF is a global macro we cannot use e.g. a namespace scope to disambiguate. 119 | #ifdef EOF 120 | #undef EOF 121 | #endif 122 | 123 | #define INVALID_INDEX (size_t)-1 124 | template using Ref = std::shared_ptr; 125 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | virtual ~ATNDeserializationOptions() {}; 25 | 26 | static const ATNDeserializationOptions& getDefaultOptions(); 27 | 28 | bool isReadOnly(); 29 | 30 | void makeReadOnly(); 31 | 32 | bool isVerifyATN(); 33 | 34 | void setVerifyATN(bool verify); 35 | 36 | bool isGenerateRuleBypassTransitions(); 37 | 38 | void setGenerateRuleBypassTransitions(bool generate); 39 | 40 | protected: 41 | virtual void throwIfReadOnly(); 42 | 43 | private: 44 | void InitializeInstanceFields(); 45 | }; 46 | 47 | } // namespace atn 48 | } // namespace antlr4 49 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ATNDeserializer.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/LexerAction.h" 9 | #include "atn/ATNDeserializationOptions.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC ATNDeserializer { 15 | public: 16 | static const size_t SERIALIZED_VERSION; 17 | 18 | /// This is the current serialized UUID. 19 | // ml: defined as function to avoid the “static initialization order fiasco”. 20 | static Guid SERIALIZED_UUID(); 21 | 22 | ATNDeserializer(); 23 | ATNDeserializer(const ATNDeserializationOptions& dso); 24 | virtual ~ATNDeserializer() {}; 25 | 26 | static Guid toUUID(const unsigned short *data, size_t offset); 27 | 28 | virtual ATN deserialize(const std::vector &input); 29 | virtual void verifyATN(const ATN &atn); 30 | 31 | static void checkCondition(bool condition); 32 | static void checkCondition(bool condition, const std::string &message); 33 | 34 | static Transition *edgeFactory(const ATN &atn, size_t type, size_t src, size_t trg, size_t arg1, size_t arg2, 35 | size_t arg3, const std::vector &sets); 36 | 37 | static ATNState *stateFactory(size_t type, size_t ruleIndex); 38 | 39 | protected: 40 | /// Determines if a particular serialized representation of an ATN supports 41 | /// a particular feature, identified by the used for serializing 42 | /// the ATN at the time the feature was first introduced. 43 | /// 44 | /// The marking the first time the feature was 45 | /// supported in the serialized ATN. 46 | /// The of the actual serialized ATN which is 47 | /// currently being deserialized. 48 | /// {@code true} if the {@code actualUuid} value represents a 49 | /// serialized ATN at or after the feature identified by {@code feature} was 50 | /// introduced; otherwise, {@code false}. 51 | virtual bool isFeatureSupported(const Guid &feature, const Guid &actualUuid); 52 | void markPrecedenceDecisions(const ATN &atn); 53 | Ref lexerActionFactory(LexerActionType type, int data1, int data2); 54 | 55 | private: 56 | /// This is the earliest supported serialized UUID. 57 | static Guid BASE_SERIALIZED_UUID(); 58 | 59 | /// This UUID indicates an extension of for the 60 | /// addition of precedence predicates. 61 | static Guid ADDED_PRECEDENCE_TRANSITIONS(); 62 | 63 | /** 64 | * This UUID indicates an extension of ADDED_PRECEDENCE_TRANSITIONS 65 | * for the addition of lexer actions encoded as a sequence of 66 | * LexerAction instances. 67 | */ 68 | static Guid ADDED_LEXER_ACTIONS(); 69 | 70 | /** 71 | * This UUID indicates the serialized ATN contains two sets of 72 | * IntervalSets, where the second set's values are encoded as 73 | * 32-bit integers to support the full Unicode SMP range up to U+10FFFF. 74 | */ 75 | static Guid ADDED_UNICODE_SMP(); 76 | 77 | /// This list contains all of the currently supported UUIDs, ordered by when 78 | /// the feature first appeared in this branch. 79 | static std::vector& SUPPORTED_UUIDS(); 80 | 81 | ATNDeserializationOptions deserializationOptions; 82 | }; 83 | 84 | } // namespace atn 85 | } // namespace antlr4 86 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ATNSerializer.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 | namespace antlr4 { 9 | namespace atn { 10 | 11 | class ANTLR4CPP_PUBLIC ATNSerializer { 12 | public: 13 | ATN *atn; 14 | 15 | ATNSerializer(ATN *atn); 16 | ATNSerializer(ATN *atn, const std::vector &tokenNames); 17 | virtual ~ATNSerializer() {}; 18 | 19 | /// 20 | /// Serialize state descriptors, edge descriptors, and decision->state map 21 | /// into list of ints: 22 | /// 23 | /// grammar-type, (ANTLRParser.LEXER, ...) 24 | /// max token type, 25 | /// num states, 26 | /// state-0-type ruleIndex, state-1-type ruleIndex, ... state-i-type 27 | /// ruleIndex optional-arg ... 28 | /// num rules, 29 | /// rule-1-start-state rule-1-args, rule-2-start-state rule-2-args, ... 30 | /// (args are token type,actionIndex in lexer else 0,0) 31 | /// num modes, 32 | /// mode-0-start-state, mode-1-start-state, ... (parser has 0 modes) 33 | /// num sets 34 | /// set-0-interval-count intervals, set-1-interval-count intervals, ... 35 | /// num total edges, 36 | /// src, trg, edge-type, edge arg1, optional edge arg2 (present always), 37 | /// ... 38 | /// num decisions, 39 | /// decision-0-start-state, decision-1-start-state, ... 40 | /// 41 | /// Convenient to pack into unsigned shorts to make as Java string. 42 | /// 43 | virtual std::vector serialize(); 44 | 45 | virtual std::string decode(const std::wstring& data); 46 | virtual std::string getTokenName(size_t t); 47 | 48 | /// Used by Java target to encode short/int array as chars in string. 49 | static std::wstring getSerializedAsString(ATN *atn); 50 | static std::vector getSerialized(ATN *atn); 51 | 52 | static std::string getDecoded(ATN *atn, std::vector &tokenNames); 53 | 54 | private: 55 | std::vector _tokenNames; 56 | 57 | void serializeUUID(std::vector &data, Guid uuid); 58 | }; 59 | 60 | } // namespace atn 61 | } // namespace antlr4 62 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ATNSimulator.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/ATN.h" 9 | #include "misc/IntervalSet.h" 10 | #include "support/CPPUtils.h" 11 | #include "atn/PredictionContext.h" 12 | 13 | namespace antlr4 { 14 | namespace atn { 15 | 16 | class ANTLR4CPP_PUBLIC ATNSimulator { 17 | public: 18 | /// Must distinguish between missing edge and edge we know leads nowhere. 19 | static const Ref ERROR; 20 | const ATN &atn; 21 | 22 | ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache); 23 | virtual ~ATNSimulator() {}; 24 | 25 | virtual void reset() = 0; 26 | 27 | /** 28 | * Clear the DFA cache used by the current instance. Since the DFA cache may 29 | * be shared by multiple ATN simulators, this method may affect the 30 | * performance (but not accuracy) of other parsers which are being used 31 | * concurrently. 32 | * 33 | * @throws UnsupportedOperationException if the current instance does not 34 | * support clearing the DFA. 35 | * 36 | * @since 4.3 37 | */ 38 | virtual void clearDFA(); 39 | virtual PredictionContextCache& getSharedContextCache(); 40 | virtual Ref getCachedContext(Ref const& context); 41 | 42 | /// @deprecated Use instead. 43 | static ATN deserialize(const std::vector &data); 44 | 45 | /// @deprecated Use instead. 46 | static void checkCondition(bool condition); 47 | 48 | /// @deprecated Use instead. 49 | static void checkCondition(bool condition, const std::string &message); 50 | 51 | /// @deprecated Use instead. 52 | static Transition *edgeFactory(const ATN &atn, int type, int src, int trg, int arg1, int arg2, int arg3, 53 | const std::vector &sets); 54 | 55 | /// @deprecated Use instead. 56 | static ATNState *stateFactory(int type, int ruleIndex); 57 | 58 | protected: 59 | static antlrcpp::SingleWriteMultipleReadLock _stateLock; // Lock for DFA states. 60 | static antlrcpp::SingleWriteMultipleReadLock _edgeLock; // Lock for the sparse edge map in DFA states. 61 | 62 | /// 63 | /// The context cache maps all PredictionContext objects that are equals() 64 | /// to a single cached copy. This cache is shared across all contexts 65 | /// in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet 66 | /// to use only cached nodes/graphs in addDFAState(). We don't want to 67 | /// fill this during closure() since there are lots of contexts that 68 | /// pop up but are not used ever again. It also greatly slows down closure(). 69 | ///

70 | /// This cache makes a huge difference in memory and a little bit in speed. 71 | /// For the Java grammar on java.*, it dropped the memory requirements 72 | /// at the end from 25M to 16M. We don't store any of the full context 73 | /// graphs in the DFA because they are limited to local context only, 74 | /// but apparently there's a lot of repetition there as well. We optimize 75 | /// the config contexts before storing the config set in the DFA states 76 | /// by literally rebuilding them with cached subgraphs only. 77 | ///

78 | /// I tried a cache for use during closure operations, that was 79 | /// whacked after each adaptivePredict(). It cost a little bit 80 | /// more time I think and doesn't save on the overall footprint 81 | /// so it's not worth the complexity. 82 | ///

83 | PredictionContextCache &_sharedContextCache; 84 | }; 85 | 86 | } // namespace atn 87 | } // namespace antlr4 88 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | 20 | }; 21 | 22 | } // namespace atn 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/AmbiguityInfo.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/DecisionEventInfo.h" 9 | #include "support/BitSet.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// This class represents profiling event information for an ambiguity. 16 | /// Ambiguities are decisions where a particular input resulted in an SLL 17 | /// conflict, followed by LL prediction also reaching a conflict state 18 | /// (indicating a true ambiguity in the grammar). 19 | /// 20 | /// 21 | /// This event may be reported during SLL prediction in cases where the 22 | /// conflicting SLL configuration set provides sufficient information to 23 | /// determine that the SLL conflict is truly an ambiguity. For example, if none 24 | /// of the ATN configurations in the conflicting SLL configuration set have 25 | /// traversed a global follow transition (i.e. 26 | /// is 0 for all configurations), then 27 | /// the result of SLL prediction for that input is known to be equivalent to the 28 | /// result of LL prediction for that input. 29 | /// 30 | /// 31 | /// In some cases, the minimum represented alternative in the conflicting LL 32 | /// configuration set is not equal to the minimum represented alternative in the 33 | /// conflicting SLL configuration set. Grammars and inputs which result in this 34 | /// scenario are unable to use , which in turn means 35 | /// they cannot use the two-stage parsing strategy to improve parsing performance 36 | /// for that input. 37 | /// 38 | /// 39 | /// 42 | class ANTLR4CPP_PUBLIC AmbiguityInfo : public DecisionEventInfo { 43 | public: 44 | /// The set of alternative numbers for this decision event that lead to a valid parse. 45 | antlrcpp::BitSet ambigAlts; 46 | 47 | /// 48 | /// Constructs a new instance of the class with the 49 | /// specified detailed ambiguity information. 50 | /// 51 | /// The decision number 52 | /// The final configuration set identifying the ambiguous 53 | /// alternatives for the current input 54 | /// The set of alternatives in the decision that lead to a valid parse. 55 | /// The predicted alt is the min(ambigAlts) 56 | /// The input token stream 57 | /// The start index for the current prediction 58 | /// The index at which the ambiguity was identified during 59 | /// prediction 60 | /// {@code true} if the ambiguity was identified during LL 61 | /// prediction; otherwise, {@code false} if the ambiguity was identified 62 | /// during SLL prediction 63 | AmbiguityInfo(size_t decision, ATNConfigSet *configs, const antlrcpp::BitSet &ambigAlts, TokenStream *input, 64 | size_t startIndex, size_t stopIndex, bool fullCtx); 65 | }; 66 | 67 | } // namespace atn 68 | } // namespace antlr4 69 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | /// TO_DO: 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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | BlockEndState *endState = nullptr; 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ContextSensitivityInfo.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/DecisionEventInfo.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// This class represents profiling event information for a context sensitivity. 15 | /// Context sensitivities are decisions where a particular input resulted in an 16 | /// SLL conflict, but LL prediction produced a single unique alternative. 17 | /// 18 | /// 19 | /// In some cases, the unique alternative identified by LL prediction is not 20 | /// equal to the minimum represented alternative in the conflicting SLL 21 | /// configuration set. Grammars and inputs which result in this scenario are 22 | /// unable to use , which in turn means they cannot use 23 | /// the two-stage parsing strategy to improve parsing performance for that 24 | /// input. 25 | /// 26 | /// 27 | /// 30 | class ANTLR4CPP_PUBLIC ContextSensitivityInfo : public DecisionEventInfo { 31 | public: 32 | /// 33 | /// Constructs a new instance of the class 34 | /// with the specified detailed context sensitivity information. 35 | /// 36 | /// The decision number 37 | /// The final configuration set containing the unique 38 | /// alternative identified by full-context prediction 39 | /// The input token stream 40 | /// The start index for the current prediction 41 | /// The index at which the context sensitivity was 42 | /// identified during full-context prediction 43 | ContextSensitivityInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, size_t stopIndex); 44 | }; 45 | 46 | } // namespace atn 47 | } // namespace antlr4 48 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/DecisionEventInfo.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 | /// This is the base class for gathering detailed information about prediction 15 | /// events which occur during parsing. 16 | /// 17 | /// Note that we could record the parser call stack at the time this event 18 | /// occurred but in the presence of left recursive rules, the stack is kind of 19 | /// meaningless. It's better to look at the individual configurations for their 20 | /// individual stacks. Of course that is a object 21 | /// not a parse tree node and so it does not have information about the extent 22 | /// (start...stop) of the various subtrees. Examining the stack tops of all 23 | /// configurations provide the return states for the rule invocations. 24 | /// From there you can get the enclosing rule. 25 | /// 26 | /// @since 4.3 27 | /// 28 | class ANTLR4CPP_PUBLIC DecisionEventInfo { 29 | public: 30 | /// 31 | /// The invoked decision number which this event is related to. 32 | /// 33 | /// 34 | const size_t decision; 35 | 36 | /// 37 | /// The configuration set containing additional information relevant to the 38 | /// prediction state when the current event occurred, or {@code null} if no 39 | /// additional information is relevant or available. 40 | /// 41 | const ATNConfigSet *configs; 42 | 43 | /// 44 | /// The input token stream which is being parsed. 45 | /// 46 | const TokenStream *input; 47 | 48 | /// 49 | /// The token index in the input stream at which the current prediction was 50 | /// originally invoked. 51 | /// 52 | const size_t startIndex; 53 | 54 | /// 55 | /// The token index in the input stream at which the current event occurred. 56 | /// 57 | const size_t stopIndex; 58 | 59 | /// 60 | /// {@code true} if the current event occurred during LL prediction; 61 | /// otherwise, {@code false} if the input occurred during SLL prediction. 62 | /// 63 | const bool fullCtx; 64 | 65 | DecisionEventInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, 66 | size_t stopIndex, bool fullCtx); 67 | }; 68 | 69 | } // namespace atn 70 | } // namespace antlr4 71 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ErrorInfo.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/DecisionEventInfo.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// This class represents profiling event information for a syntax error 15 | /// identified during prediction. Syntax errors occur when the prediction 16 | /// algorithm is unable to identify an alternative which would lead to a 17 | /// successful parse. 18 | /// 19 | /// 20 | /// 23 | class ANTLR4CPP_PUBLIC ErrorInfo : public DecisionEventInfo { 24 | public: 25 | /// 26 | /// Constructs a new instance of the class with the 27 | /// specified detailed syntax error information. 28 | /// 29 | /// The decision number 30 | /// The final configuration set reached during prediction 31 | /// prior to reaching the state 32 | /// The input token stream 33 | /// The start index for the current prediction 34 | /// The index at which the syntax error was identified 35 | /// {@code true} if the syntax error was identified during LL 36 | /// prediction; otherwise, {@code false} if the syntax error was identified 37 | /// during SLL prediction 38 | ErrorInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, size_t stopIndex, 39 | bool fullCtx); 40 | }; 41 | 42 | } // namespace atn 43 | } // namespace antlr4 44 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerAction.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/LexerActionType.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// Represents a single action which can be executed following the successful 15 | /// match of a lexer rule. Lexer actions are used for both embedded action syntax 16 | /// and ANTLR 4's new lexer command syntax. 17 | /// 18 | /// @author Sam Harwell 19 | /// @since 4.2 20 | /// 21 | class ANTLR4CPP_PUBLIC LexerAction { 22 | public: 23 | virtual ~LexerAction() {}; 24 | 25 | /// 26 | /// Gets the serialization type of the lexer action. 27 | /// 28 | /// The serialization type of the lexer action. 29 | virtual LexerActionType getActionType() const = 0; 30 | 31 | /// 32 | /// Gets whether the lexer action is position-dependent. Position-dependent 33 | /// actions may have different semantics depending on the 34 | /// index at the time the action is executed. 35 | /// 36 | /// Many lexer commands, including {@code type}, {@code skip}, and 37 | /// {@code more}, do not check the input index during their execution. 38 | /// Actions like this are position-independent, and may be stored more 39 | /// efficiently as part of the . 40 | /// 41 | /// {@code true} if the lexer action semantics can be affected by the 42 | /// position of the input at the time it is executed; 43 | /// otherwise, {@code false}. 44 | virtual bool isPositionDependent() const = 0; 45 | 46 | /// 47 | /// Execute the lexer action in the context of the specified . 48 | /// 49 | /// For position-dependent actions, the input stream must already be 50 | /// positioned correctly prior to calling this method. 51 | /// 52 | /// The lexer instance. 53 | virtual void execute(Lexer *lexer) = 0; 54 | 55 | virtual size_t hashCode() const = 0; 56 | virtual bool operator == (const LexerAction &obj) const = 0; 57 | virtual bool operator != (const LexerAction &obj) const { 58 | return !(*this == obj); 59 | } 60 | 61 | virtual std::string toString() const = 0; 62 | }; 63 | 64 | } // namespace atn 65 | } // namespace antlr4 66 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | namespace antlr4 { 9 | namespace atn { 10 | 11 | /// 12 | /// Represents the serialization type of a . 13 | /// 14 | /// @author Sam Harwell 15 | /// @since 4.2 16 | /// 17 | enum class ANTLR4CPP_PUBLIC LexerActionType : size_t { 18 | /// 19 | /// The type of a action. 20 | /// 21 | CHANNEL, 22 | /// 23 | /// The type of a action. 24 | /// 25 | CUSTOM, 26 | /// 27 | /// The type of a action. 28 | /// 29 | MODE, 30 | /// 31 | /// The type of a action. 32 | /// 33 | MORE, 34 | /// 35 | /// The type of a action. 36 | /// 37 | POP_MODE, 38 | /// 39 | /// The type of a action. 40 | /// 41 | PUSH_MODE, 42 | /// 43 | /// The type of a action. 44 | /// 45 | SKIP, 46 | /// 47 | /// The type of a action. 48 | /// 49 | TYPE, 50 | }; 51 | 52 | } // namespace atn 53 | } // namespace antlr4 54 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerChannelAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | using antlr4::Lexer; 15 | 16 | /// 17 | /// Implements the {@code channel} lexer action by calling 18 | /// with the assigned channel. 19 | /// 20 | /// @author Sam Harwell 21 | /// @since 4.2 22 | /// 23 | class ANTLR4CPP_PUBLIC LexerChannelAction final : public LexerAction { 24 | public: 25 | /// 26 | /// Constructs a new {@code channel} action with the specified channel value. 27 | /// The channel value to pass to . 28 | LexerChannelAction(int channel); 29 | 30 | /// 31 | /// Gets the channel to use for the created by the lexer. 32 | /// 33 | /// The channel to use for the created by the lexer. 34 | int getChannel() const; 35 | 36 | /// 37 | /// {@inheritDoc} 38 | /// This method returns . 39 | virtual LexerActionType getActionType() const override; 40 | 41 | /// 42 | /// {@inheritDoc} 43 | /// This method returns {@code false}. 44 | virtual bool isPositionDependent() const override; 45 | 46 | /// 47 | /// {@inheritDoc} 48 | /// 49 | /// This action is implemented by calling with the 50 | /// value provided by . 51 | /// 52 | virtual void execute(Lexer *lexer) override; 53 | 54 | virtual size_t hashCode() const override; 55 | virtual bool operator == (const LexerAction &obj) const override; 56 | virtual std::string toString() const override; 57 | 58 | private: 59 | const int _channel; 60 | }; 61 | 62 | } // namespace atn 63 | } // namespace antlr4 64 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerCustomAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Executes a custom lexer action by calling with the 16 | /// rule and action indexes assigned to the custom action. The implementation of 17 | /// a custom action is added to the generated code for the lexer in an override 18 | /// of when the grammar is compiled. 19 | /// 20 | /// This class may represent embedded actions created with the {...} 21 | /// syntax in ANTLR 4, as well as actions created for lexer commands where the 22 | /// command argument could not be evaluated when the grammar was compiled. 23 | /// 24 | /// @author Sam Harwell 25 | /// @since 4.2 26 | /// 27 | class ANTLR4CPP_PUBLIC LexerCustomAction final : public LexerAction { 28 | public: 29 | /// 30 | /// Constructs a custom lexer action with the specified rule and action 31 | /// indexes. 32 | /// 33 | /// The rule index to use for calls to 34 | /// . 35 | /// The action index to use for calls to 36 | /// . 37 | LexerCustomAction(size_t ruleIndex, size_t actionIndex); 38 | 39 | /// 40 | /// Gets the rule index to use for calls to . 41 | /// 42 | /// The rule index for the custom action. 43 | size_t getRuleIndex() const; 44 | 45 | /// 46 | /// Gets the action index to use for calls to . 47 | /// 48 | /// The action index for the custom action. 49 | size_t getActionIndex() const; 50 | 51 | /// 52 | /// {@inheritDoc} 53 | /// 54 | /// This method returns . 55 | virtual LexerActionType getActionType() const override; 56 | 57 | /// 58 | /// Gets whether the lexer action is position-dependent. Position-dependent 59 | /// actions may have different semantics depending on the 60 | /// index at the time the action is executed. 61 | /// 62 | /// Custom actions are position-dependent since they may represent a 63 | /// user-defined embedded action which makes calls to methods like 64 | /// . 65 | /// 66 | /// This method returns {@code true}. 67 | virtual bool isPositionDependent() const override; 68 | 69 | /// 70 | /// {@inheritDoc} 71 | /// 72 | /// Custom actions are implemented by calling with the 73 | /// appropriate rule and action indexes. 74 | /// 75 | virtual void execute(Lexer *lexer) override; 76 | 77 | virtual size_t hashCode() const override; 78 | virtual bool operator == (const LexerAction &obj) const override; 79 | virtual std::string toString() const override; 80 | 81 | private: 82 | const size_t _ruleIndex; 83 | const size_t _actionIndex; 84 | }; 85 | 86 | } // namespace atn 87 | } // namespace antlr4 88 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerIndexedCustomAction.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 "RuleContext.h" 9 | #include "atn/LexerAction.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// This implementation of is used for tracking input offsets 16 | /// for position-dependent actions within a . 17 | /// 18 | /// This action is not serialized as part of the ATN, and is only required for 19 | /// position-dependent lexer actions which appear at a location other than the 20 | /// end of a rule. For more information about DFA optimizations employed for 21 | /// lexer actions, see and 22 | /// . 23 | /// 24 | /// @author Sam Harwell 25 | /// @since 4.2 26 | /// 27 | class ANTLR4CPP_PUBLIC LexerIndexedCustomAction final : public LexerAction { 28 | public: 29 | /// 30 | /// Constructs a new indexed custom action by associating a character offset 31 | /// with a . 32 | /// 33 | /// Note: This class is only required for lexer actions for which 34 | /// returns {@code true}. 35 | /// 36 | /// The offset into the input , relative to 37 | /// the token start index, at which the specified lexer action should be 38 | /// executed. 39 | /// The lexer action to execute at a particular offset in the 40 | /// input . 41 | LexerIndexedCustomAction(int offset, Ref const& action); 42 | 43 | /// 44 | /// Gets the location in the input at which the lexer 45 | /// action should be executed. The value is interpreted as an offset relative 46 | /// to the token start index. 47 | /// 48 | /// The location in the input at which the lexer 49 | /// action should be executed. 50 | int getOffset() const; 51 | 52 | /// 53 | /// Gets the lexer action to execute. 54 | /// 55 | /// A object which executes the lexer action. 56 | Ref getAction() const; 57 | 58 | /// 59 | /// {@inheritDoc} 60 | /// 61 | /// This method returns the result of calling 62 | /// on the returned by . 63 | virtual LexerActionType getActionType() const override; 64 | 65 | /// 66 | /// {@inheritDoc} 67 | /// This method returns {@code true}. 68 | virtual bool isPositionDependent() const override; 69 | 70 | virtual void execute(Lexer *lexer) override; 71 | virtual size_t hashCode() const override; 72 | virtual bool operator == (const LexerAction &obj) const override; 73 | virtual std::string toString() const override; 74 | 75 | private: 76 | const int _offset; 77 | const Ref _action; 78 | }; 79 | 80 | } // namespace atn 81 | } // namespace antlr4 82 | 83 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerModeAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Implements the {@code mode} lexer action by calling with 16 | /// the assigned mode. 17 | /// 18 | /// @author Sam Harwell 19 | /// @since 4.2 20 | /// 21 | class ANTLR4CPP_PUBLIC LexerModeAction final : public LexerAction { 22 | public: 23 | /// 24 | /// Constructs a new {@code mode} action with the specified mode value. 25 | /// The mode value to pass to . 26 | LexerModeAction(int mode); 27 | 28 | /// 29 | /// Get the lexer mode this action should transition the lexer to. 30 | /// 31 | /// The lexer mode for this {@code mode} command. 32 | int getMode(); 33 | 34 | /// 35 | /// {@inheritDoc} 36 | /// This method returns . 37 | virtual LexerActionType getActionType() const override; 38 | 39 | /// 40 | /// {@inheritDoc} 41 | /// This method returns {@code false}. 42 | virtual bool isPositionDependent() const override; 43 | 44 | /// 45 | /// {@inheritDoc} 46 | /// 47 | /// This action is implemented by calling with the 48 | /// value provided by . 49 | /// 50 | virtual void execute(Lexer *lexer) override; 51 | 52 | virtual size_t hashCode() const override; 53 | virtual bool operator == (const LexerAction &obj) const override; 54 | virtual std::string toString() const override; 55 | 56 | private: 57 | const int _mode; 58 | }; 59 | 60 | } // namespace atn 61 | } // namespace antlr4 62 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerMoreAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Implements the {@code more} lexer action by calling . 16 | /// 17 | /// The {@code more} command does not have any parameters, so this action is 18 | /// implemented as a singleton instance exposed by . 19 | /// 20 | /// @author Sam Harwell 21 | /// @since 4.2 22 | /// 23 | class ANTLR4CPP_PUBLIC LexerMoreAction final : public LexerAction { 24 | public: 25 | /// 26 | /// Provides a singleton instance of this parameterless lexer action. 27 | /// 28 | static const Ref getInstance(); 29 | 30 | /// 31 | /// {@inheritDoc} 32 | /// This method returns . 33 | virtual LexerActionType getActionType() const override; 34 | 35 | /// 36 | /// {@inheritDoc} 37 | /// This method returns {@code false}. 38 | virtual bool isPositionDependent() const override; 39 | 40 | /// 41 | /// {@inheritDoc} 42 | /// 43 | /// This action is implemented by calling . 44 | /// 45 | virtual void execute(Lexer *lexer) override; 46 | 47 | virtual size_t hashCode() const override; 48 | virtual bool operator == (const LexerAction &obj) const override; 49 | virtual std::string toString() const override; 50 | 51 | private: 52 | /// Constructs the singleton instance of the lexer {@code more} command. 53 | LexerMoreAction(); 54 | }; 55 | 56 | } // namespace atn 57 | } // namespace antlr4 58 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerPopModeAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Implements the {@code popMode} lexer action by calling . 16 | /// 17 | /// The {@code popMode} command does not have any parameters, so this action is 18 | /// implemented as a singleton instance exposed by . 19 | /// 20 | /// @author Sam Harwell 21 | /// @since 4.2 22 | /// 23 | class ANTLR4CPP_PUBLIC LexerPopModeAction final : public LexerAction { 24 | public: 25 | /// 26 | /// Provides a singleton instance of this parameterless lexer action. 27 | /// 28 | static const Ref getInstance(); 29 | 30 | /// 31 | /// {@inheritDoc} 32 | /// This method returns . 33 | virtual LexerActionType getActionType() const override; 34 | 35 | /// 36 | /// {@inheritDoc} 37 | /// This method returns {@code false}. 38 | virtual bool isPositionDependent() const override; 39 | 40 | /// 41 | /// {@inheritDoc} 42 | /// 43 | /// This action is implemented by calling . 44 | /// 45 | virtual void execute(Lexer *lexer) override; 46 | 47 | virtual size_t hashCode() const override; 48 | virtual bool operator == (const LexerAction &obj) const override; 49 | virtual std::string toString() const override; 50 | 51 | private: 52 | /// Constructs the singleton instance of the lexer {@code popMode} command. 53 | LexerPopModeAction(); 54 | }; 55 | 56 | } // namespace atn 57 | } // namespace antlr4 58 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerPushModeAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Implements the {@code pushMode} lexer action by calling 16 | /// with the assigned mode. 17 | /// 18 | /// @author Sam Harwell 19 | /// @since 4.2 20 | /// 21 | class ANTLR4CPP_PUBLIC LexerPushModeAction final : public LexerAction { 22 | public: 23 | /// 24 | /// Constructs a new {@code pushMode} action with the specified mode value. 25 | /// The mode value to pass to . 26 | LexerPushModeAction(int mode); 27 | 28 | /// 29 | /// Get the lexer mode this action should transition the lexer to. 30 | /// 31 | /// The lexer mode for this {@code pushMode} command. 32 | int getMode() const; 33 | 34 | /// 35 | /// {@inheritDoc} 36 | /// This method returns . 37 | virtual LexerActionType getActionType() const override; 38 | 39 | /// 40 | /// {@inheritDoc} 41 | /// This method returns {@code false}. 42 | virtual bool isPositionDependent() const override; 43 | 44 | /// 45 | /// {@inheritDoc} 46 | /// 47 | /// This action is implemented by calling with the 48 | /// value provided by . 49 | /// 50 | virtual void execute(Lexer *lexer) override; 51 | 52 | virtual size_t hashCode() const override; 53 | virtual bool operator == (const LexerAction &obj) const override; 54 | virtual std::string toString() const override; 55 | 56 | private: 57 | const int _mode; 58 | }; 59 | 60 | } // namespace atn 61 | } // namespace antlr4 62 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerSkipAction.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/LexerAction.h" 9 | #include "atn/LexerActionType.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// 15 | /// Implements the {@code skip} lexer action by calling . 16 | /// 17 | /// The {@code skip} command does not have any parameters, so this action is 18 | /// implemented as a singleton instance exposed by . 19 | /// 20 | /// @author Sam Harwell 21 | /// @since 4.2 22 | /// 23 | class ANTLR4CPP_PUBLIC LexerSkipAction final : public LexerAction { 24 | public: 25 | /// Provides a singleton instance of this parameterless lexer action. 26 | static const Ref getInstance(); 27 | 28 | /// 29 | /// {@inheritDoc} 30 | /// This method returns . 31 | virtual LexerActionType getActionType() const override; 32 | 33 | /// 34 | /// {@inheritDoc} 35 | /// This method returns {@code false}. 36 | virtual bool isPositionDependent() const override; 37 | 38 | /// 39 | /// {@inheritDoc} 40 | /// 41 | /// This action is implemented by calling . 42 | /// 43 | virtual void execute(Lexer *lexer) override; 44 | 45 | virtual size_t hashCode() const override; 46 | virtual bool operator == (const LexerAction &obj) const override; 47 | virtual std::string toString() const override; 48 | 49 | private: 50 | /// Constructs the singleton instance of the lexer {@code skip} command. 51 | LexerSkipAction(); 52 | }; 53 | 54 | } // namespace atn 55 | } // namespace antlr4 56 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LexerTypeAction.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/LexerActionType.h" 9 | #include "atn/LexerAction.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | /// Implements the {@code type} lexer action by calling 15 | /// with the assigned type. 16 | class ANTLR4CPP_PUBLIC LexerTypeAction : public LexerAction { 17 | public: 18 | /// 19 | /// Constructs a new {@code type} action with the specified token type value. 20 | /// The type to assign to the token using . 21 | LexerTypeAction(int type); 22 | 23 | /// 24 | /// Gets the type to assign to a token created by the lexer. 25 | /// The type to assign to a token created by the lexer. 26 | virtual int getType() const; 27 | 28 | /// 29 | /// {@inheritDoc} 30 | /// This method returns . 31 | virtual LexerActionType getActionType() const override; 32 | 33 | /// 34 | /// {@inheritDoc} 35 | /// This method returns {@code false}. 36 | virtual bool isPositionDependent() const override; 37 | 38 | /// 39 | /// {@inheritDoc} 40 | /// 41 | /// This action is implemented by calling with the 42 | /// value provided by . 43 | /// 44 | virtual void execute(Lexer *lexer) override; 45 | 46 | virtual size_t hashCode() const override; 47 | virtual bool operator == (const LexerAction &obj) const override; 48 | virtual std::string toString() const override; 49 | 50 | private: 51 | const int _type; 52 | }; 53 | 54 | } // namespace atn 55 | } // namespace antlr4 56 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/LookaheadEventInfo.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/DecisionEventInfo.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// This class represents profiling event information for tracking the lookahead 14 | /// depth required in order to make a prediction. 15 | class ANTLR4CPP_PUBLIC LookaheadEventInfo : public DecisionEventInfo { 16 | public: 17 | /// The alternative chosen by adaptivePredict(), not necessarily 18 | /// the outermost alt shown for a rule; left-recursive rules have 19 | /// user-level alts that differ from the rewritten rule with a (...) block 20 | /// and a (..)* loop. 21 | size_t predictedAlt = 0; 22 | 23 | /// 24 | /// Constructs a new instance of the class with 25 | /// the specified detailed lookahead information. 26 | /// 27 | /// The decision number 28 | /// The final configuration set containing the necessary 29 | /// information to determine the result of a prediction, or {@code null} if 30 | /// the final configuration set is not available 31 | /// The input token stream 32 | /// The start index for the current prediction 33 | /// The index at which the prediction was finally made 34 | /// {@code true} if the current lookahead is part of an LL 35 | /// prediction; otherwise, {@code false} if the current lookahead is part of 36 | /// an SLL prediction 37 | LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt, TokenStream *input, size_t startIndex, 38 | size_t stopIndex, bool fullCtx); 39 | }; 40 | 41 | } // namespace atn 42 | } // namespace antlr4 43 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ParseInfo.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/DecisionInfo.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ProfilingATNSimulator; 14 | 15 | /// This class provides access to specific and aggregate statistics gathered 16 | /// during profiling of a parser. 17 | class ANTLR4CPP_PUBLIC ParseInfo { 18 | public: 19 | ParseInfo(ProfilingATNSimulator *atnSimulator); 20 | virtual ~ParseInfo() {}; 21 | 22 | /// 23 | /// Gets an array of instances containing the profiling 24 | /// information gathered for each decision in the ATN. 25 | /// 26 | /// An array of instances, indexed by decision 27 | /// number. 28 | virtual std::vector getDecisionInfo(); 29 | 30 | /// 31 | /// Gets the decision numbers for decisions that required one or more 32 | /// full-context predictions during parsing. These are decisions for which 33 | /// is non-zero. 34 | /// 35 | /// A list of decision numbers which required one or more 36 | /// full-context predictions during parsing. 37 | virtual std::vector getLLDecisions(); 38 | 39 | /// 40 | /// Gets the total time spent during prediction across all decisions made 41 | /// during parsing. This value is the sum of 42 | /// for all decisions. 43 | /// 44 | virtual long long getTotalTimeInPrediction(); 45 | 46 | /// 47 | /// Gets the total number of SLL lookahead operations across all decisions 48 | /// made during parsing. This value is the sum of 49 | /// for all decisions. 50 | /// 51 | virtual long long getTotalSLLLookaheadOps(); 52 | 53 | /// 54 | /// Gets the total number of LL lookahead operations across all decisions 55 | /// made during parsing. This value is the sum of 56 | /// for all decisions. 57 | /// 58 | virtual long long getTotalLLLookaheadOps(); 59 | 60 | /// 61 | /// Gets the total number of ATN lookahead operations for SLL prediction 62 | /// across all decisions made during parsing. 63 | /// 64 | virtual long long getTotalSLLATNLookaheadOps(); 65 | 66 | /// 67 | /// Gets the total number of ATN lookahead operations for LL prediction 68 | /// across all decisions made during parsing. 69 | /// 70 | virtual long long getTotalLLATNLookaheadOps(); 71 | 72 | /// 73 | /// Gets the total number of ATN lookahead operations for SLL and LL 74 | /// prediction across all decisions made during parsing. 75 | /// 76 | /// 77 | /// This value is the sum of and 78 | /// . 79 | /// 80 | virtual long long getTotalATNLookaheadOps(); 81 | 82 | /// 83 | /// Gets the total number of DFA states stored in the DFA cache for all 84 | /// decisions in the ATN. 85 | /// 86 | virtual size_t getDFASize(); 87 | 88 | /// 89 | /// Gets the total number of DFA states stored in the DFA cache for a 90 | /// particular decision. 91 | /// 92 | virtual size_t getDFASize(size_t decision); 93 | 94 | protected: 95 | const ProfilingATNSimulator *_atnSimulator; // non-owning, we are created by this simulator. 96 | }; 97 | 98 | } // namespace atn 99 | } // namespace antlr4 100 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/PredicateEvalInfo.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/DecisionEventInfo.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// This class represents profiling event information for semantic predicate 15 | /// evaluations which occur during prediction. 16 | /// 17 | /// 20 | class ANTLR4CPP_PUBLIC PredicateEvalInfo : public DecisionEventInfo { 21 | public: 22 | /// The semantic context which was evaluated. 23 | const Ref semctx; 24 | 25 | /// 26 | /// The alternative number for the decision which is guarded by the semantic 27 | /// context . Note that other ATN 28 | /// configurations may predict the same alternative which are guarded by 29 | /// other semantic contexts and/or . 30 | /// 31 | const size_t predictedAlt; 32 | 33 | /// The result of evaluating the semantic context . 34 | const bool evalResult; 35 | 36 | /// 37 | /// Constructs a new instance of the class with the 38 | /// specified detailed predicate evaluation information. 39 | /// 40 | /// The decision number 41 | /// The input token stream 42 | /// The start index for the current prediction 43 | /// The index at which the predicate evaluation was 44 | /// triggered. Note that the input stream may be reset to other positions for 45 | /// the actual evaluation of individual predicates. 46 | /// The semantic context which was evaluated 47 | /// The results of evaluating the semantic context 48 | /// The alternative number for the decision which is 49 | /// guarded by the semantic context {@code semctx}. See 50 | /// for more information. 51 | /// {@code true} if the semantic context was 52 | /// evaluated during LL prediction; otherwise, {@code false} if the semantic 53 | /// context was evaluated during SLL prediction 54 | /// 55 | /// 56 | /// 57 | PredicateEvalInfo(size_t decision, TokenStream *input, size_t startIndex, size_t stopIndex, 58 | Ref const& semctx, bool evalResult, size_t predictedAlt, bool fullCtx); 59 | }; 60 | 61 | } // namespace atn 62 | } // namespace antlr4 63 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | /// TO_DO: 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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/ProfilingATNSimulator.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/ParserATNSimulator.h" 9 | #include "atn/DecisionInfo.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC ProfilingATNSimulator : public ParserATNSimulator { 15 | public: 16 | ProfilingATNSimulator(Parser *parser); 17 | 18 | virtual size_t adaptivePredict(TokenStream *input, size_t decision, ParserRuleContext *outerContext) override; 19 | 20 | virtual std::vector getDecisionInfo() const; 21 | virtual dfa::DFAState* getCurrentState() const; 22 | 23 | protected: 24 | std::vector _decisions; 25 | 26 | int _sllStopIndex = 0; 27 | int _llStopIndex = 0; 28 | 29 | size_t _currentDecision = 0; 30 | dfa::DFAState *_currentState; 31 | 32 | /// 33 | /// At the point of LL failover, we record how SLL would resolve the conflict so that 34 | /// we can determine whether or not a decision / input pair is context-sensitive. 35 | /// If LL gives a different result than SLL's predicted alternative, we have a 36 | /// context sensitivity for sure. The converse is not necessarily true, however. 37 | /// It's possible that after conflict resolution chooses minimum alternatives, 38 | /// SLL could get the same answer as LL. Regardless of whether or not the result indicates 39 | /// an ambiguity, it is not treated as a context sensitivity because LL prediction 40 | /// was not required in order to produce a correct prediction for this decision and input sequence. 41 | /// It may in fact still be a context sensitivity but we don't know by looking at the 42 | /// minimum alternatives for the current input. 43 | /// 44 | size_t conflictingAltResolvedBySLL = 0; 45 | 46 | virtual dfa::DFAState* getExistingTargetState(dfa::DFAState *previousD, size_t t) override; 47 | virtual dfa::DFAState* computeTargetState(dfa::DFA &dfa, dfa::DFAState *previousD, size_t t) override; 48 | virtual std::unique_ptr computeReachSet(ATNConfigSet *closure, size_t t, bool fullCtx) override; 49 | virtual bool evalSemanticContext(Ref const& pred, ParserRuleContext *parserCallStack, 50 | size_t alt, bool fullCtx) override; 51 | virtual void reportAttemptingFullContext(dfa::DFA &dfa, const antlrcpp::BitSet &conflictingAlts, ATNConfigSet *configs, 52 | size_t startIndex, size_t stopIndex) override; 53 | virtual void reportContextSensitivity(dfa::DFA &dfa, size_t prediction, ATNConfigSet *configs, 54 | size_t startIndex, size_t stopIndex) override; 55 | virtual void reportAmbiguity(dfa::DFA &dfa, dfa::DFAState *D, size_t startIndex, size_t stopIndex, bool exact, 56 | const antlrcpp::BitSet &ambigAlts, ATNConfigSet *configs) override; 57 | }; 58 | 59 | } // namespace atn 60 | } // namespace antlr4 61 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | 29 | virtual SerializationType getSerializationType() const override; 30 | 31 | virtual bool isEpsilon() const override; 32 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 33 | 34 | virtual std::string toString() const override; 35 | }; 36 | 37 | } // namespace atn 38 | } // namespace antlr4 39 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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(); 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/atn/Transition.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 "misc/IntervalSet.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// An ATN transition between any two ATN states. Subclasses define 15 | /// atom, set, epsilon, action, predicate, rule transitions. 16 | ///

17 | /// This is a one way link. It emanates from a state (usually via a list of 18 | /// transitions) and has a target state. 19 | ///

20 | /// Since we never have to change the ATN transitions once we construct it, 21 | /// we can fix these transitions as specific classes. The DFA transitions 22 | /// on the other hand need to update the labels as it adds transitions to 23 | /// the states. We'll use the term Edge for the DFA to distinguish them from 24 | /// ATN transitions. 25 | ///

26 | class ANTLR4CPP_PUBLIC Transition { 27 | public: 28 | // constants for serialization 29 | enum SerializationType { 30 | EPSILON = 1, 31 | RANGE = 2, 32 | RULE = 3, 33 | PREDICATE = 4, // e.g., {isType(input.LT(1))}? 34 | ATOM = 5, 35 | ACTION = 6, 36 | SET = 7, // ~(A|B) or ~atom, wildcard, which convert to next 2 37 | NOT_SET = 8, 38 | WILDCARD = 9, 39 | PRECEDENCE = 10, 40 | }; 41 | 42 | static const std::vector serializationNames; 43 | 44 | /// The target of this transition. 45 | // ml: this is a reference into the ATN. 46 | ATNState *target; 47 | 48 | virtual ~Transition() {}; 49 | 50 | protected: 51 | Transition(ATNState *target); 52 | 53 | public: 54 | virtual SerializationType getSerializationType() const = 0; 55 | 56 | /** 57 | * Determines if the transition is an "epsilon" transition. 58 | * 59 | *

The default implementation returns {@code false}.

60 | * 61 | * @return {@code true} if traversing this transition in the ATN does not 62 | * consume an input symbol; otherwise, {@code false} if traversing this 63 | * transition consumes (matches) an input symbol. 64 | */ 65 | virtual bool isEpsilon() const; 66 | virtual misc::IntervalSet label() const; 67 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const = 0; 68 | 69 | virtual std::string toString() const; 70 | }; 71 | 72 | } // namespace atn 73 | } // namespace antlr4 74 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/dfa/DFA.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/DFAState.h" 9 | 10 | namespace antlrcpp { 11 | class SingleWriteMultipleReadLock; 12 | } 13 | 14 | namespace antlr4 { 15 | namespace dfa { 16 | 17 | class ANTLR4CPP_PUBLIC DFA { 18 | public: 19 | /// A set of all DFA states. Use a map so we can get old state back. 20 | /// Set only allows you to see if it's there. 21 | 22 | /// From which ATN state did we create this DFA? 23 | atn::DecisionState *const atnStartState; 24 | std::unordered_set states; // States are owned by this class. 25 | DFAState *s0; 26 | const size_t decision; 27 | 28 | DFA(atn::DecisionState *atnStartState); 29 | DFA(atn::DecisionState *atnStartState, size_t decision); 30 | DFA(const DFA &other) = delete; 31 | DFA(DFA &&other); 32 | virtual ~DFA(); 33 | 34 | /** 35 | * Gets whether this DFA is a precedence DFA. Precedence DFAs use a special 36 | * start state {@link #s0} which is not stored in {@link #states}. The 37 | * {@link DFAState#edges} array for this start state contains outgoing edges 38 | * supplying individual start states corresponding to specific precedence 39 | * values. 40 | * 41 | * @return {@code true} if this is a precedence DFA; otherwise, 42 | * {@code false}. 43 | * @see Parser#getPrecedence() 44 | */ 45 | bool isPrecedenceDfa() const; 46 | 47 | /** 48 | * Get the start state for a specific precedence value. 49 | * 50 | * @param precedence The current precedence. 51 | * @return The start state corresponding to the specified precedence, or 52 | * {@code null} if no start state exists for the specified precedence. 53 | * 54 | * @throws IllegalStateException if this is not a precedence DFA. 55 | * @see #isPrecedenceDfa() 56 | */ 57 | DFAState* getPrecedenceStartState(int precedence) const; 58 | 59 | /** 60 | * Set the start state for a specific precedence value. 61 | * 62 | * @param precedence The current precedence. 63 | * @param startState The start state corresponding to the specified 64 | * precedence. 65 | * 66 | * @throws IllegalStateException if this is not a precedence DFA. 67 | * @see #isPrecedenceDfa() 68 | */ 69 | void setPrecedenceStartState(int precedence, DFAState *startState, antlrcpp::SingleWriteMultipleReadLock &lock); 70 | 71 | /// Return a list of all states in this DFA, ordered by state number. 72 | virtual std::vector getStates() const; 73 | 74 | /** 75 | * @deprecated Use {@link #toString(Vocabulary)} instead. 76 | */ 77 | virtual std::string toString(const std::vector& tokenNames); 78 | std::string toString(const Vocabulary &vocabulary) const; 79 | 80 | virtual std::string toLexerString(); 81 | 82 | private: 83 | /** 84 | * {@code true} if this DFA is for a precedence decision; otherwise, 85 | * {@code false}. This is the backing field for {@link #isPrecedenceDfa}. 86 | */ 87 | bool _precedenceDfa; 88 | DFAState *_s0Shadow = nullptr; // ml: assigned when we created s0 ourselves. 89 | }; 90 | 91 | } // namespace atn 92 | } // namespace antlr4 93 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/misc/Interval.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 | // Helpers to convert certain unsigned symbols (e.g. Token::EOF) to their original numeric value (e.g. -1) 14 | // and vice versa. This is needed mostly for intervals to keep their original order and for toString() 15 | // methods to print the original numeric value (e.g. for tests). 16 | size_t numericToSymbol(ssize_t v); 17 | ssize_t symbolToNumeric(size_t v); 18 | 19 | /// An immutable inclusive interval a..b 20 | class ANTLR4CPP_PUBLIC Interval { 21 | public: 22 | static const Interval INVALID; 23 | 24 | // Must stay signed to guarantee the correct sort order. 25 | ssize_t a; 26 | ssize_t b; 27 | 28 | Interval(); 29 | explicit Interval(size_t a_, size_t b_); // For unsigned -> signed mappings. 30 | Interval(ssize_t a_, ssize_t b_); 31 | virtual ~Interval() {}; 32 | 33 | /// return number of elements between a and b inclusively. x..x is length 1. 34 | /// if b < a, then length is 0. 9..10 has length 2. 35 | virtual size_t length() const; 36 | 37 | bool operator == (const Interval &other) const; 38 | 39 | virtual size_t hashCode() const; 40 | 41 | /// 42 | /// Does this start completely before other? Disjoint 43 | virtual bool startsBeforeDisjoint(const Interval &other) const; 44 | 45 | /// 46 | /// Does this start at or before other? Nondisjoint 47 | virtual bool startsBeforeNonDisjoint(const Interval &other) const; 48 | 49 | /// 50 | /// Does this.a start after other.b? May or may not be disjoint 51 | virtual bool startsAfter(const Interval &other) const; 52 | 53 | /// 54 | /// Does this start completely after other? Disjoint 55 | virtual bool startsAfterDisjoint(const Interval &other) const; 56 | 57 | /// 58 | /// Does this start after other? NonDisjoint 59 | virtual bool startsAfterNonDisjoint(const Interval &other) const; 60 | 61 | /// 62 | /// Are both ranges disjoint? I.e., no overlap? 63 | virtual bool disjoint(const Interval &other) const; 64 | 65 | /// 66 | /// Are two intervals adjacent such as 0..41 and 42..42? 67 | virtual bool adjacent(const Interval &other) const; 68 | 69 | virtual bool properlyContains(const Interval &other) const; 70 | 71 | /// 72 | /// Return the interval computed from combining this and other 73 | virtual Interval Union(const Interval &other) const; 74 | 75 | /// 76 | /// Return the interval in common between this and o 77 | virtual Interval intersection(const Interval &other) const; 78 | 79 | virtual std::string toString() const; 80 | 81 | private: 82 | }; 83 | 84 | } // namespace atn 85 | } // namespace antlr4 86 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/misc/MurmurHash.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 MurmurHash { 14 | 15 | private: 16 | static const size_t DEFAULT_SEED = 0; 17 | 18 | /// Initialize the hash using the default seed value. 19 | /// Returns the intermediate hash value. 20 | public: 21 | static size_t initialize(); 22 | 23 | /// Initialize the hash using the specified seed. 24 | static size_t initialize(size_t seed); 25 | 26 | /// Update the intermediate hash value for the next input {@code value}. 27 | /// the intermediate hash value 28 | /// the value to add to the current hash 29 | /// Returns the updated intermediate hash value. 30 | static size_t update(size_t hash, size_t value); 31 | 32 | /** 33 | * Update the intermediate hash value for the next input {@code value}. 34 | * 35 | * @param hash the intermediate hash value 36 | * @param value the value to add to the current hash 37 | * @return the updated intermediate hash value 38 | */ 39 | template 40 | static size_t update(size_t hash, Ref const& value) { 41 | return update(hash, value != nullptr ? value->hashCode() : 0); 42 | } 43 | 44 | template 45 | static size_t update(size_t hash, T *value) { 46 | return update(hash, value != nullptr ? value->hashCode() : 0); 47 | } 48 | 49 | /// 50 | /// Apply the final computation steps to the intermediate value {@code hash} 51 | /// to form the final result of the MurmurHash 3 hash function. 52 | /// 53 | /// the intermediate hash value 54 | /// the number of calls to update() before calling finish() 55 | /// the final hash result 56 | static size_t finish(size_t hash, size_t entryCount); 57 | 58 | /// Utility function to compute the hash code of an array using the MurmurHash3 algorithm. 59 | /// 60 | /// @param the array element type 61 | /// the array data 62 | /// the seed for the MurmurHash algorithm 63 | /// the hash code of the data 64 | template // where T is C array type 65 | static size_t hashCode(const std::vector> &data, size_t seed) { 66 | size_t hash = initialize(seed); 67 | for (auto entry : data) { 68 | hash = update(hash, entry->hashCode()); 69 | } 70 | 71 | return finish(hash, data.size()); 72 | } 73 | }; 74 | 75 | } // namespace atn 76 | } // namespace antlr4 77 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | namespace antlr4 { 9 | namespace misc { 10 | 11 | class ANTLR4CPP_PUBLIC Predicate { 12 | public: 13 | virtual ~Predicate() {}; 14 | 15 | virtual bool test(tree::ParseTree *t) = 0; 16 | }; 17 | 18 | } // namespace tree 19 | } // namespace antlr4 20 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/Any.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 | // A standard C++ class loosely modeled after boost::Any. 7 | 8 | #pragma once 9 | 10 | #include "antlr4-common.h" 11 | 12 | #ifdef _MSC_VER 13 | #pragma warning(push) 14 | #pragma warning(disable: 4521) // 'antlrcpp::Any': multiple copy constructors specified 15 | #endif 16 | 17 | namespace antlrcpp { 18 | 19 | template 20 | using StorageType = typename std::decay::type; 21 | 22 | struct Any 23 | { 24 | bool isNull() const { return _ptr == nullptr; } 25 | bool isNotNull() const { return _ptr != nullptr; } 26 | 27 | Any() : _ptr(nullptr) { 28 | } 29 | 30 | Any(Any& that) : _ptr(that.clone()) { 31 | } 32 | 33 | Any(Any&& that) : _ptr(that._ptr) { 34 | that._ptr = nullptr; 35 | } 36 | 37 | Any(const Any& that) : _ptr(that.clone()) { 38 | } 39 | 40 | Any(const Any&& that) : _ptr(that.clone()) { 41 | } 42 | 43 | template 44 | Any(U&& value) : _ptr(new Derived>(std::forward(value))) { 45 | } 46 | 47 | template 48 | bool is() const { 49 | typedef StorageType T; 50 | 51 | auto derived = dynamic_cast *>(_ptr); 52 | 53 | return derived != nullptr; 54 | } 55 | 56 | template 57 | StorageType& as() { 58 | typedef StorageType T; 59 | 60 | auto derived = dynamic_cast*>(_ptr); 61 | 62 | if (!derived) 63 | throw std::bad_cast(); 64 | 65 | return derived->value; 66 | } 67 | 68 | template 69 | operator U() { 70 | return as>(); 71 | } 72 | 73 | Any& operator = (const Any& a) { 74 | if (_ptr == a._ptr) 75 | return *this; 76 | 77 | auto old_ptr = _ptr; 78 | _ptr = a.clone(); 79 | 80 | if (old_ptr) 81 | delete old_ptr; 82 | 83 | return *this; 84 | } 85 | 86 | Any& operator = (Any&& a) { 87 | if (_ptr == a._ptr) 88 | return *this; 89 | 90 | std::swap(_ptr, a._ptr); 91 | 92 | return *this; 93 | } 94 | 95 | virtual ~Any() { 96 | delete _ptr; 97 | } 98 | 99 | virtual bool equals(Any other) const { 100 | return _ptr == other._ptr; 101 | } 102 | 103 | private: 104 | struct Base { 105 | virtual ~Base() { } 106 | virtual Base* clone() const = 0; 107 | }; 108 | 109 | template 110 | struct Derived : Base 111 | { 112 | template Derived(U&& value_) : value(std::forward(value_)) { 113 | } 114 | 115 | T value; 116 | 117 | Base* clone() const { 118 | return new Derived(value); 119 | } 120 | 121 | }; 122 | 123 | Base* clone() const 124 | { 125 | if (_ptr) 126 | return _ptr->clone(); 127 | else 128 | return nullptr; 129 | } 130 | 131 | Base *_ptr; 132 | 133 | }; 134 | 135 | template<> inline 136 | Any::Any(std::nullptr_t&& ) : _ptr(nullptr) { 137 | } 138 | 139 | 140 | } // namespace antlrcpp 141 | 142 | #ifdef _MSC_VER 143 | #pragma warning(pop) 144 | #endif 145 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/Arrays.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 antlrcpp { 11 | 12 | class ANTLR4CPP_PUBLIC Arrays { 13 | public: 14 | 15 | static std::string listToString(const std::vector &list, const std::string &separator); 16 | 17 | template 18 | static bool equals(const std::vector &a, const std::vector &b) { 19 | if (a.size() != b.size()) 20 | return false; 21 | 22 | for (size_t i = 0; i < a.size(); ++i) 23 | if (!(a[i] == b[i])) 24 | return false; 25 | 26 | return true; 27 | } 28 | 29 | template 30 | static bool equals(const std::vector &a, const std::vector &b) { 31 | if (a.size() != b.size()) 32 | return false; 33 | 34 | for (size_t i = 0; i < a.size(); ++i) { 35 | if (a[i] == b[i]) 36 | continue; 37 | if (!(*a[i] == *b[i])) 38 | return false; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | template 45 | static bool equals(const std::vector> &a, const std::vector> &b) { 46 | if (a.size() != b.size()) 47 | return false; 48 | 49 | for (size_t i = 0; i < a.size(); ++i) { 50 | if (!a[i] && !b[i]) 51 | continue; 52 | if (!a[i] || !b[i]) 53 | return false; 54 | if (a[i] == b[i]) 55 | continue; 56 | 57 | if (!(*a[i] == *b[i])) 58 | return false; 59 | } 60 | 61 | return true; 62 | } 63 | 64 | template 65 | static std::string toString(const std::vector &source) { 66 | std::string result = "["; 67 | bool firstEntry = true; 68 | for (auto &value : source) { 69 | result += value.toString(); 70 | if (firstEntry) { 71 | result += ", "; 72 | firstEntry = false; 73 | } 74 | } 75 | return result + "]"; 76 | } 77 | 78 | template 79 | static std::string toString(const std::vector> &source) { 80 | std::string result = "["; 81 | bool firstEntry = true; 82 | for (auto &value : source) { 83 | result += value->toString(); 84 | if (firstEntry) { 85 | result += ", "; 86 | firstEntry = false; 87 | } 88 | } 89 | return result + "]"; 90 | } 91 | 92 | template 93 | static std::string toString(const std::vector &source) { 94 | std::string result = "["; 95 | bool firstEntry = true; 96 | for (auto value : source) { 97 | result += value->toString(); 98 | if (firstEntry) { 99 | result += ", "; 100 | firstEntry = false; 101 | } 102 | } 103 | return result + "]"; 104 | } 105 | 106 | }; 107 | 108 | template <> 109 | std::string Arrays::toString(const std::vector &source); 110 | } 111 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/BitSet.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 antlrcpp { 11 | 12 | class ANTLR4CPP_PUBLIC BitSet : public std::bitset<1024> { 13 | public: 14 | size_t nextSetBit(size_t pos) const { 15 | for (size_t i = pos; i < size(); i++){ 16 | if (test(i)) { 17 | return i; 18 | } 19 | } 20 | 21 | return INVALID_INDEX; 22 | } 23 | 24 | // Prints a list of every index for which the bitset contains a bit in true. 25 | friend std::wostream& operator << (std::wostream& os, const BitSet& obj) 26 | { 27 | os << "{"; 28 | size_t total = obj.count(); 29 | for (size_t i = 0; i < obj.size(); i++){ 30 | if (obj.test(i)){ 31 | os << i; 32 | --total; 33 | if (total > 1){ 34 | os << ", "; 35 | } 36 | } 37 | } 38 | 39 | os << "}"; 40 | return os; 41 | } 42 | 43 | static std::string subStringRepresentation(const std::vector::iterator &begin, 44 | const std::vector::iterator &end) { 45 | std::string result; 46 | std::vector::iterator vectorIterator; 47 | 48 | for (vectorIterator = begin; vectorIterator != end; vectorIterator++) { 49 | result += vectorIterator->toString(); 50 | } 51 | // Grab the end 52 | result += end->toString(); 53 | 54 | return result; 55 | } 56 | 57 | std::string toString(){ 58 | std::stringstream stream; 59 | stream << "{"; 60 | bool valueAdded = false; 61 | for (size_t i = 0; i < size(); ++i){ 62 | if (test(i)){ 63 | if (valueAdded) { 64 | stream << ", "; 65 | } 66 | stream << i; 67 | valueAdded = true; 68 | } 69 | } 70 | 71 | stream << "}"; 72 | return stream.str(); 73 | } 74 | 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/CPPUtils.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 antlrcpp { 11 | 12 | std::string join(std::vector strings, const std::string &separator); 13 | std::map toMap(const std::vector &keys); 14 | std::string escapeWhitespace(std::string str, bool escapeSpaces); 15 | std::string toHexString(const int t); 16 | std::string arrayToString(const std::vector &data); 17 | std::string replaceString(const std::string &s, const std::string &from, const std::string &to); 18 | std::vector split(const std::string &s, const std::string &sep, int count); 19 | std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true); 20 | 21 | // Using RAII + a lambda to implement a "finally" replacement. 22 | struct FinalAction { 23 | FinalAction(std::function f) : _cleanUp { f } {} 24 | FinalAction(FinalAction &&other) { 25 | _cleanUp = other._cleanUp; 26 | _enabled = other._enabled; 27 | other._enabled = false; // Don't trigger the lambda after ownership has moved. 28 | } 29 | ~FinalAction() { if (_enabled) _cleanUp(); } 30 | 31 | void disable() { _enabled = false; }; 32 | private: 33 | std::function _cleanUp; 34 | bool _enabled {true}; 35 | }; 36 | 37 | ANTLR4CPP_PUBLIC FinalAction finally(std::function f); 38 | 39 | // Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places. 40 | template 41 | inline bool is(T2 *obj) { // For pointer types. 42 | return dynamic_cast::type>(obj) != nullptr; 43 | } 44 | 45 | template 46 | inline bool is(Ref const& obj) { // For shared pointers. 47 | return dynamic_cast(obj.get()) != nullptr; 48 | } 49 | 50 | template 51 | std::string toString(const T &o) { 52 | std::stringstream ss; 53 | // typeid gives the mangled class name, but that's all what's possible 54 | // in a portable way. 55 | ss << typeid(o).name() << "@" << std::hex << (size_t)&o; 56 | return ss.str(); 57 | } 58 | 59 | // Get the error text from an exception pointer or the current exception. 60 | std::string what(std::exception_ptr eptr = std::current_exception()); 61 | 62 | class SingleWriteMultipleReadLock { 63 | public: 64 | void readLock(); 65 | void readUnlock(); 66 | void writeLock(); 67 | void writeUnlock(); 68 | 69 | private: 70 | std::condition_variable _readerGate; 71 | std::condition_variable _writerGate; 72 | 73 | std::mutex _mutex; 74 | size_t _activeReaders = 0; 75 | size_t _waitingWriters = 0; 76 | size_t _activeWriters = 0; 77 | }; 78 | 79 | } // namespace antlrcpp 80 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/StringUtils.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 antlrcpp { 11 | // For all conversions utf8 <-> utf32. 12 | // VS 2015 has a bug in std::codecvt_utf8 (VS 2013 works fine). 13 | #if defined(_MSC_VER) && _MSC_VER == 1900 14 | static std::wstring_convert, __int32> utfConverter; 15 | #else 16 | static std::wstring_convert, char32_t> utfConverter; 17 | #endif 18 | 19 | void replaceAll(std::string& str, const std::string& from, const std::string& to); 20 | 21 | // string <-> wstring conversion (UTF-16), e.g. for use with Window's wide APIs. 22 | ANTLR4CPP_PUBLIC std::string ws2s(const std::wstring &wstr); 23 | ANTLR4CPP_PUBLIC std::wstring s2ws(const std::string &str); 24 | } 25 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/support/guid.h: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2014 Graeme Hill (http://graemehill.ca) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef GUID_ANDROID 34 | #include 35 | #endif 36 | 37 | // Class to represent a GUID/UUID. Each instance acts as a wrapper around a 38 | // 16 byte value that can be passed around by value. It also supports 39 | // conversion to string (via the stream operator <<) and conversion from a 40 | // string via constructor. 41 | class Guid 42 | { 43 | public: 44 | 45 | // create a guid from vector of bytes 46 | Guid(const std::vector &bytes); 47 | 48 | // create a guid from array of bytes 49 | Guid(const unsigned char *bytes); 50 | 51 | // Create a guid from array of words. 52 | Guid(const uint16_t *bytes, bool reverse); 53 | 54 | // create a guid from string 55 | Guid(const std::string &fromString); 56 | 57 | // create empty guid 58 | Guid(); 59 | 60 | // copy constructor 61 | Guid(const Guid &other); 62 | 63 | // overload assignment operator 64 | Guid &operator=(const Guid &other); 65 | 66 | // overload equality and inequality operator 67 | bool operator==(const Guid &other) const; 68 | bool operator!=(const Guid &other) const; 69 | 70 | const std::string toString() const; 71 | std::vector::const_iterator begin() { return _bytes.begin(); }; 72 | std::vector::const_iterator end() { return _bytes.end(); }; 73 | std::vector::const_reverse_iterator rbegin() { return _bytes.rbegin(); }; 74 | std::vector::const_reverse_iterator rend() { return _bytes.rend(); }; 75 | 76 | 77 | private: 78 | 79 | // actual data 80 | std::vector _bytes; 81 | 82 | // make the << operator a friend so it can access _bytes 83 | friend std::ostream &operator<<(std::ostream &s, const Guid &guid); 84 | }; 85 | 86 | // Class that can create new guids. The only reason this exists instead of 87 | // just a global "newGuid" function is because some platforms will require 88 | // that there is some attached context. In the case of android, we need to 89 | // know what JNIEnv is being used to call back to Java, but the newGuid() 90 | // function would no longer be cross-platform if we parameterized the android 91 | // version. Instead, construction of the GuidGenerator may be different on 92 | // each platform, but the use of newGuid is uniform. 93 | class GuidGenerator 94 | { 95 | public: 96 | #ifdef GUID_ANDROID 97 | GuidGenerator(JNIEnv *env); 98 | #else 99 | GuidGenerator() { } 100 | #endif 101 | 102 | Guid newGuid(); 103 | 104 | #ifdef GUID_ANDROID 105 | private: 106 | JNIEnv *_env; 107 | jclass _uuidClass; 108 | jmethodID _newGuidMethod; 109 | jmethodID _mostSignificantBitsMethod; 110 | jmethodID _leastSignificantBitsMethod; 111 | #endif 112 | }; 113 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | }; 15 | 16 | } // namespace tree 17 | } // namespace antlr4 18 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | 28 | virtual antlrcpp::Any accept(ParseTreeVisitor *visitor) override; 29 | }; 30 | 31 | } // namespace tree 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/IterativeParseTreeWalker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD license"] 3 | * Copyright (c) 2012 Terence Parr 4 | * Copyright (c) 2012 Sam Harwell 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. The name of the author may not be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include "antlr4-common.h" 34 | 35 | #include "tree/ParseTreeWalker.h" 36 | 37 | namespace antlr4 { 38 | namespace tree { 39 | 40 | class ParseTreeListener; 41 | 42 | /** 43 | * An iterative (read: non-recursive) pre-order and post-order tree walker that 44 | * doesn't use the thread stack but heap-based stacks. Makes it possible to 45 | * process deeply nested parse trees. 46 | */ 47 | class ANTLR4CPP_PUBLIC IterativeParseTreeWalker : public ParseTreeWalker { 48 | public: 49 | virtual void walk(ParseTreeListener *listener, ParseTree *t) const override; 50 | }; 51 | 52 | } // namespace tree 53 | } // namespace antlr4 54 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 V get(ParseTree *node) { 33 | return _annotations[node]; 34 | } 35 | virtual void put(ParseTree *node, V value) { 36 | _annotations[node] = value; 37 | } 38 | virtual V removeFrom(ParseTree *node) { 39 | auto value = _annotations[node]; 40 | _annotations.erase(node); 41 | return value; 42 | } 43 | 44 | protected: 45 | std::map _annotations; 46 | }; 47 | 48 | } // namespace tree 49 | } // namespace antlr4 50 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/ParseTreeVisitor.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 "support/Any.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | /// 14 | /// This interface defines the basic notion of a parse tree visitor. Generated 15 | /// visitors implement this interface and the {@code XVisitor} interface for 16 | /// grammar {@code X}. 17 | /// 18 | /// @param The return type of the visit operation. Use for 19 | /// operations with no return type. 20 | // ml: no template parameter here, to avoid the need for virtual template functions. Instead we have our Any class. 21 | class ANTLR4CPP_PUBLIC ParseTreeVisitor { 22 | public: 23 | virtual ~ParseTreeVisitor() {} 24 | 25 | /// 26 | /// Visit a parse tree, and return a user-defined result of the operation. 27 | /// 28 | /// The to visit. 29 | /// The result of visiting the parse tree. 30 | virtual antlrcpp::Any visit(ParseTree *tree) = 0; 31 | 32 | /// 33 | /// Visit the children of a node, and return a user-defined result of the 34 | /// operation. 35 | /// 36 | /// The whose children should be visited. 37 | /// The result of visiting the children of the node. 38 | virtual antlrcpp::Any visitChildren(ParseTree *node) = 0; 39 | 40 | /// 41 | /// Visit a terminal node, and return a user-defined result of the operation. 42 | /// 43 | /// The to visit. 44 | /// The result of visiting the node. 45 | virtual antlrcpp::Any visitTerminal(TerminalNode *node) = 0; 46 | 47 | /// 48 | /// Visit an error node, and return a user-defined result of the operation. 49 | /// 50 | /// The to visit. 51 | /// The result of visiting the node. 52 | virtual antlrcpp::Any visitErrorNode(ErrorNode *node) = 0; 53 | 54 | }; 55 | 56 | } // namespace tree 57 | } // namespace antlr4 58 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | virtual Token* getSymbol() = 0; 16 | 17 | /** Set the parent for this leaf node. 18 | * 19 | * Technically, this is not backward compatible as it changes 20 | * the interface but no one was able to create custom 21 | * TerminalNodes anyway so I'm adding as it improves internal 22 | * code quality. 23 | * 24 | * @since 4.7 25 | */ 26 | virtual void setParent(RuleContext *parent) = 0; 27 | }; 28 | 29 | } // namespace tree 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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) override; 27 | virtual std::string toString() override; 28 | virtual std::string toStringTree() override; 29 | 30 | }; 31 | 32 | } // namespace tree 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/Trees.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 | #include "ParserRuleContext.h" 10 | #include "Recognizer.h" 11 | 12 | namespace antlr4 { 13 | namespace tree { 14 | 15 | /// A set of utility routines useful for all kinds of ANTLR trees. 16 | class ANTLR4CPP_PUBLIC Trees { 17 | public: 18 | /// Print out a whole tree in LISP form. getNodeText is used on the 19 | /// node payloads to get the text for the nodes. Detect 20 | /// parse trees and extract data appropriately. 21 | static std::string toStringTree(ParseTree *t); 22 | 23 | /// Print out a whole tree in LISP form. getNodeText is used on the 24 | /// node payloads to get the text for the nodes. Detect 25 | /// parse trees and extract data appropriately. 26 | static std::string toStringTree(ParseTree *t, Parser *recog); 27 | 28 | /// Print out a whole tree in LISP form. getNodeText is used on the 29 | /// node payloads to get the text for the nodes. Detect 30 | /// parse trees and extract data appropriately. 31 | static std::string toStringTree(ParseTree *t, const std::vector &ruleNames); 32 | static std::string getNodeText(ParseTree *t, Parser *recog); 33 | static std::string getNodeText(ParseTree *t, const std::vector &ruleNames); 34 | 35 | /// Return a list of all ancestors of this node. The first node of 36 | /// list is the root and the last is the parent of this node. 37 | static std::vector getAncestors(ParseTree *t); 38 | 39 | /** Return true if t is u's parent or a node on path to root from u. 40 | * Use == not equals(). 41 | * 42 | * @since 4.5.1 43 | */ 44 | static bool isAncestorOf(ParseTree *t, ParseTree *u); 45 | static std::vector findAllTokenNodes(ParseTree *t, size_t ttype); 46 | static std::vector findAllRuleNodes(ParseTree *t, size_t ruleIndex); 47 | static std::vector findAllNodes(ParseTree *t, size_t index, bool findTokens); 48 | 49 | /** Get all descendents; includes t itself. 50 | * 51 | * @since 4.5.1 52 | */ 53 | static std::vector getDescendants(ParseTree *t); 54 | 55 | /** @deprecated */ 56 | static std::vector descendants(ParseTree *t); 57 | 58 | /** Find smallest subtree of t enclosing range startTokenIndex..stopTokenIndex 59 | * inclusively using postorder traversal. Recursive depth-first-search. 60 | * 61 | * @since 4.5.1 62 | */ 63 | static ParserRuleContext* getRootOfSubtreeEnclosingRegion(ParseTree *t, 64 | size_t startTokenIndex, // inclusive 65 | size_t stopTokenIndex); // inclusive 66 | 67 | /** Return first node satisfying the pred 68 | * 69 | * @since 4.5.1 70 | */ 71 | static ParseTree* findNodeSuchThat(ParseTree *t, Ref const& pred); 72 | 73 | private: 74 | Trees(); 75 | }; 76 | 77 | } // namespace tree 78 | } // namespace antlr4 79 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | namespace antlr4 { 9 | namespace tree { 10 | namespace pattern { 11 | 12 | /// 13 | /// A chunk is either a token tag, a rule tag, or a span of literal text within a 14 | /// tree pattern. 15 | ///

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

23 | class ANTLR4CPP_PUBLIC Chunk { 24 | public: 25 | virtual ~Chunk() {}; 26 | 27 | /// This method returns a text representation of the tag chunk. Labeled tags 28 | /// are returned in the form {@code label:tag}, and unlabeled tags are 29 | /// returned as just the tag name. 30 | virtual std::string toString() { 31 | std::string str; 32 | return str; 33 | } 34 | }; 35 | 36 | } // namespace pattern 37 | } // namespace tree 38 | } // namespace antlr4 39 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/pattern/TagChunk.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 placeholder tag in a tree pattern. A tag can have any of the 16 | /// following forms. 17 | /// 18 | ///
    19 | ///
  • {@code expr}: An unlabeled placeholder for a parser rule {@code expr}.
  • 20 | ///
  • {@code ID}: An unlabeled placeholder for a token of type {@code ID}.
  • 21 | ///
  • {@code e:expr}: A labeled placeholder for a parser rule {@code expr}.
  • 22 | ///
  • {@code id:ID}: A labeled placeholder for a token of type {@code ID}.
  • 23 | ///
24 | /// 25 | /// This class does not perform any validation on the tag or label names aside 26 | /// from ensuring that the tag is a non-null, non-empty string. 27 | ///
28 | class ANTLR4CPP_PUBLIC TagChunk : public Chunk { 29 | public: 30 | /// 31 | /// Construct a new instance of using the specified tag and 32 | /// no label. 33 | /// 34 | /// The tag, which should be the name of a parser rule or token 35 | /// type. 36 | /// 37 | /// if {@code tag} is {@code null} or 38 | /// empty. 39 | TagChunk(const std::string &tag); 40 | virtual ~TagChunk() {}; 41 | 42 | /// 43 | /// Construct a new instance of using the specified label 44 | /// and tag. 45 | /// 46 | /// The label for the tag. If this is {@code null}, the 47 | /// represents an unlabeled tag. 48 | /// The tag, which should be the name of a parser rule or token 49 | /// type. 50 | /// 51 | /// if {@code tag} is {@code null} or 52 | /// empty. 53 | TagChunk(const std::string &label, const std::string &tag); 54 | 55 | /// 56 | /// Get the tag for this chunk. 57 | /// 58 | /// The tag for the chunk. 59 | std::string getTag(); 60 | 61 | /// 62 | /// Get the label, if any, assigned to this chunk. 63 | /// 64 | /// The label assigned to this chunk, or {@code null} if no label is 65 | /// assigned to the chunk. 66 | std::string getLabel(); 67 | 68 | /// 69 | /// This method returns a text representation of the tag chunk. Labeled tags 70 | /// are returned in the form {@code label:tag}, and unlabeled tags are 71 | /// returned as just the tag name. 72 | /// 73 | virtual std::string toString(); 74 | 75 | private: 76 | /// This is the backing field for . 77 | const std::string _tag; 78 | /// 79 | /// This is the backing field for . 80 | /// 81 | const std::string _label; 82 | }; 83 | 84 | } // namespace pattern 85 | } // namespace tree 86 | } // namespace antlr4 87 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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(); 47 | }; 48 | 49 | } // namespace pattern 50 | } // namespace tree 51 | } // namespace antlr4 52 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/pattern/TokenTagToken.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 "CommonToken.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace pattern { 13 | 14 | /// 15 | /// A object representing a token of a particular type; e.g., 16 | /// {@code }. These tokens are created for chunks where the 17 | /// tag corresponds to a lexer rule or token type. 18 | /// 19 | class ANTLR4CPP_PUBLIC TokenTagToken : public CommonToken { 20 | /// 21 | /// This is the backing field for . 22 | /// 23 | private: 24 | const std::string tokenName; 25 | /// 26 | /// This is the backing field for . 27 | /// 28 | const std::string label; 29 | 30 | /// 31 | /// Constructs a new instance of for an unlabeled tag 32 | /// with the specified token name and type. 33 | /// 34 | /// The token name. 35 | /// The token type. 36 | public: 37 | TokenTagToken(const std::string &tokenName, int type); //this(tokenName, type, nullptr); 38 | 39 | /// 40 | /// Constructs a new instance of with the specified 41 | /// token name, type, and label. 42 | /// 43 | /// The token name. 44 | /// The token type. 45 | /// The label associated with the token tag, or {@code null} if 46 | /// the token tag is unlabeled. 47 | TokenTagToken(const std::string &tokenName, int type, const std::string &label); 48 | 49 | /// 50 | /// Gets the token name. 51 | /// The token name. 52 | std::string getTokenName() const; 53 | 54 | /// 55 | /// Gets the label associated with the rule tag. 56 | /// 57 | /// The name of the label associated with the rule tag, or 58 | /// {@code null} if this is an unlabeled rule tag. 59 | std::string getLabel() const; 60 | 61 | /// 62 | /// {@inheritDoc} 63 | ///

64 | /// The implementation for returns the token tag 65 | /// formatted with {@code <} and {@code >} delimiters. 66 | ///

67 | virtual std::string getText() const override; 68 | 69 | /// 70 | /// {@inheritDoc} 71 | ///

72 | /// The implementation for returns a string of the form 73 | /// {@code tokenName:type}. 74 | ///

75 | virtual std::string toString() const override; 76 | }; 77 | 78 | } // namespace pattern 79 | } // namespace tree 80 | } // namespace antlr4 81 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/xpath/XPath.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 xpath { 13 | 14 | /// Represent a subset of XPath XML path syntax for use in identifying nodes in 15 | /// parse trees. 16 | /// 17 | /// 18 | /// Split path into words and separators {@code /} and {@code //} via ANTLR 19 | /// itself then walk path elements from left to right. At each separator-word 20 | /// pair, find set of nodes. Next stage uses those as work list. 21 | /// 22 | /// 23 | /// The basic interface is 24 | /// {@code (tree, pathString, parser)}. 25 | /// But that is just shorthand for: 26 | /// 27 | ///
28 |   ///  p = new (parser, pathString);
29 |   /// return p.(tree);
30 |   /// 
31 | /// 32 | /// 33 | /// See {@code org.antlr.v4.test.TestXPath} for descriptions. In short, this 34 | /// allows operators: 35 | /// 36 | ///
37 | ///
/
root
38 | ///
//
anywhere
39 | ///
!
invert; this must appear directly after root or anywhere 40 | /// operator
41 | ///
42 | /// 43 | /// 44 | /// and path elements: 45 | /// 46 | ///
47 | ///
ID
token name
48 | ///
'string'
any string literal token from the grammar
49 | ///
expr
rule name
50 | ///
*
wildcard matching any node
51 | ///
52 | /// 53 | /// 54 | /// Whitespace is not allowed. 55 | 56 | class ANTLR4CPP_PUBLIC XPath { 57 | public: 58 | static const std::string WILDCARD; // word not operator/separator 59 | static const std::string NOT; // word for invert operator 60 | 61 | XPath(Parser *parser, const std::string &path); 62 | virtual ~XPath() {} 63 | 64 | // TO_DO: check for invalid token/rule names, bad syntax 65 | virtual std::vector split(const std::string &path); 66 | 67 | /// Return a list of all nodes starting at {@code t} as root that satisfy the 68 | /// path. The root {@code /} is relative to the node passed to 69 | /// . 70 | virtual std::vector evaluate(ParseTree *t); 71 | 72 | protected: 73 | std::string _path; 74 | std::vector _elements; 75 | Parser *_parser; 76 | 77 | /// Convert word like {@code *} or {@code ID} or {@code expr} to a path 78 | /// element. {@code anywhere} is {@code true} if {@code //} precedes the 79 | /// word. 80 | virtual XPathElement getXPathElement(Token *wordToken, bool anywhere); 81 | }; 82 | 83 | } // namespace xpath 84 | } // namespace tree 85 | } // namespace antlr4 86 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | virtual ~XPathElement() {} 22 | 23 | /// Given tree rooted at {@code t} return all nodes matched by this path 24 | /// element. 25 | virtual std::vector evaluate(ParseTree *t); 26 | virtual std::string toString() const; 27 | 28 | void setInvert(bool value); 29 | 30 | protected: 31 | std::string _nodeName; 32 | bool _invert = false; 33 | }; 34 | 35 | } // namespace xpath 36 | } // namespace tree 37 | } // namespace antlr4 38 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/tree/xpath/XPathLexer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "antlr4-runtime.h" 5 | 6 | 7 | 8 | 9 | class XPathLexer : public antlr4::Lexer { 10 | public: 11 | enum { 12 | TOKEN_REF = 1, RULE_REF = 2, ANYWHERE = 3, ROOT = 4, WILDCARD = 5, BANG = 6, 13 | ID = 7, STRING = 8 14 | }; 15 | 16 | XPathLexer(antlr4::CharStream *input); 17 | ~XPathLexer(); 18 | 19 | virtual std::string getGrammarFileName() const override; 20 | virtual const std::vector& getRuleNames() const override; 21 | 22 | virtual const std::vector& getChannelNames() const override; 23 | virtual const std::vector& getModeNames() const override; 24 | virtual const std::vector& getTokenNames() const override; // deprecated, use vocabulary instead 25 | virtual antlr4::dfa::Vocabulary& getVocabulary() const override; 26 | 27 | virtual const std::vector getSerializedATN() const override; 28 | virtual const antlr4::atn::ATN& getATN() const override; 29 | 30 | virtual void action(antlr4::RuleContext *context, size_t ruleIndex, size_t actionIndex) override; 31 | private: 32 | static std::vector _decisionToDFA; 33 | static antlr4::atn::PredictionContextCache _sharedContextCache; 34 | static std::vector _ruleNames; 35 | static std::vector _tokenNames; 36 | static std::vector _channelNames; 37 | static std::vector _modeNames; 38 | 39 | static std::vector _literalNames; 40 | static std::vector _symbolicNames; 41 | static antlr4::dfa::Vocabulary _vocabulary; 42 | static antlr4::atn::ATN _atn; 43 | static std::vector _serializedATN; 44 | 45 | 46 | // Individual action functions triggered by action() above. 47 | void IDAction(antlr4::RuleContext *context, size_t actionIndex); 48 | 49 | // Individual semantic predicate functions triggered by sempred() above. 50 | 51 | struct Initializer { 52 | Initializer(); 53 | }; 54 | static Initializer _init; 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/antlr4-runtime/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 | -------------------------------------------------------------------------------- /runtime-osx/lib/libantlr4-runtime.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teverett/antlr4-cpp-example/a43d0910caaef189a08602fb529718a1fcc5ec9c/runtime-osx/lib/libantlr4-runtime.a -------------------------------------------------------------------------------- /runtime-osx/lib/libantlr4-runtime.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teverett/antlr4-cpp-example/a43d0910caaef189a08602fb529718a1fcc5ec9c/runtime-osx/lib/libantlr4-runtime.dylib --------------------------------------------------------------------------------