Re: Parser combinators in parsatron

2012-08-28 Thread Alexsandro Soares
Armando, Nate and Panduranga Many thanks for the answers. Regards, Alex 2012/8/28 Nate Young > On Thu, Aug 23, 2012 at 11:22 AM, Alexsandro Soares > wrote: > > Can you provide the code for this? > Certainly. > > The parser's current source position is stored in the InputState > record's `p

Re: Parser combinators in parsatron

2012-08-28 Thread Nate Young
On Thu, Aug 23, 2012 at 11:22 AM, Alexsandro Soares wrote: > Can you provide the code for this? Certainly. The parser's current source position is stored in the InputState record's `pos` field. That field is a SourcePos record consisting of the current line and column position. Most parsers, howe

Re: Parser combinators in parsatron

2012-08-27 Thread Panduranga Adusumilli
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 (re

Re: Parser combinators in parsatron

2012-08-27 Thread Panduranga Adusumilli
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

Re: Parser combinators in parsatron

2012-08-23 Thread Alexsandro Soares
Hi Nate, Can you provide the code for this? Thanks, Alex 2012/8/23 Nate Young > On Thu, Aug 23, 2012 at 9:24 AM, Alexsandro Soares > wrote: > > Ok. Thanks for the answer. > > > > Is there any way to get the line and column? > The Parsatron doesn't have any builtin facilities for extracting li

Re: Parser combinators in parsatron

2012-08-23 Thread Nate Young
On Thu, Aug 23, 2012 at 9:24 AM, Alexsandro Soares wrote: > Ok. Thanks for the answer. > > Is there any way to get the line and column? The Parsatron doesn't have any builtin facilities for extracting line numbers from tokens, you'd have to keep track of the number of newline characters your parse

Re: Parser combinators in parsatron

2012-08-23 Thread Alexsandro Soares
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 b

Re: Parser combinators in parsatron

2012-08-22 Thread Armando Blancas
pL first tries anbn: many parses zero \a's; then times has to parse zero \b's; and the parser returns the concatenation of two empty lists. An empty list isn't a failure as far as the parser either is concerned, so it won't try xdny in that case. On Wednesday, August 22, 2012 5:38:56 PM UTC-7,

Parser combinators in parsatron

2012-08-22 Thread Alexsandro Soares
Hi all, I'm using the Parsatron library to build parser combinators. I have the following definition: (defparser anbn [] (let->> [as (many (char \a)) bs (times (count as) (char \b))] (always (concat as bs (defparser xdny [] (let->> [ds (between (char \x) (char \y)