mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
start using the new typechecker and evaluator in the cc command
This commit is contained in:
@@ -19,8 +19,8 @@ import GF.Grammar.Analyse
|
|||||||
import GF.Grammar.ShowTerm
|
import GF.Grammar.ShowTerm
|
||||||
import GF.Grammar.Lookup (allOpers,allOpersTo)
|
import GF.Grammar.Lookup (allOpers,allOpersTo)
|
||||||
import GF.Compile.Rename(renameSourceTerm)
|
import GF.Compile.Rename(renameSourceTerm)
|
||||||
import GF.Compile.Compute.Concrete(normalForm,normalFlatForm,Globals(..),stdPredef)
|
import GF.Compile.Compute.Concrete2(normalForm,normalFlatForm,Globals(..),stdPredef)
|
||||||
import GF.Compile.TypeCheck.Concrete as TC(inferLType,ppType)
|
import GF.Compile.TypeCheck.ConcreteNew as TC(inferLType)
|
||||||
|
|
||||||
import GF.Command.Abstract(Option(..),isOpt,listFlags,valueString,valStrOpts)
|
import GF.Command.Abstract(Option(..),isOpt,listFlags,valueString,valStrOpts)
|
||||||
import GF.Command.CommandInfo
|
import GF.Command.CommandInfo
|
||||||
@@ -245,14 +245,16 @@ checkComputeTerm os sgr t =
|
|||||||
Nothing -> checkError (pp "No source grammar in scope")
|
Nothing -> checkError (pp "No source grammar in scope")
|
||||||
Just mo -> return mo
|
Just mo -> return mo
|
||||||
t <- renameSourceTerm sgr mo t
|
t <- renameSourceTerm sgr mo t
|
||||||
(t,_) <- inferLType sgr [] t
|
ttys <- inferLType g t
|
||||||
if isOpt "flat" os
|
if isOpt "flat" os
|
||||||
then fmap (map evalStr) (normalFlatForm (Gl sgr stdPredef) t)
|
then fmap concat (mapM (\(t,_) -> fmap (map evalStr) (normalFlatForm g t)) ttys)
|
||||||
else fmap (singleton . evalStr) (normalForm (Gl sgr stdPredef) t)
|
else fmap concat (mapM (\(t,_) -> fmap (singleton . evalStr) (normalForm g t)) ttys)
|
||||||
where
|
where
|
||||||
-- ** Try to compute pre{...} tokens in token sequences
|
-- ** Try to compute pre{...} tokens in token sequences
|
||||||
singleton x = [x]
|
singleton x = [x]
|
||||||
|
|
||||||
|
g = Gl sgr (stdPredef g)
|
||||||
|
|
||||||
evalStr t =
|
evalStr t =
|
||||||
case t of
|
case t of
|
||||||
C t1 t2 -> foldr1 C (evalC [t])
|
C t1 t2 -> foldr1 C (evalC [t])
|
||||||
|
|||||||
Reference in New Issue
Block a user