Пример #1
0
        public override Node VisitFuncDecl([NotNull] TigerParser.FuncDeclContext context)
        {
            var node = new FuncDeclNode(context);

            // ID
            node.Children.Add(
                new IdNode(context.id.Line, context.id.Column, context.id.Text));

            // PARAMS ?
            TigerParser.Type_fieldsContext typeFields = context.type_fields();
            node.Children.Add(
                typeFields == null ?
                null :
                Visit(typeFields));

            // RETURN TYPE ?
            node.Children.Add(
                context.typeId == null ?
                null :
                new IdNode(context.typeId.Line, context.typeId.Column, context.typeId.Text));

            // BODY
            node.Children.Add(Visit(context.expr()));

            return(node);
        }