ANN: Parse-EZ 0.3.0
Parse-EZ is a parser library for Clojure programmers. It allows easy mixing of declarative and imperative styles and does not require any special constructs, macros, monads, etc. to write custom parsers. All the parsing is implemented using regular Clojure functions. README: https://github.com/protoflex/parse-ez/blob/master/README.md Version 0.3.0 adds macro versions of the parse combinators for expressing combinator-nesting a bit more succinctly. Release Notes: https://github.com/protoflex/parse-ez/blob/master/ReleaseNotes.md --- Panduranga Adusumilli -- 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
Re: Parser combinators in parsatron
Alexsandro, I don't know about Parsatron, but Parse-EZ ( https://github.com/protoflex/parse-ez) provides the 'line-pos function that returns [line# column#] vector. Here is the equivalent code for your example using Parse-EZ: (use 'protoflex.parse) (defn anbn [] (let [as (regex #a+) bs (string (apply str (repeat (count as) \b)))] (str as bs))) (defn xdny [] (regex #xd+y)) (defn pL [] (any anbn xdny)) You can call your parse function pL through the parser entry function parse: user= (parse pL xddy) xddy user= (parse pL aabb) aabb user= (parse pL aacc) Parse Error (exception thrown) Panduranga Adusumilli -- 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
Re: Parser combinators in parsatron
Alexsandro, I don't know about Parsatron, but Parse-EZ ( https://github.com/protoflex/parse-ez) provides the 'line-pos' function that returns the line and column info. Here is the equivalent code for your example using Parse-EZ: -- (use 'protoflex.parse) (defn anbn [] (let [as (regex #a+) bs (string (apply str (repeat (count as) \b)))] (str as bs))) (defn xdny [] (regex #xd+y)) (defn pL [] (any anbn xdny)) - and you call your pL function through the parser entry function parse: user= (parse pL xddy) xddy user= (parse pL aabb) aabb user= (parse pL aac) Parse Error (exception thrown) On Thursday, August 23, 2012 7:54:16 PM UTC+5:30, Alexsandro Soares wrote: Ok. Thanks for the answer. Is there any way to get the line and column? For example, in this parser (defparser ident [] ( (letter) (many (either (letter) (digit) I want the token and the initial line and column. How can I change this code? Cheers, Alex -- 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