dev/sdl3-parser #1

Open
peterino wants to merge 51 commits from dev/sdl3-parser into dev/variant-engine
2 changed files with 33 additions and 8 deletions
Showing only changes of commit a2ab0f0f21 - Show all commits

View File

@ -510,10 +510,22 @@ pub const Scanner = struct {
const trimmed = std.mem.trim(u8, line, " \t\r");
// Track multi-line comments (both /** and /*)
if (std.mem.indexOf(u8, trimmed, "/*") != null) {
in_multiline_comment = true;
}
if (in_multiline_comment) {
// Only start tracking if /* appears without */ on the same line
if (!in_multiline_comment) {
if (std.mem.indexOf(u8, trimmed, "/*")) |start_pos| {
if (std.mem.indexOf(u8, trimmed, "*/")) |_| {
// Both /* and */ on same line - it's an inline comment, not multi-line
// If line starts with /*, skip it entirely
if (start_pos == 0) continue;
// Otherwise it contains an inline comment, process the line normally
} else {
// Found /* without */ - start of multi-line comment
in_multiline_comment = true;
continue;
}
}
} else {
// We're in a multi-line comment, look for */
if (std.mem.indexOf(u8, trimmed, "*/") != null) {
in_multiline_comment = false;
}
@ -590,10 +602,22 @@ pub const Scanner = struct {
const trimmed = std.mem.trim(u8, line, " \t\r");
// Track multi-line comments (both /** and /*)
if (std.mem.indexOf(u8, trimmed, "/*") != null) {
in_multiline_comment = true;
}
if (in_multiline_comment) {
// Only start tracking if /* appears without */ on the same line
if (!in_multiline_comment) {
if (std.mem.indexOf(u8, trimmed, "/*")) |start_pos| {
if (std.mem.indexOf(u8, trimmed, "*/")) |_| {
// Both /* and */ on same line - it's an inline comment, not multi-line
// If line starts with /*, skip it entirely
if (start_pos == 0) continue;
// Otherwise it contains an inline comment, process the line normally
} else {
// Found /* without */ - start of multi-line comment
in_multiline_comment = true;
continue;
}
}
} else {
// We're in a multi-line comment, look for */
if (std.mem.indexOf(u8, trimmed, "*/") != null) {
in_multiline_comment = false;
}

View File

@ -42,6 +42,7 @@ pub fn convertType(c_type: []const u8, allocator: Allocator) ![]const u8 {
// Common pointer types
if (std.mem.eql(u8, trimmed, "const char *")) return try allocator.dupe(u8, "[*c]const u8");
if (std.mem.eql(u8, trimmed, "const char **")) return try allocator.dupe(u8, "[*c][*c]const u8");
if (std.mem.eql(u8, trimmed, "const char * const *")) return try allocator.dupe(u8, "[*c]const [*c]const u8");
if (std.mem.eql(u8, trimmed, "char *")) return try allocator.dupe(u8, "[*c]u8");
if (std.mem.eql(u8, trimmed, "void *")) return try allocator.dupe(u8, "?*anyopaque");