Place <file>:<line>:<col> first in an error message.

This is the same as most compilers (e.g. gcc and clang) but also
verilog tools (e.g. yosys) output error mesasge in a standardized form.

This form can immediately be parsed by IDE tools that can jumping
through a list of error messages, placing the cursor at the given
file position.

This change simply re-arranges the error message printing to conform to that
standard.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
This commit is contained in:
Henner Zeller 2019-09-12 14:54:31 -07:00
parent 9cc211d51e
commit ff75e175be
2 changed files with 2 additions and 2 deletions

View File

@ -523,7 +523,7 @@ lexicalError :: String -> Alex a
lexicalError msg = do
(pn, _, _, _) <- alexGetInput
pos <- toTokPos pn
alexError $ msg ++ ", at " ++ show pos
alexError $ show pos ++ "error: " ++ msg
-- get the current user state
get :: Alex AlexUserState

View File

@ -1134,7 +1134,7 @@ IncOrDecOperator :: { BinOp }
parseError :: [Token] -> a
parseError a = case a of
[] -> error "Parse error: no tokens left to parse."
Token t s p : _ -> error $ "Parse error: unexpected token '" ++ s ++ "' (" ++ show t ++ ") at " ++ show p ++ "."
Token t s p : _ -> error $ show p ++ ": Parse error: unexpected token '" ++ s ++ "' (" ++ show t ++ ")"
genItemsToGenItem :: [GenItem] -> GenItem
genItemsToGenItem [x] = x