--- /dev/null
+toInt(x) :: Char -> Int{
+ if(x == '0'){ return 0;
+ } else { if(x == '1'){ return 1;
+ } else { if(x == '2'){ return 2;
+ } else { if(x == '3'){ return 3;
+ } else { if(x == '4'){ return 4;
+ } else { if(x == '5'){ return 5;
+ } else { if(x == '6'){ return 6;
+ } else { if(x == '7'){ return 7;
+ } else { if(x == '8'){ return 8;
+ } else { if(x == '9'){ return 9;
+ } else { return -1; }}}}}}}}}}
+}
+
+isDigit(x) :: Char -> Bool {
+ return toInt(x) != -1;
+}
+
+strToInt(x) :: [Char] -> Int {
+ [Char] xs = x;
+ var i = 0;
+ var m = 1;
+ if(!isEmpty(x)){
+ if(xs.hd == '-'){
+ xs = xs.tl;
+ m = -1;
+ }
+
+ while(!isEmpty(xs)){
+ i = i*10 + toInt(xs.hd);
+ xs = xs.tl;
+ }
+ }
+ return i*m;
+}
+
+main(){
+ [Char] num = "-1234";
+ print(strToInt(num));
+ return 0;
+}
foldM foldVarDecl 1 vds >>|
//and the statements
mapM_ g stms >>|
+ //Ugly hack to always return
+ g (ReturnStmt Nothing) >>|
updateAdressbook (const oldMap) >>| pure ()
annote :: Int String -> Gen ()
pre = [
FunDecl zero "1printstr" ["x"] Nothing [] [
IfStmt (FunExpr zero "isEmpty" [VarExpr zero (VarDef "x" [])] [])
- []
+ [ReturnStmt Nothing]
[FunStmt "1printchar" [VarExpr zero (VarDef "x" [FieldHd])] []
,FunStmt "1printstr" [VarExpr zero (VarDef "x" [FieldTl])] []]]
,
FunDecl zero "1printbool" ["x"] Nothing [] [
IfStmt (VarExpr zero (VarDef "x" []))
[FunStmt "1printstr" [makeStrExpr zero $ fromString "True"] []]
- [FunStmt "1printstr" [makeStrExpr zero $ fromString "False"] []]
- ]]
+ [FunStmt "1printstr" [makeStrExpr zero $ fromString "False"] []]]
+ ]
Start :: *World -> *World
Start w