using Canon.Core.Enums;
using Canon.Core.LexicalParser;
namespace Canon.Core.SyntaxNodes;
public class ProgramHead : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.ProgramHead;
///
/// 程序名称
///
public IdentifierSemanticToken ProgramName
=> (IdentifierSemanticToken)Children[1].Convert().Token;
///
/// 暂时意义不明的标识符列表
/// https://wiki.freepascal.org/Program_Structure/zh_CN
/// TODO: 查阅资料
///
public IEnumerable FileList => GetFileList();
public static ProgramHead Create(List children)
{
return new ProgramHead { Children = children };
}
private IEnumerable GetFileList()
{
if (Children.Count == 2)
{
yield break;
}
foreach (IdentifierSemanticToken token in Children[3].Convert().Identifiers)
{
yield return token;
}
}
}