|RFC - VBS Grammar firstname.lastname@example.org (Larry Lewis) (2000-12-23)|
|Re: RFC - VBS Grammar email@example.com (Joachim Durchholz) (2000-12-31)|
|Re: RFC - VBS Grammar firstname.lastname@example.org (Scott Nicol) (2000-12-31)|
|Re: RFC - VBS Grammar email@example.com (Scott Nicol) (2001-01-04)|
|Re: RFC - VBS Grammar Arargh@Enteract.com (Arargh!) (2001-01-04)|
|From:||"Scott Nicol" <firstname.lastname@example.org>|
|Date:||4 Jan 2001 00:59:22 -0500|
|Posted-Date:||04 Jan 2001 00:59:22 EST|
"Joachim Durchholz" <email@example.com> wrote in message
> Well, I once started to do something with a MS Basic (QuickBasic if
> anybody remembers), did a full analysis of the IF statement, and decided
> to scrap the project ;)
If it's any consolation, you attacked the most difficult part of the
QuickBasic syntax first (print expressions come in as a close second).
> 1. Expression parsing
> 2) Use operator precedence.
This is the easiest way, and it works.
> QuickBasic had a THEN-less form of IF, à la
> IF expression statement [ELSE statement]
This is the one-line IF, and it does have a THEN, but everything has to
occur on one line, and there is no END IF. I don't know if VBS has this or
not. VB supports one-line IF. VBS is a stripped-down version of VB,
specifically designed for embedding scripts within web pages (sort of like
of type Variant), labels, GoTo and GoSub, so I wouldn't be surprised if
one-line IF is not supported. If you want to support one-line IF, it's not
_that_ difficult. You have to distinguish between ':' and end-of-line for
statement terminators, and play around with precedence of the two one-line
IF cases (with and without ELSE) and ':'. I think it took me a few days of
tinkering with the grammar to get it right.
> I decided to scrap my project when I was done with IF and realized that
> I'd have to analyze all the other statements - WHILE, FOR, SWITCH, etc.
These are all straightforward (I assume you mean SELECT instead of SWITCH).
> ... - an alternative might have been to parse just the documented syntax
> and simply declare an error on undocumented stuff.
But that's no fun! Besides, you'll end up breaking lots of code which
relies on all of this undocumented stuff.
Return to the
Search the comp.compilers archives again.