public FunctionDef(LatteParser.MethodDefContext context) { IsMethod = true; Type = context.type(); Id = context.ID().GetText(); Block = new Block(context.block()); var arg = context.arg(); if (arg == null) { Args = new List <Arg>(); } else { var idType = arg.ID().Zip(arg.type(), (id, type) => (id, type)); Args = idType.Select(x => new Arg(x.type, x.id.GetText())).ToList(); } }
public override void ExitMethodDef(LatteParser.MethodDefContext context) { _environment.RestorePreviousVarEnv(); }
public override void EnterMethodDef(LatteParser.MethodDefContext context) { EnterFunctionDef(new FunctionDef(context), context.start.Line, context.block(), context.arg()); }