diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index 6bec920..a4a7ffb 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -105,7 +105,7 @@ IToken* Lexer::LexNext(char16_t c){ case '_': return LexIdentifierOrKeyword(); default: - if (isalpha(c)){ + if (isalpha(c) || c > 255){ return LexIdentifierOrKeyword(); } this -> ScriptData -> Diagnostics -> LogError(DiagnosticCode::UnexpectedCharacter, this -> _position - 1, 1); @@ -185,7 +185,7 @@ IToken * Lexer::LexIdentifierOrKeyword() { while (true){ char16_t next = this -> Peek(); if (next == '\0') break; - if (isalpha(next) || next == '_'){ + if (isalpha(next) || next == '_' || next > 255){ this -> Next(); end++; } diff --git a/tests/integration/Variables.cpp b/tests/integration/Variables.cpp index be3e172..ecfe129 100644 --- a/tests/integration/Variables.cpp +++ b/tests/integration/Variables.cpp @@ -62,4 +62,18 @@ end CHECK(variable->EvaluateInteger() == 2); delete script; } + +TEST_CASE( "Able to use emoji", "[integration]" ) { + Script* script = Script::Create(uR"( +💩 = "LJ" +)"); + REQUIRE(!script->Diagnostics -> HasErrors()); + script->Evaluate(); + REQUIRE(script -> HasVariable(uR"(💩)")); + auto variable = script->GetVariable(uR"(💩)"); + REQUIRE(variable != nullptr); + CHECK(*variable->EvaluateString() == u"LJ"); + delete script; +} + #endif