2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-05 08:17:25 +00:00

Add blocks and built in types to zcg cpp

This commit is contained in:
Jan
2021-02-14 00:53:23 +01:00
parent 216125739c
commit e40f1ec0b7
18 changed files with 384 additions and 25 deletions

View File

@@ -11,12 +11,17 @@ void HeaderLexer::PrepareKeywords()
m_keywords["__declspec"] = HeaderParserValueType::DECLSPEC;
m_keywords["align"] = HeaderParserValueType::ALIGN;
m_keywords["alignas"] = HeaderParserValueType::ALIGNAS;
m_keywords["char"] = HeaderParserValueType::CHAR;
m_keywords["const"] = HeaderParserValueType::CONST;
m_keywords["enum"] = HeaderParserValueType::ENUM;
m_keywords["int"] = HeaderParserValueType::INT;
m_keywords["long"] = HeaderParserValueType::LONG;
m_keywords["namespace"] = HeaderParserValueType::NAMESPACE;
m_keywords["short"] = HeaderParserValueType::SHORT;
m_keywords["struct"] = HeaderParserValueType::STRUCT;
m_keywords["typedef"] = HeaderParserValueType::TYPEDEF;
m_keywords["union"] = HeaderParserValueType::UNION;
m_keywords["unsigned"] = HeaderParserValueType::UNSIGNED;
}
HeaderParserValue HeaderLexer::GetNextToken()

View File

@@ -7,11 +7,9 @@ HeaderParser::HeaderParser(HeaderLexer* lexer, IDataRepository* targetRepository
m_repository(targetRepository)
{
auto sequenceNamespace = std::make_unique<SequenceNamespace>();
m_normal_tests.push_back(sequenceNamespace.get());
m_tests.emplace_back(std::move(sequenceNamespace));
}
const std::vector<HeaderParser::sequence_t*>& HeaderParser::GetTestsForState()
{
return m_normal_tests;
return m_state->GetBlock()->GetTestsForBlock();
}

View File

@@ -9,9 +9,6 @@ class HeaderParser final : public AbstractParser<HeaderParserValue, HeaderParser
{
IDataRepository* m_repository;
std::vector<std::unique_ptr<sequence_t>> m_tests;
std::vector<sequence_t*> m_normal_tests;
protected:
const std::vector<sequence_t*>& GetTestsForState() override;

View File

@@ -0,0 +1,13 @@
#include "HeaderParserState.h"
#include "Parsing/Header/Block/HeaderBlockNone.h"
HeaderParserState::HeaderParserState()
{
m_blocks.push(std::make_unique<HeaderBlockNone>());
}
IHeaderBlock* HeaderParserState::GetBlock() const
{
return m_blocks.top().get();
}

View File

@@ -1,7 +1,18 @@
#pragma once
#include <memory>
#include <stack>
#include "Utils/ClassUtils.h"
#include "Parsing/Header/Block/IHeaderBlock.h"
class IHeaderBlock;
class HeaderParserState
{
public:
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
};
public:
HeaderParserState();
_NODISCARD IHeaderBlock* GetBlock() const;
};

View File

@@ -2,7 +2,6 @@
#include <string>
#include "Parsing/IParserValue.h"
#include "Utils/ClassUtils.h"
#include "Parsing/TokenPos.h"
@@ -32,6 +31,15 @@ enum class HeaderParserValueType
STRING,
IDENTIFIER,
// Built-in types
BUILT_IN_FIRST,
UNSIGNED = BUILT_IN_FIRST,
CHAR,
SHORT,
INT,
LONG,
BUILT_IN_LAST = LONG,
// Keywords
DECLSPEC,
ALIGN,