Can it write an interpreter without building the tree of parse?
jeffzaroyko at gmail.com
Fri Oct 16 19:39:09 EDT 2009
On Fri, Oct 16, 2009 at 12:33 AM, Daneel Yaitskov
<rtfm.rtfm.rtfm at gmail.com> wrote:
> I want to write a interpreter which does actions (IO) inside the parse
> function. But I don't know how to do it. That code show that What I need.
> Does trick exist that the block function can contain an action (putStr)?
IO actions inside the parse function? I don't think you should want to
do this, what may work better is to have a parse function which
consumes part of the input, producing a value representing as much as
you're willing to interpret, along with the rest of the input. You
can use Parsec's getInput function for this. eg:
get1 = do token <- instruction
remaining <- getInput
More information about the Libraries