Added support for list categories.

This commit is contained in:
bringert
2005-05-25 09:41:59 +00:00
parent b3f5a2d7a1
commit e2dc03a9ca
10 changed files with 1947 additions and 1102 deletions

View File

@@ -1,6 +1,5 @@
-- automatically generated by BNF Converter
module GF.Source.TestGF where
module Main where
import System.IO ( stdin, hGetContents )
@@ -13,6 +12,8 @@ import GF.Source.PrintGF
import GF.Source.AbsGF
import GF.Data.ErrM
type ParseFun a = [Token] -> Err a
@@ -29,18 +30,29 @@ runFile v p f = putStrLn f >> readFile f >>= run v p
run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()
run v p s = let ts = myLLexer s in case p ts of
Bad s -> do putStrLn "\nParse Failed...\n"
putStrV v "Tokens:"
putStrV v $ show ts
putStrLn s
Bad s -> do putStrLn "\nParse Failed...\n"
putStrV v "Tokens:"
putStrV v $ show ts
putStrLn s
Ok tree -> do putStrLn "\nParse Successful!"
putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree
putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree
showTree v tree
showTree :: (Show a, Print a) => Int -> a -> IO ()
showTree v tree
= do
putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree
putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree
main :: IO ()
main = do args <- getArgs
case args of
[] -> hGetContents stdin >>= run 2 pGrammar
"-s":fs -> mapM_ (runFile 0 pGrammar) fs
fs -> mapM_ (runFile 2 pGrammar) fs