From 3adbe5a2757e7400edec1b9c7939201eb5ed3a10 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 28 Apr 2025 11:54:51 +0100 Subject: [PATCH] refactor: fix additional zcg x64 warnings --- .../Parsing/Impl/DefinesStreamProxy.cpp | 31 ++-- src/Parser/Parsing/Impl/DefinesStreamProxy.h | 140 ++++++++---------- src/Parser/Parsing/Matcher/AbstractMatcher.h | 2 +- .../Parsing/Matcher/AbstractMatcherFactory.h | 24 +-- src/Parser/Parsing/Matcher/MatcherResult.cpp | 8 +- src/Parser/Parsing/Matcher/MatcherResult.h | 13 +- .../Expression/SimpleExpressionMatchers.cpp | 2 +- .../Simple/Matcher/SimpleMatcherFactory.h | 26 ++-- src/Parser/Parsing/Simple/SimpleLexer.cpp | 2 +- src/Utils/Utils/Arguments/ArgumentParser.cpp | 2 +- .../Commands/Impl/CommandsParserState.cpp | 2 +- .../Matcher/CommandsCommonMatchers.cpp | 2 +- 12 files changed, 124 insertions(+), 130 deletions(-) diff --git a/src/Parser/Parsing/Impl/DefinesStreamProxy.cpp b/src/Parser/Parsing/Impl/DefinesStreamProxy.cpp index 9c241627..631b159f 100644 --- a/src/Parser/Parsing/Impl/DefinesStreamProxy.cpp +++ b/src/Parser/Parsing/Impl/DefinesStreamProxy.cpp @@ -13,12 +13,22 @@ namespace { - bool IsStringizeParameterForwardLookup(const std::string& value, size_t pos) + constexpr auto DEFINE_DIRECTIVE = "define"; + constexpr auto UNDEF_DIRECTIVE = "undef"; + constexpr auto IF_DIRECTIVE = "if"; + constexpr auto ELIF_DIRECTIVE = "elif"; + constexpr auto IFDEF_DIRECTIVE = "ifdef"; + constexpr auto IFNDEF_DIRECTIVE = "ifndef"; + constexpr auto ELSE_DIRECTIVE = "else"; + constexpr auto ENDIF_DIRECTIVE = "endif"; + constexpr auto DEFINED_KEYWORD = "defined"; + + bool IsStringizeParameterForwardLookup(const std::string& value, const size_t pos) { return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_'); } - bool IsTokenPastingOperatorForwardLookup(const std::string& value, size_t pos) + bool IsTokenPastingOperatorForwardLookup(const std::string& value, const size_t pos) { return pos + 1 < value.size() && value[pos + 1] == '#'; } @@ -31,7 +41,7 @@ DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition() { } -DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const size_t position, const bool stringize) +DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const unsigned position, const bool stringize) : m_parameter_index(index), m_parameter_position(position), m_stringize(stringize) @@ -591,7 +601,6 @@ bool DefinesStreamProxy::FindNextMacro(const std::string& input, unsigned& input { const auto inputSize = input.size(); auto wordStart = 0u; - auto lastWordEnd = 0u; auto inWord = false; auto inString = false; auto stringEscape = false; @@ -763,8 +772,7 @@ namespace } } // namespace -void DefinesStreamProxy::ProcessTokenPastingOperators( - const ParserLine& line, const unsigned& linePos, std::vector& callstack, std::string& input, unsigned& inputPos) +void DefinesStreamProxy::ProcessTokenPastingOperators(const ParserLine& line, const unsigned& linePos, std::string& input) { std::ostringstream ss; @@ -853,18 +861,17 @@ void DefinesStreamProxy::ExpandMacro(ParserLine& line, unsigned& linePos, std::ostringstream& out, std::vector& callstack, - const DefinesStreamProxy::Define* macro, + const Define* macro, const std::vector& parameterValues) { std::ostringstream rawOutput; InsertMacroParameters(rawOutput, macro, parameterValues); std::string str = rawOutput.str(); - unsigned nestedPos = 0; - ProcessNestedMacros(line, linePos, callstack, str, nestedPos); + ProcessNestedMacros(line, linePos, callstack, str); if (macro->m_contains_token_pasting_operators) - ProcessTokenPastingOperators(line, linePos, callstack, str, nestedPos); + ProcessTokenPastingOperators(line, linePos, str); out << str; } @@ -966,7 +973,7 @@ void DefinesStreamProxy::ContinueMultiLineMacro(ParserLine& line) } } -void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector& callstack, std::string& input, unsigned& inputPos) +void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector& callstack, std::string& input) { bool usesDefines = false; @@ -1021,7 +1028,7 @@ void DefinesStreamProxy::ProcessMacrosSingleLine(ParserLine& line) { unsigned pos = 0; std::vector callstack; - ProcessNestedMacros(line, pos, callstack, line.m_line, pos); + ProcessNestedMacros(line, pos, callstack, line.m_line); } void DefinesStreamProxy::ProcessMacrosMultiLine(ParserLine& line) diff --git a/src/Parser/Parsing/Impl/DefinesStreamProxy.h b/src/Parser/Parsing/Impl/DefinesStreamProxy.h index d9beffb6..2195529c 100644 --- a/src/Parser/Parsing/Impl/DefinesStreamProxy.h +++ b/src/Parser/Parsing/Impl/DefinesStreamProxy.h @@ -13,42 +13,30 @@ class DefinesStreamProxy final : public AbstractDirectiveStreamProxy { - static constexpr const char* DEFINE_DIRECTIVE = "define"; - static constexpr const char* UNDEF_DIRECTIVE = "undef"; - static constexpr const char* IF_DIRECTIVE = "if"; - static constexpr const char* ELIF_DIRECTIVE = "elif"; - static constexpr const char* IFDEF_DIRECTIVE = "ifdef"; - static constexpr const char* IFNDEF_DIRECTIVE = "ifndef"; - static constexpr const char* ELSE_DIRECTIVE = "else"; - static constexpr const char* ENDIF_DIRECTIVE = "endif"; - static constexpr const char* DEFINED_KEYWORD = "defined"; - - static constexpr auto MAX_DEFINE_ITERATIONS = 128u; - public: class DefineParameterPosition { public: - unsigned m_parameter_index; - size_t m_parameter_position; - bool m_stringize; - DefineParameterPosition(); - DefineParameterPosition(unsigned index, size_t position, bool stringize); + DefineParameterPosition(unsigned index, unsigned position, bool stringize); + + unsigned m_parameter_index; + unsigned m_parameter_position; + bool m_stringize; }; class Define { public: + Define(); + Define(std::string name, std::string value); + void IdentifyParameters(const std::vector& parameterNames); + std::string m_name; std::string m_value; std::vector m_parameter_positions; bool m_contains_token_pasting_operators; - Define(); - Define(std::string name, std::string value); - void IdentifyParameters(const std::vector& parameterNames); - private: void IdentifyTokenPasteOperatorOnly(); }; @@ -64,14 +52,27 @@ public: class MacroParameterState { public: + MacroParameterState(); + ParameterState m_parameter_state; std::ostringstream m_current_parameter; std::vector m_parameters; std::stack m_bracket_depth; - - MacroParameterState(); }; + explicit DefinesStreamProxy(IParserLineStream* stream, bool skipDirectiveLines = false); + + void AddDefine(Define define); + void Undefine(const std::string& name); + + [[nodiscard]] std::unique_ptr ParseExpression(std::shared_ptr fileName, int lineNumber, std::string expressionString); + + ParserLine NextLine() override; + bool IncludeFile(const std::string& filename) override; + void PopCurrentFile() override; + [[nodiscard]] bool IsOpen() const override; + [[nodiscard]] bool Eof() const override; + private: enum class BlockMode : uint8_t @@ -81,6 +82,45 @@ private: BLOCK_BLOCKED }; + static int GetLineEndEscapePos(const ParserLine& line); + void MatchDefineParameters(const ParserLine& line, size_t& currentPos); + void ContinueDefine(const ParserLine& line, size_t currentPos); + void ContinueParameters(const ParserLine& line, size_t& currentPos); + [[nodiscard]] bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); + [[nodiscard]] bool MatchDirectives(const ParserLine& line); + + static void ExtractParametersFromMacroUsage( + const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos); + bool FindMacroForIdentifier(const std::string& input, unsigned identifierStart, unsigned identifierEnd, const Define*& value) const; + + static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName); + void ExpandDefinedExpressions(ParserLine& line) const; + + bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define) const; + + static void ProcessTokenPastingOperators(const ParserLine& line, const unsigned& linePos, std::string& input); + static void InsertMacroParameters(std::ostringstream& out, const DefinesStreamProxy::Define* macro, const std::vector& parameterValues); + void ExpandMacro(ParserLine& line, + unsigned& linePos, + std::ostringstream& out, + std::vector& callstack, + const DefinesStreamProxy::Define* macro, + const std::vector& parameterValues); + + static void + ContinueMacroParameters(const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos); + void ContinueMultiLineMacro(ParserLine& line); + + void ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector& callstack, std::string& input); + void ProcessMacrosSingleLine(ParserLine& line); + void ProcessMacrosMultiLine(ParserLine& line); + IParserLineStream* const m_stream; const bool m_skip_directive_lines; std::map m_defines; @@ -95,58 +135,4 @@ private: const Define* m_current_macro; MacroParameterState m_multi_line_macro_parameters; - - static int GetLineEndEscapePos(const ParserLine& line); - void MatchDefineParameters(const ParserLine& line, size_t& currentPos); - void ContinueDefine(const ParserLine& line, size_t currentPos); - void ContinueParameters(const ParserLine& line, size_t& currentPos); - _NODISCARD bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition); - _NODISCARD bool MatchDirectives(const ParserLine& line); - - static void ExtractParametersFromMacroUsage( - const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos); - bool FindMacroForIdentifier(const std::string& input, unsigned identifierStart, unsigned identifierEnd, const Define*& value) const; - - static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName); - void ExpandDefinedExpressions(ParserLine& line) const; - - bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define) const; - - static void ProcessTokenPastingOperators( - const ParserLine& line, const unsigned& linePos, std::vector& callstack, std::string& input, unsigned& inputPos); - static void InsertMacroParameters(std::ostringstream& out, const DefinesStreamProxy::Define* macro, const std::vector& parameterValues); - void ExpandMacro(ParserLine& line, - unsigned& linePos, - std::ostringstream& out, - std::vector& callstack, - const DefinesStreamProxy::Define* macro, - const std::vector& parameterValues); - - static void - ContinueMacroParameters(const ParserLine& line, const unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos); - void ContinueMultiLineMacro(ParserLine& line); - - void ProcessNestedMacros(ParserLine& line, unsigned& linePos, std::vector& callstack, std::string& input, unsigned& inputPos); - void ProcessMacrosSingleLine(ParserLine& line); - void ProcessMacrosMultiLine(ParserLine& line); - -public: - explicit DefinesStreamProxy(IParserLineStream* stream, bool skipDirectiveLines = false); - - void AddDefine(Define define); - void Undefine(const std::string& name); - - _NODISCARD std::unique_ptr ParseExpression(std::shared_ptr fileName, int lineNumber, std::string expressionString); - - ParserLine NextLine() override; - bool IncludeFile(const std::string& filename) override; - void PopCurrentFile() override; - _NODISCARD bool IsOpen() const override; - _NODISCARD bool Eof() const override; }; diff --git a/src/Parser/Parsing/Matcher/AbstractMatcher.h b/src/Parser/Parsing/Matcher/AbstractMatcher.h index 8b112130..5e08d173 100644 --- a/src/Parser/Parsing/Matcher/AbstractMatcher.h +++ b/src/Parser/Parsing/Matcher/AbstractMatcher.h @@ -80,7 +80,7 @@ public: result.m_fabricated_tokens.push_back(m_transform_func(tokens)); result.m_matched_tokens.clear(); - result.m_matched_tokens.emplace_back(result.m_fabricated_tokens.size() - 1, true); + result.m_matched_tokens.emplace_back(static_cast(result.m_fabricated_tokens.size()) - 1u, true); } else if (result.m_matched_tokens.empty()) { diff --git a/src/Parser/Parsing/Matcher/AbstractMatcherFactory.h b/src/Parser/Parsing/Matcher/AbstractMatcherFactory.h index 1b957512..d91aa49b 100644 --- a/src/Parser/Parsing/Matcher/AbstractMatcherFactory.h +++ b/src/Parser/Parsing/Matcher/AbstractMatcherFactory.h @@ -16,7 +16,7 @@ template class MatcherFactoryWrapper { // TokenType must inherit IParserValue - static_assert(std::is_base_of::value); + static_assert(std::is_base_of_v); std::unique_ptr> m_matcher; @@ -73,7 +73,7 @@ public: template class AbstractMatcherFactory { // TokenType must inherit IParserValue - static_assert(std::is_base_of::value); + static_assert(std::is_base_of_v); const IMatcherForLabelSupplier* m_label_supplier; @@ -85,52 +85,52 @@ public: { } - _NODISCARD MatcherFactoryWrapper False() const + [[nodiscard]] MatcherFactoryWrapper False() const { return MatcherFactoryWrapper(std::make_unique>()); } - _NODISCARD MatcherFactoryWrapper True() const + [[nodiscard]] MatcherFactoryWrapper True() const { return MatcherFactoryWrapper(std::make_unique>()); } - _NODISCARD MatcherFactoryWrapper And(std::initializer_list>>> matchers) const + [[nodiscard]] MatcherFactoryWrapper And(std::initializer_list>>> matchers) const { return MatcherFactoryWrapper(std::make_unique>(matchers)); } - _NODISCARD MatcherFactoryWrapper And(std::vector>> matchers) const + [[nodiscard]] MatcherFactoryWrapper And(std::vector>> matchers) const { return MatcherFactoryWrapper(std::make_unique>(std::move(matchers))); } - _NODISCARD MatcherFactoryWrapper Or(std::initializer_list>>> matchers) const + [[nodiscard]] MatcherFactoryWrapper Or(std::initializer_list>>> matchers) const { return MatcherFactoryWrapper(std::make_unique>(matchers)); } - _NODISCARD MatcherFactoryWrapper Or(std::vector>> matchers) const + [[nodiscard]] MatcherFactoryWrapper Or(std::vector>> matchers) const { return MatcherFactoryWrapper(std::make_unique>(std::move(matchers))); } - _NODISCARD MatcherFactoryWrapper Loop(std::unique_ptr> matcher) const + [[nodiscard]] MatcherFactoryWrapper Loop(std::unique_ptr> matcher) const { return MatcherFactoryWrapper(std::make_unique>(std::move(matcher))); } - _NODISCARD MatcherFactoryWrapper OptionalLoop(std::unique_ptr> matcher) const + [[nodiscard]] MatcherFactoryWrapper OptionalLoop(std::unique_ptr> matcher) const { return MatcherFactoryWrapper(std::make_unique>(std::make_unique>(std::move(matcher)))); } - _NODISCARD MatcherFactoryWrapper Optional(std::unique_ptr> matcher) const + [[nodiscard]] MatcherFactoryWrapper Optional(std::unique_ptr> matcher) const { return MatcherFactoryWrapper(std::make_unique>(std::move(matcher))); } - _NODISCARD MatcherFactoryWrapper Label(const int label) const + [[nodiscard]] MatcherFactoryWrapper Label(const int label) const { return MatcherFactoryWrapper(std::make_unique>(m_label_supplier, label)); } diff --git a/src/Parser/Parsing/Matcher/MatcherResult.cpp b/src/Parser/Parsing/Matcher/MatcherResult.cpp index b79de9ce..5e7c7cb8 100644 --- a/src/Parser/Parsing/Matcher/MatcherResult.cpp +++ b/src/Parser/Parsing/Matcher/MatcherResult.cpp @@ -3,11 +3,11 @@ namespace { // The highest bit is the fabricated flag - constexpr size_t FABRICATED_FLAG_MASK = 1uz << (sizeof(size_t) * 8uz - 1uz); - constexpr size_t TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK; + constexpr unsigned FABRICATED_FLAG_MASK = 1u << (sizeof(unsigned) * 8u - 1u); + constexpr unsigned TOKEN_INDEX_MASK = ~FABRICATED_FLAG_MASK; } // namespace -MatcherResultTokenIndex::MatcherResultTokenIndex(const size_t index, const bool isFabricated) +MatcherResultTokenIndex::MatcherResultTokenIndex(const unsigned index, const bool isFabricated) { m_token_index = index & TOKEN_INDEX_MASK; if (isFabricated) @@ -19,7 +19,7 @@ bool MatcherResultTokenIndex::IsFabricated() const return m_token_index & FABRICATED_FLAG_MASK; } -size_t MatcherResultTokenIndex::GetTokenIndex() const +unsigned MatcherResultTokenIndex::GetTokenIndex() const { return m_token_index & TOKEN_INDEX_MASK; } diff --git a/src/Parser/Parsing/Matcher/MatcherResult.h b/src/Parser/Parsing/Matcher/MatcherResult.h index 719f30d5..91bfc6d5 100644 --- a/src/Parser/Parsing/Matcher/MatcherResult.h +++ b/src/Parser/Parsing/Matcher/MatcherResult.h @@ -10,12 +10,12 @@ class MatcherResultTokenIndex { public: - MatcherResultTokenIndex(size_t index, bool isFabricated); + MatcherResultTokenIndex(unsigned index, bool isFabricated); [[nodiscard]] bool IsFabricated() const; - [[nodiscard]] size_t GetTokenIndex() const; + [[nodiscard]] unsigned GetTokenIndex() const; private: - size_t m_token_index; + unsigned m_token_index; }; class MatcherResultCapture @@ -54,8 +54,9 @@ public: for (const auto& capture : other.m_captures) { if (capture.m_token_index.IsFabricated()) - m_captures.emplace_back(capture.GetCaptureId(), - MatcherResultTokenIndex(m_fabricated_tokens.size() + capture.m_token_index.GetTokenIndex(), true)); + m_captures.emplace_back( + capture.GetCaptureId(), + MatcherResultTokenIndex(static_cast(m_fabricated_tokens.size()) + capture.m_token_index.GetTokenIndex(), true)); else m_captures.emplace_back(capture.GetCaptureId(), capture.m_token_index); } @@ -63,7 +64,7 @@ public: for (const auto& token : other.m_matched_tokens) { if (token.IsFabricated()) - m_matched_tokens.emplace_back(m_fabricated_tokens.size() + token.GetTokenIndex(), true); + m_matched_tokens.emplace_back(static_cast(m_fabricated_tokens.size()) + token.GetTokenIndex(), true); else m_matched_tokens.emplace_back(token.GetTokenIndex(), false); } diff --git a/src/Parser/Parsing/Simple/Expression/SimpleExpressionMatchers.cpp b/src/Parser/Parsing/Simple/Expression/SimpleExpressionMatchers.cpp index 8a347444..ea632dda 100644 --- a/src/Parser/Parsing/Simple/Expression/SimpleExpressionMatchers.cpp +++ b/src/Parser/Parsing/Simple/Expression/SimpleExpressionMatchers.cpp @@ -191,7 +191,7 @@ std::unique_ptr SimpleExpressionMatchers::ProcessExpression(S if (operationIndex < 0 || operationIndex >= static_cast(SimpleBinaryOperationId::COUNT)) throw ParsingException(TokenPos(), "Invalid binary operation id @ Expression"); - operators.emplace_back(operators.size(), SimpleExpressionBinaryOperationType::ALL_OPERATION_TYPES[operationIndex]); + operators.emplace_back(static_cast(operators.size()), SimpleExpressionBinaryOperationType::ALL_OPERATION_TYPES[operationIndex]); } else break; diff --git a/src/Parser/Parsing/Simple/Matcher/SimpleMatcherFactory.h b/src/Parser/Parsing/Simple/Matcher/SimpleMatcherFactory.h index 7853e450..a21456e3 100644 --- a/src/Parser/Parsing/Simple/Matcher/SimpleMatcherFactory.h +++ b/src/Parser/Parsing/Simple/Matcher/SimpleMatcherFactory.h @@ -10,17 +10,17 @@ class SimpleMatcherFactory : public AbstractMatcherFactory public: explicit SimpleMatcherFactory(const IMatcherForLabelSupplier* labelSupplier); - _NODISCARD MatcherFactoryWrapper Type(SimpleParserValueType type) const; - _NODISCARD MatcherFactoryWrapper Keyword(std::string value) const; - _NODISCARD MatcherFactoryWrapper KeywordIgnoreCase(std::string value) const; - _NODISCARD MatcherFactoryWrapper KeywordPrefix(std::string value) const; - _NODISCARD MatcherFactoryWrapper Identifier() const; - _NODISCARD MatcherFactoryWrapper String() const; - _NODISCARD MatcherFactoryWrapper Integer() const; - _NODISCARD MatcherFactoryWrapper IntegerWithSign() const; - _NODISCARD MatcherFactoryWrapper FloatingPoint() const; - _NODISCARD MatcherFactoryWrapper FloatingPointWithSign() const; - _NODISCARD MatcherFactoryWrapper Char(char c) const; - _NODISCARD MatcherFactoryWrapper MultiChar(int multiCharacterSequenceId) const; - _NODISCARD MatcherFactoryWrapper AnyCharBesides(std::vector chars) const; + [[nodiscard]] MatcherFactoryWrapper Type(SimpleParserValueType type) const; + [[nodiscard]] MatcherFactoryWrapper Keyword(std::string value) const; + [[nodiscard]] MatcherFactoryWrapper KeywordIgnoreCase(std::string value) const; + [[nodiscard]] MatcherFactoryWrapper KeywordPrefix(std::string value) const; + [[nodiscard]] MatcherFactoryWrapper Identifier() const; + [[nodiscard]] MatcherFactoryWrapper String() const; + [[nodiscard]] MatcherFactoryWrapper Integer() const; + [[nodiscard]] MatcherFactoryWrapper IntegerWithSign() const; + [[nodiscard]] MatcherFactoryWrapper FloatingPoint() const; + [[nodiscard]] MatcherFactoryWrapper FloatingPointWithSign() const; + [[nodiscard]] MatcherFactoryWrapper Char(char c) const; + [[nodiscard]] MatcherFactoryWrapper MultiChar(int multiCharacterSequenceId) const; + [[nodiscard]] MatcherFactoryWrapper AnyCharBesides(std::vector chars) const; }; diff --git a/src/Parser/Parsing/Simple/SimpleLexer.cpp b/src/Parser/Parsing/Simple/SimpleLexer.cpp index d20fee7f..6b48f1c3 100644 --- a/src/Parser/Parsing/Simple/SimpleLexer.cpp +++ b/src/Parser/Parsing/Simple/SimpleLexer.cpp @@ -79,7 +79,7 @@ bool SimpleLexer::ReadMultiCharacterToken(const MultiCharacterTokenLookupEntry* linePos++; } - m_current_line_offset = m_current_line_offset - 1 + multiTokenLookup->m_value.size(); + m_current_line_offset = m_current_line_offset - 1 + static_cast(multiTokenLookup->m_value.size()); return true; } diff --git a/src/Utils/Utils/Arguments/ArgumentParser.cpp b/src/Utils/Utils/Arguments/ArgumentParser.cpp index caff4ce1..8192f778 100644 --- a/src/Utils/Utils/Arguments/ArgumentParser.cpp +++ b/src/Utils/Utils/Arguments/ArgumentParser.cpp @@ -98,7 +98,7 @@ bool ArgumentParser::ParseArguments(std::vector& args) m_matched_options[matchedOption] = std::vector(); } - const auto parameterCount = matchedOption->m_parameters.size(); + const auto parameterCount = static_cast(matchedOption->m_parameters.size()); if (argIndex + parameterCount >= argCount) { std::cout << std::format("Not enough parameters for option '{}'.\n", arg); diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParserState.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParserState.cpp index 00ed3005..0169d5ed 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParserState.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParserState.cpp @@ -130,7 +130,7 @@ bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& t if (foundDefinition == nullptr) { - currentSeparatorPos = typeNameValue.size(); + currentSeparatorPos = static_cast(typeNameValue.size()); foundDefinition = m_repository->GetDataDefinitionByName(typeNameValue); } diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Matcher/CommandsCommonMatchers.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Matcher/CommandsCommonMatchers.cpp index 8bed3923..29aa8e4d 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Matcher/CommandsCommonMatchers.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Matcher/CommandsCommonMatchers.cpp @@ -376,7 +376,7 @@ std::unique_ptr operands.emplace_back(std::move(firstStatementPart)); if (result.PeekAndRemoveIfTag(TAG_EVALUATION_OPERATION) == TAG_EVALUATION_OPERATION) - operators.emplace_back(operators.size(), result.NextCapture(CAPTURE_BINARY_OPERATION_TYPE).OpTypeValue()); + operators.emplace_back(static_cast(operators.size()), result.NextCapture(CAPTURE_BINARY_OPERATION_TYPE).OpTypeValue()); else break;