diff options
| author | aarne <unknown> | 2004-09-14 17:05:46 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-09-14 17:05:46 +0000 |
| commit | fe045070cf4333cee0e634db5c877493d1b16030 (patch) | |
| tree | 285273eb564dbd3ad510a183a1c701ec02a1b57a /src/GF/Canon/TestGFC.hs | |
| parent | 35f884ddfd984edb7d580cd54c6f2f1ad9358a34 (diff) | |
gfcm header
Diffstat (limited to 'src/GF/Canon/TestGFC.hs')
| -rw-r--r-- | src/GF/Canon/TestGFC.hs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/GF/Canon/TestGFC.hs b/src/GF/Canon/TestGFC.hs index 2210f4df3..ee4175610 100644 --- a/src/GF/Canon/TestGFC.hs +++ b/src/GF/Canon/TestGFC.hs @@ -1,5 +1,9 @@ -- automatically generated by BNF Converter -module TestGFC where +module Main where + + +import IO ( stdin, hGetContents ) +import System ( getArgs, getProgName ) import LexGFC import ParGFC @@ -7,19 +11,29 @@ import SkelGFC import PrintGFC import AbsGFC + import ErrM 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 pCanon + [f] -> runFile pCanon f + _ -> do progName <- getProgName + putStrLn $ progName ++ ": excess arguments." |
