The project is for the final project of class "Programming Language Design (CE6145*)"
Click here and watch part B. (Backup)
- Get one-line input from user (String)
- e.g.
(3%5) + (7%10) * (5%3)
- e.g.
- Turn the input to a List ([String])
- e.g.
[(3%5), +, (7%10), *, (5%3)]
- e.g.
- Calculate all the * and / operators, from left to right ([String])
- e.g.
[(3%5), +, 7%6]
- e.g.
- Calculate all the + and - operators, from left to right (String)
- e.g.
53%30
- e.g.
- Print the result
Fraction
or followed by one or moreOperator Fraction
- Operator:
+
,-
,*
, or/
- Fraction: An
%
between two integers. Wrapped with one pair of()
is allowed.
- Operator:
- for a positive answer, output the Fraction like
A%B
- for a negative answer, output the Fraction like
(A)%B
- if 'divide by zero' occured, throw an exception with message "divide by zero"
- You have to download ghc first.
- Execute
run.bat
in Windows - Execute
run.sh
in Linux