]> Some of my projects - anidbudpclient.git/commitdiff
Fix AniAdd lexer
authorAPTX <redacted>
Sat, 7 Mar 2026 04:55:51 +0000 (13:55 +0900)
committerAPTX <redacted>
Sat, 7 Mar 2026 04:55:51 +0000 (13:55 +0900)
The new regex engine matches the regex slightly differently leading
to splitting quoted string on spaces in some cases.

Also fixes compiling with PARSER_DEBUG enabled.

renameparser/AniAdd/lexer.cpp

index b3606ab2f6c1e8b8bc13577363704d38a1c956ee..b12a7d7e07fee713c2d174aff90fe4839ad642d1 100644 (file)
@@ -37,7 +37,7 @@ bool Lexer::next()
                return false;
        }
 #ifdef PARSER_DEBUG
-       QString m = rx.cap();
+       QString m = m_last_match.captured(0);
        qDebug() << "TOKEN=" << m;
 #endif
        m_pos += m_last_match.capturedLength();
@@ -131,7 +131,8 @@ void Lexer::staticInit()
        staticInitialised = true;
 }
 
-const char *Lexer::regexp = ":=|=|%|\\?|:|\\$|,|\\(|\\)|\\[|\\]|\\{|\\}|\\n|else|if|(:?//|#)[^\\n]*\\n|[^\"\\[\\]:= {}(),%$?\\n]+|\"[^\"]*\"|'[^']*'";
+const char *Lexer::regexp =
+       ":=|=|%|\\?|:|\\$|,|\\(|\\)|\\[|\\]|\\{|\\}|\\n|else|if|(:?//|#)[^\\n]*\\n|\"[^\"]*\"|'[^']*'|[^\"\\[\\]:= {}(),%$?\\n]+";
 
 QRegularExpression Lexer::rx(Lexer::regexp);
 QMap<QString, int> Lexer::tokenMap;