summaryrefslogtreecommitdiff
path: root/compiler/Parser/ParserForAttribute.cs
blob: ae149b0fa7f17f54843fcf8d446cc370e0f0bba0 (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
namespace AtLangCompiler;

[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class ParserForAttribute : Attribute
{
    public TokenType TokenType { get; }
    public short InputTokens { get; }
    public string InputSeparator { get; }
    public bool HasBody { get; }
    public TokenType? PrerequisiteToken { get; }

    public ParserForAttribute(TokenType tokenType,
        short inputTokens = 0,
        string inputSeparator = ",",
        bool hasBody = false,
        TokenType prerequisiteToken = TokenType.AT)
    {
        this.TokenType = tokenType;
        this.InputTokens = inputTokens;
        this.InputSeparator = inputSeparator;
        this.HasBody = hasBody;
        this.PrerequisiteToken = prerequisiteToken == TokenType.AT ? null : prerequisiteToken;
    }
}