Commit 9f180f91 by Zachary Snow

improve `line error message

parent ad98c145
...@@ -1002,7 +1002,10 @@ handleDirective (posOrig, _, _, strOrig) len = do ...@@ -1002,7 +1002,10 @@ handleDirective (posOrig, _, _, strOrig) len = do
let Just line = readMaybe lineStr :: Maybe Int let Just line = readMaybe lineStr :: Maybe Int
let Just level = readMaybe levelStr :: Maybe Int let Just level = readMaybe levelStr :: Maybe Int
return (line, filename, level) return (line, filename, level)
_ -> lexicalError $ "unexpected tokens following `begin_keywords: " ++ show toks _ -> lexicalError $
"unexpected tokens types following `line: "
++ show (map tokenName toks) ++ "; should be: "
++ show [Lit_number, Lit_string, Lit_number]
let filename = init $ tail quotedFilename let filename = init $ tail quotedFilename
setCurrentFile filename setCurrentFile filename
(AlexPn f _ c, prev, _, str) <- alexGetInput (AlexPn f _ c, prev, _, str) <- alexGetInput
......
...@@ -10,6 +10,7 @@ module Language.SystemVerilog.Parser.Tokens ...@@ -10,6 +10,7 @@ module Language.SystemVerilog.Parser.Tokens
, TokenName (..) , TokenName (..)
, Position (..) , Position (..)
, tokenString , tokenString
, tokenName
) where ) where
import Text.Printf import Text.Printf
...@@ -17,6 +18,9 @@ import Text.Printf ...@@ -17,6 +18,9 @@ import Text.Printf
tokenString :: Token -> String tokenString :: Token -> String
tokenString (Token _ s _) = s tokenString (Token _ s _) = s
tokenName :: Token -> TokenName
tokenName (Token kw _ _) = kw
data Position data Position
= Position String Int Int = Position String Int Int
deriving Eq deriving Eq
......
Markdown is supported
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