forked from jasder/antlr
Fixed a number of warnings for VS.
This commit is contained in:
parent
a7b9499230
commit
0e0ecfafde
|
@ -0,0 +1,40 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4cpp-vs2015", "..\..\runtime\antlr4cpp-vs2015.vcxproj", "{A9762991-1B57-4DCE-90C0-EE42B96947BE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug DLL|x64 = Debug DLL|x64
|
||||
Debug DLL|x86 = Debug DLL|x86
|
||||
Debug Static|x64 = Debug Static|x64
|
||||
Debug Static|x86 = Debug Static|x86
|
||||
Release DLL|x64 = Release DLL|x64
|
||||
Release DLL|x86 = Release DLL|x86
|
||||
Release Static|x64 = Release Static|x64
|
||||
Release Static|x86 = Release Static|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug DLL|x64.ActiveCfg = Debug DLL|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug DLL|x64.Build.0 = Debug DLL|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug DLL|x86.ActiveCfg = Debug DLL|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug DLL|x86.Build.0 = Debug DLL|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug Static|x64.ActiveCfg = Debug Static|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug Static|x64.Build.0 = Debug Static|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug Static|x86.ActiveCfg = Debug Static|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug Static|x86.Build.0 = Debug Static|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release DLL|x64.ActiveCfg = Release DLL|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release DLL|x64.Build.0 = Release DLL|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release DLL|x86.ActiveCfg = Release DLL|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release DLL|x86.Build.0 = Release DLL|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release Static|x64.ActiveCfg = Release Static|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release Static|x64.Build.0 = Release Static|x64
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release Static|x86.ActiveCfg = Release Static|Win32
|
||||
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release Static|x86.Build.0 = Release Static|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -386,7 +386,7 @@ std::string BufferedTokenStream::getSourceName() const
|
|||
std::string BufferedTokenStream::getText() {
|
||||
lazyInit();
|
||||
fill();
|
||||
return getText(misc::Interval(0, size() - 1));
|
||||
return getText(misc::Interval(0U, size() - 1));
|
||||
}
|
||||
|
||||
std::string BufferedTokenStream::getText(const misc::Interval &interval) {
|
||||
|
|
|
@ -288,7 +288,7 @@ Token* DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
|
|||
|
||||
_errorSymbols.push_back(recognizer->getTokenFactory()->create(
|
||||
{ current->getTokenSource(), current->getTokenSource()->getInputStream() },
|
||||
(int)expectedTokenType, tokenText, Token::DEFAULT_CHANNEL, -1, -1,
|
||||
expectedTokenType, tokenText, Token::DEFAULT_CHANNEL, INVALID_INDEX, INVALID_INDEX,
|
||||
current->getLine(), current->getCharPositionInLine()));
|
||||
|
||||
return _errorSymbols.back().get();
|
||||
|
|
|
@ -63,7 +63,7 @@ void Lexer::reset() {
|
|||
token.reset();
|
||||
type = Token::INVALID_TYPE;
|
||||
channel = Token::DEFAULT_CHANNEL;
|
||||
tokenStartCharIndex = -1;
|
||||
tokenStartCharIndex = INVALID_INDEX;
|
||||
tokenStartCharPositionInLine = 0;
|
||||
tokenStartLine = 0;
|
||||
type = 0;
|
||||
|
@ -311,7 +311,7 @@ void Lexer::InitializeInstanceFields() {
|
|||
_syntaxErrors = 0;
|
||||
token = nullptr;
|
||||
_factory = CommonTokenFactory::DEFAULT;
|
||||
tokenStartCharIndex = -1;
|
||||
tokenStartCharIndex = INVALID_INDEX;
|
||||
tokenStartLine = 0;
|
||||
tokenStartCharPositionInLine = 0;
|
||||
hitEOF = false;
|
||||
|
|
|
@ -287,7 +287,7 @@ Ref<InterpreterRuleContext> ParserInterpreter::createInterpreterRuleContext(std:
|
|||
void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
|
||||
atn::RuleStartState *ruleStartState = _atn.ruleToStartState[p->ruleIndex];
|
||||
if (ruleStartState->isLeftRecursiveRule) {
|
||||
std::pair<Ref<ParserRuleContext>, int> parentContext = _parentContextStack.top();
|
||||
std::pair<Ref<ParserRuleContext>, size_t> parentContext = _parentContextStack.top();
|
||||
_parentContextStack.pop();
|
||||
|
||||
unrollRecursionContexts(parentContext.first);
|
||||
|
@ -311,14 +311,14 @@ void ParserInterpreter::recover(RecognitionException &e) {
|
|||
Token *tok = e.getOffendingToken();
|
||||
size_t expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
|
||||
_errorToken = getTokenFactory()->create({ tok->getTokenSource(), tok->getTokenSource()->getInputStream() },
|
||||
expectedTokenType, tok->getText(), Token::DEFAULT_CHANNEL, -1, -1, // invalid start/stop
|
||||
expectedTokenType, tok->getText(), Token::DEFAULT_CHANNEL, INVALID_INDEX, INVALID_INDEX, // invalid start/stop
|
||||
tok->getLine(), tok->getCharPositionInLine());
|
||||
_ctx->addErrorNode(_errorToken.get());
|
||||
}
|
||||
else { // NoViableAlt
|
||||
Token *tok = e.getOffendingToken();
|
||||
_errorToken = getTokenFactory()->create({ tok->getTokenSource(), tok->getTokenSource()->getInputStream() },
|
||||
Token::INVALID_TYPE, tok->getText(), Token::DEFAULT_CHANNEL, -1, -1, // invalid start/stop
|
||||
Token::INVALID_TYPE, tok->getText(), Token::DEFAULT_CHANNEL, INVALID_INDEX, INVALID_INDEX, // invalid start/stop
|
||||
tok->getLine(), tok->getCharPositionInLine());
|
||||
_ctx->addErrorNode(_errorToken.get());
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace antlr4 {
|
|||
* Those values are used to create new recursive rule invocation contexts
|
||||
* associated with left operand of an alt like "expr '*' expr".
|
||||
*/
|
||||
std::stack<std::pair<Ref<ParserRuleContext>, int>> _parentContextStack;
|
||||
std::stack<std::pair<Ref<ParserRuleContext>, size_t>> _parentContextStack;
|
||||
|
||||
/** We need a map from (decision,inputIndex)->forced alt for computing ambiguous
|
||||
* parse trees. For now, we allow exactly one override.
|
||||
|
|
|
@ -85,5 +85,5 @@ IRecognizer* RecognitionException::getRecognizer() const {
|
|||
}
|
||||
|
||||
void RecognitionException::InitializeInstanceFields() {
|
||||
_offendingState = -1;
|
||||
_offendingState = INVALID_INDEX;
|
||||
}
|
||||
|
|
|
@ -267,11 +267,11 @@ std::vector<TokenStreamRewriter::RewriteOperation*> TokenStreamRewriter::initial
|
|||
}
|
||||
|
||||
std::string TokenStreamRewriter::getText() {
|
||||
return getText(DEFAULT_PROGRAM_NAME, Interval(0, tokens->size() - 1));
|
||||
return getText(DEFAULT_PROGRAM_NAME, Interval(0UL, tokens->size() - 1));
|
||||
}
|
||||
|
||||
std::string TokenStreamRewriter::getText(std::string programName) {
|
||||
return getText(programName, Interval(0, tokens->size() - 1));
|
||||
return getText(programName, Interval(0UL, tokens->size() - 1));
|
||||
}
|
||||
|
||||
std::string TokenStreamRewriter::getText(const Interval &interval) {
|
||||
|
|
|
@ -78,7 +78,7 @@ void UnbufferedCharStream::sync(size_t want) {
|
|||
|
||||
size_t UnbufferedCharStream::fill(size_t n) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (_data.size() > 0 && _data.back() == static_cast<char32_t>(EOF)) { // TODO: we cannot encode -1 as this is not a valid code point
|
||||
if (_data.size() > 0 && _data.back() == EOF) {
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,12 +72,13 @@
|
|||
#ifdef _WIN64
|
||||
typedef __int64 ssize_t;
|
||||
#else
|
||||
typedef int ssize_t;
|
||||
typedef __int32 ssize_t;
|
||||
#endif
|
||||
|
||||
#if _MSC_VER == 1900
|
||||
// VS 2015 has a known bug when using std::codecvt_utf8<char32_t>
|
||||
// so we have to temporarily use __int32 instead.
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/1403302/unresolved-external-when-using-codecvt-utf8
|
||||
typedef std::basic_string<__int32> i32string;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ ATN ATNDeserializer::deserialize(const std::vector<uint16_t>& input) {
|
|||
|
||||
size_t ruleIndex = data[p++];
|
||||
if (ruleIndex == 0xFFFF) { // Max Unicode char limit imposed by ANTLR.
|
||||
ruleIndex = -1;
|
||||
ruleIndex = INVALID_INDEX;
|
||||
}
|
||||
|
||||
ATNState *s = stateFactory(stype, ruleIndex);
|
||||
|
@ -612,7 +612,7 @@ void ATNDeserializer::checkCondition(bool condition, const std::string &message)
|
|||
}
|
||||
}
|
||||
|
||||
Guid ATNDeserializer::toUUID(const unsigned short *data, int offset) {
|
||||
Guid ATNDeserializer::toUUID(const unsigned short *data, size_t offset) {
|
||||
return Guid((uint16_t *)data + offset, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace atn {
|
|||
ATNDeserializer(const ATNDeserializationOptions& dso);
|
||||
virtual ~ATNDeserializer() {};
|
||||
|
||||
static Guid toUUID(const unsigned short *data, int offset);
|
||||
static Guid toUUID(const unsigned short *data, size_t offset);
|
||||
|
||||
virtual ATN deserialize(const std::vector<uint16_t> &input);
|
||||
virtual void verifyATN(const ATN &atn);
|
||||
|
|
|
@ -99,7 +99,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
continue;
|
||||
}
|
||||
|
||||
int stateType = s->getStateType();
|
||||
size_t stateType = s->getStateType();
|
||||
if (is<DecisionState *>(s) && (static_cast<DecisionState *>(s))->nonGreedy) {
|
||||
nonGreedyStates.push_back(s->stateNumber);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
precedenceStates.push_back(s->stateNumber);
|
||||
}
|
||||
|
||||
data.push_back((size_t)stateType);
|
||||
data.push_back(stateType);
|
||||
|
||||
if (s->ruleIndex == INVALID_INDEX) {
|
||||
data.push_back(0xFFFF);
|
||||
|
@ -324,10 +324,10 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
|
||||
case LexerActionType::CUSTOM:
|
||||
{
|
||||
int ruleIndex = std::dynamic_pointer_cast<LexerCustomAction>(action)->getRuleIndex();
|
||||
int actionIndex = std::dynamic_pointer_cast<LexerCustomAction>(action)->getActionIndex();
|
||||
data.push_back(ruleIndex != -1 ? ruleIndex : 0xFFFF);
|
||||
data.push_back(actionIndex != -1 ? actionIndex : 0xFFFF);
|
||||
size_t ruleIndex = std::dynamic_pointer_cast<LexerCustomAction>(action)->getRuleIndex();
|
||||
size_t actionIndex = std::dynamic_pointer_cast<LexerCustomAction>(action)->getActionIndex();
|
||||
data.push_back(ruleIndex != INVALID_INDEX ? ruleIndex : 0xFFFF);
|
||||
data.push_back(actionIndex != INVALID_INDEX ? actionIndex : 0xFFFF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ std::string ATNSerializer::decode(const std::wstring &inpdata) {
|
|||
}
|
||||
|
||||
std::string buf;
|
||||
int p = 0;
|
||||
size_t p = 0;
|
||||
size_t version = data[p++];
|
||||
if (version != ATNDeserializer::SERIALIZED_VERSION) {
|
||||
std::string reason = "Could not deserialize ATN with version " + std::to_string(version) + "(expected " +
|
||||
|
@ -422,17 +422,17 @@ std::string ATNSerializer::decode(const std::wstring &inpdata) {
|
|||
}
|
||||
|
||||
p++; // skip grammarType
|
||||
int maxType = data[p++];
|
||||
size_t maxType = data[p++];
|
||||
buf.append("max type ").append(std::to_string(maxType)).append("\n");
|
||||
int nstates = data[p++];
|
||||
for (int i = 0; i < nstates; i++) {
|
||||
size_t nstates = data[p++];
|
||||
for (size_t i = 0; i < nstates; i++) {
|
||||
size_t stype = data[p++];
|
||||
if (stype == ATNState::ATN_INVALID_TYPE) { // ignore bad type of states
|
||||
continue;
|
||||
}
|
||||
size_t ruleIndex = data[p++];
|
||||
if (ruleIndex == 0xFFFF) {
|
||||
ruleIndex = -1;
|
||||
ruleIndex = INVALID_INDEX;
|
||||
}
|
||||
|
||||
std::string arg = "";
|
||||
|
@ -601,7 +601,7 @@ std::string ATNSerializer::getTokenName(size_t t) {
|
|||
}
|
||||
|
||||
if (_tokenNames.size() > 0 && t < _tokenNames.size()) {
|
||||
return _tokenNames[(size_t)t];
|
||||
return _tokenNames[t];
|
||||
}
|
||||
|
||||
return std::to_string(t);
|
||||
|
|
|
@ -57,16 +57,16 @@ using namespace antlr4::atn;
|
|||
using namespace antlrcpp;
|
||||
|
||||
void LexerATNSimulator::SimState::reset() {
|
||||
index = -1;
|
||||
index = INVALID_INDEX;
|
||||
line = 0;
|
||||
charPos = -1;
|
||||
charPos = INVALID_INDEX;
|
||||
dfaState = nullptr; // Don't delete. It's just a reference.
|
||||
}
|
||||
|
||||
void LexerATNSimulator::SimState::InitializeInstanceFields() {
|
||||
index = -1;
|
||||
index = INVALID_INDEX;
|
||||
line = 0;
|
||||
charPos = -1;
|
||||
charPos = INVALID_INDEX;
|
||||
}
|
||||
|
||||
int LexerATNSimulator::match_calls = 0;
|
||||
|
|
|
@ -39,14 +39,14 @@ using namespace antlr4;
|
|||
using namespace antlr4::atn;
|
||||
using namespace antlr4::misc;
|
||||
|
||||
LexerCustomAction::LexerCustomAction(int ruleIndex, int actionIndex) : _ruleIndex(ruleIndex), _actionIndex(actionIndex) {
|
||||
LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex) : _ruleIndex(ruleIndex), _actionIndex(actionIndex) {
|
||||
}
|
||||
|
||||
int LexerCustomAction::getRuleIndex() const {
|
||||
size_t LexerCustomAction::getRuleIndex() const {
|
||||
return _ruleIndex;
|
||||
}
|
||||
|
||||
int LexerCustomAction::getActionIndex() const {
|
||||
size_t LexerCustomAction::getActionIndex() const {
|
||||
return _actionIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,19 +60,19 @@ namespace atn {
|
|||
/// <seealso cref="Recognizer#action"/>. </param>
|
||||
/// <param name="actionIndex"> The action index to use for calls to
|
||||
/// <seealso cref="Recognizer#action"/>. </param>
|
||||
LexerCustomAction(int ruleIndex, int actionIndex);
|
||||
LexerCustomAction(size_t ruleIndex, size_t actionIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rule index to use for calls to <seealso cref="Recognizer#action"/>.
|
||||
/// </summary>
|
||||
/// <returns> The rule index for the custom action. </returns>
|
||||
int getRuleIndex() const;
|
||||
size_t getRuleIndex() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the action index to use for calls to <seealso cref="Recognizer#action"/>.
|
||||
/// </summary>
|
||||
/// <returns> The action index for the custom action. </returns>
|
||||
int getActionIndex() const;
|
||||
size_t getActionIndex() const;
|
||||
|
||||
/// <summary>
|
||||
/// {@inheritDoc}
|
||||
|
@ -105,8 +105,8 @@ namespace atn {
|
|||
virtual std::string toString() const override;
|
||||
|
||||
private:
|
||||
const int _ruleIndex;
|
||||
const int _actionIndex;
|
||||
const size_t _ruleIndex;
|
||||
const size_t _actionIndex;
|
||||
};
|
||||
|
||||
} // namespace atn
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
using namespace antlr4;
|
||||
using namespace antlr4::atn;
|
||||
|
||||
LookaheadEventInfo::LookaheadEventInfo(int decision, ATNConfigSet *configs, int predictedAlt,
|
||||
TokenStream *input, int startIndex, int stopIndex, bool fullCtx)
|
||||
LookaheadEventInfo::LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt,
|
||||
TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx)
|
||||
: DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) {
|
||||
|
||||
this->predictedAlt = predictedAlt;
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace atn {
|
|||
/// the outermost alt shown for a rule; left-recursive rules have
|
||||
/// user-level alts that differ from the rewritten rule with a (...) block
|
||||
/// and a (..)* loop.
|
||||
int predictedAlt = 0;
|
||||
size_t predictedAlt = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the <seealso cref="LookaheadEventInfo"/> class with
|
||||
|
@ -60,8 +60,8 @@ namespace atn {
|
|||
/// <param name="fullCtx"> {@code true} if the current lookahead is part of an LL
|
||||
/// prediction; otherwise, {@code false} if the current lookahead is part of
|
||||
/// an SLL prediction </param>
|
||||
LookaheadEventInfo(int decision, ATNConfigSet *configs, int predictedAlt, TokenStream *input, int startIndex,
|
||||
int stopIndex, bool fullCtx);
|
||||
LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt, TokenStream *input, size_t startIndex,
|
||||
size_t stopIndex, bool fullCtx);
|
||||
};
|
||||
|
||||
} // namespace atn
|
||||
|
|
|
@ -44,7 +44,7 @@ ssize_t antlr4::misc::symbolToNumeric(size_t v) {
|
|||
|
||||
Interval const Interval::INVALID;
|
||||
|
||||
Interval::Interval() : Interval(-1L, -2L) {
|
||||
Interval::Interval() : Interval((ssize_t)-1, -2) { // Need an explicit cast here for VS.
|
||||
}
|
||||
|
||||
Interval::Interval(size_t a_, size_t b_) : Interval(symbolToNumeric(a_), symbolToNumeric(b_)) {
|
||||
|
|
Loading…
Reference in New Issue