Code: Select all
<line comment> ::= ["REM"|"'"] {<printable character>}+ <newline>
<declaration> ::= "DIM" <variable> {"," <variable>}* "AS" <type>{"(" [<constant>|<variable>] ")"}
<simple conditional> ::= "IF" <boolean clause> "THEN" <block> {"ELSEIF" <boolean clause> "THEN" <block>}* {"ELSE" <block>} "ENDIF"
<compound conditional> ::= "WHERE" [<guarded conditional>|<multiple conditional>] "ENDWHERE"
<guarded conditional> ::= "VALUE" "OF" <variable> <is sequence>
<is sequence> ::= {<is statement>}+ "IS" "DEFAULT" ":" <block> "ENDIS"
<is statement> ::= "IS" <value> {"," <value>}+ ":" <block> ["ENDIS"| "FALLTHRU"]
<multiple conditional> ::= {<result statement>}+ "RESULT" "DEFAULT" ":" <block> "ENDRESULT"
<result clause> ::= "RESULT" "OF" <boolean clause> "IS" <block> "ENDRESULT"
<unconditional loop> ::= "DO" <block> "ENDDO"
<opening-conditional loop> ::= ["WHILE"|"UNTIL"] <boolean clause> <unconditional loop>
<closing-conditional loop> ::= <unconditional loop> ["WHILE"|"UNTIL"] <boolean clause>
<for loop> ::= "FOR" <variable> "FROM" [<constant>|<variable>] ["TO"|"DOWNTO"] [<constant>|<variable>] "STEP" [<constant>|<variable>] <unconditional loop>
<for-each loop> ::= "FOR EACH" <variable> "IN" [<array variable>|<collection variable>] {"USING" <iterator function>} <unconditional loop>
I have also combined all the loop constructs so that the all use a single looping primitive, [tt]DO[/tt]. The different types of conditional loops are all basically variants in this.
I've also come up with a new construct, [tt]WHERE[/tt], which combine both the [tt]SELECT CASE[/tt] form from VB (which is now [tt]VALUE OF... IS[/tt], a more easiyl readable form IMAO) with a new [tt]RESULT OF..IS[/tt], which is somewhat like a [tt](cond)[/tt] statement in Lisp. While it is somewhat redundant (the [tt]IF..THEN..ELSEIF..ELSE[/tt] handles it more or less), it does make it clearer that there are several options in a row coming. Note that the default clause is not optional, though it can be empty.