Make LPGF testsuite work (but still fails)

stack test :lpgf
This commit is contained in:
John J. Camilleri
2021-01-25 13:41:33 +01:00
parent f24c50339b
commit 32b0860925
4 changed files with 162 additions and 13 deletions

159
gf.cabal
View File

@@ -363,32 +363,143 @@ test-suite lpgf
src/compiler src/compiler
src/runtime/haskell src/runtime/haskell
testsuite/lpgf testsuite/lpgf
build-depends:
array,
base>=4.3 && <5,
bytestring,
containers,
ghc-prim,
mtl,
pretty,
random,
utf8-string
other-modules: other-modules:
Data.Binary Data.Binary
Data.Binary.Builder Data.Binary.Builder
Data.Binary.Get Data.Binary.Get
Data.Binary.IEEE754 Data.Binary.IEEE754
Data.Binary.Put Data.Binary.Put
GF
GF.Command.Abstract
GF.Command.CommandInfo
GF.Command.Commands
GF.Command.CommonCommands
GF.Command.Help
GF.Command.Importing
GF.Command.Interpreter
GF.Command.Messages
GF.Command.Parse
GF.Command.SourceCommands
GF.Command.TreeOperations
GF.Compile
GF.Compile.CFGtoPGF
GF.Compile.CheckGrammar
GF.Compile.Compute.ConcreteNew
GF.Compile.Compute.Predef
GF.Compile.Compute.Value
GF.Compile.ConcreteToHaskell
GF.Compile.ExampleBased
GF.Compile.Export
GF.Compile.GenerateBC
GF.Compile.GeneratePMCFG
GF.Compile.GetGrammar
GF.Compile.GrammarToCanonical
GF.Compile.GrammarToLPGF
GF.Compile.GrammarToPGF
GF.Compile.Multi
GF.Compile.Optimize
GF.Compile.PGFtoHaskell
GF.Compile.PGFtoJava
GF.Compile.PGFtoJS
GF.Compile.PGFtoJSON
GF.Compile.PGFtoProlog
GF.Compile.PGFtoPython
GF.Compile.ReadFiles
GF.Compile.Rename
GF.Compile.SubExOpt
GF.Compile.Tags
GF.Compile.ToAPI
GF.Compile.TypeCheck.Abstract
GF.Compile.TypeCheck.ConcreteNew
GF.Compile.TypeCheck.Primitives
GF.Compile.TypeCheck.RConcrete
GF.Compile.TypeCheck.TC
GF.Compile.Update
GF.CompileInParallel
GF.CompileOne
GF.Compiler
GF.Data.BacktrackM
GF.Data.ErrM
GF.Data.Graph
GF.Data.Graphviz
GF.Data.Operations
GF.Data.Relation
GF.Data.Str
GF.Data.Utilities
GF.Data.XML
GF.Grammar
GF.Grammar.Analyse
GF.Grammar.Binary
GF.Grammar.BNFC
GF.Grammar.Canonical
GF.Grammar.CanonicalJSON
GF.Grammar.CFG
GF.Grammar.EBNF
GF.Grammar.Grammar
GF.Grammar.Lexer
GF.Grammar.Lockfield
GF.Grammar.Lookup
GF.Grammar.Macros
GF.Grammar.Parser
GF.Grammar.PatternMatch
GF.Grammar.Predef
GF.Grammar.Printer
GF.Grammar.ShowTerm
GF.Grammar.Unify
GF.Grammar.Values
GF.Haskell
GF.Infra.BuildInfo
GF.Infra.CheckM
GF.Infra.Concurrency
GF.Infra.Dependencies
GF.Infra.GetOpt
GF.Infra.Ident
GF.Infra.Location
GF.Infra.Option
GF.Infra.SIO
GF.Infra.UseIO
GF.Interactive
GF.JavaScript.AbsJS
GF.JavaScript.PrintJS
GF.Main
GF.Quiz
GF.Speech.CFGToFA
GF.Speech.FiniteState
GF.Speech.GSL
GF.Speech.JSGF
GF.Speech.PGFToCFG
GF.Speech.PrRegExp
GF.Speech.RegExp
GF.Speech.SISR
GF.Speech.SLF
GF.Speech.SRG
GF.Speech.SRGS_ABNF
GF.Speech.SRGS_XML
GF.Speech.VoiceXML
GF.Support
GF.System.Catch
GF.System.Concurrency
GF.System.Console
GF.System.Directory
GF.System.Process
GF.System.Signal
GF.Text.Clitics
GF.Text.Coding
GF.Text.Lexing
GF.Text.Pretty
GF.Text.Transliterations
LPGF LPGF
Paths_gf
PGF PGF
PGF.Binary PGF.Binary
PGF.ByteCode PGF.ByteCode
PGF.CId PGF.CId
PGF.Data PGF.Data
PGF.Expr PGF.Expr
PGF.Expr
PGF.Forest PGF.Forest
PGF.Generate PGF.Generate
PGF.Internal
PGF.Linearize PGF.Linearize
PGF.Macros PGF.Macros
PGF.Morphology PGF.Morphology
@@ -396,6 +507,7 @@ test-suite lpgf
PGF.Optimize PGF.Optimize
PGF.Paraphrase PGF.Paraphrase
PGF.Parse PGF.Parse
PGF.Printer
PGF.Probabilistic PGF.Probabilistic
PGF.Tree PGF.Tree
PGF.TrieMap PGF.TrieMap
@@ -403,4 +515,29 @@ test-suite lpgf
PGF.TypeCheck PGF.TypeCheck
PGF.Utilities PGF.Utilities
PGF.VisualizeTree PGF.VisualizeTree
if flag(interrupt)
cpp-options: -DUSE_INTERRUPT
other-modules: GF.System.UseSignal
else
other-modules: GF.System.NoSignal
build-depends:
array,
base>=4.6 && <5,
bytestring,
containers,
directory,
filepath,
ghc-prim,
haskeline,
json,
mtl,
parallel>=3,
pretty,
process,
random,
terminfo,
time,
transformers-compat,
unix,
utf8-string
default-language: Haskell2010 default-language: Haskell2010

View File

@@ -1,4 +1,4 @@
module GF.Compile (compileToPGF, link, linkl, batchCompile, srcAbsName) where module GF.Compile (compileToPGF, compileToLPGF, link, linkl, batchCompile, srcAbsName) where
import GF.Compile.GrammarToPGF(mkCanon2pgf) import GF.Compile.GrammarToPGF(mkCanon2pgf)
import GF.Compile.GrammarToLPGF(mkCanon2lpgf) import GF.Compile.GrammarToLPGF(mkCanon2lpgf)
@@ -32,6 +32,9 @@ import LPGF(LPGF)
compileToPGF :: Options -> [FilePath] -> IOE PGF compileToPGF :: Options -> [FilePath] -> IOE PGF
compileToPGF opts fs = link opts . snd =<< batchCompile opts fs compileToPGF opts fs = link opts . snd =<< batchCompile opts fs
compileToLPGF :: Options -> [FilePath] -> IOE LPGF
compileToLPGF opts fs = linkl opts . snd =<< batchCompile opts fs
-- | Link a grammar into a 'PGF' that can be used to 'PGF.linearize' and -- | Link a grammar into a 'PGF' that can be used to 'PGF.linearize' and
-- 'PGF.parse' with the "PGF" run-time system. -- 'PGF.parse' with the "PGF" run-time system.
link :: Options -> (ModuleName,Grammar) -> IOE PGF link :: Options -> (ModuleName,Grammar) -> IOE PGF

View File

@@ -1,4 +1,4 @@
module GF.Compiler (mainGFC, linkGrammars, writePGF, writeOutputs) where module GF.Compiler (mainGFC, linkGrammars, writePGF, writeLPGF, writeOutputs) where
import PGF import PGF
import PGF.Internal(concretes,optimizePGF,unionPGF) import PGF.Internal(concretes,optimizePGF,unionPGF)

View File

@@ -1,5 +1,7 @@
import LPGF import LPGF
import PGF (Tree, mkCId, mkApp, readLanguage, showLanguage, showExpr) import PGF (Tree, mkCId, mkApp, readLanguage, showLanguage, showExpr)
import GF (compileToLPGF, writeLPGF)
import GF.Support (noOptions)
import Control.Monad (forM_) import Control.Monad (forM_)
import qualified Data.Map as Map import qualified Data.Map as Map
@@ -7,7 +9,14 @@ import Text.Printf (printf)
main :: IO () main :: IO ()
main = do main = do
-- Compile LPGF
lpgf <- compileToLPGF noOptions ["testsuite/lpgf/ZeroEng.gf", "testsuite/lpgf/ZeroGer.gf"]
writeLPGF noOptions lpgf
-- Read back from file
lpgf <- readLPGF "Zero.lpgf" lpgf <- readLPGF "Zero.lpgf"
-- Do some linearization
forM_ [tree1, tree2, tree3] $ \tree -> do forM_ [tree1, tree2, tree3] $ \tree -> do
putStrLn (showExpr [] tree) putStrLn (showExpr [] tree)
forM_ (Map.toList (concretes lpgf)) $ \(lang,concr) -> forM_ (Map.toList (concretes lpgf)) $ \(lang,concr) ->