feat: updated engine

This commit is contained in:
Sara Gerretsen 2026-07-10 17:04:34 +02:00
parent cbe99774ff
commit f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions

View file

@ -35,6 +35,7 @@
#include "../gdscript_parser.h"
#include "../gdscript_tokenizer.h"
#include "../gdscript_tokenizer_buffer.h"
#include "gdscript_test_runner.h"
#include "core/config/project_settings.h"
#include "core/io/file_access.h"
@ -64,19 +65,19 @@ static void test_tokenizer(const String &p_code, const Vector<String> &p_lines)
StringBuilder token;
token += " --> "; // Padding for line number.
// Files without trailing newline can produce dedent tokens on non-existent lines.
const String &start_line = current.start_line <= p_lines.size() ? p_lines[current.start_line - 1] : String();
const String &end_line = current.start_line <= p_lines.size() ? p_lines[current.start_line - 1] : String();
if (current.start_line != current.end_line) {
// Print "vvvvvv" to point at the token.
StringBuilder pointer;
pointer += " "; // Padding for line number.
int line_width = 0;
if (current.start_line - 1 >= 0 && current.start_line - 1 < p_lines.size()) {
line_width = p_lines[current.start_line - 1].replace("\t", tab).length();
}
const int offset = MAX(0, current.start_column - 1);
const int width = MAX(0, line_width - current.start_column + 1);
pointer += String::chr(' ').repeat(offset) + String::chr('v').repeat(width);
const int line_width = start_line.length() + start_line.count("\t") + (tab_size - 1);
const int start_offset = current.start_column - 1 + (current.start_column > 1 ? start_line.count("\t", 0, current.start_column - 1) * (tab_size - 1) : 0);
const int width = line_width - start_offset;
pointer += String::chr(' ').repeat(start_offset) + String::chr('v').repeat(width);
print_line(pointer.as_string());
}
@ -91,12 +92,13 @@ static void test_tokenizer(const String &p_code, const Vector<String> &p_lines)
pointer += " "; // Padding for line number.
if (current.start_line == current.end_line) {
const int offset = MAX(0, current.start_column - 1);
const int width = MAX(0, current.end_column - current.start_column);
pointer += String::chr(' ').repeat(offset) + String::chr('^').repeat(width);
const int start_offset = current.start_column - 1 + (current.start_column > 1 ? start_line.count("\t", 0, current.start_column - 1) * (tab_size - 1) : 0);
const int end_offset = current.end_column - 1 + (current.end_column > 1 ? end_line.count("\t", 0, current.end_column - 1) * (tab_size - 1) : 0);
const int width = end_offset - start_offset;
pointer += String::chr(' ').repeat(start_offset) + String::chr('^').repeat(width);
} else {
const int width = MAX(0, current.end_column - 1);
pointer += String::chr('^').repeat(width);
const int end_offset = current.end_column - 1 + (current.end_column > 1 ? end_line.count("\t", 0, current.end_column - 1) * (tab_size - 1) : 0);
pointer += String::chr('^').repeat(end_offset);
}
print_line(pointer.as_string());
@ -175,7 +177,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const
if (err != OK) {
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
for (const GDScriptParser::ParserError &error : errors) {
print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
print_line(vformat("%02d:%02d: %s", error.start_line, error.start_column, error.message));
}
}
@ -185,7 +187,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const
if (err != OK) {
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
for (const GDScriptParser::ParserError &error : errors) {
print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
print_line(vformat("%02d:%02d: %s", error.start_line, error.start_column, error.message));
}
}
@ -261,7 +263,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con
print_line("Error in parser:");
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
for (const GDScriptParser::ParserError &error : errors) {
print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
print_line(vformat("%02d:%02d: %s", error.start_line, error.start_column, error.message));
}
return;
}
@ -273,7 +275,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con
print_line("Error in analyzer:");
const List<GDScriptParser::ParserError> &errors = parser.get_errors();
for (const GDScriptParser::ParserError &error : errors) {
print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message));
print_line(vformat("%02d:%02d: %s", error.start_line, error.start_column, error.message));
}
return;
}