/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : ModuleDef.pkg */ /* Version : 13 Juillet 2000 */ /* Module definitions functions */ /* */ /***************************************************************************************/ /**************************************************************************************** * * definition block access functions * ****************************************************************************************/ fun defByName (def, name) = let def -> [n _] in !strcmpi n name ;; fun getDef (defs, name) = search_in_list defs @defByName name ;; /*************************************************************************************** Get a definition block of a definition list Return value: [[S r1] r1] (success) or nil (failure) ***************************************************************************************/ fun _GetDefBlock (definitions, defName) = switchstr definitions defName;; /*************************************************************************************** Get a definition line from a definition block Return value: [S r1] (success) or nil (failure) ***************************************************************************************/ fun _GetDefLine (definition, defLine) = switchstr definition defLine;; /*************************************************************************************** set a block of definition of a module if the new block value is nil then suppress the block definition Return value: 1 (success) ***************************************************************************************/ fun _SetDefBlock (definitions, defName, defBlock) = let remove_from_list definitions (getDef definitions defName) -> defs in if defBlock == nil then defs else [defName defBlock]::defs ;; /*************************************************************************************** Add a line in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun _AddDefLine (definitions, defName, defLine) = let _GetDefBlock definitions defName -> defBlock in if defBlock == nil then _SetDefBlock definitions defName (defLine::nil) else if isf_in_list defBlock @strlist_cmpi defLine then definitions else _SetDefBlock definitions defName (defLine::defBlock) ;; /*************************************************************************************** Add a list of lines in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun _AddDefLineList (definitions, defName, listDefLine) = if listDefLine == nil then definitions else let listDefLine -> [defLine nextDefLine] in ( _AddDefLine definitions defName defLine; _AddDefLineList definitions defName nextDefLine ) ;; /*************************************************************************************** Update a line in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun _SetDefLine (definitions, defName, defLineName, defLineValues) = let switchstr definitions defName -> defBlock in let defLineName::defLineValues -> defLine in _SetDefBlock definitions defName (f_replace_in_list defBlock @defByName defLineName defLine) ;; /**************************************************************************************** * * Extract some definitions from a list of definitions * ****************************************************************************************/ fun _GetDefs (definitions, defNameList) = let defNameList -> [first next] in if first == nil then nil else let switchstr definitions first -> def in if def == nil then _GetDefs definitions next else [first def]::(_GetDefs definitions next) ;;