aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/src/Godosa.Core/Runs/Scripts/ScriptAst.cs
blob: 9fa265493d569e41698c2a99b497992521e72019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Provenance: own design — shared run scripts
namespace Godosa.Core.Runs.Scripts;

public enum BlockKind { Setup, Step, Try }

/// <summary>One parsed line (or block header) of a <c>.steps</c> file; <see cref="Text"/> = the trimmed source line.</summary>
public abstract record Node(SourceRef At, string Text);
public sealed record VerbNode(SourceRef At, string Text, string Verb, string Args) : Node(At, Text);
public sealed record WaitNode(SourceRef At, string Text, string Condition, int Timeout) : Node(At, Text);
public sealed record ExpectNode(SourceRef At, string Text, string Condition) : Node(At, Text);
public sealed record SetNode(SourceRef At, string Text, string Name, string Value) : Node(At, Text);
public sealed record IncludeNode(SourceRef At, string Text, string Path) : Node(At, Text);
public sealed record CallNode(SourceRef At, string Text, string Name, IReadOnlyList<string> Args) : Node(At, Text);
public sealed record CheckpointNode(SourceRef At, string Text, string Name) : Node(At, Text);
public sealed record BlockNode(SourceRef At, string Text, BlockKind Kind, string? Label, IReadOnlyList<Node> Body) : Node(At, Text);
public sealed record DefNode(SourceRef At, string Text, string Name, IReadOnlyList<string> Params, IReadOnlyList<Node> Body) : Node(At, Text);

public sealed record ScriptFile(string Path, int Format, RunMode? Mode, ulong? Seed, IReadOnlyList<string> VarFiles,
    IReadOnlyList<Node> Body, IReadOnlyList<ScriptError> Errors);

public static class ScriptFormat
{
    /// <summary>Newest format version this runner knows; every older one stays supported.</summary>
    public const int Latest = 1;
}