forked from GitHub/gf-core
Changed name of Con constructor in GFC.cf to avoid errors on Windows when generating Java code with BNFC for the GFC grammar. CON is a reserved filename on Windows. Con was changed to Par, and all the code using was changed too.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
|
||||
-- automatically generated by BNF Converter
|
||||
module GF.Canon.TestGFC where
|
||||
module Main where
|
||||
|
||||
|
||||
import System.IO ( stdin, hGetContents )
|
||||
import IO ( stdin, hGetContents )
|
||||
import System ( getArgs, getProgName )
|
||||
|
||||
import GF.Canon.LexGFC
|
||||
@@ -11,6 +10,8 @@ import GF.Canon.ParGFC
|
||||
import GF.Canon.SkelGFC
|
||||
import GF.Canon.PrintGFC
|
||||
import GF.Canon.AbsGFC
|
||||
import GF.Infra.Ident
|
||||
|
||||
|
||||
|
||||
import GF.Data.ErrM
|
||||
@@ -29,18 +30,29 @@ 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
|
||||
case args of
|
||||
[] -> hGetContents stdin >>= run 2 pCanon
|
||||
"-s":fs -> mapM_ (runFile 0 pCanon) fs
|
||||
fs -> mapM_ (runFile 2 pCanon) fs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user