For Programmers: Free Programming Magazines  


Home > Archive > Functional > May 2007 > Re: Type of a Skip Parser?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Type of a Skip Parser?
Phil Armstrong

2007-05-16, 4:13 am

Alex Rubinsteyn <alex.rubinsteyn@gmail.com> wrote:
> For example, this parser recognizes the containing the character a
> ch('a') //The type of this parser is Parser<string, string>.
>
> Here are two parsers sequentially linked to recognize the string
> ("()"):
> ch('(') >> ch(')') //The type of this parser is SeqParser<string,
> string>
>
> Now, if I wanted to write something like:
> Parser<int, string>* int_in_parens = skip(ch('(')) >> integer >>
> skip(ch(')'))
>
> I encounter all sorts of difficulties. int_in_parens recognizes string
> like "(394)" and should return the enclosed integer.
> How do I write the >> combinator to accomplish this? Do I need to
> make "skippedness" part of the type (Parser<Result, Input, bool
> Skip> )?


At this point I have to ask: are you aware of the Boost::Spirit parser
combinator framework? It sounds like you're doing something very
similar.

http://spirit.sourceforge.net/

cheers, Phil

--
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com