2019-02-08 06:19:39 +01:00
|
|
|
module Language.SystemVerilog.Parser
|
2019-02-08 05:49:12 +01:00
|
|
|
( parseFile
|
|
|
|
|
, preprocess
|
|
|
|
|
) where
|
|
|
|
|
|
2019-02-08 06:19:39 +01:00
|
|
|
import Language.SystemVerilog.AST
|
|
|
|
|
import Language.SystemVerilog.Parser.Lex
|
|
|
|
|
import Language.SystemVerilog.Parser.Parse
|
|
|
|
|
import Language.SystemVerilog.Parser.Preprocess
|
|
|
|
|
import Language.SystemVerilog.Parser.Tokens
|
2019-02-08 05:49:12 +01:00
|
|
|
|
|
|
|
|
-- | Parses a file given a table of predefined macros, the file name, and the file contents.
|
|
|
|
|
parseFile :: [(String, String)] -> FilePath -> String -> [Module]
|
|
|
|
|
parseFile env file content = modules tokens
|
|
|
|
|
where
|
|
|
|
|
tokens = map relocate $ alexScanTokens $ preprocess env file content
|
|
|
|
|
relocate :: Token -> Token
|
|
|
|
|
relocate (Token t s (Position _ l c)) = Token t s $ Position file l c
|
|
|
|
|
|