From: Patrick Schönberger
Date: Wed, 28 Jul 2021 07:07:53 +0000 (+0200)
Subject: Initial commit
X-Git-Url: https://gitweb.ps.run/toc/commitdiff_plain/45409c781a9e35df68c43b1e2f028d30bf90c0a0
Initial commit
---
45409c781a9e35df68c43b1e2f028d30bf90c0a0
diff --git a/Toc.g4 b/Toc.g4
new file mode 100644
index 0000000..95c9a0d
--- /dev/null
+++ b/Toc.g4
@@ -0,0 +1,96 @@
+grammar Toc;
+
+prog: (decl)+ EOF;
+
+decl: varDecl
+ | funcDecl
+ | structDecl
+ ;
+
+varDecl: 'var' var;
+var: varName (':' type) ('=' expr)?;
+
+type: typeName;
+
+
+funcDecl: 'func' func;
+func: funcName '(' parameter ')' (':' type) body;
+parameter: (firstParameter (additionalParameter)*)?;
+firstParameter: var;
+additionalParameter: ',' var;
+
+body: '{' stmt* '}';
+
+
+structDecl: 'struct' structName '{' structMember* '}';
+structMember: structVar | structMethod;
+structVar: var;
+structMethod: func;
+
+
+stmt: (varDecl
+ | conditional
+ | loop
+ | assignment
+ | returnStmt
+ | expr) ;
+
+conditional: ifCond;
+ifCond: 'if' expr body;
+
+loop: whileLoop;
+whileLoop: 'while' expr body;
+
+assignment: identifier '=' expr;
+
+returnStmt: 'return' expr;
+
+expr: funcCall
+ | literal
+ | identifier
+ | subscript
+ | memberAccess
+ | parenExpr
+ | operatorExpr;
+
+nonOpExpr: funcCall
+ | literal
+ | identifier
+ | subscript
+ | memberAccess
+ | parenExpr;
+
+nonSubscriptExpr: funcCall
+ | identifier
+ | memberAccess
+ | parenExpr;
+
+funcCall: funcName '(' (expr (',' expr)*)? ')';
+
+operatorExpr: binaryOperator;
+binaryOperator: nonOpExpr BINARY_OPERATOR nonOpExpr (BINARY_OPERATOR nonOpExpr)*;
+
+identifier: varName;
+
+literal: INTLIT;
+
+subscript: nonSubscriptExpr '[' expr ']';
+
+memberAccess: identifier '.' identifier;
+
+parenExpr: '(' expr ')';
+
+funcName: NAME;
+varName: NAME;
+typeName: NAME;
+structName: NAME;
+
+
+BINARY_OPERATOR:
+ '+' | '-' | '*' | '/'
+ | '==' | '!='
+ | '<' | '>';
+INTLIT: ('+' | '-')? [0-9]+;
+NAME: ([a-z] | [A-Z] | [0-9])+;
+WS: [ \t\r\n]+ -> skip;
+NEWLINE: [\r\n]+;
diff --git a/antlr-4.9.2-complete.jar b/antlr-4.9.2-complete.jar
new file mode 100644
index 0000000..f68c926
Binary files /dev/null and b/antlr-4.9.2-complete.jar differ
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorListener.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorListener.h
new file mode 100644
index 0000000..d6efad1
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorListener.h
@@ -0,0 +1,167 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "RecognitionException.h"
+
+namespace antlrcpp {
+ class BitSet;
+}
+
+namespace antlr4 {
+
+ /// How to emit recognition errors (an interface in Java).
+ class ANTLR4CPP_PUBLIC ANTLRErrorListener {
+ public:
+ virtual ~ANTLRErrorListener();
+
+ ///
+ /// Upon syntax error, notify any interested parties. This is not how to
+ /// recover from errors or compute error messages.
+ /// specifies how to recover from syntax errors and how to compute error
+ /// messages. This listener's job is simply to emit a computed message,
+ /// though it has enough information to create its own message in many cases.
+ ///
+ /// The is non-null for all syntax errors except
+ /// when we discover mismatched token errors that we can recover from
+ /// in-line, without returning from the surrounding rule (via the single
+ /// token insertion and deletion mechanism).
+ ///
+ ///
+ /// What parser got the error. From this
+ /// object, you can access the context as well
+ /// as the input stream.
+ ///
+ /// The offending token in the input token
+ /// stream, unless recognizer is a lexer (then it's null). If
+ /// no viable alternative error, {@code e} has token at which we
+ /// started production for the decision.
+ ///
+ /// The line number in the input where the error occurred.
+ ///
+ /// The character position within that line where the error occurred.
+ ///
+ /// The message to emit.
+ ///
+ /// The exception generated by the parser that led to
+ /// the reporting of an error. It is null in the case where
+ /// the parser was able to recover in line without exiting the
+ /// surrounding rule.
+ virtual void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
+ size_t charPositionInLine, const std::string &msg, std::exception_ptr e) = 0;
+
+ /**
+ * This method is called by the parser when a full-context prediction
+ * results in an ambiguity.
+ *
+ * Each full-context prediction which does not result in a syntax error
+ * will call either {@link #reportContextSensitivity} or
+ * {@link #reportAmbiguity}.
+ *
+ * When {@code ambigAlts} is not null, it contains the set of potentially
+ * viable alternatives identified by the prediction algorithm. When
+ * {@code ambigAlts} is null, use {@link ATNConfigSet#getAlts} to obtain the
+ * represented alternatives from the {@code configs} argument.
+ *
+ * When {@code exact} is {@code true}, all of the potentially
+ * viable alternatives are truly viable, i.e. this is reporting an exact
+ * ambiguity. When {@code exact} is {@code false}, at least two of
+ * the potentially viable alternatives are viable for the current input, but
+ * the prediction algorithm terminated as soon as it determined that at
+ * least the minimum potentially viable alternative is truly
+ * viable.
+ *
+ * When the {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} prediction
+ * mode is used, the parser is required to identify exact ambiguities so
+ * {@code exact} will always be {@code true}.
+ *
+ * This method is not used by lexers.
+ *
+ * @param recognizer the parser instance
+ * @param dfa the DFA for the current decision
+ * @param startIndex the input index where the decision started
+ * @param stopIndex the input input where the ambiguity was identified
+ * @param exact {@code true} if the ambiguity is exactly known, otherwise
+ * {@code false}. This is always {@code true} when
+ * {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
+ * @param ambigAlts the potentially ambiguous alternatives, or {@code null}
+ * to indicate that the potentially ambiguous alternatives are the complete
+ * set of represented alternatives in {@code configs}
+ * @param configs the ATN configuration set where the ambiguity was
+ * identified
+ */
+ virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
+ const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) = 0;
+
+ /**
+ * This method is called when an SLL conflict occurs and the parser is about
+ * to use the full context information to make an LL decision.
+ *
+ * If one or more configurations in {@code configs} contains a semantic
+ * predicate, the predicates are evaluated before this method is called. The
+ * subset of alternatives which are still viable after predicates are
+ * evaluated is reported in {@code conflictingAlts}.
+ *
+ * This method is not used by lexers.
+ *
+ * @param recognizer the parser instance
+ * @param dfa the DFA for the current decision
+ * @param startIndex the input index where the decision started
+ * @param stopIndex the input index where the SLL conflict occurred
+ * @param conflictingAlts The specific conflicting alternatives. If this is
+ * {@code null}, the conflicting alternatives are all alternatives
+ * represented in {@code configs}. At the moment, conflictingAlts is non-null
+ * (for the reference implementation, but Sam's optimized version can see this
+ * as null).
+ * @param configs the ATN configuration set where the SLL conflict was
+ * detected
+ */
+ virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
+ const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) = 0;
+
+ /**
+ * This method is called by the parser when a full-context prediction has a
+ * unique result.
+ *
+ * Each full-context prediction which does not result in a syntax error
+ * will call either {@link #reportContextSensitivity} or
+ * {@link #reportAmbiguity}.
+ *
+ * For prediction implementations that only evaluate full-context
+ * predictions when an SLL conflict is found (including the default
+ * {@link ParserATNSimulator} implementation), this method reports cases
+ * where SLL conflicts were resolved to unique full-context predictions,
+ * i.e. the decision was context-sensitive. This report does not necessarily
+ * indicate a problem, and it may appear even in completely unambiguous
+ * grammars.
+ *
+ * {@code configs} may have more than one represented alternative if the
+ * full-context prediction algorithm does not evaluate predicates before
+ * beginning the full-context prediction. In all cases, the final prediction
+ * is passed as the {@code prediction} argument.
+ *
+ * Note that the definition of "context sensitivity" in this method
+ * differs from the concept in {@link DecisionInfo#contextSensitivities}.
+ * This method reports all instances where an SLL conflict occurred but LL
+ * parsing produced a unique result, whether or not that unique result
+ * matches the minimum alternative in the SLL conflicting set.
+ *
+ * This method is not used by lexers.
+ *
+ * @param recognizer the parser instance
+ * @param dfa the DFA for the current decision
+ * @param startIndex the input index where the decision started
+ * @param stopIndex the input index where the context sensitivity was
+ * finally determined
+ * @param prediction the unambiguous result of the full-context prediction
+ * @param configs the ATN configuration set where the unambiguous prediction
+ * was determined
+ */
+ virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
+ size_t prediction, atn::ATNConfigSet *configs) = 0;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorStrategy.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorStrategy.h
new file mode 100644
index 0000000..a3eecd1
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRErrorStrategy.h
@@ -0,0 +1,121 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "Token.h"
+
+namespace antlr4 {
+
+ ///
+ /// The interface for defining strategies to deal with syntax errors encountered
+ /// during a parse by ANTLR-generated parsers. We distinguish between three
+ /// different kinds of errors:
+ ///
+ ///
+ /// - The parser could not figure out which path to take in the ATN (none of
+ /// the available alternatives could possibly match)
+ /// - The current input does not match what we were looking for
+ /// - A predicate evaluated to false
+ ///
+ ///
+ /// Implementations of this interface report syntax errors by calling
+ /// .
+ ///
+ /// TODO: what to do about lexers
+ ///
+ class ANTLR4CPP_PUBLIC ANTLRErrorStrategy {
+ public:
+
+ ///
+ /// Reset the error handler state for the specified {@code recognizer}.
+ /// the parser instance
+ virtual ~ANTLRErrorStrategy();
+
+ virtual void reset(Parser *recognizer) = 0;
+
+ /**
+ * This method is called when an unexpected symbol is encountered during an
+ * inline match operation, such as {@link Parser#match}. If the error
+ * strategy successfully recovers from the match failure, this method
+ * returns the {@link Token} instance which should be treated as the
+ * successful result of the match.
+ *
+ * This method handles the consumption of any tokens - the caller should
+ * not call {@link Parser#consume} after a successful recovery.
+ *
+ * Note that the calling code will not report an error if this method
+ * returns successfully. The error strategy implementation is responsible
+ * for calling {@link Parser#notifyErrorListeners} as appropriate.
+ *
+ * @param recognizer the parser instance
+ * @throws RecognitionException if the error strategy was not able to
+ * recover from the unexpected input symbol
+ */
+ virtual Token* recoverInline(Parser *recognizer) = 0;
+
+ ///
+ /// This method is called to recover from exception {@code e}. This method is
+ /// called after by the default exception handler
+ /// generated for a rule method.
+ ///
+ ///
+ /// the parser instance
+ /// the recognition exception to recover from
+ /// if the error strategy could not recover from
+ /// the recognition exception
+ virtual void recover(Parser *recognizer, std::exception_ptr e) = 0;
+
+ ///
+ /// This method provides the error handler with an opportunity to handle
+ /// syntactic or semantic errors in the input stream before they result in a
+ /// .
+ ///
+ /// The generated code currently contains calls to after
+ /// entering the decision state of a closure block ({@code (...)*} or
+ /// {@code (...)+}).
+ ///
+ /// For an implementation based on Jim Idle's "magic sync" mechanism, see
+ /// .
+ ///
+ ///
+ /// the parser instance
+ /// if an error is detected by the error
+ /// strategy but cannot be automatically recovered at the current state in
+ /// the parsing process
+ virtual void sync(Parser *recognizer) = 0;
+
+ ///
+ /// Tests whether or not {@code recognizer} is in the process of recovering
+ /// from an error. In error recovery mode, adds
+ /// symbols to the parse tree by calling
+ /// {@link Parser#createErrorNode(ParserRuleContext, Token)} then
+ /// {@link ParserRuleContext#addErrorNode(ErrorNode)} instead of
+ /// {@link Parser#createTerminalNode(ParserRuleContext, Token)}.
+ ///
+ /// the parser instance
+ /// {@code true} if the parser is currently recovering from a parse
+ /// error, otherwise {@code false}
+ virtual bool inErrorRecoveryMode(Parser *recognizer) = 0;
+
+ ///
+ /// This method is called by when the parser successfully matches an input
+ /// symbol.
+ ///
+ /// the parser instance
+ virtual void reportMatch(Parser *recognizer) = 0;
+
+ ///
+ /// Report any kind of . This method is called by
+ /// the default exception handler generated for a rule method.
+ ///
+ /// the parser instance
+ /// the recognition exception to report
+ virtual void reportError(Parser *recognizer, const RecognitionException &e) = 0;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRFileStream.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRFileStream.h
new file mode 100644
index 0000000..6c7d619
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRFileStream.h
@@ -0,0 +1,30 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "ANTLRInputStream.h"
+
+namespace antlr4 {
+
+ /// This is an ANTLRInputStream that is loaded from a file all at once
+ /// when you construct the object (or call load()).
+ // TODO: this class needs testing.
+ class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream {
+ public:
+ ANTLRFileStream() = default;
+ ANTLRFileStream(const std::string &) = delete;
+ ANTLRFileStream(const char *data, size_t length) = delete;
+ ANTLRFileStream(std::istream &stream) = delete;
+
+ // Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM).
+ virtual void loadFromFile(const std::string &fileName);
+ virtual std::string getSourceName() const override;
+
+ private:
+ std::string _fileName; // UTF-8 encoded file name.
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRInputStream.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRInputStream.h
new file mode 100644
index 0000000..fdf857e
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/ANTLRInputStream.h
@@ -0,0 +1,76 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "CharStream.h"
+
+namespace antlr4 {
+
+ // Vacuum all input from a stream and then treat it
+ // like a string. Can also pass in a string or char[] to use.
+ // Input is expected to be encoded in UTF-8 and converted to UTF-32 internally.
+ class ANTLR4CPP_PUBLIC ANTLRInputStream : public CharStream {
+ protected:
+ /// The data being scanned.
+ // UTF-32
+ UTF32String _data;
+
+ /// 0..n-1 index into string of next char
+ size_t p;
+
+ public:
+ /// What is name or source of this char stream?
+ std::string name;
+
+ ANTLRInputStream();
+
+#if __cplusplus >= 201703L
+ ANTLRInputStream(const std::string_view &input);
+#endif
+
+ ANTLRInputStream(const std::string &input);
+ ANTLRInputStream(const char *data, size_t length);
+ ANTLRInputStream(std::istream &stream);
+
+ virtual void load(const std::string &input);
+ virtual void load(const char *data, size_t length);
+ virtual void load(std::istream &stream);
+
+ /// Reset the stream so that it's in the same state it was
+ /// when the object was created *except* the data array is not
+ /// touched.
+ virtual void reset();
+ virtual void consume() override;
+ virtual size_t LA(ssize_t i) override;
+ virtual size_t LT(ssize_t i);
+
+ ///
+ /// Return the current input symbol index 0..n where n indicates the
+ /// last symbol has been read. The index is the index of char to
+ /// be returned from LA(1).
+ ///
+ virtual size_t index() override;
+ virtual size_t size() override;
+
+ ///
+ /// mark/release do nothing; we have entire buffer
+ virtual ssize_t mark() override;
+ virtual void release(ssize_t marker) override;
+
+ ///
+ /// consume() ahead until p==index; can't just set p=index as we must
+ /// update line and charPositionInLine. If we seek backwards, just set p
+ ///
+ virtual void seek(size_t index) override;
+ virtual std::string getText(const misc::Interval &interval) override;
+ virtual std::string getSourceName() const override;
+ virtual std::string toString() const override;
+
+ private:
+ void InitializeInstanceFields();
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BailErrorStrategy.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BailErrorStrategy.h
new file mode 100644
index 0000000..2a8c36f
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BailErrorStrategy.h
@@ -0,0 +1,59 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "DefaultErrorStrategy.h"
+
+namespace antlr4 {
+
+ /**
+ * This implementation of {@link ANTLRErrorStrategy} responds to syntax errors
+ * by immediately canceling the parse operation with a
+ * {@link ParseCancellationException}. The implementation ensures that the
+ * {@link ParserRuleContext#exception} field is set for all parse tree nodes
+ * that were not completed prior to encountering the error.
+ *
+ *
+ * This error strategy is useful in the following scenarios.
+ *
+ *
+ * - Two-stage parsing: This error strategy allows the first
+ * stage of two-stage parsing to immediately terminate if an error is
+ * encountered, and immediately fall back to the second stage. In addition to
+ * avoiding wasted work by attempting to recover from errors here, the empty
+ * implementation of {@link BailErrorStrategy#sync} improves the performance of
+ * the first stage.
+ * - Silent validation: When syntax errors are not being
+ * reported or logged, and the parse result is simply ignored if errors occur,
+ * the {@link BailErrorStrategy} avoids wasting work on recovering from errors
+ * when the result will be ignored either way.
+ *
+ *
+ *
+ * {@code myparser.setErrorHandler(new BailErrorStrategy());}
+ *
+ * @see Parser#setErrorHandler(ANTLRErrorStrategy)
+ */
+ class ANTLR4CPP_PUBLIC BailErrorStrategy : public DefaultErrorStrategy {
+ ///
+ /// Instead of recovering from exception {@code e}, re-throw it wrapped
+ /// in a so it is not caught by the
+ /// rule function catches. Use to get the
+ /// original .
+ ///
+ public:
+ virtual void recover(Parser *recognizer, std::exception_ptr e) override;
+
+ /// Make sure we don't attempt to recover inline; if the parser
+ /// successfully recovers, it won't throw an exception.
+ virtual Token* recoverInline(Parser *recognizer) override;
+
+ ///
+ /// Make sure we don't attempt to recover from problems in subrules.
+ virtual void sync(Parser *recognizer) override;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BaseErrorListener.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BaseErrorListener.h
new file mode 100644
index 0000000..aad2e5d
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BaseErrorListener.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "ANTLRErrorListener.h"
+
+namespace antlrcpp {
+ class BitSet;
+}
+
+namespace antlr4 {
+
+ /**
+ * Provides an empty default implementation of {@link ANTLRErrorListener}. The
+ * default implementation of each method does nothing, but can be overridden as
+ * necessary.
+ */
+ class ANTLR4CPP_PUBLIC BaseErrorListener : public ANTLRErrorListener {
+
+ virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
+ const std::string &msg, std::exception_ptr e) override;
+
+ virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
+ const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override;
+
+ virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
+ const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override;
+
+ virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
+ size_t prediction, atn::ATNConfigSet *configs) override;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BufferedTokenStream.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BufferedTokenStream.h
new file mode 100644
index 0000000..fab74d2
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/BufferedTokenStream.h
@@ -0,0 +1,200 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "TokenStream.h"
+
+namespace antlr4 {
+
+ /**
+ * This implementation of {@link TokenStream} loads tokens from a
+ * {@link TokenSource} on-demand, and places the tokens in a buffer to provide
+ * access to any previous token by index.
+ *
+ *
+ * This token stream ignores the value of {@link Token#getChannel}. If your
+ * parser requires the token stream filter tokens to only those on a particular
+ * channel, such as {@link Token#DEFAULT_CHANNEL} or
+ * {@link Token#HIDDEN_CHANNEL}, use a filtering token stream such a
+ * {@link CommonTokenStream}.
+ */
+ class ANTLR4CPP_PUBLIC BufferedTokenStream : public TokenStream {
+ public:
+ BufferedTokenStream(TokenSource *tokenSource);
+ BufferedTokenStream(const BufferedTokenStream& other) = delete;
+
+ BufferedTokenStream& operator = (const BufferedTokenStream& other) = delete;
+
+ virtual TokenSource* getTokenSource() const override;
+ virtual size_t index() override;
+ virtual ssize_t mark() override;
+
+ virtual void release(ssize_t marker) override;
+ virtual void reset();
+ virtual void seek(size_t index) override;
+
+ virtual size_t size() override;
+ virtual void consume() override;
+
+ virtual Token* get(size_t i) const override;
+
+ /// Get all tokens from start..stop inclusively.
+ virtual std::vector get(size_t start, size_t stop);
+
+ virtual size_t LA(ssize_t i) override;
+ virtual Token* LT(ssize_t k) override;
+
+ /// Reset this token stream by setting its token source.
+ virtual void setTokenSource(TokenSource *tokenSource);
+ virtual std::vector getTokens();
+ virtual std::vector getTokens(size_t start, size_t stop);
+
+ ///
+ /// Given a start and stop index, return a List of all tokens in
+ /// the token type BitSet. Return null if no tokens were found. This
+ /// method looks at both on and off channel tokens.
+ ///
+ virtual std::vector getTokens(size_t start, size_t stop, const std::vector &types);
+ virtual std::vector getTokens(size_t start, size_t stop, size_t ttype);
+
+ /// Collect all tokens on specified channel to the right of
+ /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
+ /// EOF. If channel is -1, find any non default channel token.
+ virtual std::vector getHiddenTokensToRight(size_t tokenIndex, ssize_t channel);
+
+ ///
+ /// Collect all hidden tokens (any off-default channel) to the right of
+ /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL
+ /// or EOF.
+ ///
+ virtual std::vector getHiddenTokensToRight(size_t tokenIndex);
+
+ ///
+ /// Collect all tokens on specified channel to the left of
+ /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
+ /// If channel is -1, find any non default channel token.
+ ///
+ virtual std::vector getHiddenTokensToLeft(size_t tokenIndex, ssize_t channel);
+
+ ///
+ /// Collect all hidden tokens (any off-default channel) to the left of
+ /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
+ ///
+ virtual std::vector getHiddenTokensToLeft(size_t tokenIndex);
+
+ virtual std::string getSourceName() const override;
+ virtual std::string getText() override;
+ virtual std::string getText(const misc::Interval &interval) override;
+ virtual std::string getText(RuleContext *ctx) override;
+ virtual std::string getText(Token *start, Token *stop) override;
+
+ /// Get all tokens from lexer until EOF.
+ virtual void fill();
+
+ protected:
+ /**
+ * The {@link TokenSource} from which tokens for this stream are fetched.
+ */
+ TokenSource *_tokenSource;
+
+ /**
+ * A collection of all tokens fetched from the token source. The list is
+ * considered a complete view of the input once {@link #fetchedEOF} is set
+ * to {@code true}.
+ */
+ std::vector> _tokens;
+
+ /**
+ * The index into {@link #tokens} of the current token (next token to
+ * {@link #consume}). {@link #tokens}{@code [}{@link #p}{@code ]} should be
+ * {@link #LT LT(1)}.
+ *
+ * This field is set to -1 when the stream is first constructed or when
+ * {@link #setTokenSource} is called, indicating that the first token has
+ * not yet been fetched from the token source. For additional information,
+ * see the documentation of {@link IntStream} for a description of
+ * Initializing Methods.
+ */
+ // ml: since -1 requires to make this member signed for just this single aspect we use a member _needSetup instead.
+ // Use bool isInitialized() to find out if this stream has started reading.
+ size_t _p;
+
+ /**
+ * Indicates whether the {@link Token#EOF} token has been fetched from
+ * {@link #tokenSource} and added to {@link #tokens}. This field improves
+ * performance for the following cases:
+ *
+ *
+ * - {@link #consume}: The lookahead check in {@link #consume} to prevent
+ * consuming the EOF symbol is optimized by checking the values of
+ * {@link #fetchedEOF} and {@link #p} instead of calling {@link #LA}.
+ * - {@link #fetch}: The check to prevent adding multiple EOF symbols into
+ * {@link #tokens} is trivial with this field.
+ *
+ /// If {@code ctx.getSourceInterval()} does not return a valid interval of
+ /// tokens provided by this stream, the behavior is unspecified.
+ ///
+ ///
+ /// TokenStream stream = ...;
+ /// String text = stream.getText(ctx.getSourceInterval());
+ ///
+ ///
+ /// The context providing the source interval of tokens to get
+ /// text for.
+ /// The text of all tokens within the source interval of {@code ctx}.
+ virtual std::string getText(RuleContext *ctx) = 0;
+
+ ///
+ /// Return the text of all tokens in this stream between {@code start} and
+ /// {@code stop} (inclusive).
+ ///
+ /// If the specified {@code start} or {@code stop} token was not provided by
+ /// this stream, or if the {@code stop} occurred before the {@code start}
+ /// token, the behavior is unspecified.
+ ///
+ /// For streams which ensure that the method is
+ /// accurate for all of its provided tokens, this method behaves like the
+ /// following code. Other streams may implement this method in other ways
+ /// provided the behavior is consistent with this at a high level.
+ ///
+ ///
+ /// TokenStream stream = ...;
+ /// String text = "";
+ /// for (int i = start.getTokenIndex(); i <= stop.getTokenIndex(); i++) {
+ /// text += stream.get(i).getText();
+ /// }
+ ///
+ ///
+ /// The first token in the interval to get text for.
+ /// The last token in the interval to get text for (inclusive).
+ /// The text of all tokens lying between the specified {@code start}
+ /// and {@code stop} tokens.
+ ///
+ /// if this stream does not support
+ /// this method for the specified tokens
+ virtual std::string getText(Token *start, Token *stop) = 0;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/TokenStreamRewriter.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/TokenStreamRewriter.h
new file mode 100644
index 0000000..561607a
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/TokenStreamRewriter.h
@@ -0,0 +1,300 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+namespace antlr4 {
+
+ /**
+ * Useful for rewriting out a buffered input token stream after doing some
+ * augmentation or other manipulations on it.
+ *
+ *
+ * You can insert stuff, replace, and delete chunks. Note that the operations
+ * are done lazily--only if you convert the buffer to a {@link String} with
+ * {@link TokenStream#getText()}. This is very efficient because you are not
+ * moving data around all the time. As the buffer of tokens is converted to
+ * strings, the {@link #getText()} method(s) scan the input token stream and
+ * check to see if there is an operation at the current index. If so, the
+ * operation is done and then normal {@link String} rendering continues on the
+ * buffer. This is like having multiple Turing machine instruction streams
+ * (programs) operating on a single input tape. :)
+ *
+ *
+ * This rewriter makes no modifications to the token stream. It does not ask the
+ * stream to fill itself up nor does it advance the input cursor. The token
+ * stream {@link TokenStream#index()} will return the same value before and
+ * after any {@link #getText()} call.
+ *
+ *
+ * The rewriter only works on tokens that you have in the buffer and ignores the
+ * current input cursor. If you are buffering tokens on-demand, calling
+ * {@link #getText()} halfway through the input will only do rewrites for those
+ * tokens in the first half of the file.
+ *
+ *
+ * Since the operations are done lazily at {@link #getText}-time, operations do
+ * not screw up the token index values. That is, an insert operation at token
+ * index {@code i} does not change the index values for tokens
+ * {@code i}+1..n-1.
+ *
+ *
+ * Because operations never actually alter the buffer, you may always get the
+ * original token stream back without undoing anything. Since the instructions
+ * are queued up, you can easily simulate transactions and roll back any changes
+ * if there is an error just by removing instructions. For example,
+ *
+ *
+ * CharStream input = new ANTLRFileStream("input");
+ * TLexer lex = new TLexer(input);
+ * CommonTokenStream tokens = new CommonTokenStream(lex);
+ * T parser = new T(tokens);
+ * TokenStreamRewriter rewriter = new TokenStreamRewriter(tokens);
+ * parser.startRule();
+ *
+ *
+ *
+ * Then in the rules, you can execute (assuming rewriter is visible):
+ *
+ *
+ * Token t,u;
+ * ...
+ * rewriter.insertAfter(t, "text to put after t");}
+ * rewriter.insertAfter(u, "text after u");}
+ * System.out.println(rewriter.getText());
+ *
+ *
+ *
+ * You can also have multiple "instruction streams" and get multiple rewrites
+ * from a single pass over the input. Just name the instruction streams and use
+ * that name again when printing the buffer. This could be useful for generating
+ * a C file and also its header file--all from the same buffer:
+ *
+ *
+ * rewriter.insertAfter("pass1", t, "text to put after t");}
+ * rewriter.insertAfter("pass2", u, "text after u");}
+ * System.out.println(rewriter.getText("pass1"));
+ * System.out.println(rewriter.getText("pass2"));
+ *
+ *
+ *
+ * If you don't use named rewrite streams, a "default" stream is used as the
+ * first example shows.
+ */
+ class ANTLR4CPP_PUBLIC TokenStreamRewriter {
+ public:
+ static const std::string DEFAULT_PROGRAM_NAME;
+#if __cplusplus >= 201703L
+ static constexpr size_t PROGRAM_INIT_SIZE = 100;
+ static constexpr size_t MIN_TOKEN_INDEX = 0;
+#else
+ enum : size_t {
+ PROGRAM_INIT_SIZE = 100,
+ MIN_TOKEN_INDEX = 0,
+ };
+#endif
+
+ TokenStreamRewriter(TokenStream *tokens);
+ virtual ~TokenStreamRewriter();
+
+ TokenStream *getTokenStream();
+
+ virtual void rollback(size_t instructionIndex);
+
+ /// Rollback the instruction stream for a program so that
+ /// the indicated instruction (via instructionIndex) is no
+ /// longer in the stream. UNTESTED!
+ virtual void rollback(const std::string &programName, size_t instructionIndex);
+
+ virtual void deleteProgram();
+
+ /// Reset the program so that no instructions exist.
+ virtual void deleteProgram(const std::string &programName);
+ virtual void insertAfter(Token *t, const std::string& text);
+ virtual void insertAfter(size_t index, const std::string& text);
+ virtual void insertAfter(const std::string &programName, Token *t, const std::string& text);
+ virtual void insertAfter(const std::string &programName, size_t index, const std::string& text);
+
+ virtual void insertBefore(Token *t, const std::string& text);
+ virtual void insertBefore(size_t index, const std::string& text);
+ virtual void insertBefore(const std::string &programName, Token *t, const std::string& text);
+ virtual void insertBefore(const std::string &programName, size_t index, const std::string& text);
+
+ virtual void replace(size_t index, const std::string& text);
+ virtual void replace(size_t from, size_t to, const std::string& text);
+ virtual void replace(Token *indexT, const std::string& text);
+ virtual void replace(Token *from, Token *to, const std::string& text);
+ virtual void replace(const std::string &programName, size_t from, size_t to, const std::string& text);
+ virtual void replace(const std::string &programName, Token *from, Token *to, const std::string& text);
+
+ virtual void Delete(size_t index);
+ virtual void Delete(size_t from, size_t to);
+ virtual void Delete(Token *indexT);
+ virtual void Delete(Token *from, Token *to);
+ virtual void Delete(const std::string &programName, size_t from, size_t to);
+ virtual void Delete(const std::string &programName, Token *from, Token *to);
+
+ virtual size_t getLastRewriteTokenIndex();
+
+ /// Return the text from the original tokens altered per the
+ /// instructions given to this rewriter.
+ virtual std::string getText();
+
+ /** Return the text from the original tokens altered per the
+ * instructions given to this rewriter in programName.
+ */
+ std::string getText(std::string programName);
+
+ /// Return the text associated with the tokens in the interval from the
+ /// original token stream but with the alterations given to this rewriter.
+ /// The interval refers to the indexes in the original token stream.
+ /// We do not alter the token stream in any way, so the indexes
+ /// and intervals are still consistent. Includes any operations done
+ /// to the first and last token in the interval. So, if you did an
+ /// insertBefore on the first token, you would get that insertion.
+ /// The same is true if you do an insertAfter the stop token.
+ virtual std::string getText(const misc::Interval &interval);
+
+ virtual std::string getText(const std::string &programName, const misc::Interval &interval);
+
+ protected:
+ class RewriteOperation {
+ public:
+ /// What index into rewrites List are we?
+ size_t index;
+ std::string text;
+
+ /// Token buffer index.
+ size_t instructionIndex;
+
+ RewriteOperation(TokenStreamRewriter *outerInstance, size_t index);
+ RewriteOperation(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
+ virtual ~RewriteOperation();
+
+ /// Execute the rewrite operation by possibly adding to the buffer.
+ /// Return the index of the next token to operate on.
+
+ virtual size_t execute(std::string *buf);
+ virtual std::string toString();
+
+ private:
+ TokenStreamRewriter *const outerInstance;
+ void InitializeInstanceFields();
+ };
+
+ class InsertBeforeOp : public RewriteOperation {
+ private:
+ TokenStreamRewriter *const outerInstance;
+
+ public:
+ InsertBeforeOp(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
+
+ virtual size_t execute(std::string *buf) override;
+ };
+
+ class ReplaceOp : public RewriteOperation {
+ private:
+ TokenStreamRewriter *const outerInstance;
+
+ public:
+ size_t lastIndex;
+
+ ReplaceOp(TokenStreamRewriter *outerInstance, size_t from, size_t to, const std::string& text);
+ virtual size_t execute(std::string *buf) override;
+ virtual std::string toString() override;
+
+ private:
+ void InitializeInstanceFields();
+ };
+
+ /// Our source stream
+ TokenStream *const tokens;
+
+ /// You may have multiple, named streams of rewrite operations.
+ /// I'm calling these things "programs."
+ /// Maps String (name) -> rewrite (List)
+ std::map> _programs;
+
+ ///
+ /// Map String (program name) -> Integer index
+ std::map _lastRewriteTokenIndexes;
+ virtual size_t getLastRewriteTokenIndex(const std::string &programName);
+ virtual void setLastRewriteTokenIndex(const std::string &programName, size_t i);
+ virtual std::vector& getProgram(const std::string &name);
+
+ ///
+ /// We need to combine operations and report invalid operations (like
+ /// overlapping replaces that are not completed nested). Inserts to
+ /// same index need to be combined etc... Here are the cases:
+ ///
+ /// I.i.u I.j.v leave alone, nonoverlapping
+ /// I.i.u I.i.v combine: Iivu
+ ///
+ /// R.i-j.u R.x-y.v | i-j in x-y delete first R
+ /// R.i-j.u R.i-j.v delete first R
+ /// R.i-j.u R.x-y.v | x-y in i-j ERROR
+ /// R.i-j.u R.x-y.v | boundaries overlap ERROR
+ ///
+ /// Delete special case of replace (text==null):
+ /// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
+ ///
+ /// I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before
+ /// we're not deleting i)
+ /// I.i.u R.x-y.v | i not in (x+1)-y leave alone, nonoverlapping
+ /// R.x-y.v I.i.u | i in x-y ERROR
+ /// R.x-y.v I.x.u R.x-y.uv (combine, delete I)
+ /// R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
+ ///
+ /// I.i.u = insert u before op @ index i
+ /// R.x-y.u = replace x-y indexed tokens with u
+ ///
+ /// First we need to examine replaces. For any replace op:
+ ///
+ /// 1. wipe out any insertions before op within that range.
+ /// 2. Drop any replace op before that is contained completely within
+ /// that range.
+ /// 3. Throw exception upon boundary overlap with any previous replace.
+ ///
+ /// Then we can deal with inserts:
+ ///
+ /// 1. for any inserts to same index, combine even if not adjacent.
+ /// 2. for any prior replace with same left boundary, combine this
+ /// insert with replace and delete this replace.
+ /// 3. throw exception if index in same range as previous replace
+ ///
+ /// Don't actually delete; make op null in list. Easier to walk list.
+ /// Later we can throw as we add to index -> op map.
+ ///
+ /// Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
+ /// inserted stuff would be before the replace range. But, if you
+ /// add tokens in front of a method body '{' and then delete the method
+ /// body, I think the stuff before the '{' you added should disappear too.
+ ///
+ /// Return a map from token index to operation.
+ ///
+ virtual std::unordered_map reduceToSingleOperationPerIndex(std::vector &rewrites);
+
+ virtual std::string catOpText(std::string *a, std::string *b);
+
+ /// Get all operations before an index of a particular kind.
+ template
+ std::vector getKindOfOps(std::vector rewrites, size_t before) {
+ std::vector ops;
+ for (size_t i = 0; i < before && i < rewrites.size(); i++) {
+ T *op = dynamic_cast(rewrites[i]);
+ if (op == nullptr) { // ignore deleted or non matching entries
+ continue;
+ }
+ ops.push_back(op);
+ }
+ return ops;
+ }
+
+ private:
+ std::vector& initializeProgram(const std::string &name);
+
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedCharStream.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedCharStream.h
new file mode 100644
index 0000000..98cdcc6
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedCharStream.h
@@ -0,0 +1,123 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "CharStream.h"
+
+namespace antlr4 {
+
+ /// Do not buffer up the entire char stream. It does keep a small buffer
+ /// for efficiency and also buffers while a mark exists (set by the
+ /// lookahead prediction in parser). "Unbuffered" here refers to fact
+ /// that it doesn't buffer all data, not that's it's on demand loading of char.
+ class ANTLR4CPP_PUBLIC UnbufferedCharStream : public CharStream {
+ public:
+ /// The name or source of this char stream.
+ std::string name;
+
+ UnbufferedCharStream(std::wistream &input);
+
+ virtual void consume() override;
+ virtual size_t LA(ssize_t i) override;
+
+ ///
+ /// Return a marker that we can release later.
+ ///
+ /// The specific marker value used for this class allows for some level of
+ /// protection against misuse where {@code seek()} is called on a mark or
+ /// {@code release()} is called in the wrong order.
+ ///
+ virtual ssize_t mark() override;
+
+ ///
+ /// Decrement number of markers, resetting buffer if we hit 0.
+ ///
+ virtual void release(ssize_t marker) override;
+ virtual size_t index() override;
+
+ ///
+ /// Seek to absolute character index, which might not be in the current
+ /// sliding window. Move {@code p} to {@code index-bufferStartIndex}.
+ ///
+ virtual void seek(size_t index) override;
+ virtual size_t size() override;
+ virtual std::string getSourceName() const override;
+ virtual std::string getText(const misc::Interval &interval) override;
+
+ protected:
+ /// A moving window buffer of the data being scanned. While there's a marker,
+ /// we keep adding to buffer. Otherwise, resets so
+ /// we start filling at index 0 again.
+ // UTF-32 encoded.
+#if defined(_MSC_VER) && _MSC_VER == 1900
+ i32string _data; // Custom type for VS 2015.
+ typedef __int32 storage_type;
+#else
+ std::u32string _data;
+ typedef char32_t storage_type;
+#endif
+
+ ///
+ /// 0..n-1 index into of next character.
+ ///
+ /// The {@code LA(1)} character is {@code data[p]}. If {@code p == n}, we are
+ /// out of buffered characters.
+ ///
+ size_t _p;
+
+ ///
+ /// Count up with and down with
+ /// . When we {@code release()} the last mark,
+ /// {@code numMarkers} reaches 0 and we reset the buffer. Copy
+ /// {@code data[p]..data[n-1]} to {@code data[0]..data[(n-1)-p]}.
+ ///
+ size_t _numMarkers;
+
+ /// This is the {@code LA(-1)} character for the current position.
+ size_t _lastChar; // UTF-32
+
+ ///
+ /// When {@code numMarkers > 0}, this is the {@code LA(-1)} character for the
+ /// first character in . Otherwise, this is unspecified.
+ ///
+ size_t _lastCharBufferStart; // UTF-32
+
+ ///
+ /// Absolute character index. It's the index of the character about to be
+ /// read via {@code LA(1)}. Goes from 0 to the number of characters in the
+ /// entire stream, although the stream size is unknown before the end is
+ /// reached.
+ ///
+ size_t _currentCharIndex;
+
+ std::wistream &_input;
+
+ ///
+ /// Make sure we have 'want' elements from current position .
+ /// Last valid {@code p} index is {@code data.length-1}. {@code p+need-1} is
+ /// the char index 'need' elements ahead. If we need 1 element,
+ /// {@code (p+1-1)==p} must be less than {@code data.length}.
+ ///
+ virtual void sync(size_t want);
+
+ ///
+ /// Add {@code n} characters to the buffer. Returns the number of characters
+ /// actually added to the buffer. If the return value is less than {@code n},
+ /// then EOF was reached before {@code n} characters could be added.
+ ///
+ virtual size_t fill(size_t n);
+
+ /// Override to provide different source of characters than
+ /// .
+ virtual char32_t nextChar();
+ virtual void add(char32_t c);
+ size_t getBufferStartIndex() const;
+
+ private:
+ void InitializeInstanceFields();
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedTokenStream.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedTokenStream.h
new file mode 100644
index 0000000..244cc8d
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/UnbufferedTokenStream.h
@@ -0,0 +1,115 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "TokenStream.h"
+
+namespace antlr4 {
+
+ class ANTLR4CPP_PUBLIC UnbufferedTokenStream : public TokenStream {
+ public:
+ UnbufferedTokenStream(TokenSource *tokenSource);
+ UnbufferedTokenStream(TokenSource *tokenSource, int bufferSize);
+ UnbufferedTokenStream(const UnbufferedTokenStream& other) = delete;
+ virtual ~UnbufferedTokenStream();
+
+ UnbufferedTokenStream& operator = (const UnbufferedTokenStream& other) = delete;
+
+ virtual Token* get(size_t i) const override;
+ virtual Token* LT(ssize_t i) override;
+ virtual size_t LA(ssize_t i) override;
+
+ virtual TokenSource* getTokenSource() const override;
+
+ virtual std::string getText(const misc::Interval &interval) override;
+ virtual std::string getText() override;
+ virtual std::string getText(RuleContext *ctx) override;
+ virtual std::string getText(Token *start, Token *stop) override;
+
+ virtual void consume() override;
+
+ ///
+ /// Return a marker that we can release later.
+ ///
+ /// The specific marker value used for this class allows for some level of
+ /// protection against misuse where {@code seek()} is called on a mark or
+ /// {@code release()} is called in the wrong order.
+ ///
+ virtual ssize_t mark() override;
+ virtual void release(ssize_t marker) override;
+ virtual size_t index() override;
+ virtual void seek(size_t index) override;
+ virtual size_t size() override;
+ virtual std::string getSourceName() const override;
+
+ protected:
+ /// Make sure we have 'need' elements from current position p. Last valid
+ /// p index is tokens.length - 1. p + need - 1 is the tokens index 'need' elements
+ /// ahead. If we need 1 element, (p+1-1)==p must be less than tokens.length.
+ TokenSource *_tokenSource;
+
+ ///
+ /// A moving window buffer of the data being scanned. While there's a marker,
+ /// we keep adding to buffer. Otherwise, resets so
+ /// we start filling at index 0 again.
+ ///
+
+ std::vector> _tokens;
+
+ ///
+ /// 0..n-1 index into of next token.
+ ///
+ /// The {@code LT(1)} token is {@code tokens[p]}. If {@code p == n}, we are
+ /// out of buffered tokens.
+ ///
+ size_t _p;
+
+ ///
+ /// Count up with and down with
+ /// . When we {@code release()} the last mark,
+ /// {@code numMarkers} reaches 0 and we reset the buffer. Copy
+ /// {@code tokens[p]..tokens[n-1]} to {@code tokens[0]..tokens[(n-1)-p]}.
+ ///
+ int _numMarkers;
+
+ ///
+ /// This is the {@code LT(-1)} token for the current position.
+ ///
+ Token *_lastToken;
+
+ ///
+ /// When {@code numMarkers > 0}, this is the {@code LT(-1)} token for the
+ /// first token in . Otherwise, this is {@code null}.
+ ///
+ Token *_lastTokenBufferStart;
+
+ ///
+ /// Absolute token index. It's the index of the token about to be read via
+ /// {@code LT(1)}. Goes from 0 to the number of tokens in the entire stream,
+ /// although the stream size is unknown before the end is reached.
+ ///
+ /// This value is used to set the token indexes if the stream provides tokens
+ /// that implement .
+ ///
+ size_t _currentTokenIndex;
+
+ virtual void sync(ssize_t want);
+
+ ///
+ /// Add {@code n} elements to the buffer. Returns the number of tokens
+ /// actually added to the buffer. If the return value is less than {@code n},
+ /// then EOF was reached before {@code n} tokens could be added.
+ ///
+ virtual size_t fill(size_t n);
+ virtual void add(std::unique_ptr t);
+
+ size_t getBufferStartIndex() const;
+
+ private:
+ void InitializeInstanceFields();
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/Vocabulary.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/Vocabulary.h
new file mode 100644
index 0000000..e8924bf
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/Vocabulary.h
@@ -0,0 +1,192 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "antlr4-common.h"
+
+namespace antlr4 {
+namespace dfa {
+
+ /// This class provides a default implementation of the
+ /// interface.
+ class ANTLR4CPP_PUBLIC Vocabulary {
+ public:
+ /// Gets an empty instance.
+ ///
+ ///
+ /// No literal or symbol names are assigned to token types, so
+ /// returns the numeric value for all tokens
+ /// except .
+ static const Vocabulary EMPTY_VOCABULARY;
+
+ Vocabulary() {}
+ Vocabulary(Vocabulary const&) = default;
+ virtual ~Vocabulary();
+
+ ///
+ /// Constructs a new instance of from the specified
+ /// literal and symbolic token names.
+ ///
+ /// The literal names assigned to tokens, or {@code null}
+ /// if no literal names are assigned.
+ /// The symbolic names assigned to tokens, or
+ /// {@code null} if no symbolic names are assigned.
+ ///
+ ///
+ ///
+ Vocabulary(const std::vector &literalNames, const std::vector &symbolicNames);
+
+ ///
+ /// Constructs a new instance of from the specified
+ /// literal, symbolic, and display token names.
+ ///
+ /// The literal names assigned to tokens, or {@code null}
+ /// if no literal names are assigned.
+ /// The symbolic names assigned to tokens, or
+ /// {@code null} if no symbolic names are assigned.
+ /// The display names assigned to tokens, or {@code null}
+ /// to use the values in {@code literalNames} and {@code symbolicNames} as
+ /// the source of display names, as described in
+ /// .
+ ///
+ ///
+ ///
+ ///
+ Vocabulary(const std::vector &literalNames, const std::vector &symbolicNames,
+ const std::vector &displayNames);
+
+ ///
+ /// Returns a instance from the specified set of token
+ /// names. This method acts as a compatibility layer for the single
+ /// {@code tokenNames} array generated by previous releases of ANTLR.
+ ///
+ /// The resulting vocabulary instance returns {@code null} for
+ /// and , and the
+ /// value from {@code tokenNames} for the display names.
+ ///
+ /// The token names, or {@code null} if no token names are
+ /// available.
+ /// A instance which uses {@code tokenNames} for
+ /// the display names of tokens.
+ static Vocabulary fromTokenNames(const std::vector &tokenNames);
+
+ ///
+ /// Returns the highest token type value. It can be used to iterate from
+ /// zero to that number, inclusively, thus querying all stored entries.
+ /// the highest token type value
+ virtual size_t getMaxTokenType() const;
+
+ ///
+ /// Gets the string literal associated with a token type. The string returned
+ /// by this method, when not {@code null}, can be used unaltered in a parser
+ /// grammar to represent this token type.
+ ///
+ /// The following table shows examples of lexer rules and the literal
+ /// names assigned to the corresponding token types.
+ ///
+ ///
+ ///
+ /// | Rule |
+ /// Literal Name |
+ /// Java String Literal |
+ ///
+ ///
+ /// | {@code THIS : 'this';} |
+ /// {@code 'this'} |
+ /// {@code "'this'"} |
+ ///
+ ///
+ /// | {@code SQUOTE : '\'';} |
+ /// {@code '\''} |
+ /// {@code "'\\''"} |
+ ///
+ ///
+ /// | {@code ID : [A-Z]+;} |
+ /// n/a |
+ /// {@code null} |
+ ///
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The string literal associated with the specified token type, or
+ /// {@code null} if no string literal is associated with the type.
+ virtual std::string getLiteralName(size_t tokenType) const;
+
+ ///
+ /// Gets the symbolic name associated with a token type. The string returned
+ /// by this method, when not {@code null}, can be used unaltered in a parser
+ /// grammar to represent this token type.
+ ///
+ /// This method supports token types defined by any of the following
+ /// methods:
+ ///
+ ///
+ /// - Tokens created by lexer rules.
+ /// - Tokens defined in a
tokens{} block in a lexer or parser
+ /// grammar.
+ /// - The implicitly defined {@code EOF} token, which has the token type
+ /// .
+ ///
+ ///
+ /// The following table shows examples of lexer rules and the literal
+ /// names assigned to the corresponding token types.
+ ///
+ ///
+ ///
+ /// | Rule |
+ /// Symbolic Name |
+ ///
+ ///
+ /// | {@code THIS : 'this';} |
+ /// {@code THIS} |
+ ///
+ ///
+ /// | {@code SQUOTE : '\'';} |
+ /// {@code SQUOTE} |
+ ///
+ ///
+ /// | {@code ID : [A-Z]+;} |
+ /// {@code ID} |
+ ///
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The symbolic name associated with the specified token type, or
+ /// {@code null} if no symbolic name is associated with the type.
+ virtual std::string getSymbolicName(size_t tokenType) const;
+
+ ///
+ /// Gets the display name of a token type.
+ ///
+ /// ANTLR provides a default implementation of this method, but
+ /// applications are free to override the behavior in any manner which makes
+ /// sense for the application. The default implementation returns the first
+ /// result from the following list which produces a non-{@code null}
+ /// result.
+ ///
+ ///
+ /// - The result of
+ /// - The result of
+ /// - The result of
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The display name of the token type, for use in error reporting or
+ /// other user-visible messages which reference specific token types.
+ virtual std::string getDisplayName(size_t tokenType) const;
+
+ private:
+ std::vector const _literalNames;
+ std::vector const _symbolicNames;
+ std::vector const _displayNames;
+ const size_t _maxTokenType = 0;
+ };
+
+} // namespace atn
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/WritableToken.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/WritableToken.h
new file mode 100644
index 0000000..56bc9d0
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/WritableToken.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "Token.h"
+
+namespace antlr4 {
+
+ class ANTLR4CPP_PUBLIC WritableToken : public Token {
+ public:
+ virtual ~WritableToken();
+ virtual void setText(const std::string &text) = 0;
+ virtual void setType(size_t ttype) = 0;
+ virtual void setLine(size_t line) = 0;
+ virtual void setCharPositionInLine(size_t pos) = 0;
+ virtual void setChannel(size_t channel) = 0;
+ virtual void setTokenIndex(size_t index) = 0;
+ };
+
+} // namespace antlr4
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/antlr4-common.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/antlr4-common.h
new file mode 100644
index 0000000..4731297
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/antlr4-common.h
@@ -0,0 +1,140 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include