Ejemplo n.º 1
0
        public bool Visit(WriteStatementNode node)
        {
            //todo: rmk when add pointers

            foreach (var arg in node.Args)
            {
                arg.Accept(this);

                var realType = arg.Type;

                if (realType is SymTypeAlias symTypeAlias)
                {
                    realType = symTypeAlias.Type;
                }

                switch (realType)
                {
                case SymInt _:
                case SymChar _:
                case SymString _:
                case SymDouble _:
                case SymBool _:
                    break;

                default:
                    var t = ExprNode.GetClosestToken(arg);
                    throw new WritelnUnsupportedType(realType, t.Lexeme, t.Line, t.Column);
                }
            }
            //todo: function cal return lvalues
            return(true);
        }
Ejemplo n.º 2
0
        public PrinterNode Visit(WriteStatementNode node)
        {
            var pNode = new PrinterNode("Wrtite" + (node.IsLn ? "ln" : ""));

            foreach (var arg in node.Args)
            {
                pNode.AddChild(arg.Accept(this));
            }
            return(pNode);
        }