From cdaf1888c015f08c107627b7c755bc6a53e08858 Mon Sep 17 00:00:00 2001 From: johnvg Date: Fri, 31 Aug 2001 10:42:33 +0000 Subject: added ArrayAndListInstances,OverloadedListPatterns and OverloadedListType replaced PE_Compr by PE_ListCompr and PE_ArrayCompr git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@703 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- frontend/syntax.dcl | 29 +++++++++++++++------ frontend/syntax.icl | 74 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 72 insertions(+), 31 deletions(-) diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl index dfc980d..a439b05 100644 --- a/frontend/syntax.dcl +++ b/frontend/syntax.dcl @@ -113,6 +113,13 @@ instance toString Ident :: IndexRange = { ir_from :: !Index, ir_to :: !Index } +:: ArrayAndListInstances = { + ali_array_first_instance_indices :: ![Int], + ali_list_first_instance_indices :: ![Int], + ali_tail_strict_list_first_instance_indices :: ![Int], + ali_instances_range :: !IndexRange + } + :: Index :== Int NoIndex :== -1 @@ -541,7 +548,6 @@ cIsALocalVar :== False | VI_Labelled_Empty {#Char} // RWS debugging | VI_LocalLetVar // RWS, mark Let vars during case transformation - :: ExtendedVarInfo = EVI_VarType !AType :: ArgumentPosition :== Int @@ -686,8 +692,7 @@ cNonRecursiveAppl :== False | EI_Attribute !Int - - /* EI_DictionaryType is used to store the instance type of a class. This type are used during fusion to generate proper types for + /* EI_DictionaryType is used to store the instance type of a class. This type is used during fusion to generate proper types for the fusion result (i.e. the resulting function after elimination of dictionaries) */ | EI_DictionaryType !Type @@ -1010,7 +1015,8 @@ cNonUniqueSelection :== False | PE_Case !Ident !ParsedExpr [CaseAlt] | PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr | PE_Let !Bool !LocalDefs !ParsedExpr - | PE_Compr !GeneratorKind !ParsedExpr ![Qualifier] + | PE_ListCompr /*predef_cons_index:*/ !Int /*predef_nil_index:*/ !Int !ParsedExpr ![Qualifier] + | PE_ArrayCompr !ParsedExpr ![Qualifier] | PE_Sequ Sequence | PE_WildCard | PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */ @@ -1165,10 +1171,17 @@ cIsNotStrict :== False , dyn_type_code :: !TypeCodeExpression /* filled after type checking */ } -:: CasePatterns = AlgebraicPatterns !(Global Index) ![AlgebraicPattern] - | BasicPatterns !BasicType [BasicPattern] - | DynamicPatterns [DynamicPattern] /* auxiliary */ - | NoPattern /* auxiliary */ +:: CasePatterns= AlgebraicPatterns !(Global Index) ![AlgebraicPattern] + | BasicPatterns !BasicType [BasicPattern] + | DynamicPatterns [DynamicPattern] /* auxiliary */ + | OverloadedListPatterns !OverloadedListType !Expression ![AlgebraicPattern] + | NoPattern /* auxiliary */ + +:: OverloadedListType = UnboxedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_u index, nil_u index + | UnboxedTailStrictList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_uts index, nil_uts index + | OverloadedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons index, nil index + +instance == OverloadedListType :: Selection = RecordSelection !(Global DefinedSymbol) !Int | ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression diff --git a/frontend/syntax.icl b/frontend/syntax.icl index cc7bd47..8f94015 100644 --- a/frontend/syntax.icl +++ b/frontend/syntax.icl @@ -111,6 +111,13 @@ where toString {import_module} = toString import_module :: IndexRange = { ir_from :: !Index, ir_to :: !Index } +:: ArrayAndListInstances = { + ali_array_first_instance_indices :: ![Int], + ali_list_first_instance_indices :: ![Int], + ali_tail_strict_list_first_instance_indices :: ![Int], + ali_instances_range :: !IndexRange + } + :: Index :== Int NoIndex :== -1 @@ -526,7 +533,6 @@ cIsALocalVar :== False | VI_Labelled_Empty {#Char} // RWS debugging | VI_LocalLetVar // RWS, mark Let vars during case transformation - :: ExtendedVarInfo = EVI_VarType !AType :: ArgumentPosition :== Int @@ -985,7 +991,8 @@ cNonUniqueSelection :== False | PE_Case !Ident !ParsedExpr [CaseAlt] | PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr | PE_Let !Bool !LocalDefs !ParsedExpr - | PE_Compr !GeneratorKind !ParsedExpr ![Qualifier] + | PE_ListCompr /*predef_cons_index:*/ !Int /*predef_nil_index:*/ !Int !ParsedExpr ![Qualifier] + | PE_ArrayCompr !ParsedExpr ![Qualifier] | PE_Sequ Sequence | PE_WildCard | PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */ @@ -1114,10 +1121,15 @@ cIsNotStrict :== False , dyn_type_code :: !TypeCodeExpression /* filled after type checking */ } -:: CasePatterns = AlgebraicPatterns !(Global Index) ![AlgebraicPattern] - | BasicPatterns !BasicType [BasicPattern] - | DynamicPatterns [DynamicPattern] /* auxiliary */ - | NoPattern /* auxiliary */ +:: CasePatterns= AlgebraicPatterns !(Global Index) ![AlgebraicPattern] + | BasicPatterns !BasicType [BasicPattern] + | DynamicPatterns [DynamicPattern] /* auxiliary */ + | OverloadedListPatterns !OverloadedListType !Expression ![AlgebraicPattern] + | NoPattern /* auxiliary */ + +:: OverloadedListType = UnboxedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_u index, nil_u index + | UnboxedTailStrictList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_uts index, nil_uts index + | OverloadedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons index, nil index :: Selection = RecordSelection !(Global DefinedSymbol) !Int | ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression @@ -1458,6 +1470,7 @@ where (<<<) file (BasicPatterns type patterns) = file <<< " " << String // somewhat hacky readable {id_name} - | id_name=="_cons" || id_name=="_nil" - = "list constructor" | size id_name>0 && id_name.[0]=='_' - = id_name%(1, size id_name-1) + | id_name=="_Cons" || id_name=="_Nil" + = "list constructor" + | id_name=="_!Cons" || id_name=="_!Nil" + = "! list constructor" + | id_name=="_#Cons" || id_name=="_#Nil" + = "# list constructor" + | id_name=="_Cons!" || id_name=="_Nil!" + = "list constructor !" + | id_name=="_!Cons!" || id_name=="_!Nil!" + = "! list constructor !" + | id_name=="_#Cons!" || id_name=="_#Nil!" + = "# list constructor !" + = id_name%(1, size id_name-1) = id_name instance <<< ImportedIdent @@ -2071,6 +2095,10 @@ instance == Annotation where (==) a1 a2 = equal_constructor a1 a2 +instance == OverloadedListType +where + (==) a1 a2 = equal_constructor a1 a2 + EmptySymbolTableEntry :== EmptySymbolTableEntryCAF.boxed_symbol_table_entry ::BoxedSymbolTableEntry = {boxed_symbol_table_entry::!SymbolTableEntry} -- cgit v1.2.3