Parsing integers [was: Re: [Haskell-cafe] help]
catamorphism at gmail.com
Sun Dec 9 16:07:23 EST 2007
On 12/9/07, Ryan Bloor <ryanbloor at hotmail.com> wrote:
> I have a function parseInt... which needs an error guard for when the input
> is not an Int.
> parseInt :: Parser
> parseInt  = 
> parseInt xs = let (digits, rest) = span isDigit (removeSpace xs)
> in [(EInt (read digits), removeSpace rest)]
> Also... I have a function that does this... parseBinaryOp "+" "(5 + 2) if"
> gives...[(Int 5, Int 2, "if")]
> so, op is '+' or "&&". I am unsure of how to begin...
> parseBinaryOp :: String -> String -> [(Expr, Expr, String)]
> parseBinaryOp op str
If this isn't homework, try posting again and phrasing your question
in the form of a question; saying "I am unsure of how to begin"
doesn't help us help you think about the problem.
Tim Chevalier * catamorphism.org * Often in error, never in doubt
"[Teaching children to read] will make America what we want it to be,
a literate country and a hopefuller country." -- George W. Bush
More information about the Haskell-Cafe