From 1c2e8f59960c18b5e5794fba214a3f0906fb074d Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Thu, 23 Feb 2023 23:05:54 +1300 Subject: Parsing overhaul (slightly better errors) --- DSL/StdLib.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'DSL/StdLib.hs') 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' -- cgit v1.2.1