diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2022-08-10 20:40:09 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2022-08-10 23:41:19 +0200 |
commit | efaed91a6007772acf066e7876c06462f4e68fd4 (patch) | |
tree | 9520557ac7fcca474af577cbe367a17ae6bde885 /src/Parser.hs | |
parent | c90a5abf0eeded8ff8a4aaee5ef35674236ed197 (diff) |
Let statement
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index fa85f8c..bce5a02 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -184,6 +184,18 @@ getSourceLine = do , TL.toStrict $ TL.takeWhile (/='\n') $ pstateInput pstate ] + +letStatement :: TestParser [TestStep] +letStatement = do + line <- getSourceLine + wsymbol "let" + name <- VarName . (:[]) <$> identifier + sc + symbol "=" + value <- stringExpr + return [Let line name value] + + command :: (Generic b, GInit (Rep b)) => String -> [Param b] -> (SourceLine -> b -> TestParser a) -> TestParser [a] command name params fin = do origline <- getSourceLine @@ -292,7 +304,8 @@ testWait = do parseTestDefinition :: TestParser Test parseTestDefinition = label "test definition" $ toplevel $ do block (\name steps -> return $ Test name $ concat steps) header $ choice - [ testSpawn + [ letStatement + , testSpawn , testSend , testExpect , testGuard |