diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-07 22:47:03 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-07 22:47:03 +0200 |
commit | e59f73feb427e4741ddf1801a21cdcb8f9b9b82b (patch) | |
tree | e78f50bcb7aedd7d34be9737079c261a9201a057 /src/Command.hs | |
parent | f61d1bfa8a36e2f50fcfa7efc7612317d79da2a1 (diff) | |
download | 2017-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
Diffstat (limited to 'src/Command.hs')
-rw-r--r-- | src/Command.hs | 10 |
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 | ||
19 | quoteChars, escapeChars :: [Char] | ||
20 | quoteChars = ['"', '\''] | ||
21 | escapeChars = ['\\'] | ||
22 | |||
23 | isQuote, isEscape :: Char -> Bool | ||
24 | isQuote q = q `elem` quoteChars | ||
25 | isEscape e = e `elem` escapeChars | ||
26 | |||
19 | parseCmd :: SequenceM m => String -> m Cmd | 27 | parseCmd :: SequenceM m => String -> m Cmd |
20 | parseCmd = parseCmd' . split | 28 | parseCmd = 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 | ||
54 | parseCmd' :: SequenceM m => [String] -> m Cmd | 60 | parseCmd' :: SequenceM m => [String] -> m Cmd |
55 | parseCmd' [] = return Empty | 61 | parseCmd' [] = return Empty |