]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ExpressionParsing.scl
(refs #7307) Added features field to SCL module header
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / ExpressionParsing.scl
1 import "Prelude"
2
3 data Exp = Exp String
4
5 expToString :: Exp -> String
6 expToString (Exp s) = s
7
8 instance Additive Exp where
9     zero = Exp "0"
10     Exp a + Exp b = Exp ("(" + a + " + " + b + ")")
11
12 instance Ring Exp where
13     one = Exp "1"
14     neg (Exp a) = Exp ("(-" + a + ")")
15     Exp a * Exp b = Exp ("(" + a + " * " + b + ")")
16     Exp a - Exp b = Exp ("(" + a + " - " + b + ")")
17     fromInteger x = Exp (show x)
18     
19 a = Exp "a"
20 b = Exp "b"
21 c = Exp "c"
22 d = Exp "d"
23 e = Exp "e"
24
25 main = expToString (a + b*c + d*e)
26 --
27 ((a + (b * c)) + (d * e))