Skip to content

Instantly share code, notes, and snippets.

@cgrand
Created October 29, 2009 13:48
Show Gist options
  • Save cgrand/221456 to your computer and use it in GitHub Desktop.
Save cgrand/221456 to your computer and use it in GitHub Desktop.
;; implicit pass on :space
(def g
(grammar {:space :space
:main :expr*}
:space [" "+]
:expr #{:symbol ["(" :expr* ")"]}
:symbol ["a"+ "b" (but "a" "b")]))
(comment
=> (-> g (step "(ab ab)") eof) ; yuk!
([nil [[{:tag :expr, :content ["(" {:tag :expr, :content [{:tag :symbol, :content ["ab"], :length 2}], :length 2} {:tag :space, :content [" "], :length 1} {:tag :expr, :content [{:tag :symbol, :content ["ab"], :length 2}], :length 2} ")"], :length 7}] []] nil])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment