mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-19 09:49:33 -06:00
Use canonical GF in LPGF compiler
Still contains some hardcoded values, missing cases. I notice now that LPGF and Canonical GF are almost identical, so maybe we don't need a new LPGF format, just a linearization-only runtime which works on canonical grammars. The argument for keeping LGPF is that it would be optimized for size and speed.
This commit is contained in:
@@ -44,7 +44,8 @@ data LinType =
|
||||
|
||||
-- | Linearisation function
|
||||
data LinFun =
|
||||
LFEmpty
|
||||
LFError String
|
||||
| LFEmpty
|
||||
| LFToken String
|
||||
| LFConcat LinFun LinFun
|
||||
| LFInt Int
|
||||
@@ -125,6 +126,7 @@ type Context = [LinFun]
|
||||
-- | Operational semantics, Table 2
|
||||
eval :: Context -> LinFun -> LinFun
|
||||
eval cxt t = case t of
|
||||
LFError err -> error err
|
||||
LFEmpty -> LFEmpty
|
||||
LFToken tok -> LFToken tok
|
||||
LFConcat s t -> LFConcat v w
|
||||
@@ -136,8 +138,14 @@ eval cxt t = case t of
|
||||
where vs = map (eval cxt) ts
|
||||
LFProjection t u -> vs !! (i-1)
|
||||
where
|
||||
LFTuple vs = eval cxt t
|
||||
LFInt i = eval cxt u
|
||||
-- LFTuple vs = eval cxt t
|
||||
-- LFInt i = eval cxt u
|
||||
vs = case eval cxt t of
|
||||
LFTuple vs -> vs
|
||||
x -> error $ "ERROR expected LFTuple, got: " ++ show x
|
||||
i = case eval cxt u of
|
||||
LFInt j -> j
|
||||
x -> error $ "ERROR expected LFInt, got: " ++ show x
|
||||
LFArgument i -> cxt !! (i-1)
|
||||
|
||||
-- | Turn concrete syntax terms into an actual string
|
||||
|
||||
Reference in New Issue
Block a user