Re: Writing a C/C++ compiler in C++

hkaiser@users.sourceforge.net (hkaiser)
12 Feb 2004 11:04:22 -0500

          From comp.compilers

Related articles
Writing a C/C++ compiler in C++ dezakin@usa.net (2004-01-22)
Re: Writing a C/C++ compiler in C++ david.boyle@ed.tadpole.com (2004-01-31)
Re: Writing a C/C++ compiler in C++ haberg@matematik.su.se (2004-02-01)
Re: Writing a C/C++ compiler in C++ jo@spiffy.ox.compsoc.net (Joel Dillon) (2004-02-01)
Re: Writing a C/C++ compiler in C++ vbdis@aol.com (2004-02-01)
Re: Writing a C/C++ compiler in C++ dezakin@usa.net (2004-02-01)
Re: Writing a C/C++ compiler in C++ vbdis@aol.com (2004-02-04)
Re: Writing a C/C++ compiler in C++ hkaiser@users.sourceforge.net (2004-02-12)
Re: Writing a C/C++ compiler in C++ jakacki@hotmail.com (2004-02-12)
Re: Writing a C/C++ compiler in C++ jo@spiffy.ox.compsoc.net (Joel Dillon) (2004-02-13)
Re: Writing a C/C++ compiler in C++ vbdis@aol.com (2004-02-26)
Re: Writing a C/C++ compiler in C++ walter@digitalmars.com (Walter) (2004-02-26)
| List of all articles for this month |
From: hkaiser@users.sourceforge.net (hkaiser)
Newsgroups: comp.compilers
Date: 12 Feb 2004 11:04:22 -0500
Organization: http://groups.google.com
References: 04-01-146 04-02-019
Keywords: C++
Posted-Date: 12 Feb 2004 11:04:22 EST

vbdis@aol.com (VBDis) wrote in message news:04-02-019...
> dezakin@usa.net (Dez Akin) schreibt:
> >As far as I understand it you write a lexer that tokenizes all the
> >symbols, then write a parser that parses all of the tokens
>
> Don't forget the preprocessor! When K&R C could work with an external
> preprocessor, newer C specs require that the preprocessor is part of
> the lexer. The combined lexer/preprocessor then has to recognize
> various "languages", different for C/C++, preprocessor directives and
> (optional) assembly code. If you decide to use an external
> preprocessor, for simplicity, then you may encounter problems with the
> line and column numbers for error messages.
>
> Since I started to implement an halfways conforming C
> lexer/preprocessor, I know why a C compiler is so much slower than
> e.g. the Delphi compiler, as was the topic of an former thread.


Please consider to have a look at the Wave library (currently proposed
for Boost review), which implements a fully Standards conformant C/C++
preprocessing lexer. Essentially it's an iterator, which returns the
preprocessed C/C++ tokens. The used lexer is re2c based, so it is very
flexible and provides comparable characteristics as a hand written
lexer.


Regards Hartmut


Post a followup to this message

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