use new exit lable

This commit is contained in:
Youmu Liu
2026-09-14 18:21:23 +08:00
parent 9e9078ced1
commit 57587bec16
6 changed files with 169 additions and 197 deletions
+8 -2
View File
@@ -38,8 +38,14 @@ namespace Nitload
SequenceEmitter<string> body = new();
List<SequenceEmitter<string>> functions = [];
SourceGenContext context = new();
ExitLabel exit = context.RequestExitLabel(ExitMode.Goto);
GenerateMethodSource(analysis.Ast.Root, body, functions, context, exit);
ExitLabel local_fail = context.RequestExitLabel(ExitKind.MatchFailed);
ExitLabel backtrack = local_fail;
ExitLabel end = context.RequestExitLabel(ExitKind.MatchEnd);
GenerateMethodSource(analysis.Ast.Root, body, functions, context, local_fail, ref backtrack);
_ = body.AppendLine($"goto {end.GetLabelName()};")
.AppendLine($"{local_fail.GetLabelName()}: {{}}")
.AppendLine("// TODO(NGRA): Produce the root failure result here.")
.AppendLine($"{end.GetLabelName()}: {{}}");
foreach (string line in body.ToList()) {
Console.WriteLine(line);