
hi I am writing a basic Parser from scratch. So far I have functions;# removeSpaces# match - which checks if a string is a substring of another# orParser which combines two parser's abilities# Basic pasrers like... parseInt, parseTrue, parseFalse, parseBoolusing the orParser on True and False.What I want to do now is have a parseBinaryOp that recognises:parseBinaryOp "+" "(5 + 2) if" >>>gives>> [(EInt 5, EInt 2, "if")]So I think that I have to split the initial string into four parts."+" becomes op'(' becomes tokenF')' becomes tokenB"5" becomes e1"2" becomes e2parseBinaryOp :: String -> String -> [(Expr, Expr, String)]parseBinaryOp op str = let (tokenF,e1,op,e2,tokenB) =I am not sure how to go about separating the string for how I need itusing my other functiuons. Ryan _________________________________________________________________ Celeb spotting – Play CelebMashup and win cool prizes https://www.celebmashup.com

Ryan Bloor wrote:
hi
I am writing a basic Parser from scratch. So far I have functions;
I think you need to read http://www.cs.nott.ac.uk/~gmh/pearl.pdf Paul.

I second that emotion.
That is the perfect paper to read if you've never done a parser and need
one. There is also source code corresponding to the paper if you google
around.
t.
Paul Johnson
hi
I am writing a basic Parser from scratch. So far I have functions;
I think you need to read http://www.cs.nott.ac.uk/~gmh/pearl.pdf Paul. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
participants (3)
-
Paul Johnson
-
Ryan Bloor
-
Thomas Hartman