1
0
forked from GitHub/gf-core

fix the haskell binding to handle parse errors

This commit is contained in:
kr.angelov
2014-04-04 11:46:40 +00:00
parent dafaef7fec
commit bd892b8a1d
3 changed files with 28 additions and 7 deletions

View File

@@ -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