Shader: Add import statement (not doing anything for now)

This commit is contained in:
Jérôme Leclercq
2022-03-04 18:27:37 +01:00
parent ca83f363a3
commit b6cd85d6fe
23 changed files with 101 additions and 0 deletions

View File

@@ -649,14 +649,23 @@ namespace Nz::ShaderLang
return { parameterName, std::move(parameterType) };
}
ShaderAst::StatementPtr Parser::ParseImportStatement()
{
Expect(Advance(), TokenType::Import);
std::vector<std::string> modulePath;
modulePath.push_back(ParseIdentifierAsName());
while (Peek().type == TokenType::Divide) //< /
{
Consume();
modulePath.push_back(ParseIdentifierAsName());
}
Expect(Advance(), TokenType::Semicolon);
return ShaderBuilder::Import(std::move(modulePath));
}
ShaderAst::StatementPtr Parser::ParseOptionDeclaration()
@@ -715,6 +724,12 @@ namespace Nz::ShaderLang
case TokenType::External:
return ParseExternalBlock(std::move(attributes));
case TokenType::Import:
if (!attributes.empty())
throw UnexpectedToken{};
return ParseImportStatement();
case TokenType::OpenSquareBracket:
assert(attributes.empty());
return ParseRootStatement(ParseAttributes());