summaryrefslogtreecommitdiff
path: root/gf-book/examples/chapter8/CalculatorJ.gf
blob: c5f40c8d3e07a9969e18aeaa26b191652033b3fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
concrete CalculatorJ of Calculator = open Prelude in {
lincat 
  Exp = SS ;
lin
  EPlus  = postfix "iadd" ;
  EMinus = postfix "isub" ;
  ETimes = postfix "imul" ;
  EDiv   = postfix "idiv" ;
  EInt i = ss ("ldc" ++ i.s) ;
oper
  postfix : Str -> SS -> SS -> SS = \op,x,y -> 
    ss (x.s ++ ";" ++ y.s ++ ";" ++ op) ;
}