4 <meta http-equiv="Content-Type"
5 content="text/html; charset=iso-8859-1">
6 <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
7 <title>Ed's Toolkit</title>
10 <body bgcolor="#FFFFFF">
12 <h1 align="center">Superset C++ Grammar</h1>
16 <p>This work area supports a demonstration of the superset C++
17 grammar described in Chapter 5 of <a
18 href="mailto:Ed.Willink@rrl.co.uk">Ed Willink</a>'s thesis on <a
19 href="http://www.computing.surrey.ac.uk/research/dsrg/fog/FogThesis.html">Meta-Compilation
20 for C++</a>. It contains working lex and yacc grammars that
21 enable C++ source to be lexically analysed, then syntactically
22 analysed without semantic knowlege. The lex and yacc grammar have
23 their action routines defined by macros in the hope that
24 reconfiguration may be possible without editing the grammars
25 directly. The dummy implementations of the yacc macros do nothing
26 other than count statements and diagnose the back-tracking
27 behaviour. Users may add their own syntactic level code. A proper
28 C++ parser needs semantic analysis as well, including correction
29 of minor misprses at the syntactic level. Semantic interpretaion
31 href="http://www.computing.surrey.ac.uk/research/dsrg/fog/">FOG</a>
32 from which this demonstration is split off.</p>
34 <p>The work area is self-sufficient, requiring only <em>lex</em>
35 and <em>yacc</em>, or <em>flex</em> and <em>bison</em>.</p>
41 <p>The test grammar is a simple command line utility, for
42 analysing a single <strong>pre-processed</strong> source file
43 (use CC -E to run just the preprocessor on your source files)..</p>
45 <pre> grammar [options] < source-file</pre>
47 <p>The full set of command line options is:</p>
49 <pre> -c Recognise only C keywords - approximates C rather than C++ parsing
50 -m Display mark activity.
52 -t Echo source line text.
53 -y Display yacc diagnostics.</pre>
55 <p>On completion a three line diagnostic summarises the search
62 <p><a href="CxxSrc.tgz">CxxSrc.tgz</a>, <a href="CxxNtSrc.tgz">CxxNtSrc.tgz</a>
63 The source distribution kit including a Sun or NT executable.</p>
65 <p><a href="CxxLexer.l">CxxLexer.l</a> A simple lexer for all C
68 <p><a href="CxxParser.y">CxxParser.y</a> The parser,
69 automatically extracted from FogParser.y.</p>
71 <p><a href="CxxToken.hxx">CxxToken.hxx</a>, <a
72 href="CxxToken.cxx">CxxToken.cxx</a> A trivial class used by the
73 parser to represent each parsed token.</p>
75 <p><a href="CxxLexing.hxx">CxxLexing.hxx</a>, <a
76 href="CxxLexing.cxx">CxxLexing.cxx</a> Interface and
77 implementation of token creation routines for the lexer.</p>
79 <p><a href="CxxParsing.hxx">CxxParsing.hxx</a>, <a
80 href="CxxParsing.cxx">CxxParsing.cxx</a> Interface and
81 implementation of token manioulation routines for the parser.</p>
83 <p><a href="CxxLexer.cpp">CxxLexer.cpp</a>, <a
84 href="CxxParser.cpp">CxxParser.cpp</a>, <a href="CxxToken.cpp">CxxToken.cpp</a>
85 Degenerate compilation units for the above.</p>
87 <p><a href="makefile">makefile</a>, <a href="makefile.macros">makefile.macros</a>,
88 <a href="CxxLexer.l">makefile.unix</a> Unix build scripts</p>
90 <p><a href="makefile.gmake">makefile.gmake</a>, <a
91 href="makefile.macros">makefile.macros</a>, <a href="grammar.dsw">grammar.dsw</a>,
92 <a href="grammar.dsp">grammar.dsp</a> NT build scripts and
93 DevStudio workspace and project</p>
95 <p><a><u>sun4o/grammar</u></a> Built executable (on Unix)</p>
97 <p><a><u>Release/grammar.exe</u></a> Built executable (on NT)</p>
103 <p>The code builds under Solaris 2.5 and with Sun C++ 4.2.</p>
107 <p>or Gnu egcs-1.0.2 release, with flex 2.3.7, bison 1.16</p>
115 <p>The code builds under NT 4 and has been tested with DevStudio
116 V6 and cygwin 1.1.</p>
120 <p>You need cygwin, the latest version of which is available <a
121 href="ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/setup.exe">ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/setup.exe</a></p>
123 <p>A slightly easier to install earlier version (used by the
125 href="ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/old/cygwin-b20/full.exe">ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/old/cygwin-b20/full.exe</a></p>
127 <p>Use a mirror site listed at <a
128 href="http://sources.redhat.com/cygwin/mirrors.html">http://sources.redhat.com/cygwin/mirrors.html</a>.</p>
130 <p>The older cygwin is a simple standard NT installation - just
131 run full.exe (with administrator rights) and accept the default
132 installation paths (gnu tools build them in). The newer cygwin is
133 much smarter, doing automatic selective downloads - which the
134 author's firewall messes up.</p>
136 <h3>b) Path configuration</h3>
138 <p>You may want to make cygwin tools accessible from command
141 <pre>Start->Settings->ControlPanel
144 Value C:\cygwin\cygwin-b20\H-i586-cygwin32\BIN</pre>
146 <h3>c) DevStudio configuration</h3>
148 <p>You need to configure DevStudio to use cygwin.</p>
152 <pre>Tools->Options->Directories
153 Show Directories For Executable files
154 Add C:\cygwin\bin</pre>
156 <h3>d) Unpacking</h3>
158 <p>Then use winzip or gunzip to extract all of <a
159 href="CxxNtSrc.tgz">CxxNtSrc.tgz</a>:</p>
161 <pre>double click in Explorer on <a href="CxxNtSrc.tgz">CxxNtSrc.tgz</a>
162 Yes to decompress archive to temporary file
164 Actions...->Extract
165 All Files, to e.g. C:\CxxGrammar, use Folder names, Extract
168 <h3>e) DevStudio build</h3>
170 <pre>Double click in Explorer on <a href="grammar.dsw">grammar.dsw</a>
171 If prompted to browse for a SourceSafe project Click No.
172 If prompted to attempt SourceSafe connection in another session click No.
173 Select your preferred configuration (Win32 Debug is default)
174 Select FileView|grammar Files->Targets->executable
176 after a few seconds everything is built</pre>
178 <p>DevStudio reports 0 errors and 1 warnings</p>
180 <pre>Build : warning : failed to (or don't know how to) build 'C:\CxxGrammar\Targets\executable'</pre>
182 <p>The warning is an artefact of fake build targets</p>
184 <p>Everything in DevStudio is compiled using a makefile.gmake
185 target which is selected for a <CTRL>F7 in the Workspace
186 window. Steer clear of the standard DevStudio F7 which builds all
187 targets: backup then clean then executables then realclean then
188 test etc. No harm is done but it takes a long time.</p>
192 <p><i>Last updated <!--webbot bot="Timestamp" startspan
193 s-type="EDITED" s-format="%d %B, %Y" -->28 July, 2001<!--webbot
194 bot="Timestamp" i-checksum="21078" endspan -->.</i> </p>