Improve GDScript "unexpected token in class body" parser error

This parser error was misleading.

Fixes:
1. Now points at correct line
2. For identifiers, prints out `Identifier "%s"`
This commit is contained in:
JackErb 2024-11-30 14:29:30 -08:00
parent 893bbdfde8
commit 13fcb05e7b
5 changed files with 20 additions and 1 deletions

View file

@ -164,6 +164,15 @@ const char *GDScriptTokenizer::Token::get_name() const {
return token_names[type];
}
String GDScriptTokenizer::Token::get_debug_name() const {
switch (type) {
case IDENTIFIER:
return vformat(R"(identifier "%s")", source);
default:
return vformat(R"("%s")", get_name());
}
}
bool GDScriptTokenizer::Token::can_precede_bin_op() const {
switch (type) {
case IDENTIFIER: