private ParseTree parseDoWhileStatement ( ) { SourcePosition start = getTreeStartLocation ( ) ; eat ( TokenType . DO ) ; ParseTree body = parseStatement ( ) ; eat ( TokenType . WHILE ) ; eat ( TokenType . OPEN_PAREN ) ; ParseTree condition = parseExpression ( ) ; eat ( TokenType . CLOSE_PAREN ) ; // The semicolon after the "do-while" is optional. if ( peek ( TokenType . SEMI_COLON ) ) { eat ( TokenType . SEMI_COLON ) ; } return new DoWhileStatementTree ( getTreeLocation ( start ) , body , condition ) ; }
12 . 6 . 1 The do - while Statement