Most importantly: Case operators should not be inlined indiscriminately, because that might duplicate work (e.g. via a variable pattern for the scrutinee, where the variable is used more than once)
Unified · Split
| @@ -237,7 +237,10 @@ schConstant : (String -> String) -> Constant -> String · 236 unmodified lines | |||
| 237 | schConstant _ (I x) = show x | 237 | schConstant _ (I x) = show x |
| 238 | schConstant _ (BI x) = show x | 238 | schConstant _ (BI x) = show x |
| 239 | schConstant schString (Str x) = schString x | 239 | schConstant schString (Str x) = schString x |
| 240 | schConstant _ (Ch x) = "#\\" ++ cast x | 240 | schConstant _ (Ch x) |
| 241 | = if (the Int (cast x) >= 32 && the Int (cast x) < 127) | ||
| 242 | then "#\\" ++ cast x | ||
| 243 | else "(integer->char " ++ show (the Int (cast x)) ++ ")" | ||
| 241 | schConstant _ (Db x) = show x | 244 | schConstant _ (Db x) = show x |
| 242 | schConstant _ WorldVal = "#f" | 245 | schConstant _ WorldVal = "#f" |
| 243 | schConstant _ IntType = "#t" | 246 | schConstant _ IntType = "#t" |
| @@ -202,7 +202,6 @@ caseBlock {vars} rigc elabinfo fc nest env scr scrtm scrty caseRig alts expected · 201 unmodified lines | |||
| 202 | = maybe (App fc applyEnv scrtm) | 202 | = maybe (App fc applyEnv scrtm) |
| 203 | (const applyEnv) | 203 | (const applyEnv) |
| 204 | splitOn | 204 | splitOn |
| 205 | setFlag fc casen Inline | ||
| 206 | 205 | ||
| 207 | let alts' = map (updateClause casen splitOn nest env) alts | 206 | let alts' = map (updateClause casen splitOn nest env) alts |
| 208 | log 2 $ "Generated alts: " ++ show alts' | 207 | log 2 $ "Generated alts: " ++ show alts' |
| @@ -31,7 +31,7 @@ data Grammar : (tok : Type) -> (consumes : Bool) -> Type -> Type where · 30 unmodified lines | |||
| 31 | Grammar tok c1 a -> (a -> Grammar tok c2 b) -> | 31 | Grammar tok c1 a -> (a -> Grammar tok c2 b) -> |
| 32 | Grammar tok (c1 || c2) b | 32 | Grammar tok (c1 || c2) b |
| 33 | Alt : {c1, c2 : Bool} -> | 33 | Alt : {c1, c2 : Bool} -> |
| 34 | Grammar tok c1 ty -> Grammar tok c2 ty -> | 34 | Grammar tok c1 ty -> Lazy (Grammar tok c2 ty) -> |
| 35 | Grammar tok (c1 && c2) ty | 35 | Grammar tok (c1 && c2) ty |
| 36 | 36 | ||
| 37 | ||| Sequence two grammars. If either consumes some input, the sequence is | 37 | ||| Sequence two grammars. If either consumes some input, the sequence is |
| @@ -69,7 +69,7 @@ join {c1 = True} p = SeqEat p id · 31 unmodified lines | |||
| 69 | export | 69 | export |
| 70 | (<|>) : {c1,c2 : Bool} -> | 70 | (<|>) : {c1,c2 : Bool} -> |
| 71 | Grammar tok c1 ty -> | 71 | Grammar tok c1 ty -> |
| 72 | Grammar tok c2 ty -> | 72 | Lazy (Grammar tok c2 ty) -> |
| 73 | Grammar tok (c1 && c2) ty | 73 | Grammar tok (c1 && c2) ty |
| 74 | (<|>) = Alt | 74 | (<|>) = Alt |
| 75 | 75 | ||