Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created February 27, 2021 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogaiu/4f3b87c4ee56cfa128438646430cfbd4 to your computer and use it in GitHub Desktop.
Save sogaiu/4f3b87c4ee56cfa128438646430cfbd4 to your computer and use it in GitHub Desktop.
using janet to detect delimiter issues
With content (in example0.janet):
(defn b
[]
(def a
1))
[:a {:b 1}
1
Janet 1.15.2-local linux/x64 - '(doc)' for help
repl:1:> (def p (parser/new))
<core/parser 0x55B3BD88B910>
repl:2:> (def buf (slurp "./example0.janet"))
@"(defn b\n []\n (def a\n 1))\n\n[:a {:b 1}\n1\n"
repl:3:> (parser/consume p buf)
44
repl:4:> (parser/error p)
nil
repl:5:> (parser/state p)
@{:delimiters "[" :frames @[@{:args @[nil] :column 0 :line 1 :type :root} @{:args @[((defn b [] (def a 1))) :a {:b 1}] :column 1 :line 6 :type :tuple}]}
repl:6:> (parser/status p)
:pending
repl:7:> (parser/eof p)
<core/parser 0x55B3BD88B910>
repl:8:> (parser/error p)
"unexpected end of source, [ opened at line 6, column 1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment