diff options
Diffstat (limited to 'assignment-13/uFPL/C.dcl')
-rw-r--r-- | assignment-13/uFPL/C.dcl | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/assignment-13/uFPL/C.dcl b/assignment-13/uFPL/C.dcl new file mode 100644 index 0000000..f9d3595 --- /dev/null +++ b/assignment-13/uFPL/C.dcl @@ -0,0 +1,73 @@ +definition module uFPL.C + +from Data.Maybe import :: Maybe + +from uFPL.Arduino import :: Button +from uFPL.Util import class print + +:: Signedness = Sig | Unsig + +:: CType + = CTChar Signedness + | CTBool + | CTInt Signedness + | CTLong Signedness + | CTVoid + | CTArray CType + | CTStruct String + +:: CExpr + = CEButton Button + | CEGlobal String + | CEInfix String CExpr CExpr + | CEApp String [CExpr] + | CEBool Bool + | CEInt Int + | CEChar Char + | CEBArray Int [Bool] + | CEIArray Int [Int] + | CEIf CExpr CExpr CExpr + | CERef CExpr + | CEDeref CExpr + | CEStruct [(String, CExpr)] + +:: CBody + = CBReturn (Maybe CExpr) + | CBIf CExpr CBody CBody + | CBWhile CExpr CBody + | CBAssign String CExpr + | CBSeq CBody CBody + | CBEmpty + | CBExpr CExpr + +(`seq`) infix 0 :: CBody CBody -> CBody + +:: CVar = + { name :: String + , type :: CType + , value :: CExpr + } + +:: CFun = + { params :: [(Int, CType)] + , body :: CBody + , fresh :: Int + , type :: CType + , name :: String + } + +:: CProg = + { bootstrap :: String + , globals :: [CVar] + , funs :: [CFun] + } + +instance print Signedness +instance print CType +instance print CExpr +instance print CBody +instance print CVar +instance print CFun +instance print CProg + +combinePrograms :: CProg CProg -> CProg |