ShaderLang: Improve lexer

This commit is contained in:
Jérôme Leclercq 2021-03-11 23:20:22 +01:00
parent da81a5b871
commit 5598487e87
1 changed files with 25 additions and 16 deletions

View File

@ -100,6 +100,7 @@ namespace Nz::ShaderLang
{
if (Peek() == '>')
{
currentPos++;
tokenType = TokenType::FunctionReturn;
break;
}
@ -225,7 +226,10 @@ namespace Nz::ShaderLang
{
char next = Peek();
if (next == '[')
{
currentPos++;
tokenType = TokenType::OpenAttribute;
}
else
tokenType = TokenType::OpenSquareBracket;
@ -236,7 +240,10 @@ namespace Nz::ShaderLang
{
char next = Peek();
if (next == ']')
{
currentPos++;
tokenType = TokenType::ClosingAttribute;
}
else
tokenType = TokenType::ClosingSquareBracket;
@ -255,10 +262,7 @@ namespace Nz::ShaderLang
case '(': tokenType = TokenType::OpenParenthesis; break;
case ')': tokenType = TokenType::ClosingParenthesis; break;
default: break;
}
if (!tokenType)
default:
{
if (IsAlphaNum(c))
{
@ -275,6 +279,11 @@ namespace Nz::ShaderLang
}
else
tokenType = it->second;
break;
}
else
throw UnrecognizedToken{};
}
}