示例#1
0
文件: Print.cs 项目: 4e7/MetaL
 public override string go()
 {
     Lexems.Lexema l = null;
     while ((l = getToken()) != null && l.GetType().Name != "Endl")
     {
         this.lexems.Add(l);
     }
     if (l == null)
     {
         addError(new EndlMissedError(), 0);
     }
     string operand = new Operand(this).go();
     return "\t------------------fake print of "+operand+" \n";
 }
示例#2
0
        public override string go()
        {
            Lexems.Lexema l=null;
            this.result = "ax";
            string s=null;

            while ((l = getToken()) != null && (this.command = isBinaryOperand(l)) == null)
            {
                if (l.GetType().Name == "Begin")
                {

                        this.lexems.Add(l);

                        while ((l = getToken()) != null)
                        {
                            this.lexems.Add(l);
                        }

                    Operand o = new Operand(this);
                    string operand = o.go();
                    this.result = operand;
                    this.calculations = o.calculations;
                    return "\n";

                }
                this.lexems.Add(l);
            }
            if (l == null)
            {

                Operand o =new Operand(this);
                string operand = o.go();
                calculations = o.calculations;
                if (operand != null)
                {

                }
                else
                {
                    addError(new BinaryOperatorOperandMissed(), 0);
                }
                return "\tmov ax," + operand+"\n";
            }
            SubExpression eL = new SubExpression(this);
            string lOperand = eL.go();

            while ((l = getToken()) != null )
            {
                this.lexems.Add(l);
            }

            SubExpression eR = new SubExpression(this);
            string rOperand = eR.go();

            if (lOperand == null||rOperand==null)
            {
                addError(new BinaryOperatorOperandMissed(), 0);
            }
            else
            {
                this.result="ax";
                s = lOperand + "\n";
                s += "\tmov ax," + eL.result+"\n";
                s += rOperand + "\n";
                s += "\t" + command + " ax," + eR.result+"\n";

            }
            return s;
        }