diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-15 22:20:33 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-15 22:20:33 +0200 |
commit | 2bc126785982cc0c66672c21d8baec905d1f2b3c (patch) | |
tree | 10692e541e756913d01403eb6428049ebe124f62 /src/Parser/Shell.hs | |
parent | 338ac0efb3d2e2a258d949268ed6b27b3ecae1a0 (diff) |
Single-quoted strings in shell
Diffstat (limited to 'src/Parser/Shell.hs')
-rw-r--r-- | src/Parser/Shell.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Parser/Shell.hs b/src/Parser/Shell.hs index 0f34fee..a61352d 100644 --- a/src/Parser/Shell.hs +++ b/src/Parser/Shell.hs @@ -22,6 +22,7 @@ import Script.Shell parseArgument :: TestParser (Expr Text) parseArgument = lexeme $ fmap (App AnnNone (Pure T.concat) <$> foldr (liftA2 (:)) (Pure [])) $ some $ choice [ doubleQuotedString + , singleQuotedString , escapedChar , stringExpansion , unquotedString @@ -44,6 +45,10 @@ parseArgument = lexeme $ fmap (App AnnNone (Pure T.concat) <$> foldr (liftA2 (:) ] App AnnNone (Pure T.concat) . foldr (liftA2 (:)) (Pure []) <$> inner + singleQuotedString :: TestParser (Expr Text) + singleQuotedString = do + Pure . TL.toStrict <$> (char '\'' *> takeWhileP Nothing (/= '\'') <* char '\'') + escapedChar :: TestParser (Expr Text) escapedChar = do void $ char '\\' |