View Single Post
  #1   Spotlight this post!  
Unread 06-11-2001, 01:20
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Improving PBASIC: Request for Comments

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.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me