Am Dienstag, 9. April 2013 11:41:38 UTC+2 schrieb puzzler: > > On Tue, Apr 9, 2013 at 1:33 AM, Tassilo Horn <ts...@gnu.org > <javascript:>>wrote: > >> Nice, but providing the grammar as a plain string looks somewhat >> unnatural to me. Why not something like this (parser being a macro)? >> >> (def as-and-bs >> (parser >> S = AB* . >> AB = A B . >> A = "a" + . >> B = "b" + .)) >> >> > I played around with that, but even if you suppress evaluation by using a > macro, Clojure's reader makes strong assumptions about certain symbols. > For example, it is standard in EBNF notation for {} to mean zero-or-more. > But if you include {A B C} in your grammar using the macro approach, > Clojure's reader will throw an error because it treats {} as a map and > expects an even number of forms to follow. That was the main reason, but > it also makes the notation much more sensitive to whitespace (for example, > AB * versus AB*). Gradually, those little issues start making it look less > and less like traditional notation. There's something really nice about > just being able to copy and paste a grammar off of a website and have it > just work. > > What about something like this, a little like enlive does encode selectors?
(insta/parser :S [:AB :*] :AB [:A :B] :A ["a" :*] :B ["b" :*]) -billy. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.