| 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
|