From 8e9f71bbec90d74390cae13db6f091bc5609f79e Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 14 May 2012 22:13:30 +1000 Subject: Moved a number of article format parsing functions to a separate file --- Semantic.hs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'Semantic.hs') diff --git a/Semantic.hs b/Semantic.hs index 0697179..e40f4bc 100644 --- a/Semantic.hs +++ b/Semantic.hs @@ -1,4 +1,3 @@ -import Control.Monad( liftM ) import System( getArgs ) import Data.List import qualified Data.Set as Set @@ -7,6 +6,7 @@ import TypeVar import Term import Theorem import Object +import Parse @@ -70,9 +70,7 @@ parse n = Command (number n) name :: String -> ((Stack,Dictionary,Assumptions,Theorems) -> (Stack,Dictionary,Assumptions,Theorems)) name str = \(s,d,a,t) -> - let unQuoted = init . tail $ str - escaped = removeEscChars unQuoted - wordList = words . (map (\x -> if (x == '.') then ' ' else x)) $ escaped + let wordList = (separateBy '.') . removeEscChars . removeQuotes $ str name = Name (init wordList) (last wordList) s' = Stack $ ObjName name : (stackList s) in (s',d,a,t) @@ -370,22 +368,6 @@ doSemanticCheck = -- important to use foldl here so commands get applied in the correct order -getLines :: FilePath -> IO [String] -getLines = liftM lines . readFile - - -stripReturn :: String -> String -stripReturn s = if (last s == '\r') then init s else s - - -removeEscChars :: String -> String -removeEscChars [] = [] -removeEscChars (x:[]) = [x] -removeEscChars x = if (head x == '\\') - then (x!!1) : (removeEscChars . (drop 2) $ x) - else (head x) : (removeEscChars . tail $ x) - - main = do args <- getArgs list <- getLines $ head args -- cgit