Skip to content

Commit 9ccc416

Browse files
author
xasopheno
committed
-- comments in wgsl
1 parent 6ebbd70 commit 9ccc416

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

parser/src/wgsl_dsl.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ pub fn compile_dsl_to_wgsl(src: &str) -> Result<String, DslError> {
8989
if trimmed.is_empty() {
9090
continue;
9191
}
92-
// Preserve both // and -- style comments
93-
if trimmed.starts_with("//") || trimmed.starts_with("--") {
92+
// Convert -- style comments to // for WGSL compatibility
93+
if trimmed.starts_with("--") {
94+
result.push(format!(" //{}", &trimmed[2..]));
95+
continue;
96+
}
97+
// Preserve // style comments
98+
if trimmed.starts_with("//") {
9499
result.push(format!(" {}", trimmed));
95100
continue;
96101
}
@@ -370,12 +375,13 @@ mod tests {
370375
}
371376

372377
#[test]
373-
fn test_double_dash_comments_preserved() {
374-
// -- style comments should also be preserved
378+
fn test_double_dash_comments_converted() {
379+
// -- style comments should be converted to // for WGSL compatibility
375380
let input = "Xm 2;\n-- this is a comment\nYm 3";
376381
let output = compile_dsl_to_wgsl(input).unwrap();
377382
println!("Output:\n{}", output);
378-
assert!(output.contains("-- this is a comment"), "-- comment should be preserved");
383+
assert!(output.contains("// this is a comment"), "-- comment should be converted to //");
384+
assert!(!output.contains("--"), "-- should not appear in WGSL output");
379385
assert!(output.contains("x = x * 2"));
380386
assert!(output.contains("y = y * 3"));
381387
}

0 commit comments

Comments
 (0)