Skip to content

Instantly share code, notes, and snippets.

(ns parse2
(:refer-clojure :exclude [char])
(:require [clojure.core :as core]
[clojure.string :as str]
[clojure.java.io :as io]
[zetta.core :as z]
[zetta.parser.seq :as s]
[zetta.combinators :as c])
(:use [zetta.core :only [<$> <* *> <|> do-parser]]))
(ns blah
(:use [zetta.parser.seq :only (whitespace number char)]
[zetta.combinators :only (choice around)]
[zetta.core :only (*>, <*)])
(:require [zetta.core :as z]))
(def whitespaces (many whitespace))
(def id4
(around
;Hrm... I actually tried a similar approach before but:
(def identifier2
(around
whitespaces
(choice
[(*> (string "#")
(<* number (string "#")))
(*> (string "#")
(<* number (string "=")))])))
(def identifier
(around
whitespaces
(choice
[(<$> (partial apply vector)
(*> (string "#")
(<* number (string "#"))))
; ^ I think you should be using just number here right?
; you are trying to parse (many1 digit)
(<$> (partial apply vector)