mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-15 09:17:57 -05:00
Reformat code with clang format
This commit is contained in:
@ -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
|
||||
|
@ -19,10 +19,7 @@ HeaderBlockType HeaderBlockEnum::GetType()
|
||||
|
||||
const std::vector<IHeaderBlock::sequence_t*>& HeaderBlockEnum::GetTestsForBlock()
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceCloseBlock(true),
|
||||
new SequenceEnumMember()
|
||||
});
|
||||
static std::vector<sequence_t*> tests({new SequenceCloseBlock(true), new SequenceEnumMember()});
|
||||
|
||||
return tests;
|
||||
}
|
||||
@ -51,9 +48,7 @@ void HeaderBlockEnum::OnClose(HeaderParserState* state)
|
||||
state->AddDataType(std::make_unique<TypedefDefinition>(m_namespace, m_variable_name, std::make_unique<TypeDeclaration>(m_enum_definition)));
|
||||
}
|
||||
|
||||
void HeaderBlockEnum::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block)
|
||||
{
|
||||
}
|
||||
void HeaderBlockEnum::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) {}
|
||||
|
||||
void HeaderBlockEnum::AddEnumMember(std::unique_ptr<EnumMember> enumMember)
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Domain/Definition/BaseTypeDefinition.h"
|
||||
#include "Domain/Definition/EnumDefinition.h"
|
||||
#include "IHeaderBlock.h"
|
||||
#include "IHeaderBlockNameHolder.h"
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "Domain/Definition/BaseTypeDefinition.h"
|
||||
#include "Domain/Definition/EnumDefinition.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
class HeaderBlockEnum final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining
|
||||
{
|
||||
|
@ -20,15 +20,13 @@ HeaderBlockType HeaderBlockNamespace::GetType()
|
||||
|
||||
const std::vector<IHeaderBlock::sequence_t*>& HeaderBlockNamespace::GetTestsForBlock()
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceCloseBlock(false),
|
||||
new SequenceEnum(),
|
||||
new SequenceForwardDecl(),
|
||||
new SequenceNamespace(),
|
||||
new SequenceStruct(),
|
||||
new SequenceTypedef(),
|
||||
new SequenceUnion()
|
||||
});
|
||||
static std::vector<sequence_t*> tests({new SequenceCloseBlock(false),
|
||||
new SequenceEnum(),
|
||||
new SequenceForwardDecl(),
|
||||
new SequenceNamespace(),
|
||||
new SequenceStruct(),
|
||||
new SequenceTypedef(),
|
||||
new SequenceUnion()});
|
||||
|
||||
return tests;
|
||||
}
|
||||
@ -43,6 +41,4 @@ void HeaderBlockNamespace::OnClose(HeaderParserState* state)
|
||||
state->m_namespace.Pop();
|
||||
}
|
||||
|
||||
void HeaderBlockNamespace::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block)
|
||||
{
|
||||
}
|
||||
void HeaderBlockNamespace::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) {}
|
||||
|
@ -14,26 +14,14 @@ HeaderBlockType HeaderBlockNone::GetType()
|
||||
|
||||
const std::vector<IHeaderBlock::sequence_t*>& HeaderBlockNone::GetTestsForBlock()
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceEnum(),
|
||||
new SequenceForwardDecl(),
|
||||
new SequenceNamespace(),
|
||||
new SequenceStruct(),
|
||||
new SequenceTypedef(),
|
||||
new SequenceUnion()
|
||||
});
|
||||
|
||||
static std::vector<sequence_t*> tests(
|
||||
{new SequenceEnum(), new SequenceForwardDecl(), new SequenceNamespace(), new SequenceStruct(), new SequenceTypedef(), new SequenceUnion()});
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
void HeaderBlockNone::OnOpen(HeaderParserState* state)
|
||||
{
|
||||
}
|
||||
void HeaderBlockNone::OnOpen(HeaderParserState* state) {}
|
||||
|
||||
void HeaderBlockNone::OnClose(HeaderParserState* state)
|
||||
{
|
||||
}
|
||||
void HeaderBlockNone::OnClose(HeaderParserState* state) {}
|
||||
|
||||
void HeaderBlockNone::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block)
|
||||
{
|
||||
}
|
||||
void HeaderBlockNone::OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) {}
|
||||
|
@ -24,13 +24,8 @@ HeaderBlockType HeaderBlockStruct::GetType()
|
||||
|
||||
const std::vector<IHeaderBlock::sequence_t*>& HeaderBlockStruct::GetTestsForBlock()
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceCloseBlock(true),
|
||||
new SequenceEnum(),
|
||||
new SequenceStruct(),
|
||||
new SequenceUnion(),
|
||||
new SequenceVariable()
|
||||
});
|
||||
static std::vector<sequence_t*> tests(
|
||||
{new SequenceCloseBlock(true), new SequenceEnum(), new SequenceStruct(), new SequenceUnion(), new SequenceVariable()});
|
||||
|
||||
return tests;
|
||||
}
|
||||
@ -66,7 +61,7 @@ void HeaderBlockStruct::OnClose(HeaderParserState* state)
|
||||
for (auto& member : m_members)
|
||||
structDefinition->m_members.emplace_back(std::move(member));
|
||||
|
||||
if(m_has_custom_align)
|
||||
if (m_has_custom_align)
|
||||
{
|
||||
structDefinition->m_alignment_override = static_cast<unsigned>(m_custom_alignment);
|
||||
structDefinition->m_has_alignment_override = true;
|
||||
@ -83,7 +78,8 @@ void HeaderBlockStruct::OnChildBlockClose(HeaderParserState* state, IHeaderBlock
|
||||
auto* variableDefining = dynamic_cast<IHeaderBlockVariableDefining*>(block);
|
||||
|
||||
if (variableDefining && variableDefining->IsDefiningVariable())
|
||||
m_members.emplace_back(std::make_shared<Variable>(variableDefining->GetVariableName(), std::make_unique<TypeDeclaration>(variableDefining->GetVariableType())));
|
||||
m_members.emplace_back(
|
||||
std::make_shared<Variable>(variableDefining->GetVariableName(), std::make_unique<TypeDeclaration>(variableDefining->GetVariableType())));
|
||||
}
|
||||
|
||||
void HeaderBlockStruct::AddVariable(std::shared_ptr<Variable> variable)
|
||||
|
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Domain/Definition/StructDefinition.h"
|
||||
#include "Domain/Definition/Variable.h"
|
||||
#include "IHeaderBlock.h"
|
||||
#include "IHeaderBlockNameHolder.h"
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "IHeaderBlockVariableHolder.h"
|
||||
#include "Domain/Definition/StructDefinition.h"
|
||||
#include "Domain/Definition/Variable.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class HeaderBlockStruct final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining, public IHeaderBlockVariableHolder
|
||||
{
|
||||
|
@ -24,13 +24,8 @@ HeaderBlockType HeaderBlockUnion::GetType()
|
||||
|
||||
const std::vector<IHeaderBlock::sequence_t*>& HeaderBlockUnion::GetTestsForBlock()
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceCloseBlock(true),
|
||||
new SequenceEnum(),
|
||||
new SequenceStruct(),
|
||||
new SequenceUnion(),
|
||||
new SequenceVariable()
|
||||
});
|
||||
static std::vector<sequence_t*> tests(
|
||||
{new SequenceCloseBlock(true), new SequenceEnum(), new SequenceStruct(), new SequenceUnion(), new SequenceVariable()});
|
||||
|
||||
return tests;
|
||||
}
|
||||
@ -83,7 +78,8 @@ void HeaderBlockUnion::OnChildBlockClose(HeaderParserState* state, IHeaderBlock*
|
||||
auto* variableDefining = dynamic_cast<IHeaderBlockVariableDefining*>(block);
|
||||
|
||||
if (variableDefining && variableDefining->IsDefiningVariable())
|
||||
m_members.emplace_back(std::make_shared<Variable>(variableDefining->GetVariableName(), std::make_unique<TypeDeclaration>(variableDefining->GetVariableType())));
|
||||
m_members.emplace_back(
|
||||
std::make_shared<Variable>(variableDefining->GetVariableName(), std::make_unique<TypeDeclaration>(variableDefining->GetVariableType())));
|
||||
}
|
||||
|
||||
void HeaderBlockUnion::AddVariable(std::shared_ptr<Variable> variable)
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
void AddVariable(std::shared_ptr<Variable> variable) override;
|
||||
void SetCustomAlignment(int alignment);
|
||||
void Inherit(const StructDefinition* parentStruct);
|
||||
|
||||
|
||||
void SetBlockName(const TokenPos& nameTokenPos, std::string name) override;
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
enum class HeaderBlockType
|
||||
{
|
||||
@ -16,6 +16,7 @@ enum class HeaderBlockType
|
||||
|
||||
class HeaderParserValue;
|
||||
class HeaderParserState;
|
||||
|
||||
class IHeaderBlock
|
||||
{
|
||||
public:
|
||||
@ -35,4 +36,4 @@ public:
|
||||
virtual void OnOpen(HeaderParserState* state) = 0;
|
||||
virtual void OnClose(HeaderParserState* state) = 0;
|
||||
virtual void OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) = 0;
|
||||
};
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Domain/Definition/DataDefinition.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class IHeaderBlockVariableDefining
|
||||
{
|
||||
public:
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Domain/Definition/Variable.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class IHeaderBlockVariableHolder
|
||||
{
|
||||
public:
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "HeaderFileReader.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
#include "Impl/HeaderLexer.h"
|
||||
#include "Impl/HeaderParser.h"
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
@ -15,6 +11,10 @@
|
||||
#include "Parsing/PostProcessing/CreateStructureInformationPostProcessor.h"
|
||||
#include "Parsing/PostProcessing/IPostProcessor.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
HeaderFileReader::HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@ -83,7 +83,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
result = parser->SaveToRepository(repository);
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if(m_args->m_verbose)
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Processing header took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
|
||||
}
|
||||
@ -91,8 +91,10 @@ bool HeaderFileReader::ReadHeaderFile(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,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ZoneCodeGeneratorArguments.h"
|
||||
#include "Parsing/IPackValueSupplier.h"
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/PostProcessing/IPostProcessor.h"
|
||||
#include "Persistence/IDataRepository.h"
|
||||
#include "ZoneCodeGeneratorArguments.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class HeaderFileReader
|
||||
{
|
||||
|
@ -33,136 +33,136 @@ HeaderParserValue HeaderLexer::GetNextToken()
|
||||
switch (c)
|
||||
{
|
||||
case '\"':
|
||||
{
|
||||
return HeaderParserValue::String(GetPreviousCharacterPos(), new std::string(ReadString()));
|
||||
}
|
||||
{
|
||||
return HeaderParserValue::String(GetPreviousCharacterPos(), new std::string(ReadString()));
|
||||
}
|
||||
|
||||
case '<':
|
||||
{
|
||||
if (!IsLineEnd())
|
||||
{
|
||||
if (!IsLineEnd())
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
const auto nextChar = PeekChar();
|
||||
|
||||
if (nextChar == '=')
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
const auto nextChar = PeekChar();
|
||||
|
||||
if (nextChar == '=')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::LessEqual(pos);
|
||||
}
|
||||
if (nextChar == '<')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::ShiftLeft(pos);
|
||||
}
|
||||
NextChar();
|
||||
return HeaderParserValue::LessEqual(pos);
|
||||
}
|
||||
if (nextChar == '<')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::ShiftLeft(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
case '>':
|
||||
{
|
||||
if (!IsLineEnd())
|
||||
{
|
||||
if (!IsLineEnd())
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
const auto nextChar = PeekChar();
|
||||
|
||||
if (nextChar == '=')
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
const auto nextChar = PeekChar();
|
||||
|
||||
if (nextChar == '=')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::GreaterEqual(pos);
|
||||
}
|
||||
if (nextChar == '>')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::ShiftRight(pos);
|
||||
}
|
||||
NextChar();
|
||||
return HeaderParserValue::GreaterEqual(pos);
|
||||
}
|
||||
if (nextChar == '>')
|
||||
{
|
||||
NextChar();
|
||||
return HeaderParserValue::ShiftRight(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
case '=':
|
||||
{
|
||||
if (NextCharInLineIs('='))
|
||||
{
|
||||
if (NextCharInLineIs('='))
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::Equals(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::Equals(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
case '&':
|
||||
{
|
||||
if (NextCharInLineIs('&'))
|
||||
{
|
||||
if (NextCharInLineIs('&'))
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::LogicalAnd(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::LogicalAnd(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
case '|':
|
||||
{
|
||||
if (NextCharInLineIs('|'))
|
||||
{
|
||||
if (NextCharInLineIs('|'))
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::LogicalOr(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::LogicalOr(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
case '!':
|
||||
{
|
||||
if (NextCharInLineIs('='))
|
||||
{
|
||||
if (NextCharInLineIs('='))
|
||||
{
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::NotEqual(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
NextChar();
|
||||
return HeaderParserValue::NotEqual(pos);
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (isspace(c))
|
||||
break;
|
||||
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
if (isdigit(c))
|
||||
{
|
||||
if (isspace(c))
|
||||
break;
|
||||
bool isFloatingPointValue;
|
||||
bool hasSignPrefix;
|
||||
double doubleValue;
|
||||
int integerValue;
|
||||
|
||||
const auto pos = GetPreviousCharacterPos();
|
||||
if(isdigit(c))
|
||||
{
|
||||
bool isFloatingPointValue;
|
||||
bool hasSignPrefix;
|
||||
double doubleValue;
|
||||
int integerValue;
|
||||
ReadNumber(isFloatingPointValue, hasSignPrefix, doubleValue, integerValue);
|
||||
|
||||
ReadNumber(isFloatingPointValue, hasSignPrefix, doubleValue, integerValue);
|
||||
if (isFloatingPointValue)
|
||||
return HeaderParserValue::FloatingPoint(pos, doubleValue);
|
||||
|
||||
if (isFloatingPointValue)
|
||||
return HeaderParserValue::FloatingPoint(pos, doubleValue);
|
||||
|
||||
return HeaderParserValue::Integer(pos, integerValue);
|
||||
}
|
||||
|
||||
if (isalpha(c) || c == '_')
|
||||
{
|
||||
auto identifier = ReadIdentifier();
|
||||
|
||||
const auto foundKeyword = m_keywords.find(identifier);
|
||||
if (foundKeyword != m_keywords.end())
|
||||
return HeaderParserValue::Keyword(pos, foundKeyword->second);
|
||||
|
||||
return HeaderParserValue::Identifier(pos, new std::string(std::move(identifier)));
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(pos, static_cast<char>(c));
|
||||
return HeaderParserValue::Integer(pos, integerValue);
|
||||
}
|
||||
|
||||
if (isalpha(c) || c == '_')
|
||||
{
|
||||
auto identifier = ReadIdentifier();
|
||||
|
||||
const auto foundKeyword = m_keywords.find(identifier);
|
||||
if (foundKeyword != m_keywords.end())
|
||||
return HeaderParserValue::Keyword(pos, foundKeyword->second);
|
||||
|
||||
return HeaderParserValue::Identifier(pos, new std::string(std::move(identifier)));
|
||||
}
|
||||
|
||||
return HeaderParserValue::Character(pos, static_cast<char>(c));
|
||||
}
|
||||
}
|
||||
|
||||
c = NextChar();
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "HeaderParserValue.h"
|
||||
#include "Parsing/Impl/AbstractLexer.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class HeaderLexer final : public AbstractLexer<HeaderParserValue>
|
||||
{
|
||||
std::unordered_map<std::string, HeaderParserValueType> m_keywords;
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "HeaderParserState.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include "Domain/Definition/EnumDefinition.h"
|
||||
#include "Parsing/Header/Block/HeaderBlockNone.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
HeaderParserState::HeaderParserState(const IPackValueSupplier* packValueSupplier)
|
||||
: m_pack_value_supplier(packValueSupplier)
|
||||
|
||||
@ -198,7 +197,5 @@ bool HeaderParserState::MoveDefinitionsToRepository(IDataRepository* repository)
|
||||
|
||||
bool HeaderParserState::SaveToRepository(IDataRepository* repository)
|
||||
{
|
||||
return ResolveForwardDeclarations()
|
||||
&& ReplaceForwardDeclarationsInDefinitions()
|
||||
&& MoveDefinitionsToRepository(repository);
|
||||
return ResolveForwardDeclarations() && ReplaceForwardDeclarationsInDefinitions() && MoveDefinitionsToRepository(repository);
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Domain/Definition/BaseTypeDefinition.h"
|
||||
#include "Domain/Definition/DataDefinition.h"
|
||||
#include "Domain/Definition/EnumMember.h"
|
||||
#include "Domain/Definition/ForwardDeclaration.h"
|
||||
#include "Parsing/IPackValueSupplier.h"
|
||||
#include "Utils/NamespaceBuilder.h"
|
||||
#include "Parsing/Header/Block/IHeaderBlock.h"
|
||||
#include "Parsing/IPackValueSupplier.h"
|
||||
#include "Persistence/IDataRepository.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Utils/NamespaceBuilder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
|
||||
class IHeaderBlock;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Parsing/IParserValue.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/TokenPos.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class HeaderParserValueType
|
||||
{
|
||||
@ -63,6 +63,7 @@ class HeaderParserValue final : public IParserValue
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
HeaderParserValueType m_type;
|
||||
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
@ -108,4 +109,4 @@ public:
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& IdentifierValue() const;
|
||||
_NODISCARD std::string& TypeNameValue() const;
|
||||
};
|
||||
};
|
||||
|
@ -1,117 +1,92 @@
|
||||
#include "HeaderCommonMatchers.h"
|
||||
|
||||
#include "HeaderMatcherFactory.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "HeaderMatcherFactory.h"
|
||||
|
||||
std::unique_ptr<HeaderCommonMatchers::matcher_t> HeaderCommonMatchers::Align(const supplier_t* labelSupplier)
|
||||
{
|
||||
const HeaderMatcherFactory create(labelSupplier);
|
||||
|
||||
return create.Or({
|
||||
create.And({
|
||||
create.Type(HeaderParserValueType::DECLSPEC),
|
||||
create.Char('('),
|
||||
create.Type(HeaderParserValueType::ALIGN),
|
||||
create.Char('('),
|
||||
create.Integer(),
|
||||
create.Char(')'),
|
||||
create.Char(')')
|
||||
}).Transform([](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
return HeaderParserValue::Integer(values[4].get().GetPos(), values[4].get().IntegerValue());
|
||||
}),
|
||||
create.And({
|
||||
create.Type(HeaderParserValueType::ALIGNAS),
|
||||
create.Char('('),
|
||||
create.Integer(),
|
||||
create.Char(')')
|
||||
}).Transform([](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
return HeaderParserValue::Integer(values[2].get().GetPos(), values[2].get().IntegerValue());
|
||||
})
|
||||
});
|
||||
return create.Or({create
|
||||
.And({create.Type(HeaderParserValueType::DECLSPEC),
|
||||
create.Char('('),
|
||||
create.Type(HeaderParserValueType::ALIGN),
|
||||
create.Char('('),
|
||||
create.Integer(),
|
||||
create.Char(')'),
|
||||
create.Char(')')})
|
||||
.Transform(
|
||||
[](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
return HeaderParserValue::Integer(values[4].get().GetPos(), values[4].get().IntegerValue());
|
||||
}),
|
||||
create.And({create.Type(HeaderParserValueType::ALIGNAS), create.Char('('), create.Integer(), create.Char(')')})
|
||||
.Transform(
|
||||
[](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
return HeaderParserValue::Integer(values[2].get().GetPos(), values[2].get().IntegerValue());
|
||||
})});
|
||||
}
|
||||
|
||||
std::unique_ptr<HeaderCommonMatchers::matcher_t> HeaderCommonMatchers::ArrayDef(const supplier_t* labelSupplier)
|
||||
{
|
||||
const HeaderMatcherFactory create(labelSupplier);
|
||||
|
||||
return create.And({
|
||||
create.Char('['),
|
||||
create.Or({
|
||||
create.Integer(),
|
||||
create.Identifier()
|
||||
}),
|
||||
create.Char(']')
|
||||
}).Transform([](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
if (values[1].get().m_type == HeaderParserValueType::INTEGER)
|
||||
return HeaderParserValue::Integer(values[1].get().GetPos(), values[1].get().IntegerValue());
|
||||
return create.And({create.Char('['), create.Or({create.Integer(), create.Identifier()}), create.Char(']')})
|
||||
.Transform(
|
||||
[](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
if (values[1].get().m_type == HeaderParserValueType::INTEGER)
|
||||
return HeaderParserValue::Integer(values[1].get().GetPos(), values[1].get().IntegerValue());
|
||||
|
||||
return HeaderParserValue::Identifier(values[1].get().GetPos(), new std::string(values[1].get().IdentifierValue()));
|
||||
});
|
||||
return HeaderParserValue::Identifier(values[1].get().GetPos(), new std::string(values[1].get().IdentifierValue()));
|
||||
});
|
||||
}
|
||||
|
||||
std::unique_ptr<HeaderCommonMatchers::matcher_t> HeaderCommonMatchers::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>(HeaderParserValueType::BUILT_IN_LAST) - static_cast<int>(HeaderParserValueType::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>(HeaderParserValueType::BUILT_IN_LAST) - static_cast<int>(HeaderParserValueType::BUILT_IN_FIRST) + 1);
|
||||
|
||||
const HeaderMatcherFactory create(labelSupplier);
|
||||
|
||||
return create.Or({
|
||||
create.And({
|
||||
create.Optional(create.Type(HeaderParserValueType::UNSIGNED)),
|
||||
create.Or({
|
||||
create.Type(HeaderParserValueType::CHAR),
|
||||
create.Type(HeaderParserValueType::SHORT),
|
||||
create.Type(HeaderParserValueType::INT),
|
||||
create.And({
|
||||
create.Type(HeaderParserValueType::LONG),
|
||||
create.Optional(create.Type(HeaderParserValueType::LONG))
|
||||
})
|
||||
})
|
||||
}).Transform([](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
std::ostringstream str;
|
||||
auto first = true;
|
||||
return create.Or(
|
||||
{create
|
||||
.And({create.Optional(create.Type(HeaderParserValueType::UNSIGNED)),
|
||||
create.Or({create.Type(HeaderParserValueType::CHAR),
|
||||
create.Type(HeaderParserValueType::SHORT),
|
||||
create.Type(HeaderParserValueType::INT),
|
||||
create.And({create.Type(HeaderParserValueType::LONG), create.Optional(create.Type(HeaderParserValueType::LONG))})})})
|
||||
.Transform(
|
||||
[](HeaderMatcherFactory::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>(HeaderParserValueType::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>(HeaderParserValueType::BUILT_IN_FIRST)];
|
||||
}
|
||||
|
||||
return HeaderParserValue::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([](HeaderMatcherFactory::token_list_t& values)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << values[0].get().IdentifierValue();
|
||||
return HeaderParserValue::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(
|
||||
[](HeaderMatcherFactory::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 HeaderParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
|
||||
})
|
||||
});
|
||||
return HeaderParserValue::TypeName(values[0].get().GetPos(), new std::string(str.str()));
|
||||
})});
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Matcher/AbstractMatcher.h"
|
||||
#include "Parsing/Matcher/MatcherLabel.h"
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
class HeaderCommonMatchers
|
||||
{
|
||||
public:
|
||||
|
@ -8,7 +8,6 @@ HeaderMatcherCharacter::HeaderMatcherCharacter(const char c)
|
||||
MatcherResult<HeaderParserValue> HeaderMatcherCharacter::CanMatch(ILexer<HeaderParserValue>* lexer, const unsigned tokenOffset)
|
||||
{
|
||||
const auto& token = lexer->GetToken(tokenOffset);
|
||||
return token.m_type == HeaderParserValueType::CHARACTER && token.CharacterValue() == m_char
|
||||
? MatcherResult<HeaderParserValue>::Match(1)
|
||||
: MatcherResult<HeaderParserValue>::NoMatch();
|
||||
return token.m_type == HeaderParserValueType::CHARACTER && token.CharacterValue() == m_char ? MatcherResult<HeaderParserValue>::Match(1)
|
||||
: MatcherResult<HeaderParserValue>::NoMatch();
|
||||
}
|
||||
|
@ -7,7 +7,5 @@ HeaderMatcherValueType::HeaderMatcherValueType(HeaderParserValueType type)
|
||||
|
||||
MatcherResult<HeaderParserValue> HeaderMatcherValueType::CanMatch(ILexer<HeaderParserValue>* lexer, const unsigned tokenOffset)
|
||||
{
|
||||
return lexer->GetToken(tokenOffset).m_type == m_type
|
||||
? MatcherResult<HeaderParserValue>::Match(1)
|
||||
: MatcherResult<HeaderParserValue>::NoMatch();
|
||||
return lexer->GetToken(tokenOffset).m_type == m_type ? MatcherResult<HeaderParserValue>::Match(1) : MatcherResult<HeaderParserValue>::NoMatch();
|
||||
}
|
||||
|
@ -1,21 +1,16 @@
|
||||
#include "SequenceCloseBlock.h"
|
||||
|
||||
#include "Parsing/Header/Block/IHeaderBlockNameHolder.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceCloseBlock::SequenceCloseBlock(const bool semicolonRequired)
|
||||
: m_semicolon_required(semicolonRequired)
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Char('}').Capture(CAPTURE_CLOSING_PARENTHESIS),
|
||||
create.Optional(create.And({
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Char(';').Tag(TAG_SEMICOLON)
|
||||
}))
|
||||
});
|
||||
AddMatchers({create.Char('}').Capture(CAPTURE_CLOSING_PARENTHESIS),
|
||||
create.Optional(create.And({create.Optional(create.Identifier().Capture(CAPTURE_NAME)), create.Char(';').Tag(TAG_SEMICOLON)}))});
|
||||
}
|
||||
|
||||
void SequenceCloseBlock::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceCloseBlock final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,24 +1,19 @@
|
||||
#include "SequenceEnum.h"
|
||||
|
||||
#include "Parsing/Header/Block/HeaderBlockEnum.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceEnum::SequenceEnum()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Typename(this), HeaderCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Type(HeaderParserValueType::ENUM),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({
|
||||
create.Char(':'),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)
|
||||
})),
|
||||
create.Char('{')
|
||||
});
|
||||
AddMatchers({create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Type(HeaderParserValueType::ENUM),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({create.Char(':'), create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)})),
|
||||
create.Char('{')});
|
||||
}
|
||||
|
||||
void SequenceEnum::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
@ -30,7 +25,7 @@ void SequenceEnum::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderP
|
||||
if (result.HasNextCapture(CAPTURE_NAME))
|
||||
name = result.NextCapture(CAPTURE_NAME).IdentifierValue();
|
||||
|
||||
if(result.HasNextCapture(CAPTURE_PARENT_TYPE))
|
||||
if (result.HasNextCapture(CAPTURE_PARENT_TYPE))
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_PARENT_TYPE);
|
||||
const auto* foundTypeDefinition = state->FindType(typeNameToken.TypeNameValue());
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceEnum final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,27 +1,17 @@
|
||||
#include "SequenceEnumMember.h"
|
||||
|
||||
#include "Parsing/Header/Block/HeaderBlockEnum.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceEnumMember::SequenceEnumMember()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Optional(create.And({
|
||||
create.Char('='),
|
||||
create.Or({
|
||||
create.Identifier().Capture(CAPTURE_VALUE),
|
||||
create.Integer().Capture(CAPTURE_VALUE)
|
||||
})
|
||||
})),
|
||||
create.Or({
|
||||
create.Char(','),
|
||||
create.Char('}').NoConsume()
|
||||
})
|
||||
});
|
||||
AddMatchers(
|
||||
{create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Optional(create.And({create.Char('='), create.Or({create.Identifier().Capture(CAPTURE_VALUE), create.Integer().Capture(CAPTURE_VALUE)})})),
|
||||
create.Or({create.Char(','), create.Char('}').NoConsume()})});
|
||||
}
|
||||
|
||||
void SequenceEnumMember::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceEnumMember final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,21 +1,19 @@
|
||||
#include "SequenceForwardDecl.h"
|
||||
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceForwardDecl::SequenceForwardDecl()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Or({
|
||||
create.Type(HeaderParserValueType::ENUM).Tag(TAG_ENUM),
|
||||
create.Type(HeaderParserValueType::STRUCT).Tag(TAG_STRUCT),
|
||||
create.Type(HeaderParserValueType::UNION).Tag(TAG_UNION)
|
||||
}).Capture(CAPTURE_TYPE),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(';')
|
||||
});
|
||||
AddMatchers({create
|
||||
.Or({create.Type(HeaderParserValueType::ENUM).Tag(TAG_ENUM),
|
||||
create.Type(HeaderParserValueType::STRUCT).Tag(TAG_STRUCT),
|
||||
create.Type(HeaderParserValueType::UNION).Tag(TAG_UNION)})
|
||||
.Capture(CAPTURE_TYPE),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(';')});
|
||||
}
|
||||
|
||||
void SequenceForwardDecl::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
@ -23,7 +21,7 @@ void SequenceForwardDecl::ProcessMatch(HeaderParserState* state, SequenceResult<
|
||||
const auto typeTag = result.NextTag();
|
||||
DataDefinitionType type;
|
||||
|
||||
switch(typeTag)
|
||||
switch (typeTag)
|
||||
{
|
||||
case TAG_ENUM:
|
||||
type = DataDefinitionType::ENUM;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceForwardDecl final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "SequenceNamespace.h"
|
||||
|
||||
|
||||
#include "Parsing/Header/Block/HeaderBlockNamespace.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
@ -8,11 +7,7 @@ SequenceNamespace::SequenceNamespace()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Type(HeaderParserValueType::NAMESPACE),
|
||||
create.Type(HeaderParserValueType::IDENTIFIER).Capture(CAPTURE_NAME),
|
||||
create.Char('{')
|
||||
});
|
||||
AddMatchers({create.Type(HeaderParserValueType::NAMESPACE), create.Type(HeaderParserValueType::IDENTIFIER).Capture(CAPTURE_NAME), create.Char('{')});
|
||||
}
|
||||
|
||||
void SequenceNamespace::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceNamespace final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "SequenceStruct.h"
|
||||
|
||||
#include "Parsing/Header/Block/HeaderBlockStruct.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceStruct::SequenceStruct()
|
||||
{
|
||||
@ -10,18 +10,13 @@ SequenceStruct::SequenceStruct()
|
||||
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Align(this), HeaderCommonMatchers::LABEL_ALIGN);
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Typename(this), HeaderCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST)),
|
||||
create.Type(HeaderParserValueType::STRUCT),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({
|
||||
create.Char(':'),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)
|
||||
})),
|
||||
create.Char('{')
|
||||
});
|
||||
AddMatchers({create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST)),
|
||||
create.Type(HeaderParserValueType::STRUCT),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({create.Char(':'), create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)})),
|
||||
create.Char('{')});
|
||||
}
|
||||
|
||||
void SequenceStruct::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
@ -37,12 +32,12 @@ void SequenceStruct::ProcessMatch(HeaderParserState* state, SequenceResult<Heade
|
||||
if (result.HasNextCapture(CAPTURE_ALIGN))
|
||||
structBlock->SetCustomAlignment(result.NextCapture(CAPTURE_ALIGN).IntegerValue());
|
||||
|
||||
if(result.HasNextCapture(CAPTURE_PARENT_TYPE))
|
||||
if (result.HasNextCapture(CAPTURE_PARENT_TYPE))
|
||||
{
|
||||
const auto& parentTypeToken = result.NextCapture(CAPTURE_PARENT_TYPE);
|
||||
const auto* parentDefinition = state->FindType(parentTypeToken.TypeNameValue());
|
||||
|
||||
if(parentDefinition == nullptr && !state->m_namespace.IsEmpty())
|
||||
if (parentDefinition == nullptr && !state->m_namespace.IsEmpty())
|
||||
{
|
||||
const auto fullTypeName = NamespaceBuilder::Combine(state->m_namespace.ToString(), parentTypeToken.TypeNameValue());
|
||||
parentDefinition = state->FindType(fullTypeName);
|
||||
@ -51,7 +46,7 @@ void SequenceStruct::ProcessMatch(HeaderParserState* state, SequenceResult<Heade
|
||||
if (parentDefinition == nullptr)
|
||||
throw ParsingException(parentTypeToken.GetPos(), "Cannot find specified parent type");
|
||||
|
||||
if(parentDefinition->GetType() != DataDefinitionType::STRUCT)
|
||||
if (parentDefinition->GetType() != DataDefinitionType::STRUCT)
|
||||
throw ParsingException(parentTypeToken.GetPos(), "Parent type must be a struct");
|
||||
|
||||
structBlock->Inherit(dynamic_cast<const StructDefinition*>(parentDefinition));
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceStruct final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceTypedef::SequenceTypedef()
|
||||
{
|
||||
@ -13,36 +13,28 @@ SequenceTypedef::SequenceTypedef()
|
||||
AddLabeledMatchers(HeaderCommonMatchers::ArrayDef(this), HeaderCommonMatchers::LABEL_ARRAY_DEF);
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Typename(this), HeaderCommonMatchers::LABEL_TYPENAME);
|
||||
|
||||
AddLabeledMatchers(
|
||||
{
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.OptionalLoop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')
|
||||
}, LABEL_ARRAY_OF_POINTERS);
|
||||
AddLabeledMatchers({create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.OptionalLoop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')},
|
||||
LABEL_ARRAY_OF_POINTERS);
|
||||
|
||||
AddLabeledMatchers(
|
||||
{
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Char('('),
|
||||
create.Loop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(')'),
|
||||
create.Loop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')
|
||||
}, LABEL_POINTER_TO_ARRAY);
|
||||
AddLabeledMatchers({create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Char('('),
|
||||
create.Loop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(')'),
|
||||
create.Loop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')},
|
||||
LABEL_POINTER_TO_ARRAY);
|
||||
|
||||
AddMatchers({
|
||||
create.Type(HeaderParserValueType::TYPEDEF),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Or({
|
||||
create.Label(LABEL_ARRAY_OF_POINTERS).Tag(TAG_ARRAY_OF_POINTERS),
|
||||
create.Label(LABEL_POINTER_TO_ARRAY).Tag(TAG_POINTER_TO_ARRAY)
|
||||
})
|
||||
});
|
||||
AddMatchers(
|
||||
{create.Type(HeaderParserValueType::TYPEDEF),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Or({create.Label(LABEL_ARRAY_OF_POINTERS).Tag(TAG_ARRAY_OF_POINTERS), create.Label(LABEL_POINTER_TO_ARRAY).Tag(TAG_POINTER_TO_ARRAY)})});
|
||||
}
|
||||
|
||||
void SequenceTypedef::AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const
|
||||
@ -93,7 +85,7 @@ void SequenceTypedef::ProcessMatch(HeaderParserState* state, SequenceResult<Head
|
||||
auto typedefDefinition = std::make_unique<TypedefDefinition>(state->m_namespace.ToString(), name, std::make_unique<TypeDeclaration>(type));
|
||||
typedefDefinition->m_type_declaration->m_is_const = result.PeekAndRemoveIfTag(TAG_CONST) == TAG_CONST;
|
||||
|
||||
if(result.HasNextCapture(CAPTURE_ALIGN))
|
||||
if (result.HasNextCapture(CAPTURE_ALIGN))
|
||||
{
|
||||
const auto& alignToken = result.NextCapture(CAPTURE_ALIGN);
|
||||
typedefDefinition->m_alignment_override = static_cast<unsigned>(alignToken.IntegerValue());
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceTypedef final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "SequenceUnion.h"
|
||||
|
||||
#include "Parsing/Header/Block/HeaderBlockUnion.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceUnion::SequenceUnion()
|
||||
{
|
||||
@ -10,18 +10,13 @@ SequenceUnion::SequenceUnion()
|
||||
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Align(this), HeaderCommonMatchers::LABEL_ALIGN);
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Typename(this), HeaderCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST)),
|
||||
create.Type(HeaderParserValueType::UNION),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({
|
||||
create.Char(':'),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)
|
||||
})),
|
||||
create.Char('{')
|
||||
});
|
||||
AddMatchers({create.Optional(create.Type(HeaderParserValueType::TYPEDEF).Tag(TAG_TYPEDEF)),
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST)),
|
||||
create.Type(HeaderParserValueType::UNION),
|
||||
create.Optional(create.Label(HeaderCommonMatchers::LABEL_ALIGN).Capture(CAPTURE_ALIGN)),
|
||||
create.Optional(create.Identifier().Capture(CAPTURE_NAME)),
|
||||
create.Optional(create.And({create.Char(':'), create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_PARENT_TYPE)})),
|
||||
create.Char('{')});
|
||||
}
|
||||
|
||||
void SequenceUnion::ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceUnion final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
#include "Parsing/Header/Block/IHeaderBlockVariableHolder.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
SequenceVariable::SequenceVariable()
|
||||
{
|
||||
@ -14,36 +14,26 @@ SequenceVariable::SequenceVariable()
|
||||
AddLabeledMatchers(HeaderCommonMatchers::ArrayDef(this), HeaderCommonMatchers::LABEL_ARRAY_DEF);
|
||||
AddLabeledMatchers(HeaderCommonMatchers::Typename(this), HeaderCommonMatchers::LABEL_TYPENAME);
|
||||
|
||||
AddLabeledMatchers(
|
||||
{
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.OptionalLoop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Optional(create.And({
|
||||
create.Char(':'),
|
||||
create.Integer().Capture(CAPTURE_BIT_SIZE)
|
||||
})),
|
||||
create.Char(';')
|
||||
}, LABEL_ARRAY_OF_POINTERS);
|
||||
AddLabeledMatchers({create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.OptionalLoop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Optional(create.And({create.Char(':'), create.Integer().Capture(CAPTURE_BIT_SIZE)})),
|
||||
create.Char(';')},
|
||||
LABEL_ARRAY_OF_POINTERS);
|
||||
|
||||
AddLabeledMatchers(
|
||||
{
|
||||
create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Char('('),
|
||||
create.Loop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(')'),
|
||||
create.Loop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')
|
||||
}, LABEL_POINTER_TO_ARRAY);
|
||||
AddLabeledMatchers({create.Optional(create.Type(HeaderParserValueType::CONST).Tag(TAG_CONST)),
|
||||
create.Label(HeaderCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Char('('),
|
||||
create.Loop(create.Char('*').Tag(TAG_POINTER)),
|
||||
create.Identifier().Capture(CAPTURE_NAME),
|
||||
create.Char(')'),
|
||||
create.Loop(create.Label(HeaderCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY)),
|
||||
create.Char(';')},
|
||||
LABEL_POINTER_TO_ARRAY);
|
||||
|
||||
AddMatchers(create.Or({
|
||||
create.Label(LABEL_ARRAY_OF_POINTERS).Tag(TAG_ARRAY_OF_POINTERS),
|
||||
create.Label(LABEL_POINTER_TO_ARRAY).Tag(TAG_POINTER_TO_ARRAY)
|
||||
}));
|
||||
AddMatchers(create.Or({create.Label(LABEL_ARRAY_OF_POINTERS).Tag(TAG_ARRAY_OF_POINTERS), create.Label(LABEL_POINTER_TO_ARRAY).Tag(TAG_POINTER_TO_ARRAY)}));
|
||||
}
|
||||
|
||||
void SequenceVariable::AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const
|
||||
@ -105,7 +95,7 @@ void SequenceVariable::ProcessMatch(HeaderParserState* state, SequenceResult<Hea
|
||||
variable->m_has_alignment_override = true;
|
||||
}
|
||||
|
||||
if(result.HasNextCapture(CAPTURE_BIT_SIZE))
|
||||
if (result.HasNextCapture(CAPTURE_BIT_SIZE))
|
||||
{
|
||||
const auto& bitSizeToken = result.NextCapture(CAPTURE_BIT_SIZE);
|
||||
variable->m_type_declaration->m_custom_bit_size = bitSizeToken.IntegerValue();
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderParser.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserState.h"
|
||||
#include "Parsing/Header/Impl/HeaderParserValue.h"
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
class SequenceVariable final : public HeaderParser::sequence_t
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "CalculateSizeAndAlignPostProcessor.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Utils/AlignmentUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
unsigned CalculateSizeAndAlignPostProcessor::GetPointerSizeForArchitecture(const Architecture architecture)
|
||||
{
|
||||
switch (architecture)
|
||||
@ -141,7 +141,8 @@ bool CalculateSizeAndAlignPostProcessor::CalculateSize(IDataRepository* reposito
|
||||
currentBitOffset = 0;
|
||||
}
|
||||
|
||||
definition->m_size = AlignmentUtils::Align(definition->m_size, member->GetForceAlignment() ? member->GetAlignment() : std::min(member->GetAlignment(), definition->m_pack));
|
||||
definition->m_size = AlignmentUtils::Align(
|
||||
definition->m_size, member->GetForceAlignment() ? member->GetAlignment() : std::min(member->GetAlignment(), definition->m_pack));
|
||||
|
||||
member->m_offset = definition->m_size;
|
||||
|
||||
@ -186,8 +187,7 @@ bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* reposi
|
||||
if (declaration->m_flags & TypeDeclaration::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
|
||||
if(!CalculateAlign(repository, declaration)
|
||||
|| !CalculateSize(repository, declaration))
|
||||
if (!CalculateAlign(repository, declaration) || !CalculateSize(repository, declaration))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -208,8 +208,7 @@ bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* reposi
|
||||
|
||||
structDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
if (!CalculateAlign(repository, structDefinition)
|
||||
|| !CalculateSize(repository, structDefinition))
|
||||
if (!CalculateAlign(repository, structDefinition) || !CalculateSize(repository, structDefinition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -232,8 +231,7 @@ bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* reposi
|
||||
|
||||
unionDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
if (!CalculateAlign(repository, unionDefinition)
|
||||
|| !CalculateSize(repository, unionDefinition))
|
||||
if (!CalculateAlign(repository, unionDefinition) || !CalculateSize(repository, unionDefinition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -246,19 +244,19 @@ bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* reposi
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateFieldsIfNecessary(IDataRepository* repository, const DataDefinition* definition)
|
||||
{
|
||||
if(definition->GetType() == DataDefinitionType::STRUCT)
|
||||
if (definition->GetType() == DataDefinitionType::STRUCT)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<StructDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
if(definition->GetType() == DataDefinitionType::UNION)
|
||||
if (definition->GetType() == DataDefinitionType::UNION)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<UnionDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
if(definition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
if (definition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<TypedefDefinition*>(const_cast<DataDefinition*>(definition))->m_type_declaration.get());
|
||||
|
@ -4,19 +4,19 @@
|
||||
|
||||
bool CreateMemberInformationPostProcessor::CreateMemberInformationForStructure(IDataRepository* repository, StructureInformation* structure) const
|
||||
{
|
||||
for(const auto& member : structure->m_definition->m_members)
|
||||
for (const auto& member : structure->m_definition->m_members)
|
||||
{
|
||||
StructureInformation* typeInfo = nullptr;
|
||||
const auto* currentDefinition = member->m_type_declaration->m_type;
|
||||
|
||||
while(currentDefinition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
while (currentDefinition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
currentDefinition = dynamic_cast<const TypedefDefinition*>(currentDefinition)->m_type_declaration->m_type;
|
||||
}
|
||||
|
||||
const auto* memberDefinition = dynamic_cast<const DefinitionWithMembers*>(currentDefinition);
|
||||
|
||||
if(memberDefinition != nullptr)
|
||||
if (memberDefinition != nullptr)
|
||||
typeInfo = repository->GetInformationFor(memberDefinition);
|
||||
|
||||
structure->m_ordered_members.emplace_back(std::make_unique<MemberInformation>(structure, typeInfo, member.get()));
|
||||
@ -29,8 +29,10 @@ bool CreateMemberInformationPostProcessor::PostProcess(IDataRepository* reposito
|
||||
{
|
||||
const auto& allStructureInformation = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allStructureInformation.begin(), allStructureInformation.end(), [this, repository](StructureInformation* structure)
|
||||
{
|
||||
return CreateMemberInformationForStructure(repository, structure);
|
||||
});
|
||||
return std::all_of(allStructureInformation.begin(),
|
||||
allStructureInformation.end(),
|
||||
[this, repository](StructureInformation* structure)
|
||||
{
|
||||
return CreateMemberInformationForStructure(repository, structure);
|
||||
});
|
||||
}
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
bool CreateStructureInformationPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
for(auto* structDefinition : repository->GetAllStructs())
|
||||
for (auto* structDefinition : repository->GetAllStructs())
|
||||
{
|
||||
auto* information = repository->GetInformationFor(structDefinition);
|
||||
if(information == nullptr)
|
||||
if (information == nullptr)
|
||||
repository->Add(std::make_unique<StructureInformation>(structDefinition));
|
||||
}
|
||||
|
||||
for(auto* unionDefinition : repository->GetAllUnions())
|
||||
for (auto* unionDefinition : repository->GetAllUnions())
|
||||
{
|
||||
auto* information = repository->GetInformationFor(unionDefinition);
|
||||
if(information == nullptr)
|
||||
if (information == nullptr)
|
||||
repository->Add(std::make_unique<StructureInformation>(unionDefinition));
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,7 @@ bool LeafsPostProcessor::IsLeaf(StructureInformation* info)
|
||||
if (computations.HasDynamicArraySize())
|
||||
return false;
|
||||
|
||||
if (member->m_type != nullptr
|
||||
&& member->m_type != info
|
||||
&& !IsLeaf(member->m_type))
|
||||
if (member->m_type != nullptr && member->m_type != info && !IsLeaf(member->m_type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ bool MemberLeafsPostProcessor::MemberIsLeaf(MemberInformation* member)
|
||||
|
||||
void MemberLeafsPostProcessor::ProcessInfo(StructureInformation* info)
|
||||
{
|
||||
for(const auto& member : info->m_ordered_members)
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
member->m_is_leaf = MemberIsLeaf(member.get());
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ bool UnionsPostProcessor::ProcessUnion(StructureInformation* info)
|
||||
auto lastEntryWithoutCondition = 0u;
|
||||
auto entriesWithoutConditionCount = 0u;
|
||||
|
||||
for(const auto& member : info->m_ordered_members)
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
if(!member->m_condition && !member->m_is_leaf)
|
||||
if (!member->m_condition && !member->m_is_leaf)
|
||||
{
|
||||
entriesWithoutConditionCount++;
|
||||
lastEntryWithoutCondition = index;
|
||||
@ -40,11 +40,13 @@ bool UnionsPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
const auto& allInfos = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allInfos.begin(), allInfos.end(), [](StructureInformation* info)
|
||||
{
|
||||
if (info->m_definition->GetType() != DataDefinitionType::UNION)
|
||||
return true;
|
||||
return std::all_of(allInfos.begin(),
|
||||
allInfos.end(),
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
if (info->m_definition->GetType() != DataDefinitionType::UNION)
|
||||
return true;
|
||||
|
||||
return ProcessUnion(info);
|
||||
});
|
||||
return ProcessUnion(info);
|
||||
});
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "UsagesPostProcessor.h"
|
||||
|
||||
#include "Domain/Computations/MemberComputations.h"
|
||||
#include "Domain/Computations/StructureComputations.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "Domain/Computations/MemberComputations.h"
|
||||
#include "Domain/Computations/StructureComputations.h"
|
||||
|
||||
bool UsagesPostProcessor::ProcessAsset(StructureInformation* info)
|
||||
{
|
||||
std::set<StructureInformation*> processedInfos;
|
||||
@ -14,23 +14,23 @@ bool UsagesPostProcessor::ProcessAsset(StructureInformation* info)
|
||||
|
||||
processingQueue.push(info);
|
||||
|
||||
while(!processingQueue.empty())
|
||||
while (!processingQueue.empty())
|
||||
{
|
||||
auto* currentStructure = processingQueue.front();
|
||||
processingQueue.pop();
|
||||
|
||||
if(processedInfos.find(currentStructure) != processedInfos.end())
|
||||
if (processedInfos.find(currentStructure) != processedInfos.end())
|
||||
continue;
|
||||
processedInfos.emplace(currentStructure);
|
||||
|
||||
for (const auto& member : currentStructure->m_ordered_members)
|
||||
{
|
||||
if(member->m_type == nullptr)
|
||||
if (member->m_type == nullptr)
|
||||
continue;
|
||||
|
||||
const MemberComputations computations(member.get());
|
||||
|
||||
if(computations.ShouldIgnore())
|
||||
if (computations.ShouldIgnore())
|
||||
continue;
|
||||
|
||||
if (computations.ContainsNonEmbeddedReference())
|
||||
@ -63,9 +63,11 @@ bool UsagesPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
const auto& allInfos = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allInfos.begin(), allInfos.end(), [](StructureInformation* info)
|
||||
{
|
||||
const StructureComputations computations(info);
|
||||
return !computations.IsAsset() || ProcessAsset(info);
|
||||
});
|
||||
return std::all_of(allInfos.begin(),
|
||||
allInfos.end(),
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
const StructureComputations computations(info);
|
||||
return !computations.IsAsset() || ProcessAsset(info);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user