public override void EnterFunctionDecl(TuringParser.FunctionDeclContext context) { if (context.ID()[0].GetText() != context.ID()[1].GetText()) { PrintErrorAndExit(1001, $"Two function ids `{context.ID()[0].GetText()}`" + $" and `{context.ID()[1].GetText()}` don't match in function declaration"); } InFunction = true; string paramString = String.Join(",", context.formalParam().Select(param => "int " + param.ID().GetText())); OutLine($"static int {context.ID()[0].GetText()} ({paramString}) {{"); }
public override void ExitFunctionDecl(TuringParser.FunctionDeclContext context) { OutLine("}"); InFunction = false; }