Re: Generating a simple hand-coded like recursive descent parser

Tommy Thorn <tommy.thorn@gmail.com>
18 Sep 2006 09:45:58 -0400

          From comp.compilers

Related articles
[13 earlier articles]
Re: Generating a simple hand-coded like recursive descent parser mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-09-11)
Re: Generating a simple hand-coded like recursive descent parser mr.waverlye@verizon.net (Mr.E) (2006-09-11)
Re: Generating a simple hand-coded like recursive descent parser ArarghMail609@Arargh.com (2006-09-11)
Re: Generating a simple hand-coded like recursive descent parser mr.waverlye@verizon.net (Mr.E) (2006-09-11)
Re: Generating a simple hand-coded like recursive descent parser tommy.thorn@gmail.com (Tommy Thorn) (2006-09-12)
Re: Generating a simple hand-coded like recursive descent parser mr.waverlye@verizon.net (Mr.E) (2006-09-16)
Re: Generating a simple hand-coded like recursive descent parser tommy.thorn@gmail.com (Tommy Thorn) (2006-09-18)
Re: Generating a simple hand-coded like recursive descent parser DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-09-21)
Re: Generating a simple hand-coded like recursive descent parser chris.dollin@hp.com (Chris Dollin) (2006-09-22)
Re: Generating a simple hand-coded like recursive descent parser DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-09-25)
Re: Generating a simple hand-coded like recursive descent parser chris.dollin@hp.com (Chris Dollin) (2006-09-25)
Re: Generating a simple hand-coded like recursive descent parser DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-09-26)
Re: Generating a simple hand-coded like recursive descent parser zebedee@zebedee.net (zebedee) (2006-09-28)
[26 later articles]
| List of all articles for this month |

From: Tommy Thorn <tommy.thorn@gmail.com>
Newsgroups: comp.compilers
Date: 18 Sep 2006 09:45:58 -0400
Organization: Sonic.Net
References: 06-09-02906-09-042 06-09-048 06-09-060 06-09-078
Keywords: parse
Posted-Date: 18 Sep 2006 09:45:58 EDT

Mr.E wrote:
> For me this is a labor of love but at the moment it's just laborious.


Which part is laborious? Hopefully not understanding the snippets I've
shown you.




> I've wanted to learn to write a compiler for years. So many
> concepts and intricacies that I never had to think about just using
> a language are becoming painfully obvious to me as a first time
> compiler writer.


Welcome to the new world. By far the best way to fully learn a
programming language is to write a compiler for it. That is where you
really have to consider all details. For example, before actually doing
to work, most people think that C is an LALR(1) language or simpler (*).


For me compilers are really fun. I can only recommend that you take it
very slow. Focus on compiling a tiny language fully from source to
something executable, and then grow it slowly to a full language. This
is much better than trying to make a parser for the full language right
off the bat.




> Syntax analysis, semantic analysis, error recovery has my head
> throbbing. I really want my first compiler to be completely hand
> written so I can really appreciate the intricacies of writing one.


For a small language, that trivial enough to do. Even Linus shunned
automatic parser generators when we wrote his Semantic C checker
(sparse). I agree with him, for a stable language, automatic tools are
not worth the trouble. You end up wasting time and energy dealing with
and learning about them, rather than working on your compiler.




> At the same time I'm thinking there are tools available that would make
> the job so much simpler, probably faster, with fewer errors.


No tool can replace understanding. Once you understand, you'll see that
the parser generators don't really save you much time.


I have a follow up to my example, but I think I'll post that in a
separate article as this is long enough already.


Tommy




(*) It's not. The lexer has to know which names are types, otherwise it
becomes impossible to tell if the statement
      x * y;
is a declation of a pointer to x or an expression multiplying x and y.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.