Shader: Add attribute and square bracket tokens (first step for attribute support)

This commit is contained in:
Jérôme Leclercq 2021-03-11 18:03:25 +01:00
parent 3f74ee4d66
commit 8135f22b2f
2 changed files with 26 additions and 0 deletions

View File

@ -13,8 +13,10 @@
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)
NAZARA_SHADERLANG_TOKEN(Colon)
NAZARA_SHADERLANG_TOKEN(Comma)
NAZARA_SHADERLANG_TOKEN(Divide)
@ -29,7 +31,9 @@ NAZARA_SHADERLANG_TOKEN(Let)
NAZARA_SHADERLANG_TOKEN(Multiply)
NAZARA_SHADERLANG_TOKEN(Minus)
NAZARA_SHADERLANG_TOKEN(Plus)
NAZARA_SHADERLANG_TOKEN(OpenAttribute)
NAZARA_SHADERLANG_TOKEN(OpenCurlyBracket)
NAZARA_SHADERLANG_TOKEN(OpenSquareBracket)
NAZARA_SHADERLANG_TOKEN(OpenParenthesis)
NAZARA_SHADERLANG_TOKEN(Semicolon)
NAZARA_SHADERLANG_TOKEN(Return)

View File

@ -221,6 +221,28 @@ namespace Nz::ShaderLang
break;
}
case '[':
{
char next = Peek();
if (next == '[')
tokenType = TokenType::OpenAttribute;
else
tokenType = TokenType::OpenSquareBracket;
break;
}
case ']':
{
char next = Peek();
if (next == ']')
tokenType = TokenType::ClosingAttribute;
else
tokenType = TokenType::ClosingSquareBracket;
break;
}
case '=': tokenType = TokenType::Assign; break;
case '+': tokenType = TokenType::Plus; break;
case '*': tokenType = TokenType::Multiply; break;