Commits

Moritz Heidkamp committed 6248535

Comments

  • Participants
  • Parent commits 8c99a98

Comments (0)

Files changed (2)

File edn-impl.scm

                           (string-append number suffix))))))
       (result-parser 'float number arbitrary-precision?))))
 
+(define edn-comment
+  (preceded-by (is #\;) (repeated item until: (any-of (is #\newline) (none-of item)))))
+
 (define edn-element
   (recursive-parser
    (preceded-by
             edn-float
             edn-integer
             edn-keyword
-            edn-symbol))))
+            edn-symbol
+            (preceded-by edn-comment
+                         (any-of (edn-element)
+                                 (parser-error "Invalid edn input")))))))
 
 (define (collection-parser result-parser-name open close #!optional items-parser)
   (sequence* ((_ (is open))

File tests/read.scm

     ((_ in out)
      (test-read in out ""))))
 
-(define-syntax test-read-fail
-  (syntax-rules ()
-    ((_ in)
-     (test-read in #f in))))
-
 (define-syntax test-read-error
   (syntax-rules ()
     ((_ in)
 
 (test-group "custom parsers"
   (register-edn-parser! 'vector list->vector)
-  (test-read "[1 2 3]" (vector 1 2 3)))
+  (test-read "[1 2 3]" (vector 1 2 3))
+  (edn-parsers (default-edn-parsers)))
+
+(test-group "comments"
+  (test-read "  ; foo\n; bar \n baz" 'baz)
+  (test-read-error "; foo"))
 
 (test-end)