AngouriMath

Navigation

← Back to list of members

Parse​(System.​String)

 Method (no overloads)

Summary

Parses an expression silently, that is,
without throwing an exception. Instead,
it returns a Failure in case of encountered
errors during parsing.

Returns

Returns a type union of the successful result and
failure, which is a type union of multiple reasons
it may have failed.

Example

Multiple ways to parse an expression.
Entity expr1 = "a + b";
var expr2 = FromString("a + b");
var expr3 = FromString("a + b", useCache: false);
var expr4 = (Entity)"a + b";
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") 
    )
);

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online