diff options
-rw-r--r-- | frontend/check.icl | 8 | ||||
-rw-r--r-- | frontend/explicitimports.icl | 12 | ||||
-rw-r--r-- | frontend/parse.icl | 35 | ||||
-rw-r--r-- | frontend/syntax.dcl | 17 | ||||
-rw-r--r-- | frontend/syntax.icl | 4 |
5 files changed, 30 insertions, 46 deletions
diff --git a/frontend/check.icl b/frontend/check.icl index 4bfade5..c32e805 100644 --- a/frontend/check.icl +++ b/frontend/check.icl @@ -1863,10 +1863,10 @@ checkDclModules imports_of_icl_mod dcl_modules icl_functions macro_defs heaps cs = get_symbol imp_decl (get_ident imp_decl) state where get_ident :: !ImportDeclaration -> Ident - get_ident (ID_Function {ii_ident}) = ii_ident - get_ident (ID_Class {ii_ident} _) = ii_ident - get_ident (ID_Type {ii_ident} _) = ii_ident - get_ident (ID_Record {ii_ident} _) = ii_ident + get_ident (ID_Function ii_ident) = ii_ident + get_ident (ID_Class ii_ident _) = ii_ident + get_ident (ID_Type ii_ident _) = ii_ident + get_ident (ID_Record ii_ident _) = ii_ident get_ident (ID_Instance class_ident instance_ident _) = instance_ident get_symbol :: ImportDeclaration !Ident !*([Ident],Int,[ImportNrAndIdents],*(Heap SymbolTableEntry)) -> ([Ident],Int,[ImportNrAndIdents],.(Heap SymbolTableEntry)) diff --git a/frontend/explicitimports.icl b/frontend/explicitimports.icl index 8670490..5efb402 100644 --- a/frontend/explicitimports.icl +++ b/frontend/explicitimports.icl @@ -103,7 +103,7 @@ imp_decl_to_string (ID_OldSyntax idents) = "ID_OldSyntax "+++idents_to_string id idents_to_string [{id_name}:l] = toString id_name+++","+++idents_to_string l */ -getBelongingSymbolsFromID :: !ImportDeclaration -> Optional [ImportedIdent] +getBelongingSymbolsFromID :: !ImportDeclaration -> Optional [Ident] getBelongingSymbolsFromID (ID_Class _ x) = x getBelongingSymbolsFromID (ID_Type _ x) = x getBelongingSymbolsFromID (ID_Record _ x) = x @@ -265,7 +265,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod new_ste = { ste & ste_kind = STE_BelongingSymbol i, ste_previous = ste } = (i+1, writePtr id_info new_ste cs_symbol_table) - get_opt_nr_and_ident position eii_ident {ii_ident=ii_ident=:{id_info}} (cs_error, cs_symbol_table) + get_opt_nr_and_ident position eii_ident ii_ident=:{id_info} (cs_error, cs_symbol_table) # ({ste_kind}, cs_symbol_table) = readPtr id_info cs_symbol_table = case ste_kind of STE_BelongingSymbol i @@ -374,7 +374,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod eii_declaring_modules visited_modules = (No, [], eii_declaring_modules, visited_modules) - search_imported_symbol :: !Int ![ImportNrAndIdents] -> (!Bool, !Optional [ImportedIdent]) + search_imported_symbol :: !Int ![ImportNrAndIdents] -> (!Bool, !Optional [Ident]) search_imported_symbol imported_symbol [] = (False, No) search_imported_symbol imported_symbol [{ini_symbol_nr, ini_imp_decl}:t] @@ -382,7 +382,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod = (True, getBelongingSymbolsFromID ini_imp_decl) = search_imported_symbol imported_symbol t - belong_ident_found :: !Ident !(Optional [ImportedIdent]) -> Bool + belong_ident_found :: !Ident !(Optional [Ident]) -> Bool belong_ident_found belong_ident No // like from m import ::T = False @@ -393,10 +393,10 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod // like from m import ::T(C1,C2) = is_member belong_ident import_list - is_member :: !Ident ![ImportedIdent] -> Bool + is_member :: !Ident ![Ident] -> Bool is_member belong_ident [] = False - is_member belong_ident [{ii_ident}:t] + is_member belong_ident [ii_ident:t] | belong_ident==ii_ident = True = is_member belong_ident t diff --git a/frontend/parse.icl b/frontend/parse.icl index 17650b4..a3ca6d8 100644 --- a/frontend/parse.icl +++ b/frontend/parse.icl @@ -1145,22 +1145,22 @@ wantImportDeclarationT token pState DoubleColonToken # (name, pState) = wantConstructorName "import type" pState (type_id, pState) = stringToIdent name IC_Type pState - (ii_extended, token, pState) = optional_extension_with_next_token pState + (token, pState) = nextToken FunctionContext pState | token == OpenToken # (conses, pState) = want_names (wantConstructorName "import type (..)") IC_Expression CloseToken pState - -> (ID_Type { ii_ident = type_id, ii_extended = ii_extended } (Yes conses), pState) + -> (ID_Type type_id (Yes conses), pState) | token == CurlyOpenToken # (fields, pState) = want_names (wantLowerCaseName "import record fields") (IC_Field type_id) CurlyCloseToken pState - -> (ID_Record { ii_ident = type_id, ii_extended = ii_extended } (Yes fields), pState) - -> (ID_Type { ii_ident = type_id, ii_extended = ii_extended } No, tokenBack pState) + -> (ID_Record type_id (Yes fields), pState) + -> (ID_Type type_id No, tokenBack pState) ClassToken # (name, pState) = want pState (class_id, pState) = stringToIdent name IC_Class pState - (ii_extended, token, pState) = optional_extension_with_next_token pState + (token, pState) = nextToken FunctionContext pState | token == OpenToken # (members, pState) = want_names want IC_Expression CloseToken pState - -> (ID_Class { ii_ident = class_id, ii_extended = ii_extended } (Yes members), pState) - -> (ID_Class { ii_ident = class_id, ii_extended = ii_extended } No, tokenBack pState) + -> (ID_Class class_id (Yes members), pState) + -> (ID_Class class_id No, tokenBack pState) InstanceToken # (class_name, pState) = want pState // (ii_extended, pState) = optional_extension pState // MW: removed but still not ok @@ -1169,14 +1169,14 @@ wantImportDeclarationT token pState (class_id, pState) = stringToIdent class_name IC_Class pState (inst_id, pState) = stringToIdent class_name (IC_Instance types) pState (context, pState) = optionalContext pState - -> (ID_Instance { ii_ident = class_id, ii_extended = ii_extended } inst_id (types,context), pState) + -> (ID_Instance class_id inst_id (types,context), pState) IdentToken fun_name # (fun_id, pState) = stringToIdent fun_name IC_Expression pState (ii_extended, pState) = optional_extension pState - -> (ID_Function { ii_ident = fun_id, ii_extended = ii_extended }, pState) + -> (ID_Function fun_id, pState) token # (fun_id, pState) = stringToIdent "dummy" IC_Expression pState - -> ( ID_Function { ii_ident = fun_id, ii_extended = False } + -> ( ID_Function fun_id , parseError "from import" (Yes token) "imported item" pState ) where @@ -1189,26 +1189,19 @@ where want_list_of_names want_fun ident_kind close_token pState # (name, pState) = want_fun pState (name_id, pState) = stringToIdent name ident_kind pState - (ii_extended, token, pState) = optional_extension_with_next_token pState + (token, pState) = nextToken FunctionContext pState | token == CommaToken # (names, pState) = want_list_of_names want_fun ident_kind close_token pState - = ([{ ii_ident = name_id, ii_extended = ii_extended } : names], pState) + = ([name_id : names], pState) | token == close_token - = ([{ ii_ident = name_id, ii_extended = ii_extended }], pState) - = ([{ ii_ident = name_id, ii_extended = ii_extended }], parseError "ImportDeclaration" (Yes token) ")" pState) + = ([name_id], pState) + = ([name_id], parseError "ImportDeclaration" (Yes token) ")" pState) optional_extension pState # (token, pState) = nextToken FunctionContext pState | token == DotDotToken = (True, pState) = (False, tokenBack pState) - - optional_extension_with_next_token pState - # (token, pState) = nextToken FunctionContext pState - | token == DotDotToken - # (token, pState) = nextToken FunctionContext pState - = (True, token, pState) - = (False, token, pState) /* Classes and instances diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl index 331ef76..34001ad 100644 --- a/frontend/syntax.dcl +++ b/frontend/syntax.dcl @@ -455,16 +455,11 @@ instance toString (Import from_symbol), AttributeVar, TypeAttribute, Annotation :: ParsedImport :== Import ImportDeclaration -:: ImportedIdent = - { ii_ident :: !Ident - , ii_extended :: !Bool - } - -:: ImportDeclaration = ID_Function !ImportedIdent - | ID_Class !ImportedIdent !(Optional [ImportedIdent]) - | ID_Type !ImportedIdent !(Optional [ImportedIdent]) - | ID_Record !ImportedIdent !(Optional [ImportedIdent]) - | ID_Instance !ImportedIdent !Ident !(![Type],![TypeContext]) +:: ImportDeclaration = ID_Function !Ident + | ID_Class !Ident !(Optional [Ident]) + | ID_Type !Ident !(Optional [Ident]) + | ID_Record !Ident !(Optional [Ident]) + | ID_Instance !Ident !Ident !(![Type],![TypeContext]) cIsImportedLibrary :== True cIsImportedObject :== False @@ -1423,7 +1418,7 @@ instance == ModuleKind, Ident instance <<< (Module a) | <<< a, ParsedDefinition, InstanceType, AttributeVar, TypeVar, SymbolType, Expression, Type, Ident, (Global object) | <<< object, Position, CaseAlt, AType, FunDef, ParsedExpr, TypeAttribute, (Bind a b) | <<< a & <<< b, FieldNameOrQualifiedFieldName, ParsedConstructor, (TypeDef a) | <<< a, TypeVarInfo, AttrVarInfo, - BasicValue, ATypeVar, TypeRhs, (Import from_symbol) | <<< from_symbol, ImportDeclaration, ImportedIdent, CasePatterns, + BasicValue, ATypeVar, TypeRhs, (Import from_symbol) | <<< from_symbol, ImportDeclaration, CasePatterns, (Optional a) | <<< a, ConsVariable, BasicType, Annotation, SelectorKind, Selection, SelectorDef, ConsDef, LocalDefs, FreeVar, ClassInstance, SignClassification, TypeCodeExpression, CoercionPosition, AttrInequality, LetBind, Declaration, STE_Kind, BoundVar, TypeSymbIdent, diff --git a/frontend/syntax.icl b/frontend/syntax.icl index 102b743..7093137 100644 --- a/frontend/syntax.icl +++ b/frontend/syntax.icl @@ -962,10 +962,6 @@ readable {id_name} = id_name%(1, size id_name-1) = id_name -instance <<< ImportedIdent -where - (<<<) file {ii_ident, ii_extended} = file <<< ii_ident <<< ' ' <<< ii_extended - instance == ModuleKind where (==) mk1 mk2 = equal_constructor mk1 mk2 |