Allow else-if statements

This commit is contained in:
Neemek 2025-01-03 22:35:13 +01:00
parent 0ab370b8e4
commit c170f0c0c6
Signed by: neemek
GPG key ID: 28360A8951CD0E9B

View file

@ -393,7 +393,12 @@ func (p *Parser) statement() (Node, error) {
var otherwise Node var otherwise Node
if p.accept(TokenElse) { if p.accept(TokenElse) {
otherwise, err = p.block(false) // allow else if
if p.curr.Type == TokenIf {
otherwise, err = p.statement()
} else {
otherwise, err = p.block(false)
}
if err != nil { if err != nil {
return nil, err return nil, err
} }