summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-10-20 14:36:30 +0000
committerhallgren <hallgren@chalmers.se>2011-10-20 14:36:30 +0000
commited451653bd9fa4d835cb263c06d0ecb9133b9935 (patch)
treecf6cc1e56c5cac76d4c9fb6c09a6bad456e3c151 /src/compiler/GF/Grammar
parente5accc0d8d3c6d9cace9d4aff482ab285bf7e01b (diff)
Introduce an explicit error value in the Term type
This makes it easier to treat run-time errors (e.g. caused by calls to Predef.error) in a way that is more typical for a lazy functional language.
Diffstat (limited to 'src/compiler/GF/Grammar')
-rw-r--r--src/compiler/GF/Grammar/Grammar.hs2
-rw-r--r--src/compiler/GF/Grammar/Printer.hs1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/GF/Grammar/Grammar.hs b/src/compiler/GF/Grammar/Grammar.hs
index 686164539..ae29ab6d5 100644
--- a/src/compiler/GF/Grammar/Grammar.hs
+++ b/src/compiler/GF/Grammar/Grammar.hs
@@ -161,7 +161,7 @@ data Term =
| Alts Term [(Term, Term)] -- ^ alternatives by prefix: @pre {t ; s\/c ; ...}@
| Strs [Term] -- ^ conditioning prefix strings: @strs {s ; ...}@
-
+ | Error String -- ^ error values returned by Predef.error
deriving (Show, Eq, Ord)
data Patt =
diff --git a/src/compiler/GF/Grammar/Printer.hs b/src/compiler/GF/Grammar/Printer.hs
index ef31af3bb..5fa9121fc 100644
--- a/src/compiler/GF/Grammar/Printer.hs
+++ b/src/compiler/GF/Grammar/Printer.hs
@@ -192,6 +192,7 @@ ppTerm q d (Typed e t) = char '<' <> ppTerm q 0 e <+> colon <+> ppTerm q 0 t <>
ppTerm q d (ImplArg e) = braces (ppTerm q 0 e)
ppTerm q d (ELincat cat t) = prec d 4 (text "lincat" <+> ppIdent cat <+> ppTerm q 5 t)
ppTerm q d (ELin cat t) = prec d 4 (text "lin" <+> ppIdent cat <+> ppTerm q 5 t)
+ppTerm q d (Error s) = prec d 4 (text "Predef.error" <+> str s)
ppEquation q (ps,e) = hcat (map (ppPatt q 2) ps) <+> text "->" <+> ppTerm q 0 e