1
0
forked from GitHub/gf-core

Improve base case in table handling, cleanup. Add run-phrasebook script, current output:

Bul ✗
Cat ✗
Chi ✓
Dan ✓
Dut ✓
Eng ✓
Est ✓
Fin ✗
Fre ✗
Ger ✓
Hin ✓
Ita ✗
Jpn ✓
Lav ✓
Nor ✓
Pol ✓
Ron ✓
Snd ✗
Spa ✗
Swe ✓
Tha ✓
Urd ✓

Passed 15 | Failed 7 | Total 22
This commit is contained in:
John J. Camilleri
2021-03-04 17:09:35 +01:00
parent bca1e2286d
commit 70581c2d8c
2 changed files with 39 additions and 9 deletions

View File

@@ -174,11 +174,15 @@ mkCanon2lpgf opts gr am = do
-- remove one level of depth and recurse
let
handleGroup :: [C.TableRowValue] -> Either String (L.LinFun, Maybe C.LinType)
handleGroup [C.TableRow _ lv] = val2lin lv -- TODO suspect
handleGroup [C.TableRow patt lv] =
case reducePattern patt of
Just patt' -> do
(lf,lt) <- handleGroup [C.TableRow patt' lv]
return (L.Tuple [lf],lt)
Nothing -> val2lin lv
handleGroup rows = do
let reductions = map reduceRow rows
let rows' = map fromJust reductions
val2lin (C.TableValue lt rows') -- TODO lt is wrong here
let rows' = map reduceRow rows
val2lin (C.TableValue lt rows') -- lt is wrong here, but is unused
reducePattern :: C.LinPattern -> Maybe C.LinPattern
reducePattern patt =
@@ -198,11 +202,10 @@ mkCanon2lpgf opts gr am = do
_ -> error $ printf "Unhandled pattern in reducing: %s" (show patt)
reduceRow :: C.TableRowValue -> Maybe C.TableRowValue
reduceRow row@(C.TableRow patt lv) =
case reducePattern patt of
Just patt' -> Just $ C.TableRow patt' lv
Nothing -> Nothing
reduceRow :: C.TableRowValue -> C.TableRowValue
reduceRow (C.TableRow patt lv) =
let Just patt' = reducePattern patt
in C.TableRow patt' lv
-- ts :: [(L.LinFun, Maybe C.LinType)]
ts <- mapM handleGroup grps