From ff75e175bee7394f2ab27075c50462591da2fc14 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Thu, 12 Sep 2019 14:54:31 -0700 Subject: [PATCH] Place :: 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 --- src/Language/SystemVerilog/Parser/Lex.x | 2 +- src/Language/SystemVerilog/Parser/Parse.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/SystemVerilog/Parser/Lex.x b/src/Language/SystemVerilog/Parser/Lex.x index 5e7d14a..96da705 100644 --- a/src/Language/SystemVerilog/Parser/Lex.x +++ b/src/Language/SystemVerilog/Parser/Lex.x @@ -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 diff --git a/src/Language/SystemVerilog/Parser/Parse.y b/src/Language/SystemVerilog/Parser/Parse.y index 03f18d7..7df017b 100644 --- a/src/Language/SystemVerilog/Parser/Parse.y +++ b/src/Language/SystemVerilog/Parser/Parse.y @@ -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