Commit f47d0617 authored by John van Groningen's avatar John van Groningen
Browse files

optimize array comprehensions,

optimize dot dot generators,
fixed bug in array comprehensions with more than one qualifier,
removed 'c' before 'cIsListGenerator' and 'cIsArrayGenerator'
parent b2d03b17
......@@ -2187,7 +2187,7 @@ where
| is_pattern
-> (PE_Empty, parseError "want list expression" No "No \\\\ expression in a pattern" pState)
| length acc == 1
-> wantComprehension cIsListGenerator (acc!!0) pState
-> wantComprehension IsListGenerator (acc!!0) pState
// otherwise // length acc <> 1
# (nil_expr, pState) = makeNilExpression pState
pState = parseError "list comprehension" No "one expressions before \\\\" pState
......@@ -2220,9 +2220,9 @@ where
wantComprehension :: !GeneratorKind !ParsedExpr !ParseState -> (!ParsedExpr, !ParseState)
wantComprehension gen_kind exp pState
# (qualifiers, pState) = wantQualifiers pState
| gen_kind == cIsListGenerator
= (PE_Compr cIsListGenerator exp qualifiers, wantToken FunctionContext "list comprehension" SquareCloseToken pState)
= (PE_Compr cIsArrayGenerator exp qualifiers, wantToken FunctionContext "array comprehension" CurlyCloseToken pState)
| gen_kind == IsListGenerator
= (PE_Compr IsListGenerator exp qualifiers, wantToken FunctionContext "list comprehension" SquareCloseToken pState)
= (PE_Compr IsArrayGenerator exp qualifiers, wantToken FunctionContext "array comprehension" CurlyCloseToken pState)
wantQualifiers :: !ParseState -> (![Qualifier], !ParseState)
wantQualifiers pState
......@@ -2240,11 +2240,9 @@ where
(lhs_expr, pState) = wantExpression cIsAPattern pState
(token, pState) = nextToken FunctionContext pState
| token == LeftArrowToken
//MW3 was: = want_generators cIsListGenerator (toLineAndColumn qual_position) lhs_expr pState
= want_generators cIsListGenerator (toLineAndColumn qual_position) qual_filename lhs_expr pState
= want_generators IsListGenerator (toLineAndColumn qual_position) qual_filename lhs_expr pState
| token == LeftArrowColonToken
//MW3 was: = want_generators cIsArrayGenerator (toLineAndColumn qual_position) lhs_expr pState
= want_generators cIsArrayGenerator (toLineAndColumn qual_position) qual_filename lhs_expr pState
= want_generators IsArrayGenerator (toLineAndColumn qual_position) qual_filename lhs_expr pState
= ({qual_generators = [], qual_filter = No, qual_position = {lc_line = 0, lc_column = 0}, qual_filename = "" },
parseError "comprehension: qualifier" (Yes token) "qualifier(s)" pState)
......@@ -2388,7 +2386,7 @@ wantRecordOrArrayExp is_pattern pState
# (token, pState) = nextToken FunctionContext pState
-> want_record_or_array_update token expr pState
| token == DoubleBackSlashToken
-> wantComprehension cIsArrayGenerator expr pState
-> wantComprehension IsArrayGenerator expr pState
# (elems, pState) = want_array_elems token pState
-> (PE_ArrayDenot [expr : elems], pState)
where
......
This diff is collapsed.
......@@ -69,65 +69,65 @@ PD_UnqArraySizeFun :== 119
/* Enum/Comprehension functions */
PD_SmallerFun :== 120
PD_IncFun :== 121
PD_From :== 122
PD_FromThen :== 123
PD_FromTo :== 124
PD_FromThenTo :== 125
PD_LessOrEqualFun:==121
PD_SubFun:==122
PD_IncFun :== 123
PD_From :== 124
PD_FromThen :== 125
PD_FromTo :== 126
PD_FromThenTo :== 127
/* Dynamics */
PD_TypeCodeClass :== 126
PD_TypeCodeClass :== 128
PD_TypeObjectType :== 127
PD_TypeConsSymbol :== 128
PD_unify :== 129
PD_TypeObjectType :== 129
PD_TypeConsSymbol :== 130
PD_unify :== 131
// MV ..
PD_coerce :== 130
PD_variablePlaceholder :== 131
PD_StdDynamics :== 132
PD_undo_indirections :== 133
PD_coerce :== 132
PD_variablePlaceholder :== 133
PD_StdDynamics :== 134
PD_undo_indirections :== 135
/* Generics */
PD_StdGeneric :== 134
PD_TypeISO :== 135
PD_ConsISO :== 136
PD_iso_to :== 137
PD_iso_from :== 138
PD_TypeUNIT :== 139
PD_ConsUNIT :== 140
PD_TypeEITHER :== 141
PD_ConsLEFT :== 142
PD_ConsRIGHT :== 143
PD_TypePAIR :== 144
PD_ConsPAIR :== 145
PD_TypeARROW :== 146
PD_ConsARROW :== 147
PD_TypeConsDefInfo :== 148
PD_ConsConsDefInfo :== 149
PD_TypeTypeDefInfo :== 150
PD_ConsTypeDefInfo :== 151
PD_cons_info :== 152
PD_TypeCONS :== 153
PD_ConsCONS :== 154
PD_isomap_ARROW_ :== 155
PD_isomap_ID :== 156
PD_StdGeneric :== 136
PD_TypeISO :== 137
PD_ConsISO :== 138
PD_iso_to :== 139
PD_iso_from :== 140
PD_TypeUNIT :== 141
PD_ConsUNIT :== 142
PD_TypeEITHER :== 143
PD_ConsLEFT :== 144
PD_ConsRIGHT :== 145
PD_TypePAIR :== 146
PD_ConsPAIR :== 147
PD_TypeARROW :== 148
PD_ConsARROW :== 149
PD_TypeConsDefInfo :== 150
PD_ConsConsDefInfo :== 151
PD_TypeTypeDefInfo :== 152
PD_ConsTypeDefInfo :== 153
PD_cons_info :== 154
PD_TypeCONS :== 155
PD_ConsCONS :== 156
PD_isomap_ARROW_ :== 157
PD_isomap_ID :== 158
/* StdMisc */
PD_StdMisc :== 157
PD_abort :== 158
PD_undef :== 159
PD_StdMisc :== 159
PD_abort :== 160
PD_undef :== 161
PD_Start :== 160
PD_Start :== 162
// MW..
PD_DummyForStrictAliasFun :== 161
PD_DummyForStrictAliasFun :== 163
PD_NrOfPredefSymbols :== 162
// ..MW
PD_NrOfPredefSymbols :== 164
GetTupleConsIndex tup_arity :== PD_Arity2TupleSymbol + tup_arity - 2
GetTupleTypeIndex tup_arity :== PD_Arity2TupleType + tup_arity - 2
......
......@@ -67,67 +67,65 @@ PD_UnqArraySizeFun :== 119
/* Enum/Comprehension functions */
PD_SmallerFun :== 120
PD_IncFun :== 121
PD_From :== 122
PD_FromThen :== 123
PD_FromTo :== 124
PD_FromThenTo :== 125
PD_LessOrEqualFun:== 121
PD_SubFun:==122
PD_IncFun :== 123
PD_From :== 124
PD_FromThen :== 125
PD_FromTo :== 126
PD_FromThenTo :== 127
/* Dynamics */
PD_TypeCodeClass :== 126
PD_TypeCodeClass :== 128
PD_TypeObjectType :== 127
PD_TypeConsSymbol :== 128
PD_unify :== 129
PD_TypeObjectType :== 129
PD_TypeConsSymbol :== 130
PD_unify :== 131
// MV ..
PD_coerce :== 130
PD_variablePlaceholder :== 131
PD_StdDynamics :== 132
PD_undo_indirections :== 133
PD_coerce :== 132
PD_variablePlaceholder :== 133
PD_StdDynamics :== 134
PD_undo_indirections :== 135
/* Generics */
PD_StdGeneric :== 134
PD_TypeISO :== 135
PD_ConsISO :== 136
PD_iso_to :== 137
PD_iso_from :== 138
PD_TypeUNIT :== 139
PD_ConsUNIT :== 140
PD_TypeEITHER :== 141
PD_ConsLEFT :== 142
PD_ConsRIGHT :== 143
PD_TypePAIR :== 144
PD_ConsPAIR :== 145
PD_TypeARROW :== 146
PD_ConsARROW :== 147
PD_TypeConsDefInfo :== 148
PD_ConsConsDefInfo :== 149
PD_TypeTypeDefInfo :== 150
PD_ConsTypeDefInfo :== 151
PD_cons_info :== 152
PD_TypeCONS :== 153
PD_ConsCONS :== 154
PD_isomap_ARROW_ :== 155
PD_isomap_ID :== 156
PD_StdGeneric :== 136
PD_TypeISO :== 137
PD_ConsISO :== 138
PD_iso_to :== 139
PD_iso_from :== 140
PD_TypeUNIT :== 141
PD_ConsUNIT :== 142
PD_TypeEITHER :== 143
PD_ConsLEFT :== 144
PD_ConsRIGHT :== 145
PD_TypePAIR :== 146
PD_ConsPAIR :== 147
PD_TypeARROW :== 148
PD_ConsARROW :== 149
PD_TypeConsDefInfo :== 150
PD_ConsConsDefInfo :== 151
PD_TypeTypeDefInfo :== 152
PD_ConsTypeDefInfo :== 153
PD_cons_info :== 154
PD_TypeCONS :== 155
PD_ConsCONS :== 156
PD_isomap_ARROW_ :== 157
PD_isomap_ID :== 158
/* StdMisc */
PD_StdMisc :== 157
PD_abort :== 158
PD_undef :== 159
PD_StdMisc :== 159
PD_abort :== 160
PD_undef :== 161
PD_Start :== 160
// MW..
PD_DummyForStrictAliasFun :== 161
PD_NrOfPredefSymbols :== 162
// ..MW
PD_Start :== 162
PD_DummyForStrictAliasFun :== 163
PD_NrOfPredefSymbols :== 164
(<<=) infixl
(<<=) state val
......@@ -185,8 +183,9 @@ where
<<- ("uselect", IC_Expression, PD_UnqArraySelectFun) <<- ("update", IC_Expression, PD_ArrayUpdateFun)
<<- ("replace", IC_Expression, PD_ArrayReplaceFun) <<- ("size", IC_Expression, PD_ArraySizeFun)
<<- ("usize", IC_Expression, PD_UnqArraySizeFun)
// RWS ... <<- ("_smaller", IC_Expression, PD_SmallerFun) <<- ("_inc", IC_Expression, PD_IncFun)
<<- ("<", IC_Expression, PD_SmallerFun) <<- ("inc", IC_Expression, PD_IncFun)
// RWS ... <<- ("_smaller", IC_Expression, PD_SmallerFun) <<- ("_inc", IC_Expression, PD_IncFun)
<<- ("<", IC_Expression, PD_SmallerFun) <<- ("<=", IC_Expression, PD_LessOrEqualFun)
<<- ("-", IC_Expression, PD_SubFun) <<- ("inc", IC_Expression, PD_IncFun)
// ... RWS
<<- ("_from", IC_Expression, PD_From) <<- ("_from_then", IC_Expression, PD_FromThen)
<<- ("_from_to", IC_Expression, PD_FromTo) <<- ("_from_then_to", IC_Expression, PD_FromThenTo)
......
......@@ -1021,8 +1021,8 @@ cNonUniqueSelection :== False
:: GeneratorKind :== Bool
cIsListGenerator :== True
cIsArrayGenerator :== False
IsListGenerator :== True
IsArrayGenerator :== False
:: LineAndColumn = {lc_line :: !Int, lc_column :: !Int}
......
......@@ -995,8 +995,8 @@ cNonUniqueSelection :== False
:: GeneratorKind :== Bool
cIsListGenerator :== True
cIsArrayGenerator :== False
IsListGenerator :== True
IsArrayGenerator :== False
:: LineAndColumn = {lc_line :: !Int, lc_column :: !Int}
......
Supports Markdown
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