Skip comments, the dumb solution.

This commit is contained in:
Scott Richmond 2022-03-19 19:21:29 -04:00
parent 2a099298f0
commit 584ddaf705
2 changed files with 17 additions and 4 deletions

View File

@ -446,6 +446,10 @@
(parse-then (accept ::token/newline ast)) (parse-then (accept ::token/newline ast))
)) ))
(defn- parse-match-clause [parser])
(defn- parse-match [parser])
(defn- parse-expr (defn- parse-expr
([parser] (parse-expr parser sync-on)) ([parser] (parse-expr parser sync-on))
([parser sync-on] (let [token (current parser)] ([parser sync-on] (let [token (current parser)]
@ -483,6 +487,10 @@
::token/if (parse-if parser) ::token/if (parse-if parser)
::token/match (parse-match parser)
::token/comment (advance parser)
::token/error (panic parser (:message token) sync-on) ::token/error (panic parser (:message token) sync-on)
(::token/rparen ::token/rbrace ::token/rbracket) (::token/rparen ::token/rbrace ::token/rbracket)
@ -504,7 +512,11 @@
(do (do
(def pp pp/pprint) (def pp pp/pprint)
(def source "#{:a :b, :c :d}") (def source "
(1
2
&three
3)")
(def lexed (scanner/scan source)) (def lexed (scanner/scan source))
(def tokens (:tokens lexed)) (def tokens (:tokens lexed))
(def p (parser tokens)) (def p (parser tokens))

View File

@ -208,9 +208,10 @@
comm (str char)] comm (str char)]
(let [char (current-char scanner)] (let [char (current-char scanner)]
(if (= \newline char) (if (= \newline char)
(if (s/starts-with? comm "&&&") (update scanner ::line inc)
(add-token (update scanner ::line inc) ::token/docstring) ;;(if (s/starts-with? comm "&&&")
(add-token (update scanner ::line inc) ::token/comment)) ;;(add-token (update scanner ::line inc) ::token/docstring)
;;(add-token (update scanner ::line inc) ::token/comment))
(recur (advance scanner) (str comm char)))))) (recur (advance scanner) (str comm char))))))
(defn- scan-token [scanner] (defn- scan-token [scanner]