forked from jasder/antlr
Merge pull request #1902 from jm-mikkelsen/master
C++ runtime changes for high warning levels
This commit is contained in:
commit
990d4848b2
|
@ -148,4 +148,5 @@ YYYY/MM/DD, github id, Full name, email
|
||||||
2017/05/11, jimallman, Jim Allman, jim@ibang.com
|
2017/05/11, jimallman, Jim Allman, jim@ibang.com
|
||||||
2017/05/26, waf, Will Fuqua, wafuqua@gmail.com
|
2017/05/26, waf, Will Fuqua, wafuqua@gmail.com
|
||||||
2017/05/29, kosak, Corey Kosak, kosak@kosak.com
|
2017/05/29, kosak, Corey Kosak, kosak@kosak.com
|
||||||
|
2017/06/10, jm-mikkelsen, Jan Martin Mikkelsen, janm@transactionware.com
|
||||||
2017/06/25, alimg, Alim Gökkaya, alim.gokkaya@gmail.com
|
2017/06/25, alimg, Alim Gökkaya, alim.gokkaya@gmail.com
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "ANTLRErrorListener.h"
|
||||||
|
|
||||||
|
antlr4::ANTLRErrorListener::~ANTLRErrorListener()
|
||||||
|
{
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ namespace antlr4 {
|
||||||
/// How to emit recognition errors (an interface in Java).
|
/// How to emit recognition errors (an interface in Java).
|
||||||
class ANTLR4CPP_PUBLIC ANTLRErrorListener {
|
class ANTLR4CPP_PUBLIC ANTLRErrorListener {
|
||||||
public:
|
public:
|
||||||
virtual ~ANTLRErrorListener() {};
|
virtual ~ANTLRErrorListener();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Upon syntax error, notify any interested parties. This is not how to
|
/// Upon syntax error, notify any interested parties. This is not how to
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "ANTLRErrorStrategy.h"
|
||||||
|
|
||||||
|
antlr4::ANTLRErrorStrategy::~ANTLRErrorStrategy()
|
||||||
|
{
|
||||||
|
}
|
|
@ -32,7 +32,7 @@ namespace antlr4 {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the error handler state for the specified {@code recognizer}. </summary>
|
/// Reset the error handler state for the specified {@code recognizer}. </summary>
|
||||||
/// <param name="recognizer"> the parser instance </param>
|
/// <param name="recognizer"> the parser instance </param>
|
||||||
virtual ~ANTLRErrorStrategy() {};
|
virtual ~ANTLRErrorStrategy();
|
||||||
|
|
||||||
virtual void reset(Parser *recognizer) = 0;
|
virtual void reset(Parser *recognizer) = 0;
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ size_t ANTLRInputStream::LA(ssize_t i) {
|
||||||
return 0; // undefined
|
return 0; // undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t position = (ssize_t)p;
|
ssize_t position = static_cast<ssize_t>(p);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
i++; // e.g., translate LA(-1) to use offset i=0; then _data[p+0-1]
|
i++; // e.g., translate LA(-1) to use offset i=0; then _data[p+0-1]
|
||||||
if ((position + i - 1) < 0) {
|
if ((position + i - 1) < 0) {
|
||||||
|
@ -79,11 +79,11 @@ size_t ANTLRInputStream::LA(ssize_t i) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((position + i - 1) >= (ssize_t)_data.size()) {
|
if ((position + i - 1) >= static_cast<ssize_t>(_data.size())) {
|
||||||
return IntStream::EOF;
|
return IntStream::EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _data[(size_t)(position + i - 1)];
|
return _data[static_cast<size_t>((position + i - 1))];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ANTLRInputStream::LT(ssize_t i) {
|
size_t ANTLRInputStream::LT(ssize_t i) {
|
||||||
|
@ -123,8 +123,8 @@ std::string ANTLRInputStream::getText(const Interval &interval) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t start = interval.a;
|
size_t start = static_cast<size_t>(interval.a);
|
||||||
size_t stop = interval.b;
|
size_t stop = static_cast<size_t>(interval.b);
|
||||||
|
|
||||||
|
|
||||||
if (stop >= _data.size()) {
|
if (stop >= _data.size()) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ void BailErrorStrategy::recover(Parser *recognizer, std::exception_ptr e) {
|
||||||
context->exception = e;
|
context->exception = e;
|
||||||
if (context->parent == nullptr)
|
if (context->parent == nullptr)
|
||||||
break;
|
break;
|
||||||
context = (ParserRuleContext *)context->parent;
|
context = static_cast<ParserRuleContext *>(context->parent);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,7 +42,7 @@ Token* BailErrorStrategy::recoverInline(Parser *recognizer) {
|
||||||
context->exception = exception;
|
context->exception = exception;
|
||||||
if (context->parent == nullptr)
|
if (context->parent == nullptr)
|
||||||
break;
|
break;
|
||||||
context = (ParserRuleContext *)context->parent;
|
context = static_cast<ParserRuleContext *>(context->parent);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -96,7 +96,7 @@ size_t BufferedTokenStream::fetch(size_t n) {
|
||||||
std::unique_ptr<Token> t(_tokenSource->nextToken());
|
std::unique_ptr<Token> t(_tokenSource->nextToken());
|
||||||
|
|
||||||
if (is<WritableToken *>(t.get())) {
|
if (is<WritableToken *>(t.get())) {
|
||||||
(static_cast<WritableToken *>(t.get()))->setTokenIndex((int)_tokens.size());
|
(static_cast<WritableToken *>(t.get()))->setTokenIndex(_tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
_tokens.push_back(std::move(t));
|
_tokens.push_back(std::move(t));
|
||||||
|
@ -272,7 +272,7 @@ ssize_t BufferedTokenStream::previousTokenOnChannel(size_t i, size_t channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return i;
|
break;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -289,7 +289,7 @@ std::vector<Token *> BufferedTokenStream::getHiddenTokensToRight(size_t tokenInd
|
||||||
size_t from = tokenIndex + 1;
|
size_t from = tokenIndex + 1;
|
||||||
// if none onchannel to right, nextOnChannel=-1 so set to = last token
|
// if none onchannel to right, nextOnChannel=-1 so set to = last token
|
||||||
if (nextOnChannel == -1) {
|
if (nextOnChannel == -1) {
|
||||||
to = (ssize_t)size() - 1;
|
to = static_cast<ssize_t>(size() - 1);
|
||||||
} else {
|
} else {
|
||||||
to = nextOnChannel;
|
to = nextOnChannel;
|
||||||
}
|
}
|
||||||
|
@ -313,11 +313,11 @@ std::vector<Token *> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenInde
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t prevOnChannel = previousTokenOnChannel(tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
|
ssize_t prevOnChannel = previousTokenOnChannel(tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
|
||||||
if (prevOnChannel == (ssize_t)tokenIndex - 1) {
|
if (prevOnChannel == static_cast<ssize_t>(tokenIndex - 1)) {
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
// if none onchannel to left, prevOnChannel=-1 then from=0
|
// if none onchannel to left, prevOnChannel=-1 then from=0
|
||||||
size_t from = (size_t)(prevOnChannel + 1);
|
size_t from = static_cast<size_t>(prevOnChannel + 1);
|
||||||
size_t to = tokenIndex - 1;
|
size_t to = tokenIndex - 1;
|
||||||
|
|
||||||
return filterForChannel(from, to, channel);
|
return filterForChannel(from, to, channel);
|
||||||
|
@ -336,7 +336,7 @@ std::vector<Token *> BufferedTokenStream::filterForChannel(size_t from, size_t t
|
||||||
hidden.push_back(t);
|
hidden.push_back(t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (t->getChannel() == (size_t)channel) {
|
if (t->getChannel() == static_cast<size_t>(channel)) {
|
||||||
hidden.push_back(t);
|
hidden.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace antlr4 {
|
||||||
/// A source of characters for an ANTLR lexer.
|
/// A source of characters for an ANTLR lexer.
|
||||||
class ANTLR4CPP_PUBLIC CharStream : public IntStream {
|
class ANTLR4CPP_PUBLIC CharStream : public IntStream {
|
||||||
public:
|
public:
|
||||||
virtual ~CharStream() = 0;
|
virtual ~CharStream();
|
||||||
|
|
||||||
/// This method returns the text for a range of characters within this input
|
/// This method returns the text for a range of characters within this input
|
||||||
/// stream. This method is guaranteed to not throw an exception if the
|
/// stream. This method is guaranteed to not throw an exception if the
|
||||||
|
|
|
@ -35,7 +35,7 @@ CommonToken::CommonToken(std::pair<TokenSource*, CharStream*> source, size_t typ
|
||||||
_start = start;
|
_start = start;
|
||||||
_stop = stop;
|
_stop = stop;
|
||||||
if (_source.first != nullptr) {
|
if (_source.first != nullptr) {
|
||||||
_line = (int)source.first->getLine();
|
_line = static_cast<int>(source.first->getLine());
|
||||||
_charPositionInLine = source.first->getCharPositionInLine();
|
_charPositionInLine = source.first->getCharPositionInLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ using namespace antlr4;
|
||||||
|
|
||||||
const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
|
const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
|
||||||
|
|
||||||
CommonTokenFactory::CommonTokenFactory(bool copyText) : copyText(copyText) {
|
CommonTokenFactory::CommonTokenFactory(bool copyText_) : copyText(copyText_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) {
|
CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ using namespace antlr4;
|
||||||
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : CommonTokenStream(tokenSource, Token::DEFAULT_CHANNEL) {
|
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : CommonTokenStream(tokenSource, Token::DEFAULT_CHANNEL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel)
|
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel_)
|
||||||
: BufferedTokenStream(tokenSource), channel(channel) {
|
: BufferedTokenStream(tokenSource), channel(channel_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t CommonTokenStream::adjustSeekIndex(size_t i) {
|
ssize_t CommonTokenStream::adjustSeekIndex(size_t i) {
|
||||||
|
@ -25,7 +25,7 @@ Token* CommonTokenStream::LB(size_t k) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t i = (ssize_t)_p;
|
ssize_t i = static_cast<ssize_t>(_p);
|
||||||
size_t n = 1;
|
size_t n = 1;
|
||||||
// find k good tokens looking backwards
|
// find k good tokens looking backwards
|
||||||
while (n <= k) {
|
while (n <= k) {
|
||||||
|
@ -46,7 +46,7 @@ Token* CommonTokenStream::LT(ssize_t k) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
return LB((size_t)-k);
|
return LB(static_cast<size_t>(-k));
|
||||||
}
|
}
|
||||||
size_t i = _p;
|
size_t i = _p;
|
||||||
ssize_t n = 1; // we know tokens[p] is a good one
|
ssize_t n = 1; // we know tokens[p] is a good one
|
||||||
|
|
|
@ -62,18 +62,18 @@ void DefaultErrorStrategy::reportError(Parser *recognizer, const RecognitionExce
|
||||||
|
|
||||||
beginErrorCondition(recognizer);
|
beginErrorCondition(recognizer);
|
||||||
if (is<const NoViableAltException *>(&e)) {
|
if (is<const NoViableAltException *>(&e)) {
|
||||||
reportNoViableAlternative(recognizer, (const NoViableAltException &)e);
|
reportNoViableAlternative(recognizer, static_cast<const NoViableAltException &>(e));
|
||||||
} else if (is<const InputMismatchException *>(&e)) {
|
} else if (is<const InputMismatchException *>(&e)) {
|
||||||
reportInputMismatch(recognizer, (const InputMismatchException &)e);
|
reportInputMismatch(recognizer, static_cast<const InputMismatchException &>(e));
|
||||||
} else if (is<const FailedPredicateException *>(&e)) {
|
} else if (is<const FailedPredicateException *>(&e)) {
|
||||||
reportFailedPredicate(recognizer, (const FailedPredicateException &)e);
|
reportFailedPredicate(recognizer, static_cast<const FailedPredicateException &>(e));
|
||||||
} else if (is<const RecognitionException *>(&e)) {
|
} else if (is<const RecognitionException *>(&e)) {
|
||||||
recognizer->notifyErrorListeners(e.getOffendingToken(), e.what(), std::current_exception());
|
recognizer->notifyErrorListeners(e.getOffendingToken(), e.what(), std::current_exception());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultErrorStrategy::recover(Parser *recognizer, std::exception_ptr /*e*/) {
|
void DefaultErrorStrategy::recover(Parser *recognizer, std::exception_ptr /*e*/) {
|
||||||
if (lastErrorIndex == (int)recognizer->getInputStream()->index() &&
|
if (lastErrorIndex == static_cast<int>(recognizer->getInputStream()->index()) &&
|
||||||
lastErrorStates.contains(recognizer->getState())) {
|
lastErrorStates.contains(recognizer->getState())) {
|
||||||
|
|
||||||
// uh oh, another error at same token index and previously-visited
|
// uh oh, another error at same token index and previously-visited
|
||||||
|
@ -82,7 +82,7 @@ void DefaultErrorStrategy::recover(Parser *recognizer, std::exception_ptr /*e*/)
|
||||||
// at least to prevent an infinite loop; this is a failsafe.
|
// at least to prevent an infinite loop; this is a failsafe.
|
||||||
recognizer->consume();
|
recognizer->consume();
|
||||||
}
|
}
|
||||||
lastErrorIndex = (int)recognizer->getInputStream()->index();
|
lastErrorIndex = static_cast<int>(recognizer->getInputStream()->index());
|
||||||
lastErrorStates.add(recognizer->getState());
|
lastErrorStates.add(recognizer->getState());
|
||||||
misc::IntervalSet followSet = getErrorRecoverySet(recognizer);
|
misc::IntervalSet followSet = getErrorRecoverySet(recognizer);
|
||||||
consumeUntil(recognizer, followSet);
|
consumeUntil(recognizer, followSet);
|
||||||
|
@ -312,7 +312,7 @@ misc::IntervalSet DefaultErrorStrategy::getErrorRecoverySet(Parser *recognizer)
|
||||||
|
|
||||||
if (ctx->parent == nullptr)
|
if (ctx->parent == nullptr)
|
||||||
break;
|
break;
|
||||||
ctx = (RuleContext *)ctx->parent;
|
ctx = static_cast<RuleContext *>(ctx->parent);
|
||||||
}
|
}
|
||||||
recoverSet.remove(Token::EPSILON);
|
recoverSet.remove(Token::EPSILON);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ using namespace antlr4;
|
||||||
DiagnosticErrorListener::DiagnosticErrorListener() : DiagnosticErrorListener(true) {
|
DiagnosticErrorListener::DiagnosticErrorListener() : DiagnosticErrorListener(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly) : exactOnly(exactOnly) {
|
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly_) : exactOnly(exactOnly_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
|
@ -53,7 +53,7 @@ void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const
|
||||||
|
|
||||||
std::string DiagnosticErrorListener::getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa) {
|
std::string DiagnosticErrorListener::getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa) {
|
||||||
size_t decision = dfa.decision;
|
size_t decision = dfa.decision;
|
||||||
size_t ruleIndex = ((atn::ATNState*)dfa.atnStartState)->ruleIndex;
|
size_t ruleIndex = (reinterpret_cast<atn::ATNState*>(dfa.atnStartState))->ruleIndex;
|
||||||
|
|
||||||
const std::vector<std::string>& ruleNames = recognizer->getRuleNames();
|
const std::vector<std::string>& ruleNames = recognizer->getRuleNames();
|
||||||
if (ruleIndex == INVALID_INDEX || ruleIndex >= ruleNames.size()) {
|
if (ruleIndex == INVALID_INDEX || ruleIndex >= ruleNames.size()) {
|
||||||
|
|
|
@ -22,3 +22,43 @@ IOException::IOException(const std::string &msg) : std::exception(), _message(ms
|
||||||
const char* IOException::what() const NOEXCEPT {
|
const char* IOException::what() const NOEXCEPT {
|
||||||
return _message.c_str();
|
return _message.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------ IllegalStateException -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IllegalStateException::~IllegalStateException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ IllegalArgumentException --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IllegalArgumentException::~IllegalArgumentException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ NullPointerException ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NullPointerException::~NullPointerException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ IndexOutOfBoundsException -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IndexOutOfBoundsException::~IndexOutOfBoundsException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ UnsupportedOperationException ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
UnsupportedOperationException::~UnsupportedOperationException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ EmptyStackException -------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EmptyStackException::~EmptyStackException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ CancellationException -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
CancellationException::~CancellationException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------ ParseCancellationException ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ParseCancellationException::~ParseCancellationException() {
|
||||||
|
}
|
||||||
|
|
|
@ -21,32 +21,51 @@ namespace antlr4 {
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {};
|
IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
IllegalStateException(IllegalStateException const&) = default;
|
||||||
|
~IllegalStateException();
|
||||||
|
IllegalStateException& operator=(IllegalStateException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {};
|
IllegalArgumentException(IllegalArgumentException const&) = default;
|
||||||
|
IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
~IllegalArgumentException();
|
||||||
|
IllegalArgumentException& operator=(IllegalArgumentException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
NullPointerException(const std::string &msg = "") : RuntimeException(msg) {};
|
NullPointerException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
NullPointerException(NullPointerException const&) = default;
|
||||||
|
~NullPointerException();
|
||||||
|
NullPointerException& operator=(NullPointerException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {};
|
IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
IndexOutOfBoundsException(IndexOutOfBoundsException const&) = default;
|
||||||
|
~IndexOutOfBoundsException();
|
||||||
|
IndexOutOfBoundsException& operator=(IndexOutOfBoundsException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {};
|
UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
UnsupportedOperationException(UnsupportedOperationException const&) = default;
|
||||||
|
~UnsupportedOperationException();
|
||||||
|
UnsupportedOperationException& operator=(UnsupportedOperationException const&) = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException {
|
class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException {
|
||||||
public:
|
public:
|
||||||
EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {};
|
EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {}
|
||||||
|
EmptyStackException(EmptyStackException const&) = default;
|
||||||
|
~EmptyStackException();
|
||||||
|
EmptyStackException& operator=(EmptyStackException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// IOException is not a runtime exception (in the java hierarchy).
|
// IOException is not a runtime exception (in the java hierarchy).
|
||||||
|
@ -63,12 +82,18 @@ namespace antlr4 {
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException {
|
class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException {
|
||||||
public:
|
public:
|
||||||
CancellationException(const std::string &msg = "") : IllegalStateException(msg) {};
|
CancellationException(const std::string &msg = "") : IllegalStateException(msg) {}
|
||||||
|
CancellationException(CancellationException const&) = default;
|
||||||
|
~CancellationException();
|
||||||
|
CancellationException& operator=(CancellationException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException {
|
class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException {
|
||||||
public:
|
public:
|
||||||
ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {};
|
ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {}
|
||||||
|
ParseCancellationException(ParseCancellationException const&) = default;
|
||||||
|
~ParseCancellationException();
|
||||||
|
ParseCancellationException& operator=(ParseCancellationException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace antlr4
|
} // namespace antlr4
|
||||||
|
|
|
@ -28,8 +28,8 @@ FailedPredicateException::FailedPredicateException(Parser *recognizer, const std
|
||||||
atn::ATNState *s = recognizer->getInterpreter<atn::ATNSimulator>()->atn.states[recognizer->getState()];
|
atn::ATNState *s = recognizer->getInterpreter<atn::ATNSimulator>()->atn.states[recognizer->getState()];
|
||||||
atn::Transition *transition = s->transitions[0];
|
atn::Transition *transition = s->transitions[0];
|
||||||
if (is<atn::PredicateTransition*>(transition)) {
|
if (is<atn::PredicateTransition*>(transition)) {
|
||||||
_ruleIndex = ((atn::PredicateTransition *)transition)->ruleIndex;
|
_ruleIndex = static_cast<atn::PredicateTransition *>(transition)->ruleIndex;
|
||||||
_predicateIndex = ((atn::PredicateTransition *)transition)->predIndex;
|
_predicateIndex = static_cast<atn::PredicateTransition *>(transition)->predIndex;
|
||||||
} else {
|
} else {
|
||||||
_ruleIndex = 0;
|
_ruleIndex = 0;
|
||||||
_predicateIndex = 0;
|
_predicateIndex = 0;
|
||||||
|
|
|
@ -13,3 +13,6 @@ InputMismatchException::InputMismatchException(Parser *recognizer)
|
||||||
: RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(),
|
: RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(),
|
||||||
recognizer->getCurrentToken()) {
|
recognizer->getCurrentToken()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputMismatchException::~InputMismatchException() {
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,9 @@ namespace antlr4 {
|
||||||
class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException {
|
class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException {
|
||||||
public:
|
public:
|
||||||
InputMismatchException(Parser *recognizer);
|
InputMismatchException(Parser *recognizer);
|
||||||
|
InputMismatchException(InputMismatchException const&) = default;
|
||||||
|
~InputMismatchException();
|
||||||
|
InputMismatchException& operator=(InputMismatchException const&) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace antlr4
|
} // namespace antlr4
|
||||||
|
|
|
@ -8,3 +8,5 @@
|
||||||
using namespace antlr4;
|
using namespace antlr4;
|
||||||
|
|
||||||
const std::string IntStream::UNKNOWN_SOURCE_NAME = "<unknown>";
|
const std::string IntStream::UNKNOWN_SOURCE_NAME = "<unknown>";
|
||||||
|
|
||||||
|
IntStream::~IntStream() = default;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace antlr4 {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ANTLR4CPP_PUBLIC IntStream {
|
class ANTLR4CPP_PUBLIC IntStream {
|
||||||
public:
|
public:
|
||||||
static const size_t EOF = (size_t)-1;
|
static const size_t EOF = std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
/// The value returned by <seealso cref="#LA LA()"/> when the end of the stream is
|
/// The value returned by <seealso cref="#LA LA()"/> when the end of the stream is
|
||||||
/// reached.
|
/// reached.
|
||||||
|
@ -40,7 +40,7 @@ namespace antlr4 {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const std::string UNKNOWN_SOURCE_NAME;
|
static const std::string UNKNOWN_SOURCE_NAME;
|
||||||
|
|
||||||
virtual ~IntStream() {};
|
virtual ~IntStream();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Consumes the current symbol in the stream. This method has the following
|
/// Consumes the current symbol in the stream. This method has the following
|
||||||
|
|
|
@ -19,8 +19,8 @@ namespace antlr4 {
|
||||||
class ANTLR4CPP_PUBLIC Lexer : public Recognizer, public TokenSource {
|
class ANTLR4CPP_PUBLIC Lexer : public Recognizer, public TokenSource {
|
||||||
public:
|
public:
|
||||||
static const size_t DEFAULT_MODE = 0;
|
static const size_t DEFAULT_MODE = 0;
|
||||||
static const size_t MORE = (size_t)-2;
|
static const size_t MORE = static_cast<size_t>(-2);
|
||||||
static const size_t SKIP = (size_t)-3;
|
static const size_t SKIP = static_cast<size_t>(-3);
|
||||||
|
|
||||||
static const size_t DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
|
static const size_t DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
|
||||||
static const size_t HIDDEN = Token::HIDDEN_CHANNEL;
|
static const size_t HIDDEN = Token::HIDDEN_CHANNEL;
|
||||||
|
|
|
@ -28,7 +28,7 @@ atn::ATNConfigSet* LexerNoViableAltException::getDeadEndConfigs() {
|
||||||
std::string LexerNoViableAltException::toString() {
|
std::string LexerNoViableAltException::toString() {
|
||||||
std::string symbol;
|
std::string symbol;
|
||||||
if (_startIndex < getInputStream()->size()) {
|
if (_startIndex < getInputStream()->size()) {
|
||||||
symbol = ((CharStream *)getInputStream())->getText(misc::Interval(_startIndex, _startIndex));
|
symbol = static_cast<CharStream *>(getInputStream())->getText(misc::Interval(_startIndex, _startIndex));
|
||||||
symbol = antlrcpp::escapeWhitespace(symbol, false);
|
symbol = antlrcpp::escapeWhitespace(symbol, false);
|
||||||
}
|
}
|
||||||
std::string format = "LexerNoViableAltException('" + symbol + "')";
|
std::string format = "LexerNoViableAltException('" + symbol + "')";
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
using namespace antlr4;
|
using namespace antlr4;
|
||||||
|
|
||||||
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens) : ListTokenSource(std::move(tokens), "") {
|
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_) : ListTokenSource(std::move(tokens_), "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_, const std::string &sourceName_)
|
ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_, const std::string &sourceName_)
|
||||||
|
@ -32,7 +32,7 @@ ListTokenSource::ListTokenSource(std::vector<std::unique_ptr<Token>> tokens_, co
|
||||||
|
|
||||||
size_t stop = std::max(INVALID_INDEX, start - 1);
|
size_t stop = std::max(INVALID_INDEX, start - 1);
|
||||||
tokens.emplace_back((_factory->create({ this, getInputStream() }, Token::EOF, "EOF",
|
tokens.emplace_back((_factory->create({ this, getInputStream() }, Token::EOF, "EOF",
|
||||||
Token::DEFAULT_CHANNEL, start, stop, (int)lastToken->getLine(), lastToken->getCharPositionInLine())));
|
Token::DEFAULT_CHANNEL, start, stop, static_cast<int>(lastToken->getLine()), lastToken->getCharPositionInLine())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ using namespace antlrcpp;
|
||||||
|
|
||||||
std::map<std::vector<uint16_t>, atn::ATN> Parser::bypassAltsAtnCache;
|
std::map<std::vector<uint16_t>, atn::ATN> Parser::bypassAltsAtnCache;
|
||||||
|
|
||||||
Parser::TraceListener::TraceListener(Parser *outerInstance) : outerInstance(outerInstance) {
|
Parser::TraceListener::TraceListener(Parser *outerInstance_) : outerInstance(outerInstance_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Parser::TraceListener::~TraceListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TraceListener::enterEveryRule(ParserRuleContext *ctx) {
|
void Parser::TraceListener::enterEveryRule(ParserRuleContext *ctx) {
|
||||||
|
@ -56,6 +59,9 @@ void Parser::TraceListener::exitEveryRule(ParserRuleContext *ctx) {
|
||||||
|
|
||||||
Parser::TrimToSizeListener Parser::TrimToSizeListener::INSTANCE;
|
Parser::TrimToSizeListener Parser::TrimToSizeListener::INSTANCE;
|
||||||
|
|
||||||
|
Parser::TrimToSizeListener::~TrimToSizeListener() {
|
||||||
|
}
|
||||||
|
|
||||||
void Parser::TrimToSizeListener::enterEveryRule(ParserRuleContext * /*ctx*/) {
|
void Parser::TrimToSizeListener::enterEveryRule(ParserRuleContext * /*ctx*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace antlr4 {
|
||||||
class TraceListener : public tree::ParseTreeListener {
|
class TraceListener : public tree::ParseTreeListener {
|
||||||
public:
|
public:
|
||||||
TraceListener(Parser *outerInstance);
|
TraceListener(Parser *outerInstance);
|
||||||
virtual ~TraceListener() {};
|
virtual ~TraceListener();
|
||||||
|
|
||||||
virtual void enterEveryRule(ParserRuleContext *ctx) override;
|
virtual void enterEveryRule(ParserRuleContext *ctx) override;
|
||||||
virtual void visitTerminal(tree::TerminalNode *node) override;
|
virtual void visitTerminal(tree::TerminalNode *node) override;
|
||||||
|
@ -36,7 +36,7 @@ namespace antlr4 {
|
||||||
public:
|
public:
|
||||||
static TrimToSizeListener INSTANCE;
|
static TrimToSizeListener INSTANCE;
|
||||||
|
|
||||||
virtual ~TrimToSizeListener() {};
|
virtual ~TrimToSizeListener();
|
||||||
|
|
||||||
virtual void enterEveryRule(ParserRuleContext *ctx) override;
|
virtual void enterEveryRule(ParserRuleContext *ctx) override;
|
||||||
virtual void visitTerminal(tree::TerminalNode *node) override;
|
virtual void visitTerminal(tree::TerminalNode *node) override;
|
||||||
|
@ -375,7 +375,7 @@ namespace antlr4 {
|
||||||
*/
|
*/
|
||||||
bool isTrace() const;
|
bool isTrace() const;
|
||||||
|
|
||||||
tree::ParseTreeTracker& getTreeTracker() { return _tracker; };
|
tree::ParseTreeTracker& getTreeTracker() { return _tracker; }
|
||||||
|
|
||||||
/** How to create a token leaf node associated with a parent.
|
/** How to create a token leaf node associated with a parent.
|
||||||
* Typically, the terminal node to create is not a function of the parent
|
* Typically, the terminal node to create is not a function of the parent
|
||||||
|
|
|
@ -174,19 +174,19 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
// We are at the start of a left recursive rule's (...)* loop
|
// We are at the start of a left recursive rule's (...)* loop
|
||||||
// and we're not taking the exit branch of loop.
|
// and we're not taking the exit branch of loop.
|
||||||
InterpreterRuleContext *localctx = createInterpreterRuleContext(_parentContextStack.top().first,
|
InterpreterRuleContext *localctx = createInterpreterRuleContext(_parentContextStack.top().first,
|
||||||
_parentContextStack.top().second, (int)_ctx->getRuleIndex());
|
_parentContextStack.top().second, static_cast<int>(_ctx->getRuleIndex()));
|
||||||
pushNewRecursionContext(localctx, _atn.ruleToStartState[p->ruleIndex]->stateNumber, (int)_ctx->getRuleIndex());
|
pushNewRecursionContext(localctx, _atn.ruleToStartState[p->ruleIndex]->stateNumber, static_cast<int>(_ctx->getRuleIndex()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case atn::Transition::ATOM:
|
case atn::Transition::ATOM:
|
||||||
match((int)((atn::AtomTransition*)(transition))->_label);
|
match(static_cast<int>(static_cast<atn::AtomTransition*>(transition)->_label));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case atn::Transition::RANGE:
|
case atn::Transition::RANGE:
|
||||||
case atn::Transition::SET:
|
case atn::Transition::SET:
|
||||||
case atn::Transition::NOT_SET:
|
case atn::Transition::NOT_SET:
|
||||||
if (!transition->matches((int)_input->LA(1), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
|
if (!transition->matches(static_cast<int>(_input->LA(1)), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
|
||||||
recoverInline();
|
recoverInline();
|
||||||
}
|
}
|
||||||
matchWildcard();
|
matchWildcard();
|
||||||
|
@ -198,11 +198,11 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
|
|
||||||
case atn::Transition::RULE:
|
case atn::Transition::RULE:
|
||||||
{
|
{
|
||||||
atn::RuleStartState *ruleStartState = (atn::RuleStartState*)(transition->target);
|
atn::RuleStartState *ruleStartState = static_cast<atn::RuleStartState*>(transition->target);
|
||||||
size_t ruleIndex = ruleStartState->ruleIndex;
|
size_t ruleIndex = ruleStartState->ruleIndex;
|
||||||
InterpreterRuleContext *newctx = createInterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
|
InterpreterRuleContext *newctx = createInterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
|
||||||
if (ruleStartState->isLeftRecursiveRule) {
|
if (ruleStartState->isLeftRecursiveRule) {
|
||||||
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, ((atn::RuleTransition*)(transition))->precedence);
|
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<atn::RuleTransition*>(transition)->precedence);
|
||||||
} else {
|
} else {
|
||||||
enterRule(newctx, transition->target->stateNumber, ruleIndex);
|
enterRule(newctx, transition->target->stateNumber, ruleIndex);
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
|
|
||||||
case atn::Transition::PREDICATE:
|
case atn::Transition::PREDICATE:
|
||||||
{
|
{
|
||||||
atn::PredicateTransition *predicateTransition = (atn::PredicateTransition*)(transition);
|
atn::PredicateTransition *predicateTransition = static_cast<atn::PredicateTransition*>(transition);
|
||||||
if (!sempred(_ctx, predicateTransition->ruleIndex, predicateTransition->predIndex)) {
|
if (!sempred(_ctx, predicateTransition->ruleIndex, predicateTransition->predIndex)) {
|
||||||
throw FailedPredicateException(this);
|
throw FailedPredicateException(this);
|
||||||
}
|
}
|
||||||
|
@ -220,15 +220,15 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
|
|
||||||
case atn::Transition::ACTION:
|
case atn::Transition::ACTION:
|
||||||
{
|
{
|
||||||
atn::ActionTransition *actionTransition = (atn::ActionTransition*)(transition);
|
atn::ActionTransition *actionTransition = static_cast<atn::ActionTransition*>(transition);
|
||||||
action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
|
action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case atn::Transition::PRECEDENCE:
|
case atn::Transition::PRECEDENCE:
|
||||||
{
|
{
|
||||||
if (!precpred(_ctx, ((atn::PrecedencePredicateTransition*)(transition))->precedence)) {
|
if (!precpred(_ctx, static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence)) {
|
||||||
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(((atn::PrecedencePredicateTransition*)(transition))->precedence) + ")");
|
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<atn::PrecedencePredicateTransition*>(transition)->precedence) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -283,7 +283,7 @@ void ParserInterpreter::recover(RecognitionException &e) {
|
||||||
if (_input->index() == i) {
|
if (_input->index() == i) {
|
||||||
// no input consumed, better add an error node
|
// no input consumed, better add an error node
|
||||||
if (is<InputMismatchException *>(&e)) {
|
if (is<InputMismatchException *>(&e)) {
|
||||||
InputMismatchException &ime = (InputMismatchException&)e;
|
InputMismatchException &ime = static_cast<InputMismatchException&>(e);
|
||||||
Token *tok = e.getOffendingToken();
|
Token *tok = e.getOffendingToken();
|
||||||
size_t expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
|
size_t expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
|
||||||
_errorToken = getTokenFactory()->create({ tok->getTokenSource(), tok->getTokenSource()->getInputStream() },
|
_errorToken = getTokenFactory()->create({ tok->getTokenSource(), tok->getTokenSource()->getInputStream() },
|
||||||
|
|
|
@ -27,6 +27,9 @@ RecognitionException::RecognitionException(const std::string &message, Recognize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecognitionException::~RecognitionException() {
|
||||||
|
}
|
||||||
|
|
||||||
size_t RecognitionException::getOffendingState() const {
|
size_t RecognitionException::getOffendingState() const {
|
||||||
return _offendingState;
|
return _offendingState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,9 @@ namespace antlr4 {
|
||||||
Token *offendingToken = nullptr);
|
Token *offendingToken = nullptr);
|
||||||
RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input,
|
RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input,
|
||||||
ParserRuleContext *ctx, Token *offendingToken = nullptr);
|
ParserRuleContext *ctx, Token *offendingToken = nullptr);
|
||||||
~RecognitionException() {}
|
RecognitionException(RecognitionException const&) = default;
|
||||||
|
~RecognitionException();
|
||||||
|
RecognitionException& operator=(RecognitionException const&) = default;
|
||||||
|
|
||||||
/// Get the ATN state number the parser was in at the time the error
|
/// Get the ATN state number the parser was in at the time the error
|
||||||
/// occurred. For NoViableAltException and
|
/// occurred. For NoViableAltException and
|
||||||
|
|
|
@ -27,6 +27,9 @@ Recognizer::Recognizer() {
|
||||||
_proxListener.addErrorListener(&ConsoleErrorListener::INSTANCE);
|
_proxListener.addErrorListener(&ConsoleErrorListener::INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Recognizer::~Recognizer() {
|
||||||
|
}
|
||||||
|
|
||||||
dfa::Vocabulary const& Recognizer::getVocabulary() const {
|
dfa::Vocabulary const& Recognizer::getVocabulary() const {
|
||||||
static dfa::Vocabulary vocabulary = dfa::Vocabulary::fromTokenNames(getTokenNames());
|
static dfa::Vocabulary vocabulary = dfa::Vocabulary::fromTokenNames(getTokenNames());
|
||||||
return vocabulary;
|
return vocabulary;
|
||||||
|
|
|
@ -11,10 +11,13 @@ namespace antlr4 {
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC Recognizer {
|
class ANTLR4CPP_PUBLIC Recognizer {
|
||||||
public:
|
public:
|
||||||
static const size_t EOF = (size_t)-1;
|
static const size_t EOF = std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
Recognizer();
|
Recognizer();
|
||||||
virtual ~Recognizer() {};
|
Recognizer(Recognizer const&) = delete;
|
||||||
|
virtual ~Recognizer();
|
||||||
|
|
||||||
|
Recognizer& operator=(Recognizer const&) = delete;
|
||||||
|
|
||||||
/** Used to print out token names like ID during debugging and
|
/** Used to print out token names like ID during debugging and
|
||||||
* error reporting. The generated parsers implement a method
|
* error reporting. The generated parsers implement a method
|
||||||
|
|
|
@ -19,10 +19,10 @@ RuleContext::RuleContext() {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleContext::RuleContext(RuleContext *parent, size_t invokingState) {
|
RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
this->parent = parent;
|
this->parent = parent_;
|
||||||
this->invokingState = invokingState;
|
this->invokingState = invokingState_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RuleContext::depth() {
|
int RuleContext::depth() {
|
||||||
|
@ -31,7 +31,7 @@ int RuleContext::depth() {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (p->parent == nullptr)
|
if (p->parent == nullptr)
|
||||||
break;
|
break;
|
||||||
p = (RuleContext *)p->parent;
|
p = static_cast<RuleContext *>(p->parent);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
@ -112,7 +112,7 @@ std::string RuleContext::toString(const std::vector<std::string> &ruleNames, Rul
|
||||||
|
|
||||||
if (currentParent->parent == nullptr) // No parent anymore.
|
if (currentParent->parent == nullptr) // No parent anymore.
|
||||||
break;
|
break;
|
||||||
currentParent = (RuleContext *)currentParent->parent;
|
currentParent = static_cast<RuleContext *>(currentParent->parent);
|
||||||
if (!ruleNames.empty() || !currentParent->isEmpty()) {
|
if (!ruleNames.empty() || !currentParent->isEmpty()) {
|
||||||
ss << " ";
|
ss << " ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "Token.h"
|
||||||
|
|
||||||
|
antlr4::Token::~Token() {
|
||||||
|
}
|
|
@ -18,11 +18,11 @@ namespace antlr4 {
|
||||||
|
|
||||||
/// During lookahead operations, this "token" signifies we hit rule end ATN state
|
/// During lookahead operations, this "token" signifies we hit rule end ATN state
|
||||||
/// and did not follow it despite needing to.
|
/// and did not follow it despite needing to.
|
||||||
static const size_t EPSILON = (size_t)-2;
|
static const size_t EPSILON = std::numeric_limits<size_t>::max() - 1;
|
||||||
static const size_t MIN_USER_TOKEN_TYPE = 1;
|
static const size_t MIN_USER_TOKEN_TYPE = 1;
|
||||||
static const size_t EOF = IntStream::EOF;
|
static const size_t EOF = IntStream::EOF;
|
||||||
|
|
||||||
virtual ~Token() {};
|
virtual ~Token();
|
||||||
|
|
||||||
/// All tokens go to the parser (unless skip() is called in that rule)
|
/// All tokens go to the parser (unless skip() is called in that rule)
|
||||||
/// on a particular "channel". The parser tunes to a particular channel
|
/// on a particular "channel". The parser tunes to a particular channel
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace antlr4 {
|
||||||
template<typename Symbol>
|
template<typename Symbol>
|
||||||
class ANTLR4CPP_PUBLIC TokenFactory {
|
class ANTLR4CPP_PUBLIC TokenFactory {
|
||||||
public:
|
public:
|
||||||
virtual ~TokenFactory() {};
|
virtual ~TokenFactory() {}
|
||||||
|
|
||||||
/// This is the method used to create tokens in the lexer and in the
|
/// This is the method used to create tokens in the lexer and in the
|
||||||
/// error handling strategy. If text!=null, than the start and stop positions
|
/// error handling strategy. If text!=null, than the start and stop positions
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "TokenSource.h"
|
||||||
|
|
||||||
|
antlr4::TokenSource::~TokenSource() {
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ namespace antlr4 {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ANTLR4CPP_PUBLIC TokenSource {
|
class ANTLR4CPP_PUBLIC TokenSource {
|
||||||
public:
|
public:
|
||||||
virtual ~TokenSource() {};
|
virtual ~TokenSource();
|
||||||
|
|
||||||
/// Return a <seealso cref="Token"/> object from your input stream (usually a
|
/// Return a <seealso cref="Token"/> object from your input stream (usually a
|
||||||
/// <seealso cref="CharStream"/>). Do not fail/return upon lexing error; keep chewing
|
/// <seealso cref="CharStream"/>). Do not fail/return upon lexing error; keep chewing
|
||||||
|
|
|
@ -14,19 +14,23 @@ using namespace antlr4;
|
||||||
|
|
||||||
using antlr4::misc::Interval;
|
using antlr4::misc::Interval;
|
||||||
|
|
||||||
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance, size_t index)
|
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance_, size_t index_)
|
||||||
: outerInstance(outerInstance) {
|
: outerInstance(outerInstance_) {
|
||||||
|
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
this->index = index;
|
this->index = index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance, size_t index,
|
TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *outerInstance_, size_t index_,
|
||||||
const std::string& text) : outerInstance(outerInstance) {
|
const std::string& text_) : outerInstance(outerInstance_) {
|
||||||
|
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
this->index = index;
|
this->index = index_;
|
||||||
this->text = text;
|
this->text = text_;
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenStreamRewriter::RewriteOperation::~RewriteOperation()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TokenStreamRewriter::RewriteOperation::execute(std::string * /*buf*/) {
|
size_t TokenStreamRewriter::RewriteOperation::execute(std::string * /*buf*/) {
|
||||||
|
@ -45,8 +49,8 @@ void TokenStreamRewriter::RewriteOperation::InitializeInstanceFields() {
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStreamRewriter::InsertBeforeOp::InsertBeforeOp(TokenStreamRewriter *outerInstance, size_t index, const std::string& text)
|
TokenStreamRewriter::InsertBeforeOp::InsertBeforeOp(TokenStreamRewriter *outerInstance_, size_t index_, const std::string& text_)
|
||||||
: RewriteOperation(outerInstance, index, text), outerInstance(outerInstance) {
|
: RewriteOperation(outerInstance_, index_, text_), outerInstance(outerInstance_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TokenStreamRewriter::InsertBeforeOp::execute(std::string *buf) {
|
size_t TokenStreamRewriter::InsertBeforeOp::execute(std::string *buf) {
|
||||||
|
@ -57,8 +61,8 @@ size_t TokenStreamRewriter::InsertBeforeOp::execute(std::string *buf) {
|
||||||
return index + 1;
|
return index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStreamRewriter::ReplaceOp::ReplaceOp(TokenStreamRewriter *outerInstance, size_t from, size_t to, const std::string& text)
|
TokenStreamRewriter::ReplaceOp::ReplaceOp(TokenStreamRewriter *outerInstance_, size_t from, size_t to, const std::string& text)
|
||||||
: RewriteOperation(outerInstance, from, text), outerInstance(outerInstance) {
|
: RewriteOperation(outerInstance_, from, text), outerInstance(outerInstance_) {
|
||||||
|
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
lastIndex = to;
|
lastIndex = to;
|
||||||
|
@ -84,7 +88,7 @@ void TokenStreamRewriter::ReplaceOp::InitializeInstanceFields() {
|
||||||
|
|
||||||
const std::string TokenStreamRewriter::DEFAULT_PROGRAM_NAME = "default";
|
const std::string TokenStreamRewriter::DEFAULT_PROGRAM_NAME = "default";
|
||||||
|
|
||||||
TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens) : tokens(tokens) {
|
TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_) {
|
||||||
_programs[DEFAULT_PROGRAM_NAME].reserve(PROGRAM_INIT_SIZE);
|
_programs[DEFAULT_PROGRAM_NAME].reserve(PROGRAM_INIT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,10 +417,10 @@ std::string TokenStreamRewriter::catOpText(std::string *a, std::string *b) {
|
||||||
std::string x = "";
|
std::string x = "";
|
||||||
std::string y = "";
|
std::string y = "";
|
||||||
if (a != nullptr) {
|
if (a != nullptr) {
|
||||||
x = std::string(*a);
|
x = *a;
|
||||||
}
|
}
|
||||||
if (b != nullptr) {
|
if (b != nullptr) {
|
||||||
y = std::string(*b);
|
y = *b;
|
||||||
}
|
}
|
||||||
return x + y;
|
return x + y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace antlr4 {
|
||||||
|
|
||||||
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index);
|
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index);
|
||||||
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
|
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
|
||||||
virtual ~RewriteOperation() {};
|
virtual ~RewriteOperation();
|
||||||
|
|
||||||
/// Execute the rewrite operation by possibly adding to the buffer.
|
/// Execute the rewrite operation by possibly adding to the buffer.
|
||||||
/// Return the index of the next token to operate on.
|
/// Return the index of the next token to operate on.
|
||||||
|
|
|
@ -22,6 +22,9 @@ Vocabulary::Vocabulary(const std::vector<std::string> &literalNames,
|
||||||
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
|
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vocabulary::~Vocabulary() {
|
||||||
|
}
|
||||||
|
|
||||||
Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
|
Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
|
||||||
if (tokenNames.empty()) {
|
if (tokenNames.empty()) {
|
||||||
return EMPTY_VOCABULARY;
|
return EMPTY_VOCABULARY;
|
||||||
|
|
|
@ -14,7 +14,9 @@ namespace dfa {
|
||||||
/// interface.
|
/// interface.
|
||||||
class ANTLR4CPP_PUBLIC Vocabulary {
|
class ANTLR4CPP_PUBLIC Vocabulary {
|
||||||
public:
|
public:
|
||||||
virtual ~Vocabulary() {};
|
Vocabulary(Vocabulary const&) = default;
|
||||||
|
virtual ~Vocabulary();
|
||||||
|
Vocabulary& operator=(Vocabulary const&) = default;
|
||||||
|
|
||||||
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
||||||
///
|
///
|
||||||
|
@ -24,7 +26,7 @@ namespace dfa {
|
||||||
/// except <seealso cref="Token#EOF"/>.</para>
|
/// except <seealso cref="Token#EOF"/>.</para>
|
||||||
static const Vocabulary EMPTY_VOCABULARY;
|
static const Vocabulary EMPTY_VOCABULARY;
|
||||||
|
|
||||||
Vocabulary() {};
|
Vocabulary() {}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
|
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "WritableToken.h"
|
||||||
|
|
||||||
|
antlr4::WritableToken::~WritableToken() {
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ namespace antlr4 {
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC WritableToken : public Token {
|
class ANTLR4CPP_PUBLIC WritableToken : public Token {
|
||||||
public:
|
public:
|
||||||
|
virtual ~WritableToken();
|
||||||
virtual void setText(const std::string &text) = 0;
|
virtual void setText(const std::string &text) = 0;
|
||||||
virtual void setType(size_t ttype) = 0;
|
virtual void setType(size_t ttype) = 0;
|
||||||
virtual void setLine(size_t line) = 0;
|
virtual void setLine(size_t line) = 0;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -76,7 +77,7 @@
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015.
|
class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015.
|
||||||
|
|
||||||
#elif __APPLE__
|
#elif defined(__APPLE__)
|
||||||
typedef std::u32string UTF32String;
|
typedef std::u32string UTF32String;
|
||||||
|
|
||||||
#define GUID_CFUUID
|
#define GUID_CFUUID
|
||||||
|
@ -124,5 +125,5 @@
|
||||||
#undef EOF
|
#undef EOF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INVALID_INDEX (size_t)-1
|
#define INVALID_INDEX std::numeric_limits<size_t>::max()
|
||||||
template<class T> using Ref = std::shared_ptr<T>;
|
template<class T> using Ref = std::shared_ptr<T>;
|
||||||
|
|
|
@ -36,7 +36,7 @@ ATN::ATN(ATN &&other) {
|
||||||
modeToStartState = std::move(other.modeToStartState);
|
modeToStartState = std::move(other.modeToStartState);
|
||||||
}
|
}
|
||||||
|
|
||||||
ATN::ATN(ATNType grammarType, size_t maxTokenType) : grammarType(grammarType), maxTokenType(maxTokenType) {
|
ATN::ATN(ATNType grammarType_, size_t maxTokenType_) : grammarType(grammarType_), maxTokenType(maxTokenType_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATN::~ATN() {
|
ATN::~ATN() {
|
||||||
|
@ -88,9 +88,12 @@ misc::IntervalSet ATN::nextTokens(ATNState *s, RuleContext *ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::IntervalSet& ATN::nextTokens(ATNState *s) const {
|
misc::IntervalSet& ATN::nextTokens(ATNState *s) const {
|
||||||
if (s->nextTokenWithinRule.isEmpty()) {
|
if (!s->nextTokenWithinRule.isReadOnly()) {
|
||||||
s->nextTokenWithinRule = nextTokens(s, nullptr);
|
std::unique_lock<std::mutex> lock { _mutex };
|
||||||
s->nextTokenWithinRule.setReadOnly(true);
|
if (!s->nextTokenWithinRule.isReadOnly()) {
|
||||||
|
s->nextTokenWithinRule = nextTokens(s, nullptr);
|
||||||
|
s->nextTokenWithinRule.setReadOnly(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s->nextTokenWithinRule;
|
return s->nextTokenWithinRule;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,9 @@ namespace atn {
|
||||||
virtual misc::IntervalSet getExpectedTokens(size_t stateNumber, RuleContext *context) const;
|
virtual misc::IntervalSet getExpectedTokens(size_t stateNumber, RuleContext *context) const;
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable std::mutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atn
|
} // namespace atn
|
||||||
|
|
|
@ -13,19 +13,19 @@ using namespace antlr4::atn;
|
||||||
|
|
||||||
const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
|
const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNState *state, size_t alt, Ref<PredictionContext> const& context)
|
ATNConfig::ATNConfig(ATNState *state_, size_t alt_, Ref<PredictionContext> const& context_)
|
||||||
: ATNConfig(state, alt, context, SemanticContext::NONE) {
|
: ATNConfig(state_, alt_, context_, SemanticContext::NONE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNState *state, size_t alt, Ref<PredictionContext> const& context, Ref<SemanticContext> const& semanticContext)
|
ATNConfig::ATNConfig(ATNState *state_, size_t alt_, Ref<PredictionContext> const& context_, Ref<SemanticContext> const& semanticContext_)
|
||||||
: state(state), alt(alt), context(context), semanticContext(semanticContext) {
|
: state(state_), alt(alt_), context(context_), semanticContext(semanticContext_) {
|
||||||
reachesIntoOuterContext = 0;
|
reachesIntoOuterContext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(Ref<ATNConfig> const& c) : ATNConfig(c, c->state, c->context, c->semanticContext) {
|
ATNConfig::ATNConfig(Ref<ATNConfig> const& c) : ATNConfig(c, c->state, c->context, c->semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state) : ATNConfig(c, state, c->context, c->semanticContext) {
|
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state_) : ATNConfig(c, state_, c->context, c->semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<SemanticContext> const& semanticContext)
|
ATNConfig::ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<SemanticContext> const& semanticContext)
|
||||||
|
|
|
@ -85,7 +85,9 @@ namespace atn {
|
||||||
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context);
|
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context);
|
||||||
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context, Ref<SemanticContext> const& semanticContext);
|
ATNConfig(Ref<ATNConfig> const& c, ATNState *state, Ref<PredictionContext> const& context, Ref<SemanticContext> const& semanticContext);
|
||||||
|
|
||||||
|
ATNConfig(ATNConfig const&) = default;
|
||||||
virtual ~ATNConfig();
|
virtual ~ATNConfig();
|
||||||
|
ATNConfig& operator=(ATNConfig const&) = default;
|
||||||
|
|
||||||
virtual size_t hashCode() const;
|
virtual size_t hashCode() const;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *
|
||||||
this->generateRuleBypassTransitions = options->generateRuleBypassTransitions;
|
this->generateRuleBypassTransitions = options->generateRuleBypassTransitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATNDeserializationOptions::~ATNDeserializationOptions() {
|
||||||
|
}
|
||||||
|
|
||||||
const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
|
const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
|
||||||
return defaultOptions;
|
return defaultOptions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,9 @@ namespace atn {
|
||||||
public:
|
public:
|
||||||
ATNDeserializationOptions();
|
ATNDeserializationOptions();
|
||||||
ATNDeserializationOptions(ATNDeserializationOptions *options);
|
ATNDeserializationOptions(ATNDeserializationOptions *options);
|
||||||
virtual ~ATNDeserializationOptions() {};
|
ATNDeserializationOptions(ATNDeserializationOptions const&) = default;
|
||||||
|
virtual ~ATNDeserializationOptions();
|
||||||
|
ATNDeserializationOptions& operator=(ATNDeserializationOptions const&) = default;
|
||||||
|
|
||||||
static const ATNDeserializationOptions& getDefaultOptions();
|
static const ATNDeserializationOptions& getDefaultOptions();
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
|
|
||||||
#include "atn/ATNDeserializer.h"
|
#include "atn/ATNDeserializer.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace antlr4;
|
using namespace antlr4;
|
||||||
using namespace antlr4::atn;
|
using namespace antlr4::atn;
|
||||||
using namespace antlrcpp;
|
using namespace antlrcpp;
|
||||||
|
@ -108,6 +110,9 @@ ATNDeserializer::ATNDeserializer(): ATNDeserializer(ATNDeserializationOptions::g
|
||||||
ATNDeserializer::ATNDeserializer(const ATNDeserializationOptions& dso): deserializationOptions(dso) {
|
ATNDeserializer::ATNDeserializer(const ATNDeserializationOptions& dso): deserializationOptions(dso) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATNDeserializer::~ATNDeserializer() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This value should never change. Updates following this version are
|
* This value should never change. Updates following this version are
|
||||||
* reflected as change in the unique ID SERIALIZED_UUID.
|
* reflected as change in the unique ID SERIALIZED_UUID.
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace atn {
|
||||||
|
|
||||||
ATNDeserializer();
|
ATNDeserializer();
|
||||||
ATNDeserializer(const ATNDeserializationOptions& dso);
|
ATNDeserializer(const ATNDeserializationOptions& dso);
|
||||||
virtual ~ATNDeserializer() {};
|
virtual ~ATNDeserializer();
|
||||||
|
|
||||||
static Guid toUUID(const unsigned short *data, size_t offset);
|
static Guid toUUID(const unsigned short *data, size_t offset);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ ATNSerializer::ATNSerializer(ATN *atn, const std::vector<std::string> &tokenName
|
||||||
_tokenNames = tokenNames;
|
_tokenNames = tokenNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATNSerializer::~ATNSerializer() { }
|
||||||
|
|
||||||
std::vector<size_t> ATNSerializer::serialize() {
|
std::vector<size_t> ATNSerializer::serialize() {
|
||||||
std::vector<size_t> data;
|
std::vector<size_t> data;
|
||||||
data.push_back(ATNDeserializer::SERIALIZED_VERSION);
|
data.push_back(ATNDeserializer::SERIALIZED_VERSION);
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace atn {
|
||||||
|
|
||||||
ATNSerializer(ATN *atn);
|
ATNSerializer(ATN *atn);
|
||||||
ATNSerializer(ATN *atn, const std::vector<std::string> &tokenNames);
|
ATNSerializer(ATN *atn, const std::vector<std::string> &tokenNames);
|
||||||
virtual ~ATNSerializer() {};
|
virtual ~ATNSerializer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize state descriptors, edge descriptors, and decision->state map
|
/// Serialize state descriptors, edge descriptors, and decision->state map
|
||||||
|
|
|
@ -23,6 +23,9 @@ ATNSimulator::ATNSimulator(const ATN &atn, PredictionContextCache &sharedContext
|
||||||
: atn(atn), _sharedContextCache(sharedContextCache) {
|
: atn(atn), _sharedContextCache(sharedContextCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATNSimulator::~ATNSimulator() {
|
||||||
|
}
|
||||||
|
|
||||||
void ATNSimulator::clearDFA() {
|
void ATNSimulator::clearDFA() {
|
||||||
throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA.");
|
throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace atn {
|
||||||
const ATN &atn;
|
const ATN &atn;
|
||||||
|
|
||||||
ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache);
|
ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache);
|
||||||
virtual ~ATNSimulator() {};
|
virtual ~ATNSimulator();
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace atn {
|
||||||
virtual ~ATNState();
|
virtual ~ATNState();
|
||||||
|
|
||||||
static const size_t INITIAL_NUM_TRANSITIONS = 4;
|
static const size_t INITIAL_NUM_TRANSITIONS = 4;
|
||||||
static const size_t INVALID_STATE_NUMBER = (size_t)-1;
|
static const size_t INVALID_STATE_NUMBER = std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ATN_INVALID_TYPE = 0,
|
ATN_INVALID_TYPE = 0,
|
||||||
|
|
|
@ -9,3 +9,6 @@ using namespace antlr4::atn;
|
||||||
|
|
||||||
AbstractPredicateTransition::AbstractPredicateTransition(ATNState *target) : Transition(target) {
|
AbstractPredicateTransition::AbstractPredicateTransition(ATNState *target) : Transition(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractPredicateTransition::~AbstractPredicateTransition() {
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace atn {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AbstractPredicateTransition(ATNState *target);
|
AbstractPredicateTransition(ATNState *target);
|
||||||
|
~AbstractPredicateTransition();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ ArrayPredictionContext::ArrayPredictionContext(std::vector<Ref<PredictionContext
|
||||||
assert(returnStates.size() > 0);
|
assert(returnStates.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayPredictionContext::~ArrayPredictionContext() {
|
||||||
|
}
|
||||||
|
|
||||||
bool ArrayPredictionContext::isEmpty() const {
|
bool ArrayPredictionContext::isEmpty() const {
|
||||||
// Since EMPTY_RETURN_STATE can only appear in the last position, we don't need to verify that size == 1.
|
// Since EMPTY_RETURN_STATE can only appear in the last position, we don't need to verify that size == 1.
|
||||||
return returnStates[0] == EMPTY_RETURN_STATE;
|
return returnStates[0] == EMPTY_RETURN_STATE;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace atn {
|
||||||
|
|
||||||
ArrayPredictionContext(Ref<SingletonPredictionContext> const& a);
|
ArrayPredictionContext(Ref<SingletonPredictionContext> const& a);
|
||||||
ArrayPredictionContext(std::vector<Ref<PredictionContext>> const& parents_, std::vector<size_t> const& returnStates);
|
ArrayPredictionContext(std::vector<Ref<PredictionContext>> const& parents_, std::vector<size_t> const& returnStates);
|
||||||
virtual ~ArrayPredictionContext() {};
|
virtual ~ArrayPredictionContext();
|
||||||
|
|
||||||
virtual bool isEmpty() const override;
|
virtual bool isEmpty() const override;
|
||||||
virtual size_t size() const override;
|
virtual size_t size() const override;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "BlockStartState.h"
|
||||||
|
|
||||||
|
antlr4::atn::BlockStartState::~BlockStartState() {
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ namespace atn {
|
||||||
/// The start of a regular {@code (...)} block.
|
/// The start of a regular {@code (...)} block.
|
||||||
class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState {
|
class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState {
|
||||||
public:
|
public:
|
||||||
|
~BlockStartState();
|
||||||
BlockEndState *endState = nullptr;
|
BlockEndState *endState = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ using namespace antlrcpp;
|
||||||
LL1Analyzer::LL1Analyzer(const ATN &atn) : _atn(atn) {
|
LL1Analyzer::LL1Analyzer(const ATN &atn) : _atn(atn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LL1Analyzer::~LL1Analyzer() {
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) const {
|
std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) const {
|
||||||
std::vector<misc::IntervalSet> look;
|
std::vector<misc::IntervalSet> look;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace atn {
|
||||||
const atn::ATN &_atn;
|
const atn::ATN &_atn;
|
||||||
|
|
||||||
LL1Analyzer(const atn::ATN &atn);
|
LL1Analyzer(const atn::ATN &atn);
|
||||||
virtual ~LL1Analyzer() {};
|
virtual ~LL1Analyzer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates the SLL(1) expected lookahead set for each outgoing transition
|
/// Calculates the SLL(1) expected lookahead set for each outgoing transition
|
||||||
|
|
|
@ -31,6 +31,9 @@ using namespace antlr4;
|
||||||
using namespace antlr4::atn;
|
using namespace antlr4::atn;
|
||||||
using namespace antlrcpp;
|
using namespace antlrcpp;
|
||||||
|
|
||||||
|
LexerATNSimulator::SimState::~SimState() {
|
||||||
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::SimState::reset() {
|
void LexerATNSimulator::SimState::reset() {
|
||||||
index = INVALID_INDEX;
|
index = INVALID_INDEX;
|
||||||
line = 0;
|
line = 0;
|
||||||
|
@ -82,8 +85,6 @@ size_t LexerATNSimulator::match(CharStream *input, size_t mode) {
|
||||||
} else {
|
} else {
|
||||||
return execATN(input, dfa.s0);
|
return execATN(input, dfa.s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Token::EOF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::reset() {
|
void LexerATNSimulator::reset() {
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace atn {
|
||||||
protected:
|
protected:
|
||||||
class SimState {
|
class SimState {
|
||||||
public:
|
public:
|
||||||
virtual ~SimState() {};
|
virtual ~SimState();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t index;
|
size_t index;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "LexerAction.h"
|
||||||
|
|
||||||
|
antlr4::atn::LexerAction::~LexerAction() {
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "atn/LexerActionType.h"
|
#include "atn/LexerActionType.h"
|
||||||
|
#include "antlr4-common.h"
|
||||||
|
|
||||||
namespace antlr4 {
|
namespace antlr4 {
|
||||||
namespace atn {
|
namespace atn {
|
||||||
|
@ -20,7 +21,7 @@ namespace atn {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ANTLR4CPP_PUBLIC LexerAction {
|
class ANTLR4CPP_PUBLIC LexerAction {
|
||||||
public:
|
public:
|
||||||
virtual ~LexerAction() {};
|
virtual ~LexerAction();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the serialization type of the lexer action.
|
/// Gets the serialization type of the lexer action.
|
||||||
|
|
|
@ -19,6 +19,9 @@ LexerActionExecutor::LexerActionExecutor(const std::vector<Ref<LexerAction>> &le
|
||||||
: _lexerActions(lexerActions), _hashCode(generateHashCode()) {
|
: _lexerActions(lexerActions), _hashCode(generateHashCode()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LexerActionExecutor::~LexerActionExecutor() {
|
||||||
|
}
|
||||||
|
|
||||||
Ref<LexerActionExecutor> LexerActionExecutor::append(Ref<LexerActionExecutor> const& lexerActionExecutor,
|
Ref<LexerActionExecutor> LexerActionExecutor::append(Ref<LexerActionExecutor> const& lexerActionExecutor,
|
||||||
Ref<LexerAction> const& lexerAction) {
|
Ref<LexerAction> const& lexerAction) {
|
||||||
if (lexerActionExecutor == nullptr) {
|
if (lexerActionExecutor == nullptr) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace atn {
|
||||||
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
|
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
|
||||||
/// <param name="lexerActions"> The lexer actions to execute. </param>
|
/// <param name="lexerActions"> The lexer actions to execute. </param>
|
||||||
LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
|
LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
|
||||||
virtual ~LexerActionExecutor() {};
|
virtual ~LexerActionExecutor();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for
|
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "antlr4-common.h"
|
||||||
|
|
||||||
namespace antlr4 {
|
namespace antlr4 {
|
||||||
namespace atn {
|
namespace atn {
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@ namespace atn {
|
||||||
/// @author Sam Harwell
|
/// @author Sam Harwell
|
||||||
/// @since 4.2
|
/// @since 4.2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
enum class ANTLR4CPP_PUBLIC LexerActionType : size_t {
|
enum class LexerActionType : size_t {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of a <seealso cref="LexerChannelAction"/> action.
|
/// The type of a <seealso cref="LexerChannelAction"/> action.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -13,6 +13,9 @@ using namespace antlr4::atn;
|
||||||
ParseInfo::ParseInfo(ProfilingATNSimulator *atnSimulator) : _atnSimulator(atnSimulator) {
|
ParseInfo::ParseInfo(ProfilingATNSimulator *atnSimulator) : _atnSimulator(atnSimulator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParseInfo::~ParseInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<DecisionInfo> ParseInfo::getDecisionInfo() {
|
std::vector<DecisionInfo> ParseInfo::getDecisionInfo() {
|
||||||
return _atnSimulator->getDecisionInfo();
|
return _atnSimulator->getDecisionInfo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,10 @@ namespace atn {
|
||||||
class ANTLR4CPP_PUBLIC ParseInfo {
|
class ANTLR4CPP_PUBLIC ParseInfo {
|
||||||
public:
|
public:
|
||||||
ParseInfo(ProfilingATNSimulator *atnSimulator);
|
ParseInfo(ProfilingATNSimulator *atnSimulator);
|
||||||
virtual ~ParseInfo() {};
|
ParseInfo(ParseInfo const&) = default;
|
||||||
|
virtual ~ParseInfo();
|
||||||
|
|
||||||
|
ParseInfo& operator=(ParseInfo const&) = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an array of <seealso cref="DecisionInfo"/> instances containing the profiling
|
/// Gets an array of <seealso cref="DecisionInfo"/> instances containing the profiling
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace atn {
|
||||||
// ml: originally Integer.MAX_VALUE, which would be (size_t)-1 for us, but this is already used in places where
|
// ml: originally Integer.MAX_VALUE, which would be (size_t)-1 for us, but this is already used in places where
|
||||||
// -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
|
// -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
|
||||||
// conflict with real return states.
|
// conflict with real return states.
|
||||||
static const size_t EMPTY_RETURN_STATE = (size_t)-10;
|
static const size_t EMPTY_RETURN_STATE = std::numeric_limits<size_t>::max() - 9;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const size_t INITIAL_HASH = 1;
|
static const size_t INITIAL_HASH = 1;
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace atn {
|
||||||
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState);
|
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState);
|
||||||
|
|
||||||
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState);
|
RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState);
|
||||||
|
RuleTransition(RuleTransition const&) = delete;
|
||||||
|
RuleTransition& operator=(RuleTransition const&) = delete;
|
||||||
|
|
||||||
virtual SerializationType getSerializationType() const override;
|
virtual SerializationType getSerializationType() const override;
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,9 @@ std::string SemanticContext::OR::toString() const {
|
||||||
|
|
||||||
const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(INVALID_INDEX, INVALID_INDEX, false);
|
const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(INVALID_INDEX, INVALID_INDEX, false);
|
||||||
|
|
||||||
|
SemanticContext::~SemanticContext() {
|
||||||
|
}
|
||||||
|
|
||||||
bool SemanticContext::operator != (const SemanticContext &other) const {
|
bool SemanticContext::operator != (const SemanticContext &other) const {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
@ -366,3 +369,9 @@ std::vector<Ref<SemanticContext::PrecedencePredicate>> SemanticContext::filterPr
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------ Operator -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SemanticContext::Operator::~Operator() {
|
||||||
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace atn {
|
||||||
*/
|
*/
|
||||||
static const Ref<SemanticContext> NONE;
|
static const Ref<SemanticContext> NONE;
|
||||||
|
|
||||||
virtual ~SemanticContext() {};
|
virtual ~SemanticContext();
|
||||||
|
|
||||||
virtual size_t hashCode() const = 0;
|
virtual size_t hashCode() const = 0;
|
||||||
virtual std::string toString() const = 0;
|
virtual std::string toString() const = 0;
|
||||||
|
@ -144,6 +144,8 @@ namespace atn {
|
||||||
*/
|
*/
|
||||||
class ANTLR4CPP_PUBLIC SemanticContext::Operator : public SemanticContext {
|
class ANTLR4CPP_PUBLIC SemanticContext::Operator : public SemanticContext {
|
||||||
public:
|
public:
|
||||||
|
virtual ~Operator() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the operands for the semantic context operator.
|
* Gets the operands for the semantic context operator.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,6 +15,9 @@ SingletonPredictionContext::SingletonPredictionContext(Ref<PredictionContext> co
|
||||||
assert(returnState != ATNState::INVALID_STATE_NUMBER);
|
assert(returnState != ATNState::INVALID_STATE_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SingletonPredictionContext::~SingletonPredictionContext() {
|
||||||
|
}
|
||||||
|
|
||||||
Ref<SingletonPredictionContext> SingletonPredictionContext::create(Ref<PredictionContext> const& parent, size_t returnState) {
|
Ref<SingletonPredictionContext> SingletonPredictionContext::create(Ref<PredictionContext> const& parent, size_t returnState) {
|
||||||
|
|
||||||
if (returnState == EMPTY_RETURN_STATE && parent) {
|
if (returnState == EMPTY_RETURN_STATE && parent) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace atn {
|
||||||
const size_t returnState;
|
const size_t returnState;
|
||||||
|
|
||||||
SingletonPredictionContext(Ref<PredictionContext> const& parent, size_t returnState);
|
SingletonPredictionContext(Ref<PredictionContext> const& parent, size_t returnState);
|
||||||
virtual ~SingletonPredictionContext() {};
|
virtual ~SingletonPredictionContext();
|
||||||
|
|
||||||
static Ref<SingletonPredictionContext> create(Ref<PredictionContext> const& parent, size_t returnState);
|
static Ref<SingletonPredictionContext> create(Ref<PredictionContext> const& parent, size_t returnState);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ Transition::Transition(ATNState *target) {
|
||||||
this->target = target;
|
this->target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transition::~Transition() {
|
||||||
|
}
|
||||||
|
|
||||||
bool Transition::isEpsilon() const {
|
bool Transition::isEpsilon() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace atn {
|
||||||
// ml: this is a reference into the ATN.
|
// ml: this is a reference into the ATN.
|
||||||
ATNState *target;
|
ATNState *target;
|
||||||
|
|
||||||
virtual ~Transition() {};
|
virtual ~Transition();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Transition(ATNState *target);
|
Transition(ATNState *target);
|
||||||
|
@ -67,6 +67,9 @@ namespace atn {
|
||||||
virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const = 0;
|
virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const = 0;
|
||||||
|
|
||||||
virtual std::string toString() const;
|
virtual std::string toString() const;
|
||||||
|
|
||||||
|
Transition(Transition const&) = delete;
|
||||||
|
Transition& operator=(Transition const&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atn
|
} // namespace atn
|
||||||
|
|
|
@ -17,6 +17,9 @@ DFASerializer::DFASerializer(const DFA *dfa, const std::vector<std::string>& tok
|
||||||
DFASerializer::DFASerializer(const DFA *dfa, const Vocabulary &vocabulary) : _dfa(dfa), _vocabulary(vocabulary) {
|
DFASerializer::DFASerializer(const DFA *dfa, const Vocabulary &vocabulary) : _dfa(dfa), _vocabulary(vocabulary) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DFASerializer::~DFASerializer() {
|
||||||
|
}
|
||||||
|
|
||||||
std::string DFASerializer::toString() const {
|
std::string DFASerializer::toString() const {
|
||||||
if (_dfa->s0 == nullptr) {
|
if (_dfa->s0 == nullptr) {
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace dfa {
|
||||||
public:
|
public:
|
||||||
DFASerializer(const DFA *dfa, const std::vector<std::string>& tnames);
|
DFASerializer(const DFA *dfa, const std::vector<std::string>& tnames);
|
||||||
DFASerializer(const DFA *dfa, const Vocabulary &vocabulary);
|
DFASerializer(const DFA *dfa, const Vocabulary &vocabulary);
|
||||||
virtual ~DFASerializer() {};
|
virtual ~DFASerializer();
|
||||||
|
|
||||||
virtual std::string toString() const;
|
virtual std::string toString() const;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ DFAState::PredPrediction::PredPrediction(const Ref<SemanticContext> &pred, int a
|
||||||
this->alt = alt;
|
this->alt = alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DFAState::PredPrediction::~PredPrediction() {
|
||||||
|
}
|
||||||
|
|
||||||
std::string DFAState::PredPrediction::toString() {
|
std::string DFAState::PredPrediction::toString() {
|
||||||
return std::string("(") + pred->toString() + ", " + std::to_string(alt) + ")";
|
return std::string("(") + pred->toString() + ", " + std::to_string(alt) + ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace dfa {
|
||||||
int alt;
|
int alt;
|
||||||
|
|
||||||
PredPrediction(const Ref<atn::SemanticContext> &pred, int alt);
|
PredPrediction(const Ref<atn::SemanticContext> &pred, int alt);
|
||||||
virtual ~PredPrediction() {};
|
virtual ~PredPrediction();
|
||||||
|
|
||||||
virtual std::string toString();
|
virtual std::string toString();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ using namespace antlr4::dfa;
|
||||||
LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary::EMPTY_VOCABULARY) {
|
LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary::EMPTY_VOCABULARY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LexerDFASerializer::~LexerDFASerializer() {
|
||||||
|
}
|
||||||
|
|
||||||
std::string LexerDFASerializer::getEdgeLabel(size_t i) const {
|
std::string LexerDFASerializer::getEdgeLabel(size_t i) const {
|
||||||
return std::string("'") + static_cast<char>(i) + "'";
|
return std::string("'") + static_cast<char>(i) + "'";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace dfa {
|
||||||
class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer {
|
class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer {
|
||||||
public:
|
public:
|
||||||
LexerDFASerializer(DFA *dfa);
|
LexerDFASerializer(DFA *dfa);
|
||||||
virtual ~LexerDFASerializer() {};
|
virtual ~LexerDFASerializer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::string getEdgeLabel(size_t i) const override;
|
virtual std::string getEdgeLabel(size_t i) const override;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
using namespace antlr4::misc;
|
using namespace antlr4::misc;
|
||||||
|
|
||||||
|
Interval::~Interval() = default;
|
||||||
|
|
||||||
size_t antlr4::misc::numericToSymbol(ssize_t v) {
|
size_t antlr4::misc::numericToSymbol(ssize_t v) {
|
||||||
return (size_t)v;
|
return (size_t)v;
|
||||||
|
|
|
@ -28,7 +28,9 @@ namespace misc {
|
||||||
Interval();
|
Interval();
|
||||||
explicit Interval(size_t a_, size_t b_); // For unsigned -> signed mappings.
|
explicit Interval(size_t a_, size_t b_); // For unsigned -> signed mappings.
|
||||||
Interval(ssize_t a_, ssize_t b_);
|
Interval(ssize_t a_, ssize_t b_);
|
||||||
virtual ~Interval() {};
|
Interval(Interval const&) = default;
|
||||||
|
virtual ~Interval();
|
||||||
|
Interval& operator=(Interval const&) = default;
|
||||||
|
|
||||||
/// return number of elements between a and b inclusively. x..x is length 1.
|
/// return number of elements between a and b inclusively. x..x is length 1.
|
||||||
/// if b < a, then length is 0. 9..10 has length 2.
|
/// if b < a, then length is 0. 9..10 has length 2.
|
||||||
|
|
|
@ -46,6 +46,21 @@ IntervalSet::IntervalSet(int n, ...) : IntervalSet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntervalSet::~IntervalSet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IntervalSet& IntervalSet::operator=(const IntervalSet& other)
|
||||||
|
{
|
||||||
|
if (_readonly) {
|
||||||
|
throw IllegalStateException("can't alter read only IntervalSet");
|
||||||
|
}
|
||||||
|
|
||||||
|
_intervals.clear();
|
||||||
|
|
||||||
|
return addAll(other);
|
||||||
|
}
|
||||||
|
|
||||||
IntervalSet IntervalSet::of(ssize_t a) {
|
IntervalSet IntervalSet::of(ssize_t a) {
|
||||||
return IntervalSet({ Interval(a, a) });
|
return IntervalSet({ Interval(a, a) });
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "misc/Interval.h"
|
#include "misc/Interval.h"
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace antlr4 {
|
namespace antlr4 {
|
||||||
namespace misc {
|
namespace misc {
|
||||||
|
@ -30,7 +31,7 @@ namespace misc {
|
||||||
protected:
|
protected:
|
||||||
/// The list of sorted, disjoint intervals.
|
/// The list of sorted, disjoint intervals.
|
||||||
std::vector<Interval> _intervals;
|
std::vector<Interval> _intervals;
|
||||||
bool _readonly;
|
std::atomic<bool> _readonly;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IntervalSet();
|
IntervalSet();
|
||||||
|
@ -38,7 +39,9 @@ namespace misc {
|
||||||
IntervalSet(const IntervalSet &set);
|
IntervalSet(const IntervalSet &set);
|
||||||
IntervalSet(int numArgs, ...);
|
IntervalSet(int numArgs, ...);
|
||||||
|
|
||||||
virtual ~IntervalSet() {}
|
virtual ~IntervalSet();
|
||||||
|
|
||||||
|
IntervalSet& operator=(const IntervalSet &set);
|
||||||
|
|
||||||
/// Create a set with a single element, el.
|
/// Create a set with a single element, el.
|
||||||
static IntervalSet of(ssize_t a);
|
static IntervalSet of(ssize_t a);
|
||||||
|
|
|
@ -57,7 +57,7 @@ size_t MurmurHash::initialize(size_t seed) {
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32 || _WIN64
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#if _WIN64
|
#if _WIN64
|
||||||
#define ENVIRONMENT64
|
#define ENVIRONMENT64
|
||||||
#else
|
#else
|
||||||
|
@ -65,8 +65,8 @@ size_t MurmurHash::initialize(size_t seed) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__
|
#if defined(__GNUC__)
|
||||||
#if __x86_64__ || __ppc64__
|
#if defined(__x86_64__) || defined(__ppc64__)
|
||||||
#define ENVIRONMENT64
|
#define ENVIRONMENT64
|
||||||
#else
|
#else
|
||||||
#define ENVIRONMENT32
|
#define ENVIRONMENT32
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "misc/Predicate.h"
|
||||||
|
|
||||||
|
antlr4::misc::Predicate::~Predicate() {
|
||||||
|
}
|
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "antlr4-common.h"
|
||||||
|
|
||||||
namespace antlr4 {
|
namespace antlr4 {
|
||||||
namespace misc {
|
namespace misc {
|
||||||
|
|
||||||
class ANTLR4CPP_PUBLIC Predicate {
|
class ANTLR4CPP_PUBLIC Predicate {
|
||||||
public:
|
public:
|
||||||
virtual ~Predicate() {};
|
virtual ~Predicate();
|
||||||
|
|
||||||
virtual bool test(tree::ParseTree *t) = 0;
|
virtual bool test(tree::ParseTree *t) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "Any.h"
|
||||||
|
|
||||||
|
antlrcpp::Any::~Any()
|
||||||
|
{
|
||||||
|
delete _ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
antlrcpp::Any::Base::~Base() {
|
||||||
|
}
|
|
@ -92,9 +92,7 @@ struct Any
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Any() {
|
virtual ~Any();
|
||||||
delete _ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool equals(Any other) const {
|
virtual bool equals(Any other) const {
|
||||||
return _ptr == other._ptr;
|
return _ptr == other._ptr;
|
||||||
|
@ -102,7 +100,7 @@ struct Any
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Base {
|
struct Base {
|
||||||
virtual ~Base() { }
|
virtual ~Base();
|
||||||
virtual Base* clone() const = 0;
|
virtual Base* clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,13 @@ namespace antlrcpp {
|
||||||
// Using RAII + a lambda to implement a "finally" replacement.
|
// Using RAII + a lambda to implement a "finally" replacement.
|
||||||
struct FinalAction {
|
struct FinalAction {
|
||||||
FinalAction(std::function<void ()> f) : _cleanUp { f } {}
|
FinalAction(std::function<void ()> f) : _cleanUp { f } {}
|
||||||
FinalAction(FinalAction &&other) {
|
FinalAction(FinalAction &&other) :
|
||||||
_cleanUp = other._cleanUp;
|
_cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
|
||||||
_enabled = other._enabled;
|
|
||||||
other._enabled = false; // Don't trigger the lambda after ownership has moved.
|
other._enabled = false; // Don't trigger the lambda after ownership has moved.
|
||||||
}
|
}
|
||||||
~FinalAction() { if (_enabled) _cleanUp(); }
|
~FinalAction() { if (_enabled) _cleanUp(); }
|
||||||
|
|
||||||
void disable() { _enabled = false; };
|
void disable() { _enabled = false; }
|
||||||
private:
|
private:
|
||||||
std::function<void ()> _cleanUp;
|
std::function<void ()> _cleanUp;
|
||||||
bool _enabled {true};
|
bool _enabled {true};
|
||||||
|
@ -52,7 +51,7 @@ namespace antlrcpp {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
// typeid gives the mangled class name, but that's all what's possible
|
// typeid gives the mangled class name, but that's all what's possible
|
||||||
// in a portable way.
|
// in a portable way.
|
||||||
ss << typeid(o).name() << "@" << std::hex << (size_t)&o;
|
ss << typeid(o).name() << "@" << std::hex << reinterpret_cast<uintptr_t>(&o);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace antlrcpp {
|
||||||
// Don't make the converter static or we have to serialize access to it.
|
// Don't make the converter static or we have to serialize access to it.
|
||||||
UTF32Converter converter;
|
UTF32Converter converter;
|
||||||
|
|
||||||
#if _MSC_VER >= 1900 && _MSC_VER < 2000
|
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||||
auto p = reinterpret_cast<const int32_t *>(data.data());
|
auto p = reinterpret_cast<const int32_t *>(data.data());
|
||||||
return converter.to_bytes(p, p + data.size());
|
return converter.to_bytes(p, p + data.size());
|
||||||
#else
|
#else
|
||||||
|
@ -36,7 +36,7 @@ namespace antlrcpp {
|
||||||
{
|
{
|
||||||
UTF32Converter converter;
|
UTF32Converter converter;
|
||||||
|
|
||||||
#if _MSC_VER >= 1900 && _MSC_VER < 2000
|
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||||
auto r = converter.from_bytes(first, last);
|
auto r = converter.from_bytes(first, last);
|
||||||
i32string s = reinterpret_cast<const int32_t *>(r.data());
|
i32string s = reinterpret_cast<const int32_t *>(r.data());
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -99,7 +99,7 @@ Guid::Guid(const uint16_t *bytes, bool reverse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// converts a single hex char to a number (0 - 15)
|
// converts a single hex char to a number (0 - 15)
|
||||||
unsigned char hexDigitToChar(char ch)
|
static unsigned char hexDigitToChar(char ch)
|
||||||
{
|
{
|
||||||
if (ch > 47 && ch < 58)
|
if (ch > 47 && ch < 58)
|
||||||
return (unsigned char)(ch - 48);
|
return (unsigned char)(ch - 48);
|
||||||
|
@ -114,7 +114,7 @@ unsigned char hexDigitToChar(char ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// converts the two hexadecimal characters to an unsigned char (a byte)
|
// converts the two hexadecimal characters to an unsigned char (a byte)
|
||||||
unsigned char hexPairToChar(char a, char b)
|
static unsigned char hexPairToChar(char a, char b)
|
||||||
{
|
{
|
||||||
return hexDigitToChar(a) * 16 + hexDigitToChar(b);
|
return hexDigitToChar(a) * 16 + hexDigitToChar(b);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue