mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
the testsuite\runtime\parser test now generates random trees to test the parser with
This commit is contained in:
@@ -3,11 +3,16 @@ import Data.Maybe
|
|||||||
import System.IO
|
import System.IO
|
||||||
import System.CPUTime
|
import System.CPUTime
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
import Data.Set as Set (fromList,toList)
|
||||||
|
|
||||||
|
start_cat = fromJust (readType "Phr")
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
pgf <- readPGF "grammar.pgf"
|
pgf <- readPGF "Lang.pgf"
|
||||||
ts <- fmap (map (fromJust . readTree) . lines) $ readFile "trees.txt"
|
trees0 <- generateRandom pgf start_cat
|
||||||
mapM_ (\l -> doTestLang pgf l ts) (languages pgf)
|
let trees = Set.toList (Set.fromList (take 5000 trees0))
|
||||||
|
hPutStrLn stderr ("Number of trees: "++show (length trees))
|
||||||
|
mapM_ (\l -> doTestLang pgf l trees) (languages pgf)
|
||||||
|
|
||||||
doTestLang pgf l ts = do
|
doTestLang pgf l ts = do
|
||||||
hPutStrLn stderr (show l)
|
hPutStrLn stderr (show l)
|
||||||
@@ -18,6 +23,7 @@ doTestLang pgf l ts = do
|
|||||||
doTest pgf lang cat ss t = do
|
doTest pgf lang cat ss t = do
|
||||||
let s = linearize pgf lang t
|
let s = linearize pgf lang t
|
||||||
putStr (s ++ " ... ")
|
putStr (s ++ " ... ")
|
||||||
|
hFlush stdout
|
||||||
let st = initState pgf lang cat
|
let st = initState pgf lang cat
|
||||||
t1 <- getCPUTime
|
t1 <- getCPUTime
|
||||||
res <- doParse st t1 [] (words s)
|
res <- doParse st t1 [] (words s)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user