Compiler - a Parser Generator Program (CPG) Version 2.0 Open Source Distribution Notes 12/17/2004 Chuck Fayle CPG is an application for specifying formal language grammars and computing, generating, and simulating the corresponding automatons. It has features which significantly extend those of the lex/yacc and flex/bison tools available on UNIX and Linux operating systems. The software is distributed under the terms of the GNU General Public License as specified in the file gpl.txt included with the source code distribution. **** Documentation **** A user guide in .pdf format is included with the distribution. Also included is a document which lists the configurable features of the application framework. Read the supplementary notes at the end of this file. **** Building the Application **** The source code distribution file is cpg_2_0.tar.gz. The source files are extracted into a directory named 'cpg'. The application is built using a gmake file that requires two environment variables for locating the X11 distribution and the Qt object library. The environment variables which must be set and exported are 1) X11DIR = X11R6 distribution root directory ( example: /usr/X11R6 ) 2) QTDIR = Qt object library root directory ( example: /usr/lib/qt3 ) Note that the gmake file is setup to use a shared Qt object library that has been built to support threading and the Standard Template Library using the -thread and -stl configure options respectively. The application uses the STL. All other include files, libraries, compiler, and linker required are standard components of most current Linux operating systems, and the default search paths for the compiler and linker should locate the items. The build should work with Qt library versions 3.x.x and GNU C++ versions 3.x.x. Type 'make' at the root of the CPG source code directory to build the application. Two binary executables are built by the gmake file. 1) compiler - the Qt based GUI application 2) cpgcmd - command line executable The binary executables are located in the 'obj' subdirectory of the root CPG source code directory after the build is complete. The command line executable 'cpgcmd' accepts the same input files as 'compiler' and can be used in automated build systems. The 'cpgcmd' executable is not dependent on the Qt object library. **** Testing the Application **** The 'grammar' subdirectory of the root CPG source code directory contains files with the extension '.grammar'. The '.grammar' files contain grammar and code generation specifications for a number of parsers that are built into the application itself. Make a copy of the 'grammar' directory and open the '.grammar' files with the 'compiler' GUI application for testing and demonstration. For the 'option.grammar' parser use an '.option' file located in the 'misc' subdirectory for input to the simulator. The '.option' files contain application framework configuration options that control the GUI layout and attributes. For the 'regexp.grammar' parser use any regular expression text that conforms to the user guide regular expression specifications for input to the simulator. The 'misc' subdirectory contains the 'regexp.input' file which specifies a regular expression for a floating point operand. In the 'misc' subdirectory the 'precedence.grammar' example illustrates precedence specifications and error token synchronization processing. Also in 'misc' the 'context.grammar' example illustrates regular expression start contexts. **** Supplementary Notes **** Some addendum notes for the user guide. Essential Error Entry Calculations: These calculations are compute intensive in both time and memory, the exact calculation typically much more so than the approximate. When performing these calculations for grammars with over 100 rules it may be useful to run a monitor application especially for 32-bit systems. Code Generation: The code generation dialog has changed as follows: 1) 'Lexical Base Name' edit field has been changed to 'Lexical Prefix Name' 2) 'Parser Base Name' edit field has been changed to 'Parser Prefix Name' 3) 'Base Class Prefix Name' edit field has been added 4) 'Generate Base And Stack Classes' check box has been added The 'Lexical Prefix Name' edit field specifies the identifier prefix string for the derived lexical driver class. The 'Parser Base Name' edit field specifies the identifier prefix string for the derived parser driver class. If the 'Generate Base And Stack Classes' check box is checked then driver base classes and a stack structure are generated. If not then the default versions in the CPG source code directory are used. When the box is checked the 'Base Class Prefix Name' edit field specifies the identifier prefix string for the lexical driver base classes, the parser driver base class, and the stack structure. These code generation parameters can be used to generate multiple parsers with separate class namespaces that utilize either a common or separate parsing stack structure definitions. This simplifies integrating multiple parsers into a single compiled application. Also, the generated files include files from the CPG source code so you must add the root CPG source code directory to the include file search path for builds that incorporate the generated code. For tty test application generation the Makefile created uses an environment variable 'CPG_DIR' to specify the root CPG source code directory and must be set before invoking gmake.