1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
> module Main where
> import System.Environment(getArgs)
> import Data.Maybe(fromJust)
> import qualified Data.Map as Map
> import Expr
#include "DV_lhs"
This requires CPP / preprocessing; use Hugs.lhs for tests with Hugs
> main
> = do
> (s:o) <- getArgs
> let x = concat o
> case doParse $ map (:[]) $ lexer s of
> ParseOK r f -> do
> putStrLn $ "Ok " ++ show r ++ "\n"
> ++ (if 'f' `elem` x then unlines (map show $ Map.toList f) else "")
> ++ (if 'r' `elem` x then unlines (map show (decode (forest_lookup f) r ::[Int])) else "")
> if 'g' `elem` x then toDV (Map.toList f) else return ()
> ParseEOF f -> do
> putStrLn $ "Premature end of input:\n"
> ++ unlines (map show $ Map.toList f)
> toDV $ Map.toList f
> ParseError ts f -> do
> putStrLn $ "Error: " ++ show ts
> toDV $ Map.toList f
> forest_lookup f i
> = fromJust $ Map.lookup i f
|