summaryrefslogtreecommitdiff
path: root/src/Command.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Command.hs')
-rw-r--r--src/Command.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Command.hs b/src/Command.hs
index 49dc966..55f4466 100644
--- a/src/Command.hs
+++ b/src/Command.hs
@@ -16,6 +16,14 @@ data Cmd = PerformAlt Alteration
16 | ParseError String 16 | ParseError String
17 | Empty 17 | Empty
18 18
19quoteChars, escapeChars :: [Char]
20quoteChars = ['"', '\'']
21escapeChars = ['\\']
22
23isQuote, isEscape :: Char -> Bool
24isQuote q = q `elem` quoteChars
25isEscape e = e `elem` escapeChars
26
19parseCmd :: SequenceM m => String -> m Cmd 27parseCmd :: SequenceM m => String -> m Cmd
20parseCmd = parseCmd' . split 28parseCmd = parseCmd' . split
21 where 29 where
@@ -48,8 +56,6 @@ parseCmd = parseCmd' . split
48 | Nothing <- e 56 | Nothing <- e
49 , isEscape c = split' ws w q (Just c) cs -- Set escaped flag at unescaped escape char 57 , isEscape c = split' ws w q (Just c) cs -- Set escaped flag at unescaped escape char
50 | otherwise = split' ws (c : w) q Nothing cs -- Append to word 58 | otherwise = split' ws (c : w) q Nothing cs -- Append to word
51 isQuote q = q `elem` ['"', '\'']
52 isEscape e = e == '\\'
53 59
54parseCmd' :: SequenceM m => [String] -> m Cmd 60parseCmd' :: SequenceM m => [String] -> m Cmd
55parseCmd' [] = return Empty 61parseCmd' [] = return Empty