diff options
| author | kr.angelov <kr.angelov@chalmers.se> | 2008-05-21 13:10:54 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@chalmers.se> | 2008-05-21 13:10:54 +0000 |
| commit | c544ef31823c7d2c28c28cae408cca5d71e6978d (patch) | |
| tree | b9693bc684d1737062e45438cedf7536cf5513d5 /src-3.0/GF/Source/TestGF.hs | |
| parent | 529374caaa6d451400f57f1ff82106d89d603944 (diff) | |
use ByteString internally in Ident, CId and Label
Diffstat (limited to 'src-3.0/GF/Source/TestGF.hs')
| -rw-r--r-- | src-3.0/GF/Source/TestGF.hs | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src-3.0/GF/Source/TestGF.hs b/src-3.0/GF/Source/TestGF.hs index e4c072467..1c5da52ab 100644 --- a/src-3.0/GF/Source/TestGF.hs +++ b/src-3.0/GF/Source/TestGF.hs @@ -1,58 +1,58 @@ --- automatically generated by BNF Converter -module Main where - - -import IO ( stdin, hGetContents ) -import System ( getArgs, getProgName ) - -import GF.Source.LexGF -import GF.Source.ParGF -import GF.Source.SkelGF -import GF.Source.PrintGF -import GF.Source.AbsGF - - - - -import GF.Source.ErrM - -type ParseFun a = [Token] -> Err a - -myLLexer = myLexer - -type Verbosity = Int - -putStrV :: Verbosity -> String -> IO () -putStrV v s = if v > 1 then putStrLn s else return () - -runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO () -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 - Ok tree -> do putStrLn "\nParse Successful!" - 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 - - - - - +-- automatically generated by BNF Converter
+module Main where
+
+
+import IO ( stdin, hGetContents )
+import System ( getArgs, getProgName )
+
+import GF.Source.LexGF
+import GF.Source.ParGF
+import GF.Source.SkelGF
+import GF.Source.PrintGF
+import GF.Source.AbsGF
+
+
+
+
+import GF.Source.ErrM
+
+type ParseFun a = [Token] -> Err a
+
+myLLexer = myLexer
+
+type Verbosity = Int
+
+putStrV :: Verbosity -> String -> IO ()
+putStrV v s = if v > 1 then putStrLn s else return ()
+
+runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()
+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
+ Ok tree -> do putStrLn "\nParse Successful!"
+ 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
+
+
+
+
+
|
