[Mono-dev] Mono-devel-list Digest, Vol 72, Issue 10

Tom Spink tspink at gmail.com
Thu Apr 7 14:30:33 EDT 2011


On 7 April 2011 05:56, Sharp BladeÎÞºñÖ®ÈÐ <sharper.than.bladez at gmail.com> wrote:
> Hello!
>
> Well,since I have a lot of experience with Antlr on C#,it does not
> seem to be a good choice to use jay.And the makefile grammar is quiet
> simple,I wonder if I could write the parser by hand.
>
> Sharp

Hello!

Unfortunately, the Makefile grammar is not as simple as you think, and
simple or not, writing parsers by hand is generally discouraged
nowadays, for the simple reason of:- why re-invent the wheel?

There are tools available for parser (and lexer) generation, which are
tried and tested and I think you'll find you'll make more mistakes
rolling your own parser, than you'll get if you use a parser
generator.

Also, writing an LALR, LR(1) or indeed any bottom-up parser by hand is
quite challenging - even for the simplest grammars.  If you really
went down this route, you'd be best off writing a top-down parser,
which can exponentially increase in size as a grammar increases.  But,
I still wouldn't recommend it, as the more you get into the grammar,
the more you'll find yourself changing your parser and wishing you'd
used a generator.

You'll also need to construct a lexer for the Makefile - which is
itself a daunting challenge.  Particularly because the Makefile syntax
is really quite complex (since it's heavily context-based), so you'd
have trouble implementing a lexer and parser yourself.

Hope this helps,

-- Tom.


More information about the Mono-devel-list mailing list