This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-17
Channels
- # beginners (52)
- # boot (116)
- # cider (21)
- # cljs-dev (44)
- # clojure (104)
- # clojure-dev (82)
- # clojure-greece (5)
- # clojure-japan (4)
- # clojure-nl (14)
- # clojure-russia (65)
- # clojure-serbia (3)
- # clojure-spec (38)
- # clojure-uk (9)
- # clojure-ukraine (1)
- # clojurescript (65)
- # clojurewest (1)
- # community-development (1)
- # core-logic (3)
- # cursive (5)
- # data-science (9)
- # datomic (13)
- # emacs (45)
- # euroclojure (1)
- # hoplon (2)
- # instaparse (23)
- # javascript (1)
- # jobs (2)
- # klipse (43)
- # leiningen (8)
- # lumo (25)
- # off-topic (7)
- # om (13)
- # om-next (3)
- # onyx (11)
- # pedestal (12)
- # planck (19)
- # proton (1)
- # re-frame (26)
- # reagent (26)
- # remote-jobs (13)
- # ring-swagger (23)
- # spacemacs (1)
- # untangled (3)
I'm having trouble creating a parser using the grammar specified here: https://developers.google.com/protocol-buffers/docs/reference/proto3-spec
I'm slurping the grammar out of a separate file, but I feel like escaped quotes still aren't being handled as I intend (e.g. quote = "'" | '"'
)
the way you have it looks likely to work to me
try making a trivial grammar that only matches a quote to make sure it works the way you expect
^ This. So much this. When I'm making grammars, I often make little phrases to match a character I haven't tested before.
"'" | '"'
looks right, but there are sometimes additional layers of escaping you have to deal with.
e.g. if you wrote your grammar as a string in a Clojure file, it would probably have to look like
(def parser (insta/parser "quote \"'\" | '\"'"))
I see this in the protobuf spec
hexEscape = '\'
that will probably throw off instaparse, since it thinks you are escaping the second '
so it should really be
hexEscape = '\\'
also, /[^\0\n\\]/
is not valid EBNF in instaparse (should be #"[^\0\n\\]"
)
strangely enough, #"[^\0\n\\]"
isn't valid clojure regex syntax, so I stole the same regex syntax from https://github.com/arpagaus/clj-protobuf/blob/master/resources/proto.ebnf
@aengelberg what's the equivalent of the …
that they've got littered all over their grammar?
I think they meant that as a shorthand for alternating between all the digits. Sadly instaparse can't infer the intermediate values, so you would have to "0" | "1" | "2" | "3" | "4" | "5" | "6" | "8" | "9"
correct