summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-05-07 22:47:03 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2016-05-07 22:47:03 +0200
commite59f73feb427e4741ddf1801a21cdcb8f9b9b82b (patch)
treee78f50bcb7aedd7d34be9737079c261a9201a057
parentf61d1bfa8a36e2f50fcfa7efc7612317d79da2a1 (diff)
download2017-01-16_17:13:37-e59f73feb427e4741ddf1801a21cdcb8f9b9b82b.tar
2017-01-16_17:13:37-e59f73feb427e4741ddf1801a21cdcb8f9b9b82b.tar.gz
2017-01-16_17:13:37-e59f73feb427e4741ddf1801a21cdcb8f9b9b82b.tar.bz2
2017-01-16_17:13:37-e59f73feb427e4741ddf1801a21cdcb8f9b9b82b.tar.xz
2017-01-16_17:13:37-e59f73feb427e4741ddf1801a21cdcb8f9b9b82b.zip
make char definitions more global
-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