From 69c1c04e84a6e1f98c11883b9e4ddbdca4fce3f5 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 18 Mar 2007 01:46:31 +0000 Subject: [PATCH] Add function for testing parser productions --- fco2/Parse.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fco2/Parse.hs b/fco2/Parse.hs index f74e422..66c151e 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -1,9 +1,7 @@ -- vim:foldmethod=marker -- Parse occam code --- FIXME: Can probably parse indentation using try and char ' ', watching the position? - -module Parse (readSource, parseSource) where +module Parse where import Data.List import Text.ParserCombinators.Parsec @@ -1124,6 +1122,11 @@ readSource fn = do --}}} --{{{ interface for other modules +testParse :: Show a => OccParser a -> String -> IO () +testParse prod text + = do let r = runParser prod emptyState "" text + putStrLn $ "Result: " ++ show r + parseSource :: String -> String -> IO (A.Process, ParseState) parseSource prep sourceFileName = case runParser sourceFile emptyState sourceFileName prep of