func parseIfStat(lexer *Lexer) *IfStat {
	exps := make([]Exp, 0, 4)
	blocks := make([]*Block, 0, 4)

	lexer.NextTokenOfKind(TOKEN_KW_IF)         // if
	exps = append(exps, parseExp(lexer))       // exp
	lexer.NextTokenOfKind(TOKEN_KW_THEN)       // then
	blocks = append(blocks, parseBlock(lexer)) // block

	for lexer.LookAhead() == TOKEN_KW_ELSEIF {
		lexer.NextToken()                          // elseif
		exps = append(exps, parseExp(lexer))       // exp
		lexer.NextTokenOfKind(TOKEN_KW_THEN)       // then
		blocks = append(blocks, parseBlock(lexer)) // block
	}

	// else block => elseif true then block
	if lexer.LookAhead() == TOKEN_KW_ELSE {
		lexer.NextToken()                           // else
		exps = append(exps, &TrueExp{lexer.Line()}) //
		blocks = append(blocks, parseBlock(lexer))  // block
	}

	lexer.NextTokenOfKind(TOKEN_KW_END) // end
	return &IfStat{exps, blocks}
}
// if exp then block {elseif exp then block} [else block] end
if exp then block {elseif exp then block} [else block] end
// if exp then block { elseif exp then block } [ else block ] end
func parseIfStat(lexer *Lexer) *IfStat {
	exps := make([]Exp, 0, 4)
	blocks := make([]*Block, 0, 4)
	lexer.NextTokenOfKind(TOKEN_KW_IF)         
	exps = append(exps, parseExp(lexer))       
	lexer.NextTokenOfKind(TOKEN_KW_THEN)       
	blocks = append(blocks, parseBlock(lexer)) 
	for lexer.LookAhead() == TOKEN_KW_ELSEIF {
		lexer.NextToken()                          
		exps = append(exps, parseExp(lexer))       
		lexer.NextTokenOfKind(TOKEN_KW_THEN)       
		blocks = append(blocks, parseBlock(lexer)) 
	}
	if lexer.LookAhead() == TOKEN_KW_ELSE {
		lexer.NextToken()                           
		exps = append(exps, &TrueExp{lexer.Line()}) 
		blocks = append(blocks, parseBlock(lexer))  
	}
	lexer.NextTokenOfKind(TOKEN_KW_END)  end
	return &IfStat{exps, blocks}
}
func parseIfStat ( lexer * Lexer ) * IfStat { exps := make ( [ ] Exp , 0 , 4 ) blocks := make ( [ ] * Block , 0 , 4 ) lexer . NextTokenOfKind ( TOKEN_KW_IF ) exps = append ( exps , parseExp ( lexer ) ) lexer . NextTokenOfKind ( TOKEN_KW_THEN ) blocks = append ( blocks , parseBlock ( lexer ) ) for lexer . LookAhead ( ) == TOKEN_KW_ELSEIF { lexer . NextToken ( ) exps = append ( exps , parseExp ( lexer ) ) lexer . NextTokenOfKind ( TOKEN_KW_THEN ) blocks = append ( blocks , parseBlock ( lexer ) ) } if lexer . LookAhead ( ) == TOKEN_KW_ELSE { lexer . NextToken ( ) exps = append ( exps , & TrueExp { lexer . Line ( ) } ) blocks = append ( blocks , parseBlock ( lexer ) ) } lexer . NextTokenOfKind ( TOKEN_KW_END ) return & IfStat { exps , blocks } }
if exp then block {elseif exp then block} [else block] end
if exp then block { elseif exp then block } [ else block ] end
// if // exp // then // block // elseif // exp // then // block // else block => elseif true then block // else // // block // end