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:
@@ -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()
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user