2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-07-16 13:09:43 +00:00

Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions
@@ -1,9 +1,5 @@
#include "CommandsFileReader.h"
#include <algorithm>
#include <chrono>
#include <iostream>
#include "Impl/CommandsLexer.h"
#include "Impl/CommandsParser.h"
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
@@ -16,6 +12,10 @@
#include "Parsing/PostProcessing/UnionsPostProcessor.h"
#include "Parsing/PostProcessing/UsagesPostProcessor.h"
#include <algorithm>
#include <chrono>
#include <iostream>
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
: m_args(args),
m_filename(std::move(filename)),
@@ -64,7 +64,7 @@ void CommandsFileReader::SetupPostProcessors()
bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
{
if(m_args->m_verbose)
if (m_args->m_verbose)
{
std::cout << "Reading commands file: " << m_filename << std::endl;
}
@@ -81,7 +81,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
const auto result = parser->Parse();
const auto end = std::chrono::steady_clock::now();
if(m_args->m_verbose)
if (m_args->m_verbose)
{
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
}
@@ -89,8 +89,10 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
if (!result)
return false;
return std::all_of(m_post_processors.begin(), m_post_processors.end(), [repository](const std::unique_ptr<IPostProcessor>& postProcessor)
{
return postProcessor->PostProcess(repository);
});
return std::all_of(m_post_processors.begin(),
m_post_processors.end(),
[repository](const std::unique_ptr<IPostProcessor>& postProcessor)
{
return postProcessor->PostProcess(repository);
});
}
@@ -1,11 +1,11 @@
#pragma once
#include <string>
#include "ZoneCodeGeneratorArguments.h"
#include "Parsing/IParserLineStream.h"
#include "Parsing/PostProcessing/IPostProcessor.h"
#include "Persistence/IDataRepository.h"
#include "ZoneCodeGeneratorArguments.h"
#include <string>
class CommandsFileReader
{
@@ -26,25 +26,23 @@ CommandsParser::CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepo
const std::vector<CommandsParser::sequence_t*>& CommandsParser::GetTestsForState()
{
static std::vector<sequence_t*> tests({
new SequenceAction(),
new SequenceAllocAlign(),
new SequenceArchitecture(),
new SequenceArrayCount(),
new SequenceArraySize(),
new SequenceAsset(),
new SequenceBlock(),
new SequenceCondition(),
new SequenceCount(),
new SequenceGame(),
new SequenceName(),
new SequenceReorder(),
new SequenceReusable(),
new SequenceScriptString(),
new SequenceSetBlock(),
new SequenceString(),
new SequenceUse()
});
static std::vector<sequence_t*> tests({new SequenceAction(),
new SequenceAllocAlign(),
new SequenceArchitecture(),
new SequenceArrayCount(),
new SequenceArraySize(),
new SequenceAsset(),
new SequenceBlock(),
new SequenceCondition(),
new SequenceCount(),
new SequenceGame(),
new SequenceName(),
new SequenceReorder(),
new SequenceReusable(),
new SequenceScriptString(),
new SequenceSetBlock(),
new SequenceString(),
new SequenceUse()});
return tests;
}
@@ -54,8 +54,7 @@ bool CommandsParserState::GetNextTypenameSeparatorPos(const std::string& typeNam
const auto typeNameValueSize = typeNameValue.size();
for (auto currentHead = startPos + 1; currentHead < typeNameValueSize; currentHead++)
{
if (typeNameValue[currentHead] == ':'
&& typeNameValue[currentHead - 1] == ':')
if (typeNameValue[currentHead] == ':' && typeNameValue[currentHead - 1] == ':')
{
separatorPos = currentHead - 1;
return true;
@@ -65,7 +64,10 @@ bool CommandsParserState::GetNextTypenameSeparatorPos(const std::string& typeNam
return false;
}
bool CommandsParserState::ExtractMembersFromTypenameInternal(const std::string& typeNameValue, unsigned typeNameOffset, StructureInformation* type, std::vector<MemberInformation*>& members)
bool CommandsParserState::ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
unsigned typeNameOffset,
StructureInformation* type,
std::vector<MemberInformation*>& members)
{
auto startOffset = typeNameOffset;
while (GetNextTypenameSeparatorPos(typeNameValue, typeNameOffset, typeNameOffset))
@@ -89,13 +91,17 @@ bool CommandsParserState::ExtractMembersFromTypenameInternal(const std::string&
return true;
}
bool CommandsParserState::GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const
bool CommandsParserState::GetMembersFromTypename(const std::string& typeNameValue,
StructureInformation* baseType,
std::vector<MemberInformation*>& members) const
{
return m_in_use != nullptr && ExtractMembersFromTypenameInternal(typeNameValue, 0, m_in_use, members)
|| ExtractMembersFromTypenameInternal(typeNameValue, 0, baseType, members);
|| ExtractMembersFromTypenameInternal(typeNameValue, 0, baseType, members);
}
bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const
bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& typeNameValue,
StructureInformation*& structure,
std::vector<MemberInformation*>& members) const
{
if (m_in_use != nullptr)
{
@@ -1,11 +1,11 @@
#pragma once
#include "Persistence/IDataRepository.h"
#include "Utils/ClassUtils.h"
#include <memory>
#include <string>
#include "Utils/ClassUtils.h"
#include "Persistence/IDataRepository.h"
class CommandsParserState
{
IDataRepository* m_repository;
@@ -13,7 +13,10 @@ class CommandsParserState
static MemberInformation* GetMemberWithName(const std::string& memberName, StructureInformation* type);
static bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, unsigned startPos, unsigned& separatorPos);
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue, unsigned typeNameOffset, StructureInformation* type, std::vector<MemberInformation*>& members);
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
unsigned typeNameOffset,
StructureInformation* type,
std::vector<MemberInformation*>& members);
public:
explicit CommandsParserState(IDataRepository* repository);
@@ -1,11 +1,11 @@
#pragma once
#include <string>
#include "Domain/Evaluation/OperationType.h"
#include "Parsing/IParserValue.h"
#include "Utils/ClassUtils.h"
#include "Parsing/TokenPos.h"
#include "Utils/ClassUtils.h"
#include <string>
enum class CommandsParserValueType
{
@@ -55,6 +55,7 @@ public:
TokenPos m_pos;
CommandsParserValueType m_type;
size_t m_hash;
union ValueType
{
char char_value;
@@ -103,4 +104,4 @@ public:
_NODISCARD size_t IdentifierHash() const;
_NODISCARD std::string& TypeNameValue() const;
_NODISCARD const OperationType* OpTypeValue() const;
};
};
@@ -1,95 +1,74 @@
#include "CommandsCommonMatchers.h"
#include <list>
#include <sstream>
#include <vector>
#include <type_traits>
#include "CommandsMatcherFactory.h"
#include "Domain/Evaluation/OperandDynamic.h"
#include "Domain/Evaluation/OperandStatic.h"
#include "Domain/Evaluation/Operation.h"
#include <list>
#include <sstream>
#include <type_traits>
#include <vector>
std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::Typename(const supplier_t* labelSupplier)
{
static constexpr const char* BUILT_IN_TYPE_NAMES[]
{
"unsigned",
"char",
"short",
"int",
"long"
};
static_assert(std::extent<decltype(BUILT_IN_TYPE_NAMES)>::value == static_cast<int>(CommandsParserValueType::BUILT_IN_LAST) - static_cast<int>(CommandsParserValueType::BUILT_IN_FIRST) + 1);
static constexpr const char* BUILT_IN_TYPE_NAMES[]{"unsigned", "char", "short", "int", "long"};
static_assert(std::extent<decltype(BUILT_IN_TYPE_NAMES)>::value
== static_cast<int>(CommandsParserValueType::BUILT_IN_LAST) - static_cast<int>(CommandsParserValueType::BUILT_IN_FIRST) + 1);
const CommandsMatcherFactory create(labelSupplier);
return create.Or({
create.And({
create.Optional(create.Type(CommandsParserValueType::UNSIGNED)),
create.Or({
create.Type(CommandsParserValueType::CHAR),
create.Type(CommandsParserValueType::SHORT),
create.Type(CommandsParserValueType::INT),
create.And({
create.Type(CommandsParserValueType::LONG),
create.Optional(create.Type(CommandsParserValueType::LONG))
})
})
}).Transform([](CommandsMatcherFactory::token_list_t& values)
{
std::ostringstream str;
auto first = true;
return create.Or(
{create
.And({create.Optional(create.Type(CommandsParserValueType::UNSIGNED)),
create.Or({create.Type(CommandsParserValueType::CHAR),
create.Type(CommandsParserValueType::SHORT),
create.Type(CommandsParserValueType::INT),
create.And({create.Type(CommandsParserValueType::LONG), create.Optional(create.Type(CommandsParserValueType::LONG))})})})
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
std::ostringstream str;
auto first = true;
for (const auto& token : values)
{
if (first)
first = false;
else
str << " ";
str << BUILT_IN_TYPE_NAMES[static_cast<int>(token.get().m_type) - static_cast<int>(CommandsParserValueType::BUILT_IN_FIRST)];
}
for (const auto& token : values)
{
if (first)
first = false;
else
str << " ";
str << BUILT_IN_TYPE_NAMES[static_cast<int>(token.get().m_type) - static_cast<int>(CommandsParserValueType::BUILT_IN_FIRST)];
}
return CommandsParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
}),
create.And({
create.Identifier(),
create.OptionalLoop(create.And({
create.Char(':'),
create.Char(':'),
create.Identifier()
}))
}).Transform([](CommandsMatcherFactory::token_list_t& values)
{
std::ostringstream str;
str << values[0].get().IdentifierValue();
return CommandsParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
}),
create.And({create.Identifier(), create.OptionalLoop(create.And({create.Char(':'), create.Char(':'), create.Identifier()}))})
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
std::ostringstream str;
str << values[0].get().IdentifierValue();
for (auto i = 3u; i < values.size(); i += 3)
str << "::" << values[i].get().IdentifierValue();
for (auto i = 3u; i < values.size(); i += 3)
str << "::" << values[i].get().IdentifierValue();
return CommandsParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
})
});
return CommandsParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
})});
}
std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::ArrayDef(const supplier_t* labelSupplier)
{
const CommandsMatcherFactory create(labelSupplier);
return create.And({
create.Char('['),
create.Or({
create.Integer(),
create.Identifier()
}),
create.Char(']')
}).Transform([](CommandsMatcherFactory::token_list_t& values)
{
if (values[1].get().m_type == CommandsParserValueType::INTEGER)
return CommandsParserValue::Integer(values[1].get().GetPos(), values[1].get().IntegerValue());
return create.And({create.Char('['), create.Or({create.Integer(), create.Identifier()}), create.Char(']')})
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
if (values[1].get().m_type == CommandsParserValueType::INTEGER)
return CommandsParserValue::Integer(values[1].get().GetPos(), values[1].get().IntegerValue());
return CommandsParserValue::Identifier(values[1].get().GetPos(), new std::string(values[1].get().IdentifierValue()));
});
return CommandsParserValue::Identifier(values[1].get().GetPos(), new std::string(values[1].get().IdentifierValue()));
});
}
static constexpr int TAG_OPERAND = std::numeric_limits<int>::max() - 1;
@@ -112,125 +91,142 @@ std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::Parse
{
const CommandsMatcherFactory create(labelSupplier);
return create.And({
create.Char('['),
create.Label(LABEL_EVALUATION),
create.Char(']').Tag(TAG_OPERAND_ARRAY_END)
}).Tag(TAG_OPERAND_ARRAY);
return create.And({create.Char('['), create.Label(LABEL_EVALUATION), create.Char(']').Tag(TAG_OPERAND_ARRAY_END)}).Tag(TAG_OPERAND_ARRAY);
}
std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::ParseOperand(const supplier_t* labelSupplier)
{
const CommandsMatcherFactory create(labelSupplier);
return create.Or({
create.And({
create.Label(LABEL_TYPENAME).Capture(CAPTURE_OPERAND_TYPENAME),
create.OptionalLoop(MatcherFactoryWrapper<CommandsParserValue>(ParseOperandArray(labelSupplier)).Capture(CAPTURE_OPERAND_ARRAY))
}).Tag(TAG_OPERAND_TYPENAME),
create.Integer().Tag(TAG_OPERAND_INTEGER).Capture(CAPTURE_OPERAND_INTEGER)
}).Tag(TAG_OPERAND);
return create
.Or({create
.And({create.Label(LABEL_TYPENAME).Capture(CAPTURE_OPERAND_TYPENAME),
create.OptionalLoop(MatcherFactoryWrapper<CommandsParserValue>(ParseOperandArray(labelSupplier)).Capture(CAPTURE_OPERAND_ARRAY))})
.Tag(TAG_OPERAND_TYPENAME),
create.Integer().Tag(TAG_OPERAND_INTEGER).Capture(CAPTURE_OPERAND_INTEGER)})
.Tag(TAG_OPERAND);
}
std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::ParseOperationType(const supplier_t* labelSupplier)
{
const CommandsMatcherFactory create(labelSupplier);
return create.Or({
create.Char('+').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_ADD);
}),
create.Char('-').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SUBTRACT);
}),
create.Char('*').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_MULTIPLY);
}),
create.Char('/').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_DIVIDE);
}),
create.Char('%').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_REMAINDER);
}),
create.Char('&').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_AND);
}),
create.Char('^').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_XOR);
}),
create.Char('|').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_OR);
}),
create.Type(CommandsParserValueType::SHIFT_LEFT).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SHIFT_LEFT);
}),
create.Type(CommandsParserValueType::SHIFT_RIGHT).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SHIFT_RIGHT);
}),
create.Char('>').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_GREATER_THAN);
}),
create.Type(CommandsParserValueType::GREATER_EQUAL).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_GREATER_EQUAL_THAN);
}),
create.Char('<').Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_LESS_THAN);
}),
create.Type(CommandsParserValueType::LESS_EQUAL).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_LESS_EQUAL_THAN);
}),
create.Type(CommandsParserValueType::EQUALS).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_EQUALS);
}),
create.Type(CommandsParserValueType::NOT_EQUAL).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_NOT_EQUAL);
}),
create.Type(CommandsParserValueType::LOGICAL_AND).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_AND);
}),
create.Type(CommandsParserValueType::LOGICAL_OR).Transform([](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_OR);
})
}).Capture(CAPTURE_BINARY_OPERATION_TYPE);
return create
.Or({create.Char('+').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_ADD);
}),
create.Char('-').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SUBTRACT);
}),
create.Char('*').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_MULTIPLY);
}),
create.Char('/').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_DIVIDE);
}),
create.Char('%').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_REMAINDER);
}),
create.Char('&').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_AND);
}),
create.Char('^').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_XOR);
}),
create.Char('|').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_BITWISE_OR);
}),
create.Type(CommandsParserValueType::SHIFT_LEFT)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SHIFT_LEFT);
}),
create.Type(CommandsParserValueType::SHIFT_RIGHT)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_SHIFT_RIGHT);
}),
create.Char('>').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_GREATER_THAN);
}),
create.Type(CommandsParserValueType::GREATER_EQUAL)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_GREATER_EQUAL_THAN);
}),
create.Char('<').Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_LESS_THAN);
}),
create.Type(CommandsParserValueType::LESS_EQUAL)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_LESS_EQUAL_THAN);
}),
create.Type(CommandsParserValueType::EQUALS)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_EQUALS);
}),
create.Type(CommandsParserValueType::NOT_EQUAL)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_NOT_EQUAL);
}),
create.Type(CommandsParserValueType::LOGICAL_AND)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_AND);
}),
create.Type(CommandsParserValueType::LOGICAL_OR)
.Transform(
[](CommandsMatcherFactory::token_list_t& values)
{
return CommandsParserValue::OpType(values[0].get().GetPos(), OperationType::OPERATION_OR);
})})
.Capture(CAPTURE_BINARY_OPERATION_TYPE);
}
std::unique_ptr<CommandsCommonMatchers::matcher_t> CommandsCommonMatchers::Evaluation(const supplier_t* labelSupplier)
{
const CommandsMatcherFactory create(labelSupplier);
return create.And({
create.Or({
create.And({
create.Optional(create.Char('!').Tag(TAG_EVALUATION_NOT)),
create.Char('('),
create.Label(LABEL_EVALUATION),
create.Char(')').Tag(TAG_EVALUATION_PARENTHESIS_END)
}).Tag(TAG_EVALUATION_PARENTHESIS),
ParseOperand(labelSupplier)
}),
create.Optional(create.And({
ParseOperationType(labelSupplier),
create.Label(LABEL_EVALUATION)
}).Tag(TAG_EVALUATION_OPERATION))
}).Tag(TAG_EVALUATION);
return create
.And({create.Or({create
.And({create.Optional(create.Char('!').Tag(TAG_EVALUATION_NOT)),
create.Char('('),
create.Label(LABEL_EVALUATION),
create.Char(')').Tag(TAG_EVALUATION_PARENTHESIS_END)})
.Tag(TAG_EVALUATION_PARENTHESIS),
ParseOperand(labelSupplier)}),
create.Optional(create.And({ParseOperationType(labelSupplier), create.Label(LABEL_EVALUATION)}).Tag(TAG_EVALUATION_OPERATION))})
.Tag(TAG_EVALUATION);
}
std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluationInParenthesis(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
@@ -248,7 +244,8 @@ std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluationInParenthe
return processedEvaluation;
}
std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessOperand(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType)
std::unique_ptr<IEvaluation>
CommandsCommonMatchers::ProcessOperand(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType)
{
const auto nextTag = result.NextTag();
@@ -293,7 +290,8 @@ std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluation(CommandsP
return ProcessEvaluation(state, result, nullptr);
}
std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluation(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType)
std::unique_ptr<IEvaluation>
CommandsCommonMatchers::ProcessEvaluation(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType)
{
if (result.PeekAndRemoveIfTag(TAG_EVALUATION) != TAG_EVALUATION)
return nullptr;
@@ -332,14 +330,15 @@ std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluation(CommandsP
throw ParsingException(TokenPos(), "Expected EvaluationTag @ Evaluation");
}
operators.sort([](const std::pair<unsigned, const OperationType*>& p1, const std::pair<unsigned, const OperationType*>& p2)
{
if(p1.second->m_precedence != p2.second->m_precedence)
return p1.second->m_precedence > p2.second->m_precedence;
operators.sort(
[](const std::pair<unsigned, const OperationType*>& p1, const std::pair<unsigned, const OperationType*>& p2)
{
if (p1.second->m_precedence != p2.second->m_precedence)
return p1.second->m_precedence > p2.second->m_precedence;
return p1.first > p2.first;
});
return p1.first > p2.first;
});
while (!operators.empty())
{
const auto [operatorIndex, operatorType] = operators.back();
@@ -350,12 +349,12 @@ std::unique_ptr<IEvaluation> CommandsCommonMatchers::ProcessEvaluation(CommandsP
operators.pop_back();
for(auto& [opIndex, _] : operators)
for (auto& [opIndex, _] : operators)
{
if (opIndex > operatorIndex)
opIndex--;
}
}
return std::move(operands.front());
}
@@ -1,8 +1,5 @@
#pragma once
#include <limits>
#include <memory>
#include "Domain/Evaluation/IEvaluation.h"
#include "Domain/Evaluation/OperationType.h"
#include "Parsing/Commands/Impl/CommandsParserState.h"
@@ -11,6 +8,9 @@
#include "Parsing/Matcher/MatcherLabel.h"
#include "Parsing/Sequence/SequenceResult.h"
#include <limits>
#include <memory>
class CommandsCommonMatchers
{
public:
@@ -20,7 +20,7 @@ public:
static constexpr int LABEL_TYPENAME = std::numeric_limits<int>::max() - 1;
static constexpr int LABEL_ARRAY_DEF = std::numeric_limits<int>::max() - 2;
static constexpr int LABEL_EVALUATION = std::numeric_limits<int>::max() - 3;
static std::unique_ptr<matcher_t> Typename(const supplier_t* labelSupplier);
static std::unique_ptr<matcher_t> ArrayDef(const supplier_t* labelSupplier);
@@ -30,10 +30,12 @@ private:
static std::unique_ptr<matcher_t> ParseOperationType(const supplier_t* labelSupplier);
static std::unique_ptr<IEvaluation> ProcessEvaluationInParenthesis(CommandsParserState* state, SequenceResult<CommandsParserValue>& result);
static std::unique_ptr<IEvaluation> ProcessOperand(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType);
static std::unique_ptr<IEvaluation>
ProcessOperand(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType);
public:
static std::unique_ptr<matcher_t> Evaluation(const supplier_t* labelSupplier);
static std::unique_ptr<IEvaluation> ProcessEvaluation(CommandsParserState* state, SequenceResult<CommandsParserValue>& result);
static std::unique_ptr<IEvaluation> ProcessEvaluation(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType);
static std::unique_ptr<IEvaluation>
ProcessEvaluation(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, StructureInformation* currentType);
};
@@ -8,7 +8,6 @@ CommandsMatcherCharacter::CommandsMatcherCharacter(const char c)
MatcherResult<CommandsParserValue> CommandsMatcherCharacter::CanMatch(ILexer<CommandsParserValue>* lexer, const unsigned tokenOffset)
{
const auto& token = lexer->GetToken(tokenOffset);
return token.m_type == CommandsParserValueType::CHARACTER && token.CharacterValue() == m_char
? MatcherResult<CommandsParserValue>::Match(1)
: MatcherResult<CommandsParserValue>::NoMatch();
return token.m_type == CommandsParserValueType::CHARACTER && token.CharacterValue() == m_char ? MatcherResult<CommandsParserValue>::Match(1)
: MatcherResult<CommandsParserValue>::NoMatch();
}
@@ -1,10 +1,10 @@
#pragma once
#include <string>
#include "Parsing/Commands/Impl/CommandsParserValue.h"
#include "Parsing/Matcher/AbstractMatcherFactory.h"
#include <string>
class CommandsMatcherFactory final : public AbstractMatcherFactory<CommandsParserValue>
{
public:
@@ -11,6 +11,6 @@ MatcherResult<CommandsParserValue> CommandsMatcherKeyword::CanMatch(ILexer<Comma
{
const auto& token = lexer->GetToken(tokenOffset);
return token.m_type == CommandsParserValueType::IDENTIFIER && token.IdentifierHash() == m_hash && token.IdentifierValue() == m_value
? MatcherResult<CommandsParserValue>::Match(1)
: MatcherResult<CommandsParserValue>::NoMatch();
? MatcherResult<CommandsParserValue>::Match(1)
: MatcherResult<CommandsParserValue>::NoMatch();
}
@@ -1,10 +1,10 @@
#pragma once
#include <string>
#include "Parsing/Commands/Impl/CommandsParserValue.h"
#include "Parsing/Matcher/AbstractMatcher.h"
#include <string>
class CommandsMatcherKeyword final : public AbstractMatcher<CommandsParserValue>
{
size_t m_hash;
@@ -7,7 +7,5 @@ CommandsMatcherValueType::CommandsMatcherValueType(CommandsParserValueType type)
MatcherResult<CommandsParserValue> CommandsMatcherValueType::CanMatch(ILexer<CommandsParserValue>* lexer, const unsigned tokenOffset)
{
return lexer->GetToken(tokenOffset).m_type == m_type
? MatcherResult<CommandsParserValue>::Match(1)
: MatcherResult<CommandsParserValue>::NoMatch();
return lexer->GetToken(tokenOffset).m_type == m_type ? MatcherResult<CommandsParserValue>::Match(1) : MatcherResult<CommandsParserValue>::NoMatch();
}
@@ -1,7 +1,7 @@
#include "SequenceAction.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceAction::SequenceAction()
{
@@ -9,31 +9,20 @@ SequenceAction::SequenceAction()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(
{
create.Char('('),
create.Optional(create.And({
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_ARG_TYPE),
create.OptionalLoop(create.And({
create.Char(','),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_ARG_TYPE)
}))
})),
create.Char(')')
}, LABEL_ACTION_ARGS);
{create.Char('('),
create.Optional(
create.And({create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_ARG_TYPE),
create.OptionalLoop(create.And({create.Char(','), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_ARG_TYPE)}))})),
create.Char(')')},
LABEL_ACTION_ARGS);
AddMatchers({
create.Keyword("set"),
create.Keyword("action"),
create.Or({
create.And({
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_ACTION_NAME)
}),
create.Identifier().Capture(CAPTURE_ACTION_NAME)
}),
create.Label(LABEL_ACTION_ARGS),
create.Char(';')
});
AddMatchers(
{create.Keyword("set"),
create.Keyword("action"),
create.Or({create.And({create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Identifier().Capture(CAPTURE_ACTION_NAME)}),
create.Identifier().Capture(CAPTURE_ACTION_NAME)}),
create.Label(LABEL_ACTION_ARGS),
create.Char(';')});
}
void SequenceAction::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -67,7 +56,7 @@ void SequenceAction::ProcessMatch(CommandsParserState* state, SequenceResult<Com
// Extract all parameter types that were specified
std::vector<DataDefinition*> parameterTypes;
while(result.HasNextCapture(CAPTURE_ARG_TYPE))
while (result.HasNextCapture(CAPTURE_ARG_TYPE))
{
const auto& argTypeToken = result.NextCapture(CAPTURE_ARG_TYPE);
auto* dataDefinition = state->GetRepository()->GetDataDefinitionByName(argTypeToken.TypeNameValue());
@@ -1,7 +1,7 @@
#include "SequenceAllocAlign.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceAllocAlign::SequenceAllocAlign()
{
@@ -9,13 +9,11 @@ SequenceAllocAlign::SequenceAllocAlign()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
AddMatchers({
create.Keyword("set"),
create.Keyword("allocalign"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')
});
AddMatchers({create.Keyword("set"),
create.Keyword("allocalign"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')});
}
void SequenceAllocAlign::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -26,7 +24,7 @@ void SequenceAllocAlign::ProcessMatch(CommandsParserState* state, SequenceResult
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), type, memberChain))
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
if(memberChain.empty())
if (memberChain.empty())
throw ParsingException(typeNameToken.GetPos(), "Need to specify a member");
auto allocAlignEvaluation = CommandsCommonMatchers::ProcessEvaluation(state, result, type);
@@ -1,17 +1,13 @@
#include "SequenceArchitecture.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceArchitecture::SequenceArchitecture()
{
const CommandsMatcherFactory create(this);
AddMatchers({
create.Keyword("architecture"),
create.Identifier().Capture(CAPTURE_ARCHITECTURE),
create.Char(';')
});
AddMatchers({create.Keyword("architecture"), create.Identifier().Capture(CAPTURE_ARCHITECTURE), create.Char(';')});
m_architecture_mapping["x86"] = Architecture::X86;
m_architecture_mapping["x64"] = Architecture::X64;
@@ -23,7 +19,7 @@ void SequenceArchitecture::ProcessMatch(CommandsParserState* state, SequenceResu
const auto foundArchitecture = m_architecture_mapping.find(architectureToken.IdentifierValue());
if(foundArchitecture == m_architecture_mapping.end())
if (foundArchitecture == m_architecture_mapping.end())
throw ParsingException(architectureToken.GetPos(), "Unknown architecture");
state->SetArchitecture(foundArchitecture->second);
@@ -1,9 +1,8 @@
#include "SequenceArrayCount.h"
#include "Domain/Definition/ArrayDeclarationModifier.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceArrayCount::SequenceArrayCount()
{
@@ -11,13 +10,11 @@ SequenceArrayCount::SequenceArrayCount()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
AddMatchers({
create.Keyword("set"),
create.Keyword("arraycount"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')
});
AddMatchers({create.Keyword("set"),
create.Keyword("arraycount"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')});
}
void SequenceArrayCount::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -29,7 +26,7 @@ void SequenceArrayCount::ProcessMatch(CommandsParserState* state, SequenceResult
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), structure, memberChain))
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
if(memberChain.empty())
if (memberChain.empty())
throw ParsingException(typeNameToken.GetPos(), "Must specify type with member");
const auto& memberDeclarationModifiers = memberChain.back()->m_member->m_type_declaration->m_declaration_modifiers;
@@ -1,9 +1,8 @@
#include "SequenceArraySize.h"
#include "Domain/Definition/ArrayDeclarationModifier.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceArraySize::SequenceArraySize()
{
@@ -11,13 +10,11 @@ SequenceArraySize::SequenceArraySize()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
AddMatchers({
create.Keyword("set"),
create.Keyword("arraysize"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION).Capture(CAPTURE_EVALUATION),
create.Char(';')
});
AddMatchers({create.Keyword("set"),
create.Keyword("arraysize"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION).Capture(CAPTURE_EVALUATION),
create.Char(';')});
}
void SequenceArraySize::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,19 +1,17 @@
#include "SequenceAsset.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceAsset::SequenceAsset()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("asset"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_ENUM_ENTRY),
create.Char(';')
});
AddMatchers({create.Keyword("asset"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_ENUM_ENTRY),
create.Char(';')});
}
void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,7 +1,7 @@
#include "SequenceBlock.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceBlock::SequenceBlock()
{
@@ -14,13 +14,11 @@ SequenceBlock::SequenceBlock()
DEFINE_FAST_FILE_BLOCK_TYPE(NORMAL);
#undef DEFINE_FAST_FILE_BLOCK_TYPE
AddMatchers({
create.Keyword("block"),
create.Identifier().Capture(CAPTURE_BLOCK_TYPE),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY),
create.Optional(create.Keyword("default").Tag(TAG_DEFAULT)),
create.Char(';')
});
AddMatchers({create.Keyword("block"),
create.Identifier().Capture(CAPTURE_BLOCK_TYPE),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY),
create.Optional(create.Keyword("default").Tag(TAG_DEFAULT)),
create.Char(';')});
}
void SequenceBlock::AddFastFileBlockToLookup(std::string name, const FastFileBlockType type)
@@ -1,9 +1,9 @@
#pragma once
#include <unordered_map>
#include "Utils/ClassUtils.h"
#include "Parsing/Commands/Impl/CommandsParser.h"
#include "Utils/ClassUtils.h"
#include <unordered_map>
class SequenceBlock final : public CommandsParser::sequence_t
{
@@ -1,8 +1,8 @@
#include "SequenceCondition.h"
#include "Domain/Evaluation/OperandStatic.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceCondition::SequenceCondition()
{
@@ -10,17 +10,13 @@ SequenceCondition::SequenceCondition()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
AddMatchers({
create.Keyword("set"),
create.Keyword("condition"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Or({
create.Keyword("always").Tag(TAG_ALWAYS),
create.Keyword("never").Tag(TAG_NEVER),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION).Tag(TAG_EVALUATION).Capture(CAPTURE_EVALUATION)
}),
create.Char(';')
});
AddMatchers({create.Keyword("set"),
create.Keyword("condition"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Or({create.Keyword("always").Tag(TAG_ALWAYS),
create.Keyword("never").Tag(TAG_NEVER),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION).Tag(TAG_EVALUATION).Capture(CAPTURE_EVALUATION)}),
create.Char(';')});
}
void SequenceCondition::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -36,7 +32,7 @@ void SequenceCondition::ProcessMatch(CommandsParserState* state, SequenceResult<
throw ParsingException(typeNameToken.GetPos(), "Conditions can only be set on members and not for types");
std::unique_ptr<IEvaluation> conditionEvaluation;
switch(result.NextTag())
switch (result.NextTag())
{
case TAG_ALWAYS:
conditionEvaluation = std::make_unique<OperandStatic>(1);
@@ -2,8 +2,8 @@
#include "Domain/Definition/ArrayDeclarationModifier.h"
#include "Domain/Definition/PointerDeclarationModifier.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceCount::SequenceCount()
{
@@ -12,18 +12,19 @@ SequenceCount::SequenceCount()
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
AddLabeledMatchers(CommandsCommonMatchers::ArrayDef(this), CommandsCommonMatchers::LABEL_ARRAY_DEF);
AddMatchers({
create.Keyword("set").Capture(CAPTURE_START),
create.Keyword("count"),
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER_RESOLVE)),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.OptionalLoop(create.Label(CommandsCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY_INDEX)),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')
});
AddMatchers({create.Keyword("set").Capture(CAPTURE_START),
create.Keyword("count"),
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER_RESOLVE)),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.OptionalLoop(create.Label(CommandsCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY_INDEX)),
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
create.Char(';')});
}
void SequenceCount::SetCountByArrayIndex(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, MemberInformation* member, PointerDeclarationModifier* pointer,
void SequenceCount::SetCountByArrayIndex(CommandsParserState* state,
SequenceResult<CommandsParserValue>& result,
MemberInformation* member,
PointerDeclarationModifier* pointer,
std::unique_ptr<IEvaluation> evaluation)
{
std::vector<int> arraySizes;
@@ -33,12 +34,12 @@ void SequenceCount::SetCountByArrayIndex(CommandsParserState* state, SequenceRes
if (modifier->GetType() == DeclarationModifierType::ARRAY)
arraySizes.push_back(dynamic_cast<ArrayDeclarationModifier*>(modifier.get())->m_size);
}
depthSize.resize(arraySizes.size());
auto currentDepthSize = 1u;
for (auto i = arraySizes.size(); i > 0; i--)
{
if(i < arraySizes.size())
if (i < arraySizes.size())
currentDepthSize *= arraySizes[i];
depthSize[i - 1] = currentDepthSize;
}
@@ -11,7 +11,10 @@ class SequenceCount final : public CommandsParser::sequence_t
static constexpr auto CAPTURE_TYPE = 2;
static constexpr auto CAPTURE_ARRAY_INDEX = 3;
static void SetCountByArrayIndex(CommandsParserState* state, SequenceResult<CommandsParserValue>& result, MemberInformation* member, PointerDeclarationModifier* pointer,
static void SetCountByArrayIndex(CommandsParserState* state,
SequenceResult<CommandsParserValue>& result,
MemberInformation* member,
PointerDeclarationModifier* pointer,
std::unique_ptr<IEvaluation> evaluation);
protected:
@@ -1,17 +1,13 @@
#include "SequenceGame.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceGame::SequenceGame()
{
const CommandsMatcherFactory create(this);
AddMatchers({
create.Keyword("game"),
create.Identifier().Capture(CAPTURE_GAME),
create.Char(';')
});
AddMatchers({create.Keyword("game"), create.Identifier().Capture(CAPTURE_GAME), create.Char(';')});
}
void SequenceGame::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,19 +1,14 @@
#include "SequenceName.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceName::SequenceName()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set"),
create.Keyword("name"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Char(';')
});
AddMatchers({create.Keyword("set"), create.Keyword("name"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Char(';')});
}
void SequenceName::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,27 +1,21 @@
#include "SequenceReorder.h"
#include <list>
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include <list>
SequenceReorder::SequenceReorder()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("reorder").Capture(CAPTURE_START),
create.Optional(create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE)),
create.Char(':'),
create.Optional(create.And({
create.Char('.'),
create.Char('.'),
create.Char('.')
}).Tag(TAG_FIND_FIRST)),
create.Loop(create.Identifier().Capture(CAPTURE_ENTRY)),
create.Char(';')
});
AddMatchers({create.Keyword("reorder").Capture(CAPTURE_START),
create.Optional(create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE)),
create.Char(':'),
create.Optional(create.And({create.Char('.'), create.Char('.'), create.Char('.')}).Tag(TAG_FIND_FIRST)),
create.Loop(create.Identifier().Capture(CAPTURE_ENTRY)),
create.Char(';')});
}
StructureInformation* SequenceReorder::GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
@@ -58,7 +52,7 @@ void SequenceReorder::ProcessMatch(CommandsParserState* state, SequenceResult<Co
auto findFirst = result.PeekAndRemoveIfTag(TAG_FIND_FIRST) == TAG_FIND_FIRST;
std::string firstVariableName;
if(findFirst)
if (findFirst)
firstVariableName = result.NextCapture(CAPTURE_ENTRY).IdentifierValue();
std::vector<std::unique_ptr<MemberInformation>> newMembers;
@@ -67,15 +61,15 @@ void SequenceReorder::ProcessMatch(CommandsParserState* state, SequenceResult<Co
for (auto& oldMember : information->m_ordered_members)
oldMembers.emplace_back(std::move(oldMember));
while(result.HasNextCapture(CAPTURE_ENTRY))
while (result.HasNextCapture(CAPTURE_ENTRY))
{
const auto& entryToken = result.NextCapture(CAPTURE_ENTRY);
const auto& nextVariableName = entryToken.IdentifierValue();
auto foundEntry = false;
for(auto i = oldMembers.begin(); i != oldMembers.end(); ++i)
for (auto i = oldMembers.begin(); i != oldMembers.end(); ++i)
{
if(i->get()->m_member->m_name == nextVariableName)
if (i->get()->m_member->m_name == nextVariableName)
{
newMembers.emplace_back(std::move(*i));
oldMembers.erase(i);
@@ -90,7 +84,7 @@ void SequenceReorder::ProcessMatch(CommandsParserState* state, SequenceResult<Co
information->m_ordered_members.clear();
while(findFirst && !oldMembers.empty())
while (findFirst && !oldMembers.empty())
{
if (oldMembers.front()->m_member->m_name == firstVariableName)
findFirst = false;
@@ -1,19 +1,15 @@
#include "SequenceReusable.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceReusable::SequenceReusable()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set"),
create.Keyword("reusable"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Char(';')
});
AddMatchers(
{create.Keyword("set"), create.Keyword("reusable"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Char(';')});
}
void SequenceReusable::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,19 +1,15 @@
#include "SequenceScriptString.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceScriptString::SequenceScriptString()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set"),
create.Keyword("scriptstring"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Char(';')
});
AddMatchers(
{create.Keyword("set"), create.Keyword("scriptstring"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Char(';')});
}
void SequenceScriptString::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,25 +1,19 @@
#include "SequenceSetBlock.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceSetBlock::SequenceSetBlock()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set").Capture(CAPTURE_START),
create.Keyword("block"),
create.Or({
create.And({
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY)
}),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY)
}),
create.Char(';')
});
AddMatchers({create.Keyword("set").Capture(CAPTURE_START),
create.Keyword("block"),
create.Or({create.And({create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY)}),
create.Identifier().Capture(CAPTURE_BLOCK_ENUM_ENTRY)}),
create.Char(';')});
}
void SequenceSetBlock::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -1,22 +1,17 @@
#include "SequenceString.h"
#include <algorithm>
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include <algorithm>
SequenceString::SequenceString()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set"),
create.Keyword("string"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Char(';')
});
AddMatchers(
{create.Keyword("set"), create.Keyword("string"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Char(';')});
}
void SequenceString::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
@@ -40,10 +35,12 @@ void SequenceString::ProcessMatch(CommandsParserState* state, SequenceResult<Com
if (!hasPointerRef)
{
const auto& modifiers = typeDecl->m_declaration_modifiers;
hasPointerRef = std::any_of(modifiers.begin(), modifiers.end(), [](const std::unique_ptr<DeclarationModifier>& modifier)
{
return modifier->GetType() == DeclarationModifierType::POINTER;
});
hasPointerRef = std::any_of(modifiers.begin(),
modifiers.end(),
[](const std::unique_ptr<DeclarationModifier>& modifier)
{
return modifier->GetType() == DeclarationModifierType::POINTER;
});
}
if (typeDecl->m_type->GetType() == DataDefinitionType::TYPEDEF)
@@ -1,18 +1,14 @@
#include "SequenceUse.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
SequenceUse::SequenceUse()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("use"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Char(';')
});
AddMatchers({create.Keyword("use"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), create.Char(';')});
}
void SequenceUse::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const