From: Mart Lubbers Date: Mon, 14 Nov 2016 15:58:23 +0000 (+0100) Subject: extend gcons and make symbol generating smaller X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=7d7b6bdf4400272d6199401bcd76794cba9055ce;p=mTask.git extend gcons and make symbol generating smaller --- diff --git a/gCons.dcl b/gCons.dcl index edd0a4a..64564da 100644 --- a/gCons.dcl +++ b/gCons.dcl @@ -17,4 +17,4 @@ derive consIndex CONS of {gcd_index},UNIT,PAIR,EITHER,OBJECT,Int,Bool,Char,Strin conses :: [a] | gconses{|*|} a generic gconses a :: Bool -> [a] -derive gconses CONS,UNIT,PAIR,EITHER,OBJECT,FIELD,RECORD,Int,Bool,Char,Real,String,(),{},{!},[],[! ],[ !],[!!] +derive gconses CONS,UNIT,PAIR,EITHER,OBJECT,FIELD,RECORD,Int,Bool,Char,Real,String,(),{},{!},[],[! ],[ !],[!!],(->) diff --git a/gCons.icl b/gCons.icl index 6ed064d..e34909a 100644 --- a/gCons.icl +++ b/gCons.icl @@ -36,8 +36,6 @@ consIndex{|Bool|} b = if b 1 0 consIndex{|Char|} c = toInt c consIndex{|String|} _ = 0 -import StdMisc, StdDebug - conses :: [a] | gconses{|*|} a conses = gconses{|*|} True @@ -62,3 +60,4 @@ gconses{|[!!]|} _ _ = [[!!]] gconses{|{}|} _ _ = [{}] gconses{|{!}|} _ _ = [{!}] gconses{|()|} _ = [()] +gconses{|(->)|} _ _ _ = [const undef] diff --git a/mTaskMakeSymbols.icl b/mTaskMakeSymbols.icl index 15b78e4..58b65e1 100644 --- a/mTaskMakeSymbols.icl +++ b/mTaskMakeSymbols.icl @@ -15,6 +15,7 @@ import StdTuple import Data.Tuple import StdList from Data.Func import $ +import Data.List from Text import class Text(join,toUpperCase), instance Text String derive consIndex BC @@ -30,7 +31,7 @@ toDefine i b = "#define " <+ toUpperCase (consName{|*|} b) <+ " " <+ i Start w # (io, w) = stdio w # io = io <<< "#ifndef MTASK_H\n#define MTASK_H\n" -# io = io <<< join "\n" (map (uncurry toDefine) (zip2 [1..] conses)) +# io = io <<< join "\n" $ zipWith toDefine [1..] conses # (ok, w) = fclose (io <<< "\n#endif\n") w | not ok = abort "Couldn't close stdio" = w