Commit 31231ba8 authored by Camil Staps's avatar Camil Staps 🚀

added CleanPrettyPrint; macros in builddb

parent ed79b665
CleanPrettyPrint @ 2a3bb584
Subproject commit 2a3bb584e1f3dfb3caf6df0a1eb8b4ed9f41fffc
...@@ -23,7 +23,7 @@ man: $(MAN) ...@@ -23,7 +23,7 @@ man: $(MAN)
%.prj: %.prj:
$(CPM) project $(basename $@) create $(CPM) project $(basename $@) create
$(SED) -i 's/\(Target:[ \t]\+\)StdEnv/\1CleanPlatform/' $@ $(SED) -i 's/\(Target:[ \t]\+\)StdEnv/\1CleanPlatform/' $@
$(SED) -i 's/[ \t]\+Path:[ \t]\+{Project}/&\n&\/CleanLevenshtein\n&\/CleanTypeUnifier\n&\/CleanTypeUnifier\/clean-compiler\/main\/\n&\/CleanTypeUnifier\/clean-compiler\/frontend\/\n&\/CleanTypeUnifier\/clean-compiler\/backend\/\n&\/CleanTypeUnifier\/clean-compiler\/main\/Unix\//' $@ $(SED) -i 's/[ \t]\+Path:[ \t]\+{Project}/&\n&\/CleanLevenshtein\n&\/CleanPrettyPrint\n&\/CleanTypeUnifier\n&\/CleanTypeUnifier\/clean-compiler\/main\/\n&\/CleanTypeUnifier\/clean-compiler\/frontend\/\n&\/CleanTypeUnifier\/clean-compiler\/backend\/\n&\/CleanTypeUnifier\/clean-compiler\/main\/Unix\//' $@
$(SED) -i 's/\([ \t]\+Path:[ \t]\+\){Project}$$/&\n\1{Application}\/lib\/ArgEnv\/\n\1{Application}\/lib\/TCPIP\//' $@ $(SED) -i 's/\([ \t]\+Path:[ \t]\+\){Project}$$/&\n\1{Application}\/lib\/ArgEnv\/\n\1{Application}\/lib\/TCPIP\//' $@
$(SED) -i 's/\($(basename $@)\).exe/\1/' $@ $(SED) -i 's/\($(basename $@)\).exe/\1/' $@
$(SED) -i 's/\(Output:[ \t]\+\)ShowConstructors/\1NoConsole/' $@ $(SED) -i 's/\(Output:[ \t]\+\)ShowConstructors/\1NoConsole/' $@
......
...@@ -63,6 +63,8 @@ findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB ...@@ -63,6 +63,8 @@ findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB
-> [(FunctionLocation, ExtendedType)] -> [(FunctionLocation, ExtendedType)]
getMacro :: MacroLocation TypeDB -> Maybe Macro getMacro :: MacroLocation TypeDB -> Maybe Macro
putMacro :: MacroLocation Macro TypeDB -> TypeDB
putMacros :: [(MacroLocation, Macro)] TypeDB -> TypeDB
getInstances :: Class TypeDB -> [Type] getInstances :: Class TypeDB -> [Type]
putInstance :: Class Type TypeDB -> TypeDB putInstance :: Class Type TypeDB -> TypeDB
......
...@@ -28,13 +28,13 @@ printersperse ia a bs = intercalate (print False a) (map (print ia) bs) ...@@ -28,13 +28,13 @@ printersperse ia a bs = intercalate (print False a) (map (print ia) bs)
derive gEq ClassOrGeneric, FunctionLocation, ClassLocation, Type, TypeDB, derive gEq ClassOrGeneric, FunctionLocation, ClassLocation, Type, TypeDB,
TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, TypeDefRhs, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, TypeDefRhs,
RecordField, Constructor, Kind RecordField, Constructor, Kind, MacroLocation, Macro
derive JSONEncode ClassOrGeneric, FunctionLocation, ClassLocation, Type, derive JSONEncode ClassOrGeneric, FunctionLocation, ClassLocation, Type,
TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation,
TypeDefRhs, RecordField, Constructor, Kind TypeDefRhs, RecordField, Constructor, Kind, MacroLocation, Macro
derive JSONDecode ClassOrGeneric, FunctionLocation, ClassLocation, Type, derive JSONDecode ClassOrGeneric, FunctionLocation, ClassLocation, Type,
TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation,
TypeDefRhs, RecordField, Constructor, Kind TypeDefRhs, RecordField, Constructor, Kind, MacroLocation, Macro
instance zero TypeDB instance zero TypeDB
where where
...@@ -106,6 +106,13 @@ findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB ...@@ -106,6 +106,13 @@ findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB
findFunction`` fs {functionmap} = toList $ foldr filterWithKey functionmap fs findFunction`` fs {functionmap} = toList $ foldr filterWithKey functionmap fs
getMacro :: MacroLocation TypeDB -> Maybe Macro getMacro :: MacroLocation TypeDB -> Maybe Macro
getMacro loc {macromap} = get loc macromap
putMacro :: MacroLocation Macro TypeDB -> TypeDB
putMacro ml m db=:{macromap} = { db & macromap = put ml m macromap }
putMacros :: [(MacroLocation, Macro)] TypeDB -> TypeDB
putMacros ms db = foldr (\(loc,m) db -> putMacro loc m db) db ms
getInstances :: Class TypeDB -> [Type] getInstances :: Class TypeDB -> [Type]
getInstances c {instancemap} = if (isNothing ts) [] (fromJust ts) getInstances c {instancemap} = if (isNothing ts) [] (fromJust ts)
......
...@@ -2,7 +2,7 @@ module builddb ...@@ -2,7 +2,7 @@ module builddb
// Project libraries // Project libraries
import qualified TypeDB as DB import qualified TypeDB as DB
from TypeDB import ::TypeExtras{..}, instance zero TypeExtras from TypeDB import ::TypeExtras{..}, instance zero TypeExtras, ::Macro{..}
// StdEnv // StdEnv
import StdFile, StdList, StdMisc, StdArray, StdBool, StdString, StdTuple import StdFile, StdList, StdMisc, StdArray, StdBool, StdString, StdTuple
...@@ -17,6 +17,9 @@ import qualified Type as T ...@@ -17,6 +17,9 @@ import qualified Type as T
from Type import class print(print), instance print [a], instance print String from Type import class print(print), instance print [a], instance print String
import CoclUtils import CoclUtils
// CleanPrettyPrint
import CleanPrettyPrint
// frontend // frontend
//import Heap, compile, parse, predef //import Heap, compile, parse, predef
import Heap import Heap
...@@ -27,13 +30,15 @@ from compile import empty_cache, ::DclCache{hash_table} ...@@ -27,13 +30,15 @@ from compile import empty_cache, ::DclCache{hash_table}
from general import ::Optional(..) from general import ::Optional(..)
from syntax import ::SymbolTable, ::SymbolTableEntry, ::Ident{..}, ::SymbolPtr, from syntax import ::SymbolTable, ::SymbolTableEntry, ::Ident{..}, ::SymbolPtr,
::Position(NoPos), ::Module{mod_ident,mod_defs}, ::Position(NoPos), ::Module{mod_ident,mod_defs},
::ParsedDefinition(PD_TypeSpec,PD_Instance,PD_Class,PD_Type,PD_Generic,PD_Derive), ::ParsedDefinition(PD_TypeSpec,PD_Instance,PD_Class,PD_Type,PD_Generic,PD_Derive,PD_Function),
::FunSpecials, ::Priority, ::ParsedModule, ::SymbolType, ::FunSpecials, ::Priority, ::ParsedModule, ::SymbolType,
::ParsedInstanceAndMembers{..}, ::ParsedInstance{pi_ident,pi_types}, ::ParsedInstanceAndMembers{..}, ::ParsedInstance{pi_ident,pi_types},
::Type, ::ClassDef{class_ident,class_args,class_context}, ::Type, ::ClassDef{class_ident,class_args,class_context},
::TypeVar, ::ParsedTypeDef, ::TypeDef, ::TypeVar, ::ParsedTypeDef, ::TypeDef,
::GenericDef{gen_ident,gen_type,gen_vars}, ::GenericDef{gen_ident,gen_type,gen_vars},
::GenericCaseDef{gc_type,gc_gcf}, ::GenericCaseFunctions(GCF), ::GCF ::GenericCaseDef{gc_type,gc_gcf}, ::GenericCaseFunctions(GCF), ::GCF,
::FunKind(FK_Macro),
::Rhs, ::ParsedExpr
from scanner import ::Priority(..), ::Assoc(..) from scanner import ::Priority(..), ::Assoc(..)
from parse import wantModule from parse import wantModule
...@@ -159,6 +164,7 @@ getModuleTypes root mod lib cache db w ...@@ -159,6 +164,7 @@ getModuleTypes root mod lib cache db w
# db = 'DB'.putFunctions (flatten $ map constructor_functions typedefs) db # db = 'DB'.putFunctions (flatten $ map constructor_functions typedefs) db
# db = 'DB'.putFunctions (pd_generics lib mod pm.mod_defs) db # db = 'DB'.putFunctions (pd_generics lib mod pm.mod_defs) db
# db = 'DB'.putDerivationss (pd_derivations pm.mod_defs) db # db = 'DB'.putDerivationss (pd_derivations pm.mod_defs) db
# db = 'DB'.putMacros (pd_macros lib mod pm.mod_defs) db
= (db,cache,w) = (db,cache,w)
where where
mkdir :: String -> String mkdir :: String -> String
...@@ -175,6 +181,14 @@ where ...@@ -175,6 +181,14 @@ where
= take (length lib - length mod - 1) lib = take (length lib - length mod - 1) lib
= lib = lib
pd_macros :: String String [ParsedDefinition] -> [('DB'.MacroLocation, 'DB'.Macro)]
pd_macros lib mod pds
= [( 'DB'.ML lib mod id.id_name
, { macro_rhs = cpp rhs
, macro_extras = zero
}
) \\ PD_Function _ id isinfix args rhs FK_Macro <- pds]
pd_derivations :: [ParsedDefinition] -> [('DB'.GenericName, ['DB'.Type])] pd_derivations :: [ParsedDefinition] -> [('DB'.GenericName, ['DB'.Type])]
pd_derivations pds pd_derivations pds
= [(id.id_name, ['T'.toType gc_type]) = [(id.id_name, ['T'.toType gc_type])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment