From e9e80fc389365e24d4300d7d5390c7d833a96c50 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 25 Jun 2008 16:54:35 +0000 Subject: changed names of resource-1.3; added a note on homepage on release --- old-examples/tutorial/calculator/CalculatorJ.gf | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 old-examples/tutorial/calculator/CalculatorJ.gf (limited to 'old-examples/tutorial/calculator/CalculatorJ.gf') diff --git a/old-examples/tutorial/calculator/CalculatorJ.gf b/old-examples/tutorial/calculator/CalculatorJ.gf new file mode 100644 index 000000000..68ff5342c --- /dev/null +++ b/old-examples/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) ; +} -- cgit v1.2.3