From bd892b8a1dd74b7f1b0fd66f498bc7c9fef1bf78 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Fri, 4 Apr 2014 11:46:40 +0000 Subject: fix the haskell binding to handle parse errors --- src/runtime/haskell-bind/examples/pgf-shell.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/runtime/haskell-bind/examples/pgf-shell.hs') diff --git a/src/runtime/haskell-bind/examples/pgf-shell.hs b/src/runtime/haskell-bind/examples/pgf-shell.hs index e111076d4..bb15508c7 100644 --- a/src/runtime/haskell-bind/examples/pgf-shell.hs +++ b/src/runtime/haskell-bind/examples/pgf-shell.hs @@ -34,10 +34,14 @@ execute pgf cmd = L lang tree -> do c <- getConcr' pgf lang putStrLn $ linearize c tree P lang s -> do c <- getConcr' pgf lang - printl $ parse c (startCat pgf) s + case parse c (startCat pgf) s of + Left tok -> putStrLn ("parse error: "++tok) + Right ts -> printl ts T from to s -> do cfrom <- getConcr' pgf from cto <- getConcr' pgf to - putl [linearize cto t|(t,_)<-parse cfrom (startCat pgf) s] + putl [linearize cto t|(t,_)<-case parse cfrom (startCat pgf) s of + Left _ -> [] + Right ts -> ts] _ -> putStrLn "Huh?" `catch` print -- cgit v1.2.3