Shader/Lang: [[attribute]] => [attribute]

This commit is contained in:
Jérôme Leclercq 2021-04-14 20:20:37 +02:00
parent 54c34869a4
commit 0bb9c37a38
3 changed files with 10 additions and 38 deletions

View File

@ -13,7 +13,6 @@
NAZARA_SHADERLANG_TOKEN(Assign)
NAZARA_SHADERLANG_TOKEN(BoolFalse)
NAZARA_SHADERLANG_TOKEN(BoolTrue)
NAZARA_SHADERLANG_TOKEN(ClosingAttribute)
NAZARA_SHADERLANG_TOKEN(ClosingParenthesis)
NAZARA_SHADERLANG_TOKEN(ClosingCurlyBracket)
NAZARA_SHADERLANG_TOKEN(ClosingSquareBracket)
@ -38,7 +37,6 @@ NAZARA_SHADERLANG_TOKEN(Multiply)
NAZARA_SHADERLANG_TOKEN(Minus)
NAZARA_SHADERLANG_TOKEN(NotEqual)
NAZARA_SHADERLANG_TOKEN(Plus)
NAZARA_SHADERLANG_TOKEN(OpenAttribute)
NAZARA_SHADERLANG_TOKEN(OpenCurlyBracket)
NAZARA_SHADERLANG_TOKEN(OpenSquareBracket)
NAZARA_SHADERLANG_TOKEN(OpenParenthesis)

View File

@ -227,34 +227,6 @@ namespace Nz::ShaderLang
break;
}
case '[':
{
char next = Peek();
if (next == '[')
{
currentPos++;
tokenType = TokenType::OpenAttribute;
}
else
tokenType = TokenType::OpenSquareBracket;
break;
}
case ']':
{
char next = Peek();
if (next == ']')
{
currentPos++;
tokenType = TokenType::ClosingAttribute;
}
else
tokenType = TokenType::ClosingSquareBracket;
break;
}
case '=':
{
char next = Peek();
@ -307,6 +279,8 @@ namespace Nz::ShaderLang
case '}': tokenType = TokenType::ClosingCurlyBracket; break;
case '(': tokenType = TokenType::OpenParenthesis; break;
case ')': tokenType = TokenType::ClosingParenthesis; break;
case '[': tokenType = TokenType::OpenSquareBracket; break;
case ']': tokenType = TokenType::ClosingSquareBracket; break;
default:
{

View File

@ -82,7 +82,7 @@ namespace Nz::ShaderLang
attributes.clear();
break;
case TokenType::OpenAttribute:
case TokenType::OpenSquareBracket:
assert(attributes.empty());
attributes = ParseAttributes();
break;
@ -262,7 +262,7 @@ namespace Nz::ShaderLang
{
std::vector<ShaderAst::Attribute> attributes;
Expect(Advance(), TokenType::OpenAttribute);
Expect(Advance(), TokenType::OpenSquareBracket);
bool expectComma = false;
for (;;)
@ -270,10 +270,10 @@ namespace Nz::ShaderLang
const Token& t = Peek();
ExpectNot(t, TokenType::EndOfStream);
if (t.type == TokenType::ClosingAttribute)
if (t.type == TokenType::ClosingSquareBracket)
{
// Parse [[attribute1]] [[attribute2]] the same as [[attribute1, attribute2]]
if (Peek(1).type == TokenType::OpenAttribute)
// Parse [attribute1] [attribute2] the same as [attribute1, attribute2]
if (Peek(1).type == TokenType::OpenSquareBracket)
{
Consume(2);
expectComma = false;
@ -316,7 +316,7 @@ namespace Nz::ShaderLang
});
}
Expect(Advance(), TokenType::ClosingAttribute);
Expect(Advance(), TokenType::ClosingSquareBracket);
return attributes;
}
@ -354,7 +354,7 @@ namespace Nz::ShaderLang
auto& extVar = externalStatement->externalVars.emplace_back();
if (token.type == TokenType::OpenAttribute)
if (token.type == TokenType::OpenSquareBracket)
{
for (const auto& [attributeType, arg] : ParseAttributes())
{
@ -521,7 +521,7 @@ namespace Nz::ShaderLang
auto& structField = description.members.emplace_back();
if (token.type == TokenType::OpenAttribute)
if (token.type == TokenType::OpenSquareBracket)
{
for (const auto& [attributeType, attributeParam] : ParseAttributes())
{