|object oriented implementations of rec. descent parsers email@example.com (1996-10-10)|
|Re: object oriented implementations of rec. descent parsers firstname.lastname@example.org (Scott Stanchfield) (1996-10-12)|
|Re: object oriented implementations of rec. descent parsers parrt@MageLang.com (Terence Parr) (1996-10-12)|
|Re: object oriented implementations of rec. descent parsers email@example.com (1996-10-12)|
|Re: object oriented implementations of rec. descent parsers firstname.lastname@example.org (1996-10-15)|
|Re: object oriented implementations of rec. descent parsers email@example.com (David L Moore) (1996-10-15)|
|Re: object oriented implementations of rec. descent parsers Hans.Walheim@Nexus.SE (Hans T Walheim) (1996-10-16)|
|From:||David L Moore <firstname.lastname@example.org>|
|Date:||15 Oct 1996 09:40:20 -0400|
Hanhwe N Kim wrote:
> I'm trying to find source code examples that
> implement recursive descent parsers in an
> object oriented language (C++ / smalltalk).
Terence Parr wrote:
> PCCTS generates C++ parsers. Grammars ...
> result in a CParser class with member functions for each
This is, of course, using a module structure rather than a class
structure - that is, the class is being used to create a package.
Using classes to emulate packages is a common and valid use of C++
classes, but it is not really object oriented.
A more object oriented approach would be to build a set of classes
representing the static semantics of the language. It seems that
each class should contain a constructor which accepts a file as
parameter and parses it, constructing an appropriate object.
However, there are some problems with this which I think make such an
approach unworkable for a real programming language:
i/ Backtracking will require throwing of exceptions, which tends to
be quite expensive. You probably need to avoid backtracking to get
decent performance (ANTLR will backtrack, I believe)
ii/ Error recovery will be similarly slow.
iii/ You would like to derive more specific objects from more general
objects. For example, an if statement class should be derived from a
general statement class. You would like to be able to add new
syntactic forms solely by derivation. I know of no elegant way to
So, making the parsing part of the behaviour of the classes, which is
what you would want to claim true "object oriented parsing" seems to be
Return to the
Search the comp.compilers archives again.