mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-05 08:17:25 +00:00
Reformat code with clang format
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user