Commit b7c46275 authored by nx's avatar nx
Browse files

[project @ 2005-06-28 23:39:51 by nx]

check_rctx has arity 8
parent 3f7fb6a2
...@@ -237,7 +237,7 @@ alexScan = do ...@@ -237,7 +237,7 @@ alexScan = do
alex_scan_tkn lc len (-1#) last_acc = return last_acc alex_scan_tkn lc len (-1#) last_acc = return last_acc
alex_scan_tkn lc len s last_acc = do alex_scan_tkn lc len s last_acc = do
new_acc <- check_accs s new_acc <- check_accs s lc len last_acc --danaxu extends arguments
c <- alexGetChar c <- alexGetChar
let {-# INLINE [0] join #-} let {-# INLINE [0] join #-}
-- This is a *hack*, the compiler doesn't eliminate the Maybe return -- This is a *hack*, the compiler doesn't eliminate the Maybe return
...@@ -262,29 +262,29 @@ alex_scan_tkn lc len s last_acc = do ...@@ -262,29 +262,29 @@ alex_scan_tkn lc len s last_acc = do
case c of case c of
Nothing -> return new_acc -- end of input Nothing -> return new_acc -- end of input
Just c' -> join c' Just c' -> join c'
where -- where
-- OPTIMISATION PROBLEM. We need to eta-expand -- OPTIMISATION PROBLEM. We need to eta-expand
-- check_accs and check_accs1. This needs a simple -- check_accs and check_accs1. This needs a simple
-- one-shot analysis of some kind, but note that -- one-shot analysis of some kind, but note that
-- check_accs1 is recursive. -- check_accs1 is recursive.
check_accs s = check_accs1 (alex_accept `unsafeAt` (I# (s))) check_accs s lc len last_acc = check_accs1 (alex_accept `unsafeAt` (I# (s))) lc len last_acc
check_accs1 accs = check_accs1 accs lc len last_acc =
case accs of case accs of
[] -> return last_acc [] -> return last_acc
(AlexAcc _ a lctx rctx : rest) -> (AlexAcc _ a lctx rctx : rest) ->
case lctx of case lctx of
Nothing -> check_rctx Nothing -> check_rctx a rctx rest lc len last_acc
Just arr | arr!lc -> check_rctx Just arr | arr!lc -> check_rctx a rctx rest lc len last_acc
| otherwise -> check_accs1 rest | otherwise -> check_accs1 rest lc len last_acc
where -- where
ok = do inp <- alexGetInput ok a len = do inp <- alexGetInput
return (AlexLastAcc a inp (I# (len))) return (AlexLastAcc a inp (I# (len)))
check_rctx = check_rctx a rctx rest lc len last_acc =
case rctx of case rctx of
Nothing -> ok Nothing -> ok a len
Just (I# (sn)) -> do Just (I# (sn)) -> do
inp <- alexGetInput inp <- alexGetInput
let c = alexInputPrevChar inp let c = alexInputPrevChar inp
...@@ -292,8 +292,8 @@ alex_scan_tkn lc len s last_acc = do ...@@ -292,8 +292,8 @@ alex_scan_tkn lc len s last_acc = do
acc <- alex_scan_tkn c 0# sn AlexNone acc <- alex_scan_tkn c 0# sn AlexNone
alexSetInput inp alexSetInput inp
case acc of case acc of
AlexNone -> check_accs1 rest AlexNone -> check_accs1 rest lc len last_acc
AlexLastAcc{} -> ok AlexLastAcc{} -> ok a len
-- TODO: there's no need to find the longest -- TODO: there's no need to find the longest
-- match when checking the right context, just -- match when checking the right context, just
-- the first match will do. -- the first match will do.
......
...@@ -3,4 +3,8 @@ module F1 where ...@@ -3,4 +3,8 @@ module F1 where
f1 = let h1 n x = if x<n then let v = h1 n (x+1) f1 = let h1 n x = if x<n then let v = h1 n (x+1)
in \y -> v (x+y) in \y -> v (x+y)
else \y -> y else \y -> y
in h1 5 1 5 in h1 5 1 5
\ No newline at end of file
g = \x1-> \x2-> \x3-> \x4-> \x5-> x1+x2+x3+x4+x5
s f = f 3
h = s g 6 7 8
\ No newline at end of file
Markdown is supported
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