Can it write an interpreter without building the tree of parse?
rtfm.rtfm.rtfm at gmail.com
Thu Oct 15 09:33:18 EDT 2009
I learn Parsec library now. Parsers from all articles which I found at
first parse input stream entirely and only then call an eval function.
Such method requires to define many data-types for each an element of a
language. And I guess that it hard to write bash interpreter with it
help. Bash makes immediately its commands. For example:
dan at tmp$ bash a.sh
a.sh: line 5: syntax error near unexpected token `)'
a.sh: line 5: `)'
dan at tmp$
First command of the script is made by bash nonetheless the error in the
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
interpret s = runParser mainf () "" s
mainf :: GenParser Char () (IO ())
mainf = do rr <- block
return $ putStrLn rr
block :: GenParser Char () String
block = do s <- string "HELLO WORLD"
----- putStrLn "There is an action"
More information about the Libraries