summaryrefslogtreecommitdiff
path: root/src/GF/Shell/PShell.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2005-12-21 19:46:48 +0000
committeraarne <aarne@cs.chalmers.se>2005-12-21 19:46:48 +0000
commit89ec5b808b56eb408f0200aa38f64c25f59aff07 (patch)
treecc1b2678da9009fcf89ab1785275ba1e2ee58ca8 /src/GF/Shell/PShell.hs
parentf4c5fcf44ad9cfa79435ce76fa40e5f57d645cce (diff)
parsing escaped strings from command line fixed
Diffstat (limited to 'src/GF/Shell/PShell.hs')
-rw-r--r--src/GF/Shell/PShell.hs15
1 files changed, 2 insertions, 13 deletions
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.