Skip to content

Commit 73e3ccc

Browse files
committed
add extend grammar grammar
1 parent 6193e79 commit 73e3ccc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

LuaParser/src/Lexer/LuaLexer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,12 @@ LuaTokenKind LuaLexer::Lex() {
345345
case '{': {
346346
// extend syntax see issue 119
347347
_reader.SaveAndNext();
348-
if (_reader.CheckNext1('@')){
348+
if (_supportNonStandardSymbol && _reader.CheckNext1('@')) {
349349
_reader.EatWhile([](char ch) { return lislalnum(ch); });
350-
if (_reader.CheckNext1('}')){
350+
if (_reader.CheckNext1('}')) {
351351
return TK_NAME;
352352
}
353+
return TK_ERR;
353354
}
354355
return '{';
355356
}
@@ -596,4 +597,3 @@ void LuaLexer::TokenError(std::string_view message, TextRange range) {
596597
void LuaLexer::SupportNonStandardSymbol() {
597598
_supportNonStandardSymbol = true;
598599
}
599-

Test/src/Grammar_unitest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ end
5454
EXPECT_FALSE(TestHelper::GetParser(R"(
5555
local t = 123/*1233*/
5656
)", true).HasError()) << "extend grammar c likely comment test fail";
57+
EXPECT_FALSE(TestHelper::GetParser(R"(
58+
local t = {@abaa}
59+
)", true).HasError()) << "extend grammar issue 119 test fail";
5760
}

0 commit comments

Comments
 (0)