Exemplo n.º 1
0
        public Stmt Assign()
        {
            Stmt stmt;
            var  tok = _look;

            this.Match(Tag.ID);
            var id = Top.Get(tok);

            if (id == null)
            {
                this.Error(tok.ToString() + " undeclared");
            }

            if (_look.TagValue == '=')
            {
                this.Move();
                stmt = new Set(id, this.Bool());
            }
            else
            {
                Access x = this.Offset(id);
                this.Match('=');
                stmt = new SetElem(x, this.Bool());
            }

            this.Match(';');
            return(stmt);
        }
Exemplo n.º 2
0
 public void TestSetElem()
 {
     var acc = new Access(new Id(new Word("arr", Tag.ID), Sara.Type.Int,0x20), new Constant(20),Sara.Type.Int);
     var setElem = new SetElem(acc, new Constant(42));
     setElem.Gen(10, 20);
     //Output:	
     //          arr [ 20 ] = 42
 }
Exemplo n.º 3
0
        public Stmt Assign()
        {
            Stmt stmt;
            var tok = _look;

            this.Match(Tag.ID);
            var id = Top.Get(tok);
            if (id == null)
                this.Error(tok.ToString() + " undeclared");

            if(_look.TagValue == '=')
            {
                this.Move();
                stmt = new Set(id, this.Bool());
            }
            else 
            {
                Access x = this.Offset(id);
                this.Match('=');
                stmt = new SetElem(x, this.Bool());
            }

            this.Match(';');
            return stmt;
        }