aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Parser/Parser.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-02 18:16:21 +0100
committerYann Herklotz <git@ymhg.org>2019-04-02 18:16:21 +0100
commitc0c799ab3f79c370e4c33b8f824489ce8b1c96ec (patch)
tree042f235cdf458e6bf5330a477435d4b34bee7859 /src/VeriFuzz/Parser/Parser.hs
parent1ef0455ddad821c2ddf64d451e99b8b5508c39c5 (diff)
downloadverismith-c0c799ab3f79c370e4c33b8f824489ce8b1c96ec.tar.gz
verismith-c0c799ab3f79c370e4c33b8f824489ce8b1c96ec.zip
Rename to Verilog
Diffstat (limited to 'src/VeriFuzz/Parser/Parser.hs')
-rw-r--r--src/VeriFuzz/Parser/Parser.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/VeriFuzz/Parser/Parser.hs b/src/VeriFuzz/Parser/Parser.hs
index 48e92ec..ff0ccdd 100644
--- a/src/VeriFuzz/Parser/Parser.hs
+++ b/src/VeriFuzz/Parser/Parser.hs
@@ -12,18 +12,14 @@ whole Verilog syntax, as the AST does not support it either.
-}
module VeriFuzz.Parser.Parser
- ( -- * Parsers
+ ( -- * Parser
parseVerilog
- , parseVerilogSrc
- , parseDescription
- , parseModDecl
- , parseContAssign
- , parseExpr
)
where
import Control.Lens
import Control.Monad (void)
+import Data.Bifunctor (bimap)
import Data.Functor (($>))
import Data.Functor.Identity (Identity)
import qualified Data.Text as T
@@ -306,12 +302,15 @@ parseModDecl = do
parseDescription :: Parser Description
parseDescription = Description <$> parseModDecl
--- | Parses a 'String' into 'VerilogSrc' by skipping any beginning whitespace
+-- | Parses a 'String' into 'Verilog' by skipping any beginning whitespace
-- and then parsing multiple Verilog source.
-parseVerilogSrc :: Parser VerilogSrc
-parseVerilogSrc = VerilogSrc <$> many parseDescription
+parseVerilogSrc :: Parser Verilog
+parseVerilogSrc = Verilog <$> many parseDescription
-- | Parse a 'String' containing verilog code. The parser currently only supports
-- the subset of Verilog that is being generated randomly.
-parseVerilog :: String -> String -> Either ParseError VerilogSrc
-parseVerilog s = parse parseVerilogSrc s . alexScanTokens . preprocess [] s
+parseVerilog :: String -- ^ Name of parsed object.
+ -> String -- ^ Content to be parsed.
+ -> Either String Verilog -- ^ Returns 'String' with error
+ -- message if parse fails.
+parseVerilog s = bimap show id . parse parseVerilogSrc s . alexScanTokens . preprocess [] s