diff options
| author | aarne <unknown> | 2004-06-24 14:06:09 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-06-24 14:06:09 +0000 |
| commit | 3b39607bbac8e6ab99198ab608f14e1f84c2f60e (patch) | |
| tree | 35b823c38ef0ed7439f1a057d939fbdfa96bc719 /src/GF/Source/TestGF.hs | |
| parent | d3db78ad31fe8b27c7ebb4e05b92d4c3986cb119 (diff) | |
last-minute bug fixes
Diffstat (limited to 'src/GF/Source/TestGF.hs')
| -rw-r--r-- | src/GF/Source/TestGF.hs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/GF/Source/TestGF.hs b/src/GF/Source/TestGF.hs index 89700bda6..b236f1347 100644 --- a/src/GF/Source/TestGF.hs +++ b/src/GF/Source/TestGF.hs @@ -1,5 +1,9 @@ -- automatically generated by BNF Converter -module TestGF where +module Main where + + +import IO ( stdin, hGetContents ) +import System ( getArgs, getProgName ) import LexGF import ParGF @@ -13,13 +17,21 @@ type ParseFun a = [Token] -> Err a myLLexer = myLexer -runFile :: (Print a, Show a) => ParseFun a -> FilePath -> IO() +runFile :: (Print a, Show a) => ParseFun a -> FilePath -> IO () runFile p f = readFile f >>= run p -run :: (Print a, Show a) => ParseFun a -> String -> IO() +run :: (Print a, Show a) => ParseFun a -> String -> IO () run p s = case (p (myLLexer s)) of Bad s -> do putStrLn "\nParse Failed...\n" putStrLn s Ok tree -> do putStrLn "\nParse Successful!" putStrLn $ "\n[Abstract Syntax]\n\n" ++ show tree putStrLn $ "\n[Linearized tree]\n\n" ++ printTree tree + +main :: IO () +main = do args <- getArgs + case args of + [] -> hGetContents stdin >>= run pGrammar + [f] -> runFile pGrammar f + _ -> do progName <- getProgName + putStrLn $ progName ++ ": excess arguments." |
