@@ -11,9 +11,6 @@ import SourceSyntax.Declaration (Assoc(..))
1111import Text.Parsec
1212import Parse.Helpers
1313
14−type OpTable = [(Int, Assoc, String)]
15−
16−preludeTable :: OpTable
1714preludeTable =
1815 [ (9, R, ".")
1916 , (8, R, "^")
@@ -29,24 +26,22 @@ preludeTable =
2926 ]
3027
3128opLevel :: OpTable -> String -> Int
32−opLevel table op = Map.findWithDefault 9 op dict
33− where dict = Map.fromList (map (\(lvl,_,op) -> (op,lvl)) table)
29+opLevel table op = fst $ Map.findWithDefault (9,L) op table
3430
3531opAssoc :: OpTable -> String -> Assoc
36−opAssoc table op = Map.findWithDefault L op dict
37− where dict = Map.fromList (map (\(_,assoc,op) -> (op,assoc)) table)
32+opAssoc table op = snd $ Map.findWithDefault (9,L) op table
3833
3934hasLevel :: OpTable -> Int -> (String, LExpr t v) -> Bool
4035hasLevel table n (op,_) = opLevel table op == n
4136
42−binops :: OpTable
43− -> IParser (LExpr t v)
37+binops :: IParser (LExpr t v)
4438 -> IParser (LExpr t v)
4539 -> IParser String
4640 -> IParser (LExpr t v)
47−binops table term last anyOp =
41+binops term last anyOp =
4842 do e <- term
49− split (table ++ preludeTable) 0 e =<< nextOps
43+ table <- getState
44+ split table 0 e =<< nextOps
5045 where
5146 nextOps = choice [ commitIf (whitespace >> anyOp) $ do
5247 whitespace ; op <- anyOp ; whitespace