public override Tree VisitFuncDeclaration(FuncDeclarationContext context) { String name = context.name.Text; ResultContext resultContext = context.result(); IList <FormalParameterContext> parameterContexts = context._params; bool isPrivate = context.isPrivate; TypeContext resType = resultContext.type(); TypeTree type; if (resType != null) { type = (TypeTree)VisitType(resType); } else { //void IToken voidToken = resultContext.Start; int len = voidToken.StopIndex - voidToken.StartIndex; type = new PrimitiveTypeNode(voidToken.Line, voidToken.Column, voidToken.Line, voidToken.Column + len, TypeTag.VOID); } VariableDeclaration[] parameters = new VariableDeclaration[parameterContexts.Count]; for (int i = 0; i < parameterContexts.Count; i++) { parameters[i] = (VariableDeclaration)VisitFormalParameter(parameterContexts[i]); } Block block = (Block)VisitBlock(context.funcBody().block()); return(new FuncDef(type.beginLine, type.beginCol, block.endLine, block.endCol, name, type, parameters, block, isPrivate)); }