Commit e34d49bd authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Added precedence check - fixes #327

parent c41d2e9d
......@@ -352,12 +352,12 @@ top-level.
> checkDeclLhs :: Decl -> SCM Decl
> checkDeclLhs (InfixDecl p fix' pr ops) =
> InfixDecl p fix' pr `liftM` mapM renameVar ops
> liftM2 (InfixDecl p fix') (checkPrecedence p pr) (mapM renameVar ops)
> checkDeclLhs (TypeSig p vs ty) =
> (\vs' -> TypeSig p vs' ty) `liftM` mapM (checkVar "type signature") vs
> checkDeclLhs (FunctionDecl p _ eqs) =
> checkEquationsLhs p eqs
> checkDeclLhs (ForeignDecl p cc ie f ty) =
> checkDeclLhs (ForeignDecl p cc ie f ty) =
> (\f' -> ForeignDecl p cc ie f' ty) `liftM` checkVar "foreign declaration" f
> checkDeclLhs ( ExternalDecl p fs) =
> ExternalDecl p `liftM` mapM (checkVar "external declaration") fs
......@@ -367,6 +367,11 @@ top-level.
> FreeDecl p `liftM` mapM (checkVar "free variables declaration") vs
> checkDeclLhs d = return d
> checkPrecedence :: Position -> Integer -> SCM Integer
> checkPrecedence p i = do
> unless (0 <= i && i <= 9) $ report $ errPrecedenceOutOfRange p i
> return i
> checkVar :: String -> Ident -> SCM Ident
> checkVar _what v = do
> -- isDC <- S.gets (isDataConstr v . renameEnv)
......@@ -975,6 +980,10 @@ Miscellaneous functions.
Error messages.
\begin{verbatim}
> errPrecedenceOutOfRange :: Position -> Integer -> Message
> errPrecedenceOutOfRange p i = posMessage p $ hsep $ map text
> ["Precedence of out range:", show i]
> errUndefinedVariable :: QualIdent -> Message
> errUndefinedVariable v = posMessage v $ hsep $ map text
> [qualName v, "is undefined"]
......
infixl 123 <$>
f <$> x = f x
Supports Markdown
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