Exemplo n.º 1
0
        protected void IfStatement()
        {
            short ifTag, elseTag;

            if (!IsIf(Current))
            {
                throw new ExpectedException(Grammar.IF);
            }

            Expression();
            Fin();

            ifTag = emitter.JumpIfFalse();
            Scan();
            Block();
            if (Current == Grammar.ELSE)
            {
                elseTag = emitter.Jump();
                emitter.UpdateJump(ifTag);

                Consume(Grammar.ELSE);
                Block();
                emitter.UpdateJump(elseTag);
            }
            else
            {
                emitter.UpdateJump(ifTag);
            }

            Consume(Grammar.ENDIF);
        }