diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-23 23:05:54 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-23 23:05:54 +1300 |
| commit | 1c2e8f59960c18b5e5794fba214a3f0906fb074d (patch) | |
| tree | 0c1d1a421ad50b5d704d512a328e13aa693deefa /DSL/StdLib.hs | |
| parent | 06692c8e1754ac8d5d671160b839723e3610fcf1 (diff) | |
Parsing overhaul (slightly better errors)
Diffstat (limited to 'DSL/StdLib.hs')
| -rw-r--r-- | DSL/StdLib.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/DSL/StdLib.hs b/DSL/StdLib.hs index 360e139..09c5338 100644 --- a/DSL/StdLib.hs +++ b/DSL/StdLib.hs @@ -3,16 +3,17 @@ module DSL.StdLib (stdlib) where import Data.Map.Strict (fromList) import DSL.Types -import DSL.BaseParsers (parse, mult, chain) +import DSL.BaseParsers (parse, mult, chain, nicePrintParserError) import DSL.Parsing (tokenizer, procP) stdlib :: ProcTable stdlib = procs where p = tokenizer `chain` mult procP + m = "Failed to parse standard library:\n" procs = case parse p (unlines sources) of - Nothing -> error "Failed to parse standard library" - Just (_, ps) -> fromList ps + Right (_, ps) -> fromList ps + Left e -> error $ m ++ nicePrintParserError e sources :: [String] sources = [ div' |
