From de15e8047e5882af40565aca3a898cdf8ad2d7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Wed, 19 Jun 2024 12:45:56 -0400 Subject: [PATCH] core: Clojure style comments `; ...` now longer supported --- core/src/yamlscript/re.clj | 3 +-- core/src/yamlscript/ysreader.clj | 3 ++- core/test/compiler-stack.yaml | 2 +- core/test/compiler.yaml | 8 ++++++++ core/test/data-mode.yaml | 4 +--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/yamlscript/re.clj b/core/src/yamlscript/re.clj index 3f28a1db..e5f3981d 100644 --- a/core/src/yamlscript/re.clj +++ b/core/src/yamlscript/re.clj @@ -38,14 +38,13 @@ return | . )") ; Character token -(def tend #"(?=[\.\,\s\]\}\)]|$)") ; End of token +(def tend #"(?=[\.\,\s\]\}\)]|$)") ; End of token (def comm #";.*(?:\n|\z)") ; Comment token (def ignr #"(?x) (?: # Ignorables | # Empty \#\!.*\n? | # hashbang line [\s,]+ | # whitespace, commas, - ;.*\n? # comments )") (def spec #"(?:~@|[~@`^])") ; Special token (def quot #"(?:\\')") ; Quote token diff --git a/core/src/yamlscript/ysreader.clj b/core/src/yamlscript/ysreader.clj index 6c6d99b1..ec2de0d9 100644 --- a/core/src/yamlscript/ysreader.clj +++ b/core/src/yamlscript/ysreader.clj @@ -302,7 +302,8 @@ (defn read-scalar [[token & tokens]] (cond (map? token) [token tokens] - (is-comment? token) [] + (is-comment? token) + (die "Clojure style comments are not allowed: '" token "'.") (= "nil" token) [(Nil) tokens] (= "true" token) [(Bln token) tokens] (= "false" token) [(Bln token) tokens] diff --git a/core/test/compiler-stack.yaml b/core/test/compiler-stack.yaml index 012bb088..e7bbf093 100644 --- a/core/test/compiler-stack.yaml +++ b/core/test/compiler-stack.yaml @@ -363,7 +363,7 @@ {:exp "; comment (foo bar)"} parse: | "=VAL", :! "yamlscript/v0", := "; comment (foo bar)" - print: | + # Semicolon comments are errors now - name: Switch to code mode diff --git a/core/test/compiler.yaml b/core/test/compiler.yaml index addbb424..1b450ad7 100644 --- a/core/test/compiler.yaml +++ b/core/test/compiler.yaml @@ -1078,3 +1078,11 @@ =>: foo.?.bar clojure: | (__ foo (list _DBG) 'bar) + + +- name: Error Clojure style comments + yamlscript: | + !yamlscript/v0 + =>: 42 ;; This is not a comment :( + error: | + ~~ This is not a comment diff --git a/core/test/data-mode.yaml b/core/test/data-mode.yaml index afb303cc..5434c9e6 100644 --- a/core/test/data-mode.yaml +++ b/core/test/data-mode.yaml @@ -92,9 +92,7 @@ yamlscript: | !yamlscript/v0 ; just a comment - build: | - nil - print: | + # Semicolon comments are errors now - name: data mode with code mode