|
10 | 10 | namespace SER.Code.MethodSystem.Methods.ParsingMethods; |
11 | 11 |
|
12 | 12 | [UsedImplicitly] |
13 | | -public class ParseResultMethod : ReturningMethod, ICanError, IReferenceResolvingMethod |
| 13 | +public class ResultInfoMethod : ReturningMethod, ICanError, IReferenceResolvingMethod |
14 | 14 | { |
15 | 15 | public override string Description => "Returns information from the parsing result."; |
16 | 16 |
|
17 | 17 | public override TypeOfValue Returns => new UnknownTypeOfValue(); |
18 | 18 |
|
19 | | - public Type ReferenceType => typeof(ParseResult); |
| 19 | + public Type ResolvesReference => typeof(Result); |
20 | 20 |
|
21 | 21 | public string[] ErrorReasons => |
22 | 22 | [ |
23 | | - "Tried to access the value when the parsing was not successful" |
| 23 | + "Tried to access the value when the result was not successful" |
24 | 24 | ]; |
25 | 25 |
|
26 | 26 | public override Argument[] ExpectedArguments { get; } = |
27 | 27 | [ |
28 | | - new ReferenceArgument<ParseResult>("parsing result"), |
| 28 | + new ReferenceArgument<Result>("parsing result"), |
29 | 29 | new OptionsArgument("info", |
30 | 30 | new("success", "Returns true if the parsing was successful"), |
| 31 | + new("failed", "Returns true if the parsing has failed"), |
31 | 32 | new("value", "The value that got parsed") |
32 | 33 | ) |
33 | 34 | ]; |
34 | 35 |
|
35 | 36 | public override void Execute() |
36 | 37 | { |
37 | | - var parseResult = Args.GetReference<ParseResult>("parsing result"); |
| 38 | + var parseResult = Args.GetReference<Result>("parsing result"); |
38 | 39 | ReturnValue = Args.GetOption("info") switch |
39 | 40 | { |
40 | 41 | "success" => new BoolValue(parseResult.Success), |
41 | 42 | "value" => parseResult.Value ?? throw new ScriptRuntimeError(this, ErrorReasons[0]), |
| 43 | + "failed" => new BoolValue(!parseResult.Success), |
42 | 44 | _ => throw new AndrzejFuckedUpException() |
43 | 45 | }; |
44 | 46 | } |
|
0 commit comments