cgrand / parsley

a DSL for creating total and truly incremental parsers in Clojure
200 stars 24 forks source link

Question: parsing multi-line strings #5

Open maryrosecook opened 12 years ago

maryrosecook commented 12 years ago

Hiya. Really enjoying using parsley. I've got a grammar up and running that can parse a number of different expressions. However, I'm struggling with defining the rules to allow lists of expressions where each expression is separated by a new line. For example:

"a\na\na\n"

I thought this grammar would parse the string above:

(def parse (parser { :main :block, :space :ws?, :root-tag :root } :block [#"i" #"\n" :+] :ws #"[ \t\r]+" ))

But I get a shift/reduce error. Could you offer me any pointers?

Thanks a lot.

cgrand commented 12 years ago

Hi Mary-Rose, It's #1 on my todo list. Technically Parsley has no lookup so blocks need an end delimiter. I've got the relevant paper at hand, I just need time. Sorry for the answer.

maryrosecook commented 12 years ago

Ah, OK. Thanks. It's good to know I wasn't going crazy! Thank you for the prompt reply.

dfreeman commented 11 years ago

FWIW, I'd love to see handling for such cases included. I know you've been busy with other projects the last several months, but is there still a chance this will make it into parsley at some point?

Thanks for all your work!

clojj commented 11 years ago

Is this issue closed ?