@@ -1,4 +1,4 @@
1−module Parse.Binop (binops, infixStmt, OpTable) where
1+module Parse.Binop (binops, OpTable) where
22
33import Control.Applicative ((<$>))
44import Control.Monad.Error
@@ -11,20 +11,6 @@ import SourceSyntax.Declaration (Assoc(..))
1111import Text.Parsec
1212import Parse.Helpers
1313
14−preludeTable =
15− [ (9, R, ".")
16− , (8, R, "^")
17− , (7, L, "*"), (7, L, "/"), (7, L, "mod"), (7, L, "div"), (7, L, "rem")
18− , (6, L, "+"), (6, L, "-")
19− , (5, R, "::"), (5, R, "++")
20− , (4, N, "<="), (4, N, ">="), (4, N, "<")
21− , (4, N, "=="), (4, N, "/="), (4, N, ">")
22− , (4, L, "~"), (4, L, "<~")
23− , (3, R, "&&")
24− , (2, R, "||")
25− , (0, R, "<|"), (0, L, "|>")
26− ]
27−
2814opLevel :: OpTable -> String -> Int
2915opLevel table op = fst $ Map.findWithDefault (9,L) op table
3016
@@ -96,13 +82,3 @@ getAssoc table n eops
9682 concat [ "Conflicting " ++ problem ++ " for binary operators ("
9783 , intercalate ", " (map fst eops), "). "
9884 , "Consider adding parentheses to disambiguate." ]
99−
100−infixStmt :: IParser (Int, Assoc, String)
101−infixStmt =
102− let infx str assoc = try (reserved ("infix" ++ str) >> return assoc) in
103− do assoc <- choice [ infx "l" L, infx "r" R, infx "" N ]
104− whitespace
105− prec <- do n <- digit ; return (read [n] :: Int)
106− whitespace
107− op <- anyOp
108− return (prec, assoc, op)