[Haskell-beginners] Operator orders affect parse result
m00nlight
dot_wangyushi at yeah.net
Mon Apr 13 06:56:47 UTC 2015
Dear Haskellers,
I have tried the "while language parser" tutorial on haskellwiki, but I encounter an problem I can not understand here,
The following is the code:
http://pastebin.com/saC9vwCn
The problem is, with the code, the parse result of "fact := a / b * c" is
*Main> parseString "fact := a / b * c"
Assign "fact" (ABinary Multiply (ABinary Divide (Var "a") (Var "b")) (Var "c"))
*Main>
But if I swap the order of "/" and "*" operators in aOperators(make "*" appear before "/" operator), then the result is
*Main> parseString "fact := a / b * c"
Assign "fact" (ABinary Divide (Var "a") (ABinary Multiply (Var "b") (Var "c")))
*Main>
So it seems that the order of the operator will affect the parse result. What's the problem with my code? How can I
make my program to produce consistent parse result.
Best Regards,
--m00nlight
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150413/44c39ec7/attachment.html>
More information about the Beginners
mailing list