2024-03-13 16:41:44 +08:00
|
|
|
|
using Canon.Core.GrammarParser;
|
|
|
|
|
|
|
|
|
|
namespace Canon.Core.Abstractions;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进行归约需要的信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Length">归约的长度</param>
|
|
|
|
|
/// <param name="Left">归约得到的左部符号</param>
|
2024-04-08 19:46:24 +08:00
|
|
|
|
public record ReduceInformation(int Length, NonTerminator Left)
|
|
|
|
|
{
|
|
|
|
|
public string GenerateCode()
|
|
|
|
|
{
|
|
|
|
|
return $"new ReduceInformation({Length}, {Left.GenerateCode()})";
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-13 16:41:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 状态的各种迁移信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface ITransformer
|
|
|
|
|
{
|
2024-04-08 19:46:24 +08:00
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
2024-03-13 16:41:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进行移进的信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IDictionary<TerminatorBase, ITransformer> ShiftTable { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进行归约的信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IDictionary<Terminator, ReduceInformation> ReduceTable { get; }
|
|
|
|
|
}
|