summaryrefslogtreecommitdiff
path: root/src/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parser')
-rw-r--r--src/Parser/Shell.hs5
-rw-r--r--src/Parser/Statement.hs11
2 files changed, 9 insertions, 7 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 '\\'
diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs
index 812c559..27e7b92 100644
--- a/src/Parser/Statement.hs
+++ b/src/Parser/Statement.hs
@@ -98,12 +98,6 @@ shellStatement = do
, do
off <- stateOffset <$> getParserState
symbol ":"
- pname <- case mbpname of
- Just pname -> return pname
- Nothing -> do
- registerParseError $ FancyError off $ S.singleton $ ErrorFail $
- "missing parameter with keyword ‘as’"
- return $ TypedVarName (VarName "")
node <- case mbnode of
Just node -> return node
Nothing -> do
@@ -115,8 +109,10 @@ shellStatement = do
void $ L.indentGuard scn GT ref
script <- shellScript
cont <- testBlock ref
+ let expr | Just pname <- mbpname = LambdaAbstraction pname cont
+ | otherwise = const <$> cont
return $ TestBlockStep EmptyTestBlock <$>
- (SpawnShell pname <$> node <*> script <*> LambdaAbstraction pname cont)
+ (SpawnShell mbpname <$> node <*> script <*> expr)
]
exprStatement :: TestParser (Expr (TestBlock ()))
@@ -428,6 +424,7 @@ testSpawn :: TestParser (Expr (TestBlock ()))
testSpawn = command "spawn" $ Spawn
<$> param "as"
<*> (bimap fromExprParam fromExprParam <$> paramOrContext "on")
+ <*> (maybe [] fromExprParam <$> param "args")
<*> innerBlockFun
testExpect :: TestParser (Expr (TestBlock ()))