Back at the end of last month, there was a
Simplifying PBasic thread going in the General Forum. I mentioned I was going to enhance my BASIC Stamp Preprocessor to add a block IF capability (IF ... ELSEIF ... ELSE ... ENDIF).
Here is my proposed syntax:
Code:
'{$IF condition 1}
statement block 1
'{$ELSEIF condition 2}
statement block 2
...
'{$ELSE}
statement block n
'{$ENDIF}
Which the preprocessor would translate to:
Code:
if (condition 1) then Label1
if (condition 2) then Label2
...
statement block n
goto EndIfLabel
Label1:
statement block 1
goto EndIfLabel
Label2:
statement block 2
goto EndIfLabel
...
EndIfLabel:
Where Label1, Label2, EndIfLabel are labels generated by the preprocessor.
My intention is to allow nested $IF ... $ENDIFs -- although I haven't worked out just how I'm going to implement that yet. I may end up disallowing nesting if implementation becomes too hairy -- or at least not supporting it in the initial implementation(s).
What do y'all think?
FYI: I chose the '{$directive parameter} format to match the '{$Stamp } directive format since I needed to parse it anyway to get the list project files.