public override AstNode VisitParam(ALangParser.ParamContext context) { return(new ParameterNode(context) { Identifier = context.ID().GetText(), Type = Type.GetType(context) }); }
public override AstNode VisitFunction(ALangParser.FunctionContext context) { var functionNode = new FunctionNode(); functionNode.Identifier = context.ID().GetText(); if (context.@params() != null) { functionNode.Params = context.@params().Accept(this); } functionNode.Type = Type.GetType(context); functionNode.AdoptChildren(context.stmts().Accept(this)); return(functionNode); }
public override AstNode VisitDcl(ALangParser.DclContext context) { AstNode node; if (context.functioncall() != null) { node = context.functioncall().Accept(this); } else { var dclNode = new DeclarationNode(context); if (context.primaryExpression() != null) { dclNode.RightHandSide = context.primaryExpression().Accept(this); } dclNode.Identifier = context.ID().GetText(); dclNode.Type = Type.GetType(context); node = dclNode; } return(node); }