[Haskell-cafe] parsebinaryoperations

Philip Weaver philip.weaver at gmail.com
Sun Dec 9 18:41:31 EST 2007


Maybe you should look into Parsec, a Haskell library for writing parsers.
Google should find what you need.

- Phil

On Dec 9, 2007 1:58 AM, Ryan Bloor <ryanbloor at hotmail.com> wrote:

> hi
>
> 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
>
> Thankyou
>
> Ryan
>
> ------------------------------
> Get closer to the jungle… I'm a Celebrity Get Me Out Of Here!<http://entertainment.uk.msn.com/tv/realitytv/im-a-celebrity/>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071209/af140408/attachment-0001.htm


More information about the Haskell-Cafe mailing list