gregtour / duck-lang

The Duck Programming Language
http://www.ducklang.org
109 stars 13 forks source link

Support else if #17

Closed gregtour closed 9 years ago

gregtour commented 9 years ago

This has been a long time coming. The Duck grammar file needs to be updated to support blocks like the following:

if condition then /* code statements _/ else if othercondition then / code statements / else // optional / code statements */ end

sh19910711 commented 9 years ago

like this?

<if> ::= if <condition> then <endl> <stmt list> <else if>
<else if> ::= else <endl> <stmt list> end
<else if> ::= else <if>
<else if> ::= end
gregtour commented 9 years ago

This CFG seemed to pass all my tests so I merged it into the grammar and rebuilt the interpreter.