diff options
-rw-r--r-- | frontend/frontend.icl | 10 | ||||
-rw-r--r-- | frontend/parse.dcl | 4 | ||||
-rw-r--r-- | frontend/parse.icl | 25 | ||||
-rw-r--r-- | frontend/postparse.icl | 18 | ||||
-rw-r--r-- | frontend/scanner.dcl | 4 | ||||
-rw-r--r-- | frontend/scanner.icl | 44 |
6 files changed, 62 insertions, 43 deletions
diff --git a/frontend/frontend.icl b/frontend/frontend.icl index 91849e3..1f8302b 100644 --- a/frontend/frontend.icl +++ b/frontend/frontend.icl @@ -1,4 +1,4 @@ -/* + /* module owner: Ronny Wichers Schreur */ implementation module frontend @@ -28,9 +28,13 @@ frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n predef_symbo frontEndInterface :: !FrontEndOptions !Ident !SearchPaths !{#DclModule} !*{#*{#FunDef}} !(Optional Bool) !*PredefinedSymbols !*HashTable (ModTimeFunction *Files) !*Files !*File !*File !*File !(Optional *File) !*Heaps -> ( !Optional *FrontEndSyntaxTree,!*{#*{#FunDef}},!{#DclModule},!Int,!*PredefinedSymbols, !*HashTable, !*Files, !*File, !*File, !*File, !Optional *File, !*Heaps) frontEndInterface options mod_ident search_paths cached_dcl_modules cached_dcl_macros list_inferred_types predef_symbols hash_table modtimefunction files error io out tcl_file heaps -// # files = trace_n ("Compiling "+++mod_ident.id_name) files + # (opt_file_dir_time,files) = fopenInSearchPaths mod_ident.id_name ".icl" search_paths FReadData modtimefunction files + | case opt_file_dir_time of No -> True; _ -> False + # error = moduleCouldNotBeImportedError True mod_ident NoPos error + = (No,{},{},0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps) + # (Yes (mod_file,mod_dir,mod_time)) = opt_file_dir_time # (ok,dynamic_type_used,mod,hash_table,error,files) - = wantModule cWantIclFile mod_ident NoPos options.feo_generics(hash_table /* ---> ("Parsing:", mod_ident)*/) error search_paths modtimefunction files + = wantModule mod_file mod_time cWantIclFile mod_ident NoPos options.feo_generics hash_table error files | not ok = (No,{},{},0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps) # cached_module_idents = [dcl_mod.dcl_name \\ dcl_mod<-:cached_dcl_modules] diff --git a/frontend/parse.dcl b/frontend/parse.dcl index fb51a61..6cecf2f 100644 --- a/frontend/parse.dcl +++ b/frontend/parse.dcl @@ -10,5 +10,7 @@ import syntax, hashtable, scanner, predef cWantIclFile :== True cWantDclFile :== False -wantModule :: !Bool !Ident !Position !Bool !*HashTable !*File !SearchPaths (ModTimeFunction *Files) !*Files +wantModule :: !*File !{#Char} !Bool !Ident !Position !Bool !*HashTable !*File !*Files -> (!Bool,!Bool,!ParsedModule, !*HashTable, !*File, !*Files) + +moduleCouldNotBeImportedError :: !Bool !Ident !Position !*File -> *File diff --git a/frontend/parse.icl b/frontend/parse.icl index 732859e..16f4f6b 100644 --- a/frontend/parse.icl +++ b/frontend/parse.icl @@ -267,18 +267,14 @@ isGlobalOrClassOrInstanceDefsContext parseContext :== parseContext bitand (cGlob cWantIclFile :== True cWantDclFile :== False -wantModule :: !Bool !Ident !Position !Bool !*HashTable !*File !SearchPaths (ModTimeFunction *Files) !*Files +wantModule :: !*File !{#Char} !Bool !Ident !Position !Bool !*HashTable !*File !*Files -> (!Bool,!Bool,!ParsedModule, !*HashTable, !*File, !*Files) -wantModule iclmodule file_id=:{id_name} import_file_position support_generics hash_table error searchPaths modtimefunction files - = case openScanner id_name file_name_extension searchPaths modtimefunction files of - (Yes (scanState, modification_time), files) - # hash_table=set_hte_mark (if iclmodule 1 0) hash_table - # (ok,dynamic_type_used,mod,hash_table,file,files) = initModule file_name modification_time scanState hash_table error files - # hash_table=set_hte_mark 0 hash_table - -> (ok,dynamic_type_used,mod,hash_table,file,files) - (No, files) - -> let mod = { mod_ident = file_id, mod_modification_time = "", mod_type = MK_None, mod_imports = [], mod_imported_objects = [],mod_foreign_exports=[],mod_defs = [] } in - (False, False, mod, hash_table, error <<< "Error " <<< import_file_position <<< ": " <<< file_name <<< " could not be imported\n", files) +wantModule file modification_time iclmodule file_id=:{id_name} import_file_position support_generics hash_table error files + # scanState = openScanner file id_name file_name_extension + # hash_table=set_hte_mark (if iclmodule 1 0) hash_table + # (ok,dynamic_type_used,mod,hash_table,file,files) = initModule file_name modification_time scanState hash_table error files + hash_table=set_hte_mark 0 hash_table + = (ok,dynamic_type_used,mod,hash_table,file,files) where file_name = id_name +++ file_name_extension file_name_extension = if iclmodule ".icl" ".dcl" @@ -373,6 +369,13 @@ where # pState = parseError "want definitions" (Yes token) "End of file" pState pState = wantEndOfDefinition "definitions" pState = want_acc_definitions acc pState + +moduleCouldNotBeImportedError :: !Bool !Ident !Position !*File -> *File +moduleCouldNotBeImportedError iclmodule file_id=:{id_name} import_file_position error + # file_name_extension = if iclmodule ".icl" ".dcl" + file_name = id_name +++ file_name_extension + = error <<< "Error " <<< import_file_position <<< ": " <<< file_name <<< " could not be imported\n" + /* [Definition] on local and global level */ diff --git a/frontend/postparse.icl b/frontend/postparse.icl index 09de749..b1e3b7c 100644 --- a/frontend/postparse.icl +++ b/frontend/postparse.icl @@ -1035,7 +1035,14 @@ parseAndScanDclModule :: !Ident !Position ![ScannedModule] ![Ident] !SearchPaths -> *(!Bool, ![ScannedModule],!*Files, !*CollectAdmin) parseAndScanDclModule dcl_module import_file_position parsed_modules cached_modules searchPaths support_generics support_dynamics modtimefunction files ca # {ca_error, ca_hash_table} = ca - # (parse_ok,dynamic_type_used,mod, ca_hash_table, err_file, files) = wantModule cWantDclFile dcl_module import_file_position support_generics ca_hash_table ca_error.pea_file searchPaths modtimefunction files + # (opt_file_dir_time,files) = fopenInSearchPaths dcl_module.id_name ".dcl" searchPaths FReadData modtimefunction files + | case opt_file_dir_time of No -> True; _ -> False + # err_file = moduleCouldNotBeImportedError False dcl_module import_file_position ca_error.pea_file + # ca & ca_error={pea_file=err_file,pea_ok=True} + = (False, [MakeEmptyModule dcl_module MK_None: parsed_modules],files, ca) + # (Yes (mod_file,mod_dir,mod_time)) = opt_file_dir_time + # (parse_ok,dynamic_type_used,mod, ca_hash_table, err_file, files) + = wantModule mod_file mod_time cWantDclFile dcl_module import_file_position support_generics ca_hash_table ca_error.pea_file files # ca = {ca & ca_hash_table=ca_hash_table, ca_error={pea_file=err_file,pea_ok=True} } | parse_ok = scan_dcl_module dcl_module mod parsed_modules searchPaths modtimefunction files ca @@ -1125,7 +1132,14 @@ where | module_n_in_cache<>NoIndex = (True,No,module_n_in_cache,[],cached_modules,files,ca) # {ca_error, ca_hash_table} = ca - # (parse_ok,dynamic_type_used,mod, hash_table, err_file, /*predefs,*/ files) = wantModule cWantDclFile mod_ident NoPos support_generics ca_hash_table ca_error.pea_file searchPaths modtimefunction files + # (opt_file_dir_time,files) = fopenInSearchPaths mod_ident.id_name ".dcl" searchPaths FReadData modtimefunction files + | case opt_file_dir_time of No -> True; _ -> False + # err_file = moduleCouldNotBeImportedError False mod_ident NoPos ca_error.pea_file + # ca & ca_error={pea_file=err_file,pea_ok=True} + = (False, No,NoIndex, [],cached_modules, files, ca) + # (Yes (mod_file,mod_dir,mod_time)) = opt_file_dir_time + # (parse_ok,dynamic_type_used,mod, hash_table, err_file, files) + = wantModule mod_file mod_time cWantDclFile mod_ident NoPos support_generics ca_hash_table ca_error.pea_file files # ca = {ca & ca_hash_table=hash_table, ca_error={pea_file=err_file,pea_ok=True}} | not parse_ok = (False, No,NoIndex, [],cached_modules, files, ca) diff --git a/frontend/scanner.dcl b/frontend/scanner.dcl index 24e66c0..3667d05 100644 --- a/frontend/scanner.dcl +++ b/frontend/scanner.dcl @@ -148,7 +148,9 @@ instance replaceToken ScanState class getPosition state :: !*state -> (!FilePosition,!*state) // Position of current Token (or Char) instance getPosition ScanState -openScanner :: !String !String !SearchPaths (ModTimeFunction *Files) !*Files -> (!Optional (ScanState, {#Char}), !*Files) // state, file time +fopenInSearchPaths :: !{#Char} !{#Char} !SearchPaths !Int (ModTimeFunction *Files) !*Files -> (Optional (*File, {#Char}, {#Char}),!*Files) + +openScanner :: !*File !String !String -> ScanState closeScanner :: !ScanState !*Files -> *Files setUseLayout :: !Bool !ScanState -> ScanState diff --git a/frontend/scanner.icl b/frontend/scanner.icl index 6b1e550..000988e 100644 --- a/frontend/scanner.icl +++ b/frontend/scanner.icl @@ -1629,26 +1629,20 @@ where toString RightAssoc = "infixr " toString NoAssoc = "infix " -openScanner :: !String !String !SearchPaths (ModTimeFunction *Files) !*Files -> (!Optional (ScanState, {#Char}), !*Files) // state, file time -openScanner file_name file_name_extension searchPaths modtimefunction files - = case fopenInSearchPaths file_name file_name_extension searchPaths FReadData modtimefunction files of - (No, files) - -> (No, files) - (Yes (file, time), files) - -> (Yes (ScanState { ss_input = Input - { inp_stream = InFile file - , inp_filename = file_name +++ file_name_extension - , inp_pos = {fp_line = 1, fp_col = 0} - , inp_tabsize = 4 - } - , ss_offsides = [(1,False)] // to generate offsides between global definitions - , ss_scanOptions = 0 - , ss_tokenBuffer = Buffer0 - }, time) - , files - ) +openScanner :: !*File !String !String -> ScanState +openScanner file file_name file_name_extension + = ScanState { ss_input = Input + { inp_stream = InFile file + , inp_filename = file_name +++ file_name_extension + , inp_pos = {fp_line = 1, fp_col = 0} + , inp_tabsize = 4 + } + , ss_offsides = [(1,False)] // to generate offsides between global definitions + , ss_scanOptions = 0 + , ss_tokenBuffer = Buffer0 + } -fopenInSearchPaths :: !{#Char} !{#Char} !SearchPaths !Int (ModTimeFunction *f) !*f -> (Optional (*File, {#Char}),!*f) | FileSystem f +fopenInSearchPaths :: !{#Char} !{#Char} !SearchPaths !Int (ModTimeFunction *Files) !*Files -> (Optional (*File, {#Char}, {#Char}),!*Files) fopenInSearchPaths moduleName fileNameExtension searchPaths mode modtimefunction f # fileName = replace_dots_by_directory_separators moduleName +++ fileNameExtension = case [path \\ (moduleName,path)<-searchPaths.sp_locations | moduleName == fileName] of @@ -1656,25 +1650,25 @@ fopenInSearchPaths moduleName fileNameExtension searchPaths mode modtimefunction # fullFileName = path +++ fileName # (opened, file, f) = fopen fullFileName mode f | opened - -> getModificationTime file fullFileName modtimefunction f + -> getModificationTime file path fullFileName modtimefunction f -> (No, f) [] -> fopenAnywhereInSearchPaths fileName searchPaths.sp_paths mode modtimefunction f where - fopenAnywhereInSearchPaths :: !{#Char} ![{#Char}] !Int (ModTimeFunction *f) *f -> (Optional (*File, {#Char}),!*f) | FileSystem f + fopenAnywhereInSearchPaths :: !{#Char} ![{#Char}] !Int (ModTimeFunction *f) *f -> (Optional (*File, {#Char}, {#Char}),!*f) | FileSystem f fopenAnywhereInSearchPaths fileName [path : paths] mode modtimefunction f # fullFileName = path +++ fileName # (opened, file, f) = fopen fullFileName mode f | opened - = getModificationTime file fullFileName modtimefunction f + = getModificationTime file path fullFileName modtimefunction f = fopenAnywhereInSearchPaths fileName paths mode modtimefunction f fopenAnywhereInSearchPaths fileName [] _ _ f = (No, f) - getModificationTime :: *File {#Char} (ModTimeFunction *f) *f -> (Optional (*File, {#Char}),!*f) | FileSystem f - getModificationTime file fullFileName modtimefunction f + getModificationTime :: *File {#Char} {#Char} (ModTimeFunction *f) *f -> (Optional (*File, {#Char}, {#Char}),!*f) | FileSystem f + getModificationTime file path fullFileName modtimefunction f # (time, f) = modtimefunction fullFileName f - = (Yes (file, time), f) + = (Yes (file, path, time), f) replace_dots_by_directory_separators :: !{#Char} -> *{#Char} replace_dots_by_directory_separators file_name |