summaryrefslogtreecommitdiff
path: root/examples/gfcc/ImperJVM.gf
diff options
context:
space:
mode:
authoraarne <unknown>2004-09-17 22:02:35 +0000
committeraarne <unknown>2004-09-17 22:02:35 +0000
commit6ec3a53d3cd1666696430d25e1d0c746f3c7dde8 (patch)
treeee8ad62e4fb72a9bee1a953f3e35bb723bc870c5 /examples/gfcc/ImperJVM.gf
parentecc132dccfc7617ed413f21ee37539475081f8ec (diff)
C compiler
Diffstat (limited to 'examples/gfcc/ImperJVM.gf')
-rw-r--r--examples/gfcc/ImperJVM.gf30
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" ;
+
+}