[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strategies for learning new languages

>    On the task of writing a compiler in a new language:
>    This may be cheating as far as the idea of writing a compiler would help
>    in successfully learning a new language, and please accept my apologies if
>    this is a silly question - I am a student and I should have probably asked
>    my CS lecturer, but do any (little or large) languages come with a parser
>    generator suitable for creating an XML parser or language parser?
>    I have just started reading the 'Dragon book' Principles of Compiler
>    Design by Aho and Ullman, and while much of it is going over my head, the
>    tools lex and yacc seem to be amazing tools, that I would like in whatever
>    language I end up using. Am I overestimating the value of such tools, or
>    are they unsuitable to be included as part of a language?

I wouldn't say you're overestimating their value... They're very
popular and very valuable, although they're by no means the silver
bullet. Generally tools like these are provided as separate packages
for a given language (as lex/yacc and friends are for C and sometimes
C++). Sometimes they're separate but distributed together, as I
believe is the case with ML-Yacc and SML of New Jersey. A few
languages or languages dialects provide such functionality
in-language. The only example I can think of right now is the Bigloo
Scheme compiler, which has library functions and special forms devoted
to the construction and use of regular and context-free grammars (note
that these are NOT part of standard Scheme).

In my opinion, this is a mixed bag. It's convenient in many ways to be
able to write grammars as syntactically normal language constructs,
manipulate them as normal data structures, etc., and it's nice that
the normal compilation process takes care of the whole thing. On the
other hand, there are some advantages to maintaining these as separate
tools: they're easily replaceable by more suitable versions with extra
features or whatever, and they may have a more natural syntax for
grammar constructs or a more natural interface for error reporting,
etc. All in all, I suppose I'm a fan of the Bigloo approach. You can
always resort to separate tools when desirable.


Matt Hellige                  matt@immute.net