Skip to content

Commit

Permalink
core: Clojure style comments ; ... now longer supported
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Jun 19, 2024
1 parent d40d7a5 commit de15e80
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions core/src/yamlscript/re.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion core/src/yamlscript/ysreader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion core/test/compiler-stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions core/test/compiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions core/test/data-mode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
yamlscript: |
!yamlscript/v0
; just a comment
build: |
nil
print: |
# Semicolon comments are errors now


- name: data mode with code mode
Expand Down

0 comments on commit de15e80

Please sign in to comment.