-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseRule.cs
More file actions
24 lines (20 loc) · 837 Bytes
/
ParseRule.cs
File metadata and controls
24 lines (20 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using EsotericDevZone.RuleBasedParser.ParseRulePatterns;
using System;
using System.Linq;
namespace EsotericDevZone.RuleBasedParser
{
internal class ParseRule
{
public string Key { get; }
public IParseRulePatternItem[] ParsePattern { get; }
public Func<ParseResult[], Token[], ParseResult> BuildMethod;
public ParseRule(Parser parser, string key, string[] parsePattern, Func<ParseResult[], Token[], ParseResult> buildMethod)
{
Key = key;
ParsePattern = parsePattern.Select(item => ParseRulePatternItems.FromString(parser, item)).ToArray();
BuildMethod = buildMethod;
}
public override string ToString()
=> $"ParseRule(Key={Key}, ParsePattern='{string.Join(" ", ParsePattern.Select(p => p.ToString()))}')";
}
}