summaryrefslogtreecommitdiff
path: root/examples-3.0/tutorial/calculator/CalculatorJ.gf
diff options
context:
space:
mode:
Diffstat (limited to 'examples-3.0/tutorial/calculator/CalculatorJ.gf')
-rw-r--r--examples-3.0/tutorial/calculator/CalculatorJ.gf25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples-3.0/tutorial/calculator/CalculatorJ.gf b/examples-3.0/tutorial/calculator/CalculatorJ.gf
new file mode 100644
index 000000000..68ff5342c
--- /dev/null
+++ b/examples-3.0/tutorial/calculator/CalculatorJ.gf
@@ -0,0 +1,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) ;
+}