From 89ec5b808b56eb408f0200aa38f64c25f59aff07 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 21 Dec 2005 19:46:48 +0000 Subject: parsing escaped strings from command line fixed --- src/GF/Shell/PShell.hs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/GF/Shell/PShell.hs') diff --git a/src/GF/Shell/PShell.hs b/src/GF/Shell/PShell.hs index 77264fee9..aba743503 100644 --- a/src/GF/Shell/PShell.hs +++ b/src/GF/Shell/PShell.hs @@ -23,6 +23,7 @@ import GF.Infra.Option import GF.Compile.PGrammar (pzIdent, pTrm) --- (string2formsAndTerm) import GF.API import GF.System.Arch (fetchCommand) +import GF.UseGrammar.Tokenize (wordsLits) import Data.Char (isDigit, isSpace) import System.IO.Error @@ -44,18 +45,6 @@ pCommandLines :: HState -> String -> [CommandLine] pCommandLines st = map (pCommandLine st) . concatMap (chunks ";;" . wordsLits) . lines --- | Like 'words', but does not split on whitespace inside --- double quotes. -wordsLits :: String -> [String] -wordsLits [] = [] -wordsLits (c:cs) | isSpace c = wordsLits (dropWhile isSpace cs) - | c == '\'' || c == '"' - = let (l,rs) = break (==c) cs - rs' = drop 1 rs - in ([c]++l++[c]):wordsLits rs' - | otherwise = let (w,rs) = break isSpace cs - in (c:w):wordsLits rs - -- | Remove single or double quotes around a string unquote :: String -> String unquote (x:xs@(_:_)) | x `elem` "\"'" && x == last xs = init xs @@ -83,7 +72,7 @@ pCommandOpt _ s = (CVoid, noOptions, [AError "no parse"]) pInputString :: String -> [CommandArg] pInputString s = case s of - ('"':_:_) -> [AString (init (tail s))] + ('"':_:_) | last s == '"' -> [AString (read s)] _ -> [AError "illegal string"] -- | command @rl@ can be written @remove_language@ etc. -- cgit v1.2.3