printing to LBNF with profiles

This commit is contained in:
aarne
2004-09-22 15:12:49 +00:00
parent 0ff7e33a85
commit 8cd24e0b91
4 changed files with 78 additions and 47 deletions

View File

@@ -1,8 +1,9 @@
abstract Imper = {
abstract Imper = PredefAbs ** {
cat
Program ;
Typ ;
NumTyp ;
ListTyp ;
Fun ListTyp Typ ;
Body ListTyp ;
@@ -17,6 +18,7 @@ abstract Imper = {
Body AS -> (Fun AS V -> Program) -> Program ;
BodyNil : Stm -> Body NilTyp ;
BodyOne : (A : Typ) -> (Var A -> Stm) -> Body (ConsTyp A NilTyp) ;
BodyCons : (A : Typ) -> (AS : ListTyp) ->
(Var A -> Body AS) -> Body (ConsTyp A AS) ;
@@ -29,22 +31,20 @@ abstract Imper = {
End : Stm ;
EVar : (A : Typ) -> Var A -> Exp A ;
EInt : Int -> Exp TInt ;
EFloat : Int -> Int -> Exp TFloat ;
ELtI : Exp TInt -> Exp TInt -> Exp TInt ;
ELtF : Exp TFloat -> Exp TFloat -> Exp TInt ;
EInt : Int -> Exp (TNum TInt) ;
EFloat : Int -> Int -> Exp (TNum TFloat) ;
ELt : (n : NumTyp) -> let Ex = Exp (TNum n) in Ex -> Ex -> Exp (TNum TInt) ;
EApp : (AS : ListTyp) -> (V : Typ) -> Fun AS V -> ListExp AS -> Exp V ;
EAddI, EMulI, ESubI : Exp TInt -> Exp TInt -> Exp TInt ;
EAddF, EMulF, ESubF : Exp TFloat -> Exp TFloat -> Exp TFloat ;
TInt : Typ ;
TFloat : Typ ;
EAdd, EMul, ESub : (n : NumTyp) -> let Ex = Exp (TNum n) in Ex -> Ex -> Ex ;
TNum : NumTyp -> Typ ;
TInt, TFloat : NumTyp ;
NilTyp : ListTyp ;
ConsTyp : Typ -> ListTyp -> ListTyp ;
NilExp : ListExp NilTyp ;
OneExp : (A : Typ) -> Exp A -> ListExp (ConsTyp A NilTyp) ;
ConsExp : (A : Typ) -> (AS : ListTyp) ->
Exp A -> ListExp AS -> ListExp (ConsExp A AS) ;
Exp A -> ListExp AS -> ListExp (ConsTyp A AS) ;
}

View File

@@ -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) ;
}