Initial shaderlang commit

This commit is contained in:
Jérôme Leclercq
2021-02-24 23:51:24 +01:00
parent d59423afca
commit 9a0f201433
7 changed files with 623 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_SHADER_LANGPARSER_HPP
#define NAZARA_SHADER_LANGPARSER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/ShaderLangLexer.hpp>
namespace Nz::ShaderLang
{
class ExpectedToken : public std::exception
{
public:
using exception::exception;
};
class UnexpectedToken : public std::exception
{
public:
using exception::exception;
};
class NAZARA_SHADER_API Parser
{
public:
inline Parser();
~Parser() = default;
void Parse(const std::vector<Token>& tokens);
private:
const Token& Advance();
void Expect(const Token& token, TokenType type);
void ExpectNext(TokenType type);
void ParseFunctionBody();
void ParseFunctionDeclaration();
void ParseFunctionParameter();
const Token& PeekNext();
struct Context
{
std::size_t tokenCount;
std::size_t tokenIndex = 0;
const Token* tokens;
};
Context* m_context;
};
}
#include <Nazara/Shader/ShaderLangParser.inl>
#endif