1:
|
val parse: infix: string -> ParseResult
|
Преобразует математическое выражение в виде строки в тип ParseResult.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
|
let goodExample = "2*x + 3*y + cos(x*y*z)"
let badExample = "2*x + 3*y + cos(x*y*z"
let printWithParseResult result =
match result with
| ParseFailure str -> str |> printfn "%s"
| ParsedExpression exp -> exp |> Infix.print |> printfn "%s"
goodExample |> Infix.parse |> printWithParseResult
badExample |> Infix.parse |> printWithParseResult
|
1:
2:
3:
4:
5:
|
2*x + 3*y + cos(x*y*z)
Error in Ln: 1 Col: 16
2*x + 3*y + cos(x*y*z
^
Expecting: end of input or infix operator
|