@@ -11,9 +11,6 @@ import SourceSyntax.Declaration (Assoc(..))
11import Text.Parsec
11import Text.Parsec
12import Parse.Helpers
12import Parse.Helpers
14−type OpTable = [(Int, Assoc, String)]
16−preludeTable :: OpTable
17preludeTable =
14preludeTable =
18 [ (9, R, ".")
15 [ (9, R, ".")
19 , (8, R, "^")
16 , (8, R, "^")
@@ -29,24 +26,22 @@ preludeTable =
31opLevel :: OpTable -> String -> Int
28opLevel :: OpTable -> String -> Int
32−opLevel table op = Map.findWithDefault 9 op dict
29+opLevel table op = fst $ Map.findWithDefault (9,L) op table
33− where dict = Map.fromList (map (\(lvl,_,op) -> (op,lvl)) table)
35opAssoc :: OpTable -> String -> Assoc
31opAssoc :: OpTable -> String -> Assoc
36−opAssoc table op = Map.findWithDefault L op dict
32+opAssoc table op = snd $ Map.findWithDefault (9,L) op table
37− where dict = Map.fromList (map (\(_,assoc,op) -> (op,assoc)) table)
39hasLevel :: OpTable -> Int -> (String, LExpr t v) -> Bool
34hasLevel :: OpTable -> Int -> (String, LExpr t v) -> Bool
40hasLevel table n (op,_) = opLevel table op == n
35hasLevel table n (op,_) = opLevel table op == n
43− -> IParser (LExpr t v)
37+binops :: IParser (LExpr t v)
44 -> IParser (LExpr t v)
38 -> IParser (LExpr t v)
45 -> IParser String
39 -> IParser String
46 -> IParser (LExpr t v)
40 -> IParser (LExpr t v)
47−binops table term last anyOp =
41+binops term last anyOp =
48 do e <- term
42 do e <- term
49− split (table ++ preludeTable) 0 e =<< nextOps
44+ split table 0 e =<< nextOps
51 nextOps = choice [ commitIf (whitespace >> anyOp) $ do
46 nextOps = choice [ commitIf (whitespace >> anyOp) $ do
52 whitespace ; op <- anyOp ; whitespace
47 whitespace ; op <- anyOp ; whitespace