newbie : modifying C++ grammar

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Fri Sep 15 13:17:00 GMT 2006


Suresh Shukla wrote:
> I have downloaded and built gcc-core and gcc-g++ (both
> 4.1.1). 
> 
> I am not able to locate the yacc file for C++. 
> I want to experiment with some grammar changes.

All parsers in GCC, but the Java parser, are hand written.  The C++ 
parser is in gcc/cp/parser.c and was rewritten for 3.4.  It is a 
backtracking recursive-descent parser (Fortran is one too; C does not 
need backtracking).  Though there are examples of C++ grammars written 
using Yacc, C++ and Fortran are so complex (and C comes close when you 
add OpenMP for example) that using Yacc only adds complexity.

Paolo



More information about the Gcc mailing list