on master help sign in
Merge pull request #2 from michaelt/master
12976d3Evan Czaplicki
src/Parse/Binop.hs+3−3
@@ -5,7 +5,7 @@ import Combinators
5import Control.Monad (liftM,guard)
5import Control.Monad (liftM,guard)
6import Control.Monad.Error
6import Control.Monad.Error
7import Data.List (foldl',splitAt,elemIndices,group,groupBy,sortBy,find)
7import Data.List (foldl',splitAt,elemIndices,group,groupBy,sortBy,find)
8−import Data.Map as Map
8+import qualified Data.Map as Map
9import Data.Maybe (mapMaybe)
9import Data.Maybe (mapMaybe)
10
10
11data Assoc = L | Non | R deriving (Eq,Show)
11data Assoc = L | Non | R deriving (Eq,Show)
@@ -45,14 +45,14 @@ binopOf seen (tbl@((lvl, L, op):rest)) ops es =
45 case elemIndices op ops of
45 case elemIndices op ops of
46 [] -> binopOf seen rest ops es
46 [] -> binopOf seen rest ops es
47 is -> case Map.lookup lvl seen of
47 is -> case Map.lookup lvl seen of
48− Nothing -> binopSplit (insert lvl (L,op) seen) tbl (last is) ops es
48+ Nothing -> binopSplit (Map.insert lvl (L,op) seen) tbl (last is) ops es
49 Just (L,_) -> binopSplit seen tbl (last is) ops es
49 Just (L,_) -> binopSplit seen tbl (last is) ops es
50 Just (assoc,op') -> Left $ errorMessage lvl op L op' assoc
50 Just (assoc,op') -> Left $ errorMessage lvl op L op' assoc
51binopOf seen (tbl@((lvl, assoc, op):rest)) ops es =
51binopOf seen (tbl@((lvl, assoc, op):rest)) ops es =
52 case elemIndices op ops of
52 case elemIndices op ops of
53 [] -> binopOf seen rest ops es
53 [] -> binopOf seen rest ops es
54 i:_ -> case Map.lookup lvl seen of
54 i:_ -> case Map.lookup lvl seen of
55− Nothing -> binopSplit (insert lvl (R,op) seen) tbl i ops es
55+ Nothing -> binopSplit (Map.insert lvl (R,op) seen) tbl i ops es
56 Just (assoc',op') ->
56 Just (assoc',op') ->
57 if assoc == assoc' && assoc /= Non then
57 if assoc == assoc' && assoc /= Non then
58 binopSplit seen tbl i ops es
58 binopSplit seen tbl i ops es