-
Notifications
You must be signed in to change notification settings - Fork 76
Parsing expression from string
WhiteBlackGoose edited this page Feb 15, 2023
·
1 revision
There are a few ways to parse an expression from string.
using AngouriMath;
var expr = MathS.FromString("1 + 1");
It will throw an exception if input is bad.
using AngouriMath;
Entity expr = "1 + 1";
It will also throw an exception in case of bad input.
Unlike others, this one won't throw. However, it returns an object which requries validation:
var expr5 = Parse("a + b").Switch(
res => res,
failure => failure.Reason.Switch<object>(
unknown => throw new("Unknown reason"),
missingOp => throw new("Missing operator"),
internalError => throw new("Internal error")
)
);
If you did not find what you were looking for, feel free to create an issue raising your problem.