private IfStatementTree parseIfStatement ( ) { SourcePosition start = getTreeStartLocation ( ) ; eat ( TokenType . IF ) ; eat ( TokenType . OPEN_PAREN ) ; ParseTree condition = parseExpression ( ) ; eat ( TokenType . CLOSE_PAREN ) ; ParseTree ifClause = parseStatement ( ) ; ParseTree elseClause = null ; if ( peek ( TokenType . ELSE ) ) { eat ( TokenType . ELSE ) ; elseClause = parseStatement ( ) ; } return new IfStatementTree ( getTreeLocation ( start ) , condition , ifClause , elseClause ) ; }
12 . 5 If Statement