Hi
folks,
I have a parser
problem. I have a basic calculator program (Graham Hutton's from Nottingham)
which contains the following code:
-- Define a parser
to handle the inputexpr :: Parser Intexpr = do t -
term
do symbol
"+"
e -
expr
return (t + e) +++
return t
term :: Parser
Curiouser and
curiouser...
expr ::
Parser Intexpr = do t -
term do symbol
"+"e
- expr return (t +
e) +++ return t
solves the undefined
variable problem but introduces a new 'Last operator in do {...} must be an
_expression_' error, which then disappears if I explicitly return
e
expr
perhaps like this:
expr = do t - term
(do symbol +
e - expr
return (t+e)
)
+++
(return t)
although I think you may also want a 'try' before the first alternative.
No, that still gives the same undefined variable error.
Thanks folks!
Writing it in a lispy manner seems to work. I see what Arthur means about the
layout - I think I'm still thinking too much in C. :)
Nik
Dr Nik FreydĂs Whitehead
University of Akureyri, Iceland
*
Having the moral