|
@@ -205,7 +205,7 @@ let assignTest =
|
|
|
"Error in Ln: 1 Col: 1"
|
|
|
"f(expr) = 42"
|
|
|
"^"
|
|
|
- "Expecting: '$', 'let' (case-insensitive), 'local' (case-insensitive) or 'set'"
|
|
|
+ "Expecting: '$', 'let' (case-insensitive) or 'set'"
|
|
|
"(case-insensitive)"
|
|
|
""
|
|
|
"The parser backtracked after:"
|
|
@@ -264,7 +264,6 @@ let StaticStmts x =
|
|
|
let If(expr, thenBody, elseBody) =
|
|
|
If(expr, emptyPoss thenBody, emptyPoss elseBody)
|
|
|
let Act(exprs, thenBody) = Act(exprs, emptyPoss thenBody)
|
|
|
-let For(x, y, z, w, thenBody) = For(x, y, z, w, emptyPoss thenBody)
|
|
|
|
|
|
let equalTwoPosStmt (note, stmt1, stmt2) =
|
|
|
match stmt1, stmt2 with
|
|
@@ -707,69 +706,6 @@ let ifTests =
|
|
|
]
|
|
|
|
|
|
[<Tests>]
|
|
|
-let forTests =
|
|
|
- let runStmts str =
|
|
|
- Qsp.Parser.Generic.runStateEither
|
|
|
- Qsp.Parser.Main.pstmt
|
|
|
- Qsp.Parser.Generic.emptyState str
|
|
|
- |> snd
|
|
|
- let runStmtsEof str =
|
|
|
- Qsp.Parser.Generic.runStateEither
|
|
|
- (Qsp.Parser.Main.pstmt .>> eof)
|
|
|
- Qsp.Parser.Generic.emptyState str
|
|
|
- |> snd
|
|
|
- testList "forTests" [
|
|
|
- testCase "multiline `for i = 4 + x to 45 / x + y:`" <| fun () ->
|
|
|
- let input =
|
|
|
- [
|
|
|
- "for i = 4 + x to 45 / x + y:"
|
|
|
- " stmt"
|
|
|
- "end"
|
|
|
- ] |> String.concat "\n"
|
|
|
- let exp =
|
|
|
- (For
|
|
|
- ((NumericType, "i"),
|
|
|
- Expr (Plus, Val (Int 4), Var (NumericType, "x")),
|
|
|
- Expr
|
|
|
- (Plus, Expr (Divide, Val (Int 45), Var (NumericType, "x")),
|
|
|
- Var (NumericType, "y")),
|
|
|
- None,
|
|
|
- [StarPl (Var (NumericType, "stmt"))]))
|
|
|
- equalTwoPosStmt("", Right (emptyPos, exp), runStmtsEof input)
|
|
|
- testCase "inline `for i = 4 + x to 45 / x + y: stmt`" <| fun () ->
|
|
|
- let input =
|
|
|
- [
|
|
|
- "for i = 4 + x to 45 / x + y: stmt"
|
|
|
- "'statement that not belong to construction'"
|
|
|
- ] |> String.concat "\n"
|
|
|
- let exp =
|
|
|
- (For
|
|
|
- ((NumericType, "i"),
|
|
|
- Expr (Plus, Val (Int 4), Var (NumericType, "x")),
|
|
|
- Expr
|
|
|
- (Plus, Expr (Divide, Val (Int 45), Var (NumericType, "x")),
|
|
|
- Var (NumericType, "y")),
|
|
|
- None,
|
|
|
- [StarPl (Var (NumericType, "stmt"))]))
|
|
|
- equalTwoPosStmt("", Right (emptyPos, exp), runStmts input)
|
|
|
- testCase "inline `for i = 4 + x to 45 / x + y step x + 1: stmt`" <| fun () ->
|
|
|
- let input =
|
|
|
- [
|
|
|
- "for i = 4 + x to 45 / x + y step x + 1: stmt"
|
|
|
- "'statement that not belong to construction'"
|
|
|
- ] |> String.concat "\n"
|
|
|
- let exp =
|
|
|
- (For
|
|
|
- ((NumericType, "i"),
|
|
|
- Expr (Plus, Val (Int 4), Var (NumericType, "x")),
|
|
|
- Expr
|
|
|
- (Plus, Expr (Divide, Val (Int 45), Var (NumericType, "x")),
|
|
|
- Var (NumericType, "y")),
|
|
|
- Some (Expr (Plus, Var (NumericType, "x"), Val (Int 1))),
|
|
|
- [StarPl (Var (NumericType, "stmt"))]))
|
|
|
- equalTwoPosStmt("", Right (emptyPos, exp), runStmts input)
|
|
|
- ]
|
|
|
-[<Tests>]
|
|
|
let stmtTests =
|
|
|
let runStmts str =
|
|
|
Qsp.Parser.Generic.runStateEither
|