Ejemplo n.º 1
0
        //while-statement ::= 'while' '(' <expression> ')' '{' <statement>* '}
        private void ParseWhileStatement()
        {
            //TODO: Consider 'break' support, but requires knowing the label
            //to which we should goto in case of a break (storing it at the
            //class level in a stack, because we could have nested scopes).

            Match(new Token(TokenType.Keyword, "while"));
            Match(new Token(TokenType.Symbol, "("));
            _codeGenerator.BeginWhile();
            ParseExpression();
            _codeGenerator.WhileCondition();
            Match(new Token(TokenType.Symbol, ")"));
            Match(new Token(TokenType.Symbol, "{"));
            ParseStatements();
            Match(new Token(TokenType.Symbol, "}"));
            _codeGenerator.EndWhile();
        }