Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created October 16, 2025 14:06
Show Gist options
  • Save sogaiu/87412c749b8eaa8ee65063f74ca0fcae to your computer and use it in GitHub Desktop.
Save sogaiu/87412c749b8eaa8ee65063f74ca0fcae to your computer and use it in GitHub Desktop.
some janet parser/* expressions
(comment
(def p (parser/new))
(parser/consume p "[:a {:x 1 :y 2}")
# =>
15
(def state (parser/state p))
state
# =>
@{:delimiters "["
:frames @[@{:args @[]
:column 0
:line 1
:type :root}
@{:args @[:a {:x 1 :y 2}]
:column 1
:line 1
:type :tuple}]}
(def status (parser/status p))
# =>
:pending
(parser/where p)
# =>
[1 15]
(parser/has-more p)
# =>
false
(parser/consume p "]")
# =>
1
(def state (parser/state p))
state
# =>
@{:delimiters ""
:frames @[@{:args @[[[:a {:x 1 :y 2}]]]
:column 0
:line 1
:type :root}]}
(def status (parser/status p))
status
# =>
:root
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment