Tiny language to study parser
I am only an enthusiast programmer. I have the dragon book and I have been trying to understand how a recursive parser works but it's pretty tough for me. I have also been looking at language source code a bit but even small languages are quite complex.
For instance: Lua is about 18K lines of code Sed is about 20K Icon is about 41K Ed (the text editor) is only about 2.7K but seems pretty different to the languages I 开发者_运维问答know.
Can anyone recommend a tiny little language to study? it does not matter if it is useful or not.
Wikipedia refers to "tiny programming language but there is not link to it.
Thanks for reading-Patrick
Tiny was originaly developed by Jack Crenshaw for his pascal based tutorial 'Lets build a compiler' now the tutorial has moved from the link I had! I believe a few people have used it, or something like it in a number of courses to teach the ideas behind compilers.
There is a version here http://www.e-booksdirectory.com/details.php?ebook=1137e
As it stands it outputs assembly targeted at MC680x0 processors as used in Atari ST/comodore Amiga type home computers of the late 1980's.
The code as stated is a intro, most of it is not sophisticated code, it is simple and works just, the parser is of a very basic desgin.
Take a look at the calculator example found on the ANTLR wiki. From there, you can try some other tasks such as parsing CSV files, or the exercises at the bottom of Terrence Parr's class site.
i would suggest studying BNF of some language like c : http://www.cs.man.ac.uk/~pjj/bnf/c_syntax.bnf
Because studying code won't help understanding the recursive parser at all. Figure what BNF is, study C_syntax bnf, try writing some code and parsing it on paper - i wrote my compiler, so this was my start, to try and understand how it works.
精彩评论