diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-09-03 19:21:50 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-09-03 19:21:50 +0000 |
| commit | 14f185d326590f6656cf7b8c734fbfc87cf0605b (patch) | |
| tree | 11b0a0c51c4226675f6cc53669d46affde7ad531 /examples/tutorial/calculator/CalculatorJ.gf | |
| parent | ee9416d5232c86c7fa084f1a384d7424ca2d8fee (diff) | |
calculator ex
Diffstat (limited to 'examples/tutorial/calculator/CalculatorJ.gf')
| -rw-r--r-- | examples/tutorial/calculator/CalculatorJ.gf | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/tutorial/calculator/CalculatorJ.gf b/examples/tutorial/calculator/CalculatorJ.gf new file mode 100644 index 000000000..15b2caffd --- /dev/null +++ b/examples/tutorial/calculator/CalculatorJ.gf @@ -0,0 +1,24 @@ +--# -path=.:prelude + +concrete CalculatorJ of Calculator = open Prelude in { + + flags lexer=codevars ; unlexer=code ; + + lincat + Prog, Exp, Var = SS ; + + lin + PEmpty = ss [] ; + PDecl exp prog = ss (exp.s ++ ";" ++ prog.s) ; + PAss vr exp prog = ss (exp.s ++ ";" ++ "istore" ++ vr.s ++ ";" ++ prog.s) ; + + EPlus = postfix "iadd" ; + EMinus = postfix "isub" ; + ETimes = postfix "imul" ; + + EInt = prefixSS "iconst" ; + EVar = prefixSS "iload" ; + + oper + postfix : Str -> SS -> SS -> SS = \op,x,y -> ss (x.s ++ ";" ++ y.s ++ ";" ++ op) ; +} |
