diff options
| author | aarne <unknown> | 2004-09-17 22:02:35 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-09-17 22:02:35 +0000 |
| commit | 6ec3a53d3cd1666696430d25e1d0c746f3c7dde8 (patch) | |
| tree | ee8ad62e4fb72a9bee1a953f3e35bb723bc870c5 /examples/gfcc/ImperJVM.gf | |
| parent | ecc132dccfc7617ed413f21ee37539475081f8ec (diff) | |
C compiler
Diffstat (limited to 'examples/gfcc/ImperJVM.gf')
| -rw-r--r-- | examples/gfcc/ImperJVM.gf | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/gfcc/ImperJVM.gf b/examples/gfcc/ImperJVM.gf new file mode 100644 index 000000000..10457fbfe --- /dev/null +++ b/examples/gfcc/ImperJVM.gf @@ -0,0 +1,30 @@ +--# -path=.:../prelude + +concrete ImperJVM of Imper = open Prelude, Precedence, ResImper in { + +flags lexer=codevars ; unlexer=code ; startcat=Stm ; + lincat + Stm = SS ; + Typ = SS ; + Exp = SS ; + Var = SS ; + + lin + Decl typ cont = ss [] ; ---- + Assign t x exp = statement (exp.s ++ t.s ++ "_store" ++ x.s) ; + Return t exp = statement (exp.s ++ t.s ++ "_return") ; + While exp loop = statement ("TEST:" ++ exp.s ++ "ifzero_goto" ++ + "END" ++ ";" ++ loop.s ++ "END") ; + Block stm = stm ; + Next stm cont = ss (stm.s ++ cont.s) ; + + EVar t x = statement (t.s ++ "_load" ++ x.s) ; + EInt n = statement ("i_push" ++ n.s) ; + EFloat a b = statement ("f_push" ++ a.s ++ "." ++ b.s) ; + EAddI x y = statement (x.s ++ y.s ++ "iadd") ; + EAddF x y = statement (x.s ++ y.s ++ "fadd") ; + + TInt = ss "i" ; + TFloat = ss "f" ; + +} |
