"Johnathan" <zork_666@[EMAIL PROTECTED]
> wrote in message
news:404c846b$0$22531$5a62ac22@[EMAIL PROTECTED]
> Hi,
>
> I'm looking for a BASIC grammar. Not necessarily the original BASIC
> language - I'd be happy with a more modern dialect like QBasic. I can
> infer a lot from Microsoft's QBASIC help file, but I'd really like to
> get my hands on a LL(1) grammar. I could probably try to write my own,
> but I don't know enough about compiler theory to do it. I'd like to
> take a stab at writing a recursive descent parser. So bearing this in
> mind, small is beautiful at this stage. :)
>
> Thankyou,
> Johnathan
Basic was one of the first languages I ever compiled/interpreted. You can,
by the way, find a Basic interpreter written in basic at:
www.moorecad.com/classicbasic
I always wrote my own grammar for Basic. You learn a lot by doing that,
and if you are going to subset Basic, you should learn how to construct
a grammar for that. Don't get hung up on the formalities. Do a "railroad
track" diagram first. The grammar will flow from that.
I recommend you use Basic as your language to implement in. Don't laugh.
you learn way more about a language by trying to write in it, and your
result will be able to compile/interpret itself -- a real, satisfying
goal of your work.
I also recommend you try making an interpreter first, at about the tolken
level. You will learn a lot from that project.
When you go fro mthe compiler, compile for a virtual machine that takes
abstract instructions on a stack machine. Its simple, you can always
add true machine code generation if you like later, and the entire project
will be up and running faster with fewer machine language hassles.
You can build the VM in the same language, in fact you can put it into
the compiler itself.
Luck.


|