namespace Canon.Core.SemanticParser;
///
/// 符号表表项类
///
public class Symbol : IEquatable
{
///
/// 符号的名称
///
public required string SymbolName { get; init; }
///
/// 符号的类型
///
public required PascalType SymbolType { get; init; }
///
/// 是否为常量
///
public bool Const { get; init; }
public bool Equals(Symbol? other)
{
if (other is null)
{
return false;
}
return SymbolName == other.SymbolName
&& SymbolType == other.SymbolType
&& Const == other.Const;
}
public override int GetHashCode()
{
return SymbolName.GetHashCode();
}
public override bool Equals(object? obj)
{
if (obj is not Symbol other)
{
return false;
}
return Equals(other);
}
}