C++ Parser



This archive contains the JavaCC grammar for the C++ language (file CPLUSPLUS.jj). As it is, the grammar parses an input source file written in C++ without performing any action in response to the grammar productions it applies. Typical usage of the grammar requires the specification of such actions, by means of Java code fragments properly inserted into the grammar productions.


The directory where the TAR archive is opened must be added to the environment variable CLASSPATH.

Execution requires the availability of a Java interpreter (version 1.2 or later) and of a C++ preprocessor (e.g., g++ -E).

Compilation requires the availability of the JavaCC compiler of compilers and of a Java compiler (version 1.2 or later). A precompiled (platform independent) byte code is provided in the TAR archive. Here are the commands to (re-)compile the parser:

 javacc CPLUSPLUS.jj 
 javac CPPParser.java 


Parsing of a given source file (e.g., example.cc) is done in two steps: first, the file is preprocessed, then the parser is executed:
 g++ -E -o example.i -c example.cc 
 java CPPParser example.i 


No external documentation is available. See the book:

B. Stroustrup,
The C++ Programming Language (2nd edition)
Addison-Wesley, 1992

for the grammar specification.