diff options
| author | aarne <unknown> | 2004-09-22 15:12:49 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-09-22 15:12:49 +0000 |
| commit | a0116fd288640a47166b5104b46d9b6fa510a563 (patch) | |
| tree | f1101b8b5ab21be0164dcd6ec17b6ee095166538 /examples/gfcc/ImperC.gf | |
| parent | 6afcb5009aa814497d2aa99a2f7d7790865b2e09 (diff) | |
printing to LBNF with profiles
Diffstat (limited to 'examples/gfcc/ImperC.gf')
| -rw-r--r-- | examples/gfcc/ImperC.gf | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/examples/gfcc/ImperC.gf b/examples/gfcc/ImperC.gf index b6396456a..28ce65a95 100644 --- a/examples/gfcc/ImperC.gf +++ b/examples/gfcc/ImperC.gf @@ -1,10 +1,10 @@ +--# -path=.:../prelude concrete ImperC of Imper = open ResImper in { flags lexer=codevars ; unlexer=code ; startcat=Stm ; lincat Exp = PrecExp ; - Body = {s,s2 : Str ; size : Size} ; - ListExp = {s : Str ; size : Size} ; + Body = {s,s2 : Str} ; lin Empty = ss [] ; @@ -12,11 +12,13 @@ concrete ImperC of Imper = open ResImper in { val.s ++ cont.$0 ++ paren body.s2 ++ "{" ++ body.s ++ "}" ++ ";" ++ cont.s) ; - BodyNil stm = stm ** {s2 = [] ; size = Zero} ; + BodyNil stm = stm ** {s2 = []} ; + BodyOne typ stm = stm ** { + s2 = typ.s ++ stm.$0 + } ; BodyCons typ _ body = { s = body.s ; - s2 = typ.s ++ body.$0 ++ separator "," body.size ++ body.s2 ; - size = nextSize body.size + s2 = typ.s ++ body.$0 ++ "," ++ body.s2 ; } ; Decl typ cont = continues (typ.s ++ cont.$0) cont ; @@ -27,24 +29,23 @@ concrete ImperC of Imper = open ResImper in { Block stm = continue ("{" ++ stm.s ++ "}") ; End = ss [] ; - EVar _ x = constant x.s ; - EInt n = constant n.s ; - EFloat a b = constant (a.s ++ "." ++ b.s) ; - EMulI, EMulF = infixL P2 "*" ; - EAddI, EAddF = infixL P1 "+" ; - ESubI, ESubF = infixL P1 "-" ; - ELtI, ELtF = infixN P0 "<" ; + EVar _ x = constant x.s ; + EInt n = constant n.s ; + EFloat a b = constant (a.s ++ "." ++ b.s) ; + EMul _ = infixL P2 "*" ; + EAdd _ = infixL P1 "+" ; + ESub _ = infixL P1 "-" ; + ELt _ = infixN P0 "<" ; EApp args val f exps = constant (f.s ++ paren exps.s) ; + TNum t = t ; TInt = ss "int" ; TFloat = ss "float" ; NilTyp = ss [] ; ConsTyp = cc2 ; - NilExp = ss [] ** {size = Zero} ; - ConsExp _ _ e es = { - s = ex e ++ separator "," es.size ++ es.s ; - size = nextSize es.size - } ; + NilExp = ss [] ; + OneExp _ e = ss (ex e) ; + ConsExp _ _ e es = ss (ex e ++ "," ++ es.s) ; } |
