Canon/Canon.Core/SyntaxNodes/ProgramStruct.cs
jackfiled d381f56e1d fix: 修复编译中的一些小问题 (#52)
Co-authored-by: Lan_G <2911328695@qq.com>
Reviewed-on: PostGuard/Canon#52
2024-04-22 21:48:57 +08:00

31 lines
781 B
C#

using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
public class ProgramStruct : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.ProgramStruct;
/// <summary>
/// 程序头
/// </summary>
public ProgramHead Head => Children[0].Convert<ProgramHead>();
/// <summary>
/// 程序体
/// </summary>
public ProgramBody Body => Children[2].Convert<ProgramBody>();
public static ProgramStruct Create(List<SyntaxNodeBase> children)
{
return new ProgramStruct { Children = children };
}
public override void GenerateCCode(CCodeBuilder builder)
{
builder.AddString("#include <stdbool.h>");
Body.GenerateCCode(builder);
}
}