
I'm using makeTokenParser and buildExpressionParser for
the inner_parser. Thanks for your thoughts, I'll use a
two-stage parser that looks for /end_section> and stores
tokens in heap and then getInput/setInput to feed the
inner_parser.
--- On Fri, 7/4/08, Jonathan Cast
The file I'm trying to parse contains mixed
From: Jonathan Cast
Subject: Re: [Haskell-cafe] parsec manyTill stack overflow To: badeadaniel@yahoo.com Cc: "Derek Elkins" , haskell-cafe@haskell.org Date: Friday, July 4, 2008, 3:29 PM On Fri, 2008-07-04 at 15:15 -0700, Badea Daniel wrote: sections like: ...
... script including arithmetic expressions ...
/end_section>
...
so I defined two parsers: one for the 'outer'
language and
the other one for the 'inner' language. I used (manyTill inner_parser end_section_parser)
Does inner_parser (or a parser it calls) recognize `/end_section'? If not, I don't think you actually need manyTill. If so, that's more difficult. Two thoughts:
* This design looks vaguely XML-ish; is it possible to use a two-stage parser, recognizing but not parsing the arithmetic expressions and then looping back over the parse tree later?
* If the part of inner_parser that would recognize /end_section (presumably as a division operator followed by an identifier?) is well isolated, you could locally exclude it there; e.g., instead of
divison_operator = operator "/"
say
division_operatory = try $ do satisfy (=='/') notFollowedBy (string "end_section") whitespace
(Or reverse the order or notFollowedBy and whitespace).
jcc