blob: 68ff5342c5d7c6c805bef3aa6040af9f07b0b196 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
--# -path=.:prelude
concrete CalculatorJ of Calculator = open Prelude in {
flags lexer=codevars ; unlexer=code ;
lincat
Prog, Exp, Var = SS ;
lin
PEmpty = ss [] ;
PInit exp prog = ss (exp.s ++ ";" ++ "istore" ++ prog.$0 ++ ";" ++ prog.s) ;
PAss vr exp prog = ss (exp.s ++ ";" ++ "istore" ++ vr.s ++ ";" ++ prog.s) ;
EPlus = postfix "iadd" ;
EMinus = postfix "isub" ;
ETimes = postfix "imul" ;
EDiv = postfix "idiv" ;
EInt = prefixSS "iconst" ;
EVar = prefixSS "iload" ;
oper
postfix : Str -> SS -> SS -> SS = \op,x,y -> ss (x.s ++ ";" ++ y.s ++ ";" ++ op) ;
}
|