From d23677456e8e61de913a81644faf671de8c406dc Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Sat, 27 Dec 2025 09:57:52 -0300 Subject: [PATCH] feat: Add semicolon as line comment delimiter Support `;` as an alternative line comment syntax alongside the existing `//` and `/* */` C-style comments. --- crates/plotnik-lib/src/parser/cst.rs | 1 + .../src/parser/tests/grammar/trivia_tests.rs | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/crates/plotnik-lib/src/parser/cst.rs b/crates/plotnik-lib/src/parser/cst.rs index 0f5f6c80..e6cb307b 100644 --- a/crates/plotnik-lib/src/parser/cst.rs +++ b/crates/plotnik-lib/src/parser/cst.rs @@ -119,6 +119,7 @@ pub enum SyntaxKind { Newline, #[regex(r"//[^\n]*", allow_greedy = true)] + #[regex(r";[^\n]*", allow_greedy = true)] LineComment, #[regex(r"/\*(?:[^*]|\*[^/])*\*/")] diff --git a/crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs index b3a773f0..18b6a8ea 100644 --- a/crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs +++ b/crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs @@ -182,3 +182,29 @@ fn comment_only_raw() { Newline "\n" "#); } + +#[test] +fn semicolon_comment() { + let input = indoc! {r#" + ; semicolon comment + Q = (identifier) + "#}; + + let res = Query::expect_valid_cst_full(input); + + insta::assert_snapshot!(res, @r#" + Root + LineComment "; semicolon comment" + Newline "\n" + Def + Id "Q" + Whitespace " " + Equals "=" + Whitespace " " + Tree + ParenOpen "(" + Id "identifier" + ParenClose ")" + Newline "\n" + "#); +}