summaryrefslogtreecommitdiff
path: root/src/GF/Source/TestGF.hs
diff options
context:
space:
mode:
authorbringert <unknown>2005-05-25 09:41:59 +0000
committerbringert <unknown>2005-05-25 09:41:59 +0000
commit65bc1948d4ebb432836996bee5dba246905c154a (patch)
treea8f54052eea58db0579443925d008ca08a79415a /src/GF/Source/TestGF.hs
parent4690a235381d5d28ac6a62a378f42f864821aca4 (diff)
Added support for list categories.
Diffstat (limited to 'src/GF/Source/TestGF.hs')
-rw-r--r--src/GF/Source/TestGF.hs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/GF/Source/TestGF.hs b/src/GF/Source/TestGF.hs
index 65c238db2..b05baade9 100644
--- a/src/GF/Source/TestGF.hs
+++ b/src/GF/Source/TestGF.hs
@@ -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,14 +30,20 @@ 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
@@ -44,3 +51,8 @@ main = do args <- getArgs
[] -> hGetContents stdin >>= run 2 pGrammar
"-s":fs -> mapM_ (runFile 0 pGrammar) fs
fs -> mapM_ (runFile 2 pGrammar) fs
+
+
+
+
+