Exemplo n.º 1
0
        public AstPrinterNode Visit(FormalParamSection node)
        {
            var printer = new AstPrinterNode(node.ToString());

            if (node.ParamModifier != null)
            {
                printer.AddChild(new AstPrinterNode(node.ParamModifier));
            }
            foreach (var param in node.ParamList)
            {
                printer.AddChild(param.Accept(this));
            }

            printer.AddChild(node.ParamType.Accept(this));
            return(printer);
        }
        public bool Visit(FormalParamSection node)
        {
            var paramSectionType = _symStack.FindType(node.ParamType.ToString());

            if (paramSectionType == null)
            {
                throw new Exception(string.Format("({0}, {1}) semantic error: type '{2}' is not found",
                                                  node.ParamType.Token.Line, node.ParamType.Token.Column, node.ParamType.ToString()));
            }

            foreach (var ident in node.ParamList)
            {
                CheckIdentifierDuplicateInScope(ident.Token);
                _symStack.AddParameter(node.ParamModifier, ident.ToString(), paramSectionType);
            }

            return(true);
        }