@Override public String visitBoilerplate(@NotNull InfixParser.BoilerplateContext ctx) { // Declare all functions. ListIterator<InfixParser.FuncContext> funcIt = ctx.func().listIterator(); String funcDefinitions = ""; while (funcIt.hasNext()) { funcDefinitions += visit(funcIt.next()); funcDefinitions += " "; } // Declare all variable names. String varDeclarations = ""; for (VariableSymbol variableSymbol : variableSymbols) { varDeclarations += "variable "; varDeclarations += variableSymbol.getCompiledVariableName(); varDeclarations += " "; } // Generate program code. String formatString = "%s%s: program %s ; program"; forthSource = String.format(formatString, varDeclarations, funcDefinitions, visit(ctx.sequence())); // This is to allow generation of the postscript parse tree at a later time. rootCtx = ctx; return forthSource; }