summaryrefslogtreecommitdiff
path: root/src/GF/Shell
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Shell')
-rw-r--r--src/GF/Shell/CommandL.hs2
-rw-r--r--src/GF/Shell/PShell.hs15
2 files changed, 3 insertions, 14 deletions
diff --git a/src/GF/Shell/CommandL.hs b/src/GF/Shell/CommandL.hs
index 3697c85db..0dc103e33 100644
--- a/src/GF/Shell/CommandL.hs
+++ b/src/GF/Shell/CommandL.hs
@@ -25,7 +25,7 @@ import GF.Compile.ShellState
import GF.Infra.Option
import GF.UseGrammar.Session
import GF.Shell.Commands
-import GF.Shell.PShell (wordsLits)
+import GF.UseGrammar.Tokenize (wordsLits)
import Data.Char
import Data.List (intersperse)
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.