X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=infobase%2Fexamples%2Fcpp_grammar_code%2Findex.html;fp=infobase%2Fexamples%2Fcpp_grammar_code%2Findex.html;h=af2afda53bb8fd78d3523d5f3efe3192ba9605f5;hb=c589a3686d4508c9c5ea7841deb9be251460ddc3;hp=0000000000000000000000000000000000000000;hpb=4c595ba63a6c5203e104fe83fee43d69d3ff7aef;p=feisty_meow.git diff --git a/infobase/examples/cpp_grammar_code/index.html b/infobase/examples/cpp_grammar_code/index.html new file mode 100644 index 00000000..af2afda5 --- /dev/null +++ b/infobase/examples/cpp_grammar_code/index.html @@ -0,0 +1,196 @@ + + +
+ + +This work area supports a demonstration of the superset C++ +grammar described in Chapter 5 of Ed Willink's thesis on Meta-Compilation +for C++. It contains working lex and yacc grammars that +enable C++ source to be lexically analysed, then syntactically +analysed without semantic knowlege. The lex and yacc grammar have +their action routines defined by macros in the hope that +reconfiguration may be possible without editing the grammars +directly. The dummy implementations of the yacc macros do nothing +other than count statements and diagnose the back-tracking +behaviour. Users may add their own syntactic level code. A proper +C++ parser needs semantic analysis as well, including correction +of minor misprses at the syntactic level. Semantic interpretaion +is provided by FOG +from which this demonstration is split off.
+ +The work area is self-sufficient, requiring only lex +and yacc, or flex and bison.
+ +The test grammar is a simple command line utility, for +analysing a single pre-processed source file +(use CC -E to run just the preprocessor on your source files)..
+ +grammar [options] < source-file+ +
The full set of command line options is:
+ +-c Recognise only C keywords - approximates C rather than C++ parsing + -m Display mark activity. + -n Echo line numbers. + -t Echo source line text. + -y Display yacc diagnostics.+ +
On completion a three line diagnostic summarises the search +activity.
+ +CxxSrc.tgz, CxxNtSrc.tgz +The source distribution kit including a Sun or NT executable.
+ +CxxLexer.l A simple lexer for all C +and/or C++ tokens
+ +CxxParser.y The parser, +automatically extracted from FogParser.y.
+ +CxxToken.hxx, CxxToken.cxx A trivial class used by the +parser to represent each parsed token.
+ +CxxLexing.hxx, CxxLexing.cxx Interface and +implementation of token creation routines for the lexer.
+ +CxxParsing.hxx, CxxParsing.cxx Interface and +implementation of token manioulation routines for the parser.
+ +CxxLexer.cpp, CxxParser.cpp, CxxToken.cpp +Degenerate compilation units for the above.
+ +makefile, makefile.macros, +makefile.unix Unix build scripts
+ +makefile.gmake, makefile.macros, grammar.dsw, +grammar.dsp NT build scripts and +DevStudio workspace and project
+ +sun4o/grammar Built executable (on Unix)
+ +Release/grammar.exe Built executable (on NT)
+ +The code builds under Solaris 2.5 and with Sun C++ 4.2.
+ +make sun+ +
or Gnu egcs-1.0.2 release, with flex 2.3.7, bison 1.16
+ +make gnu+ +
The code builds under NT 4 and has been tested with DevStudio +V6 and cygwin 1.1.
+ +You need cygwin, the latest version of which is available ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/setup.exe
+ +A slightly easier to install earlier version (used by the +author) is ftp://sunsite.org.uk:21/Mirrors/sourceware.cygnus.com/pub/cygwin/old/cygwin-b20/full.exe
+ +Use a mirror site listed at http://sources.redhat.com/cygwin/mirrors.html.
+ +The older cygwin is a simple standard NT installation - just +run full.exe (with administrator rights) and accept the default +installation paths (gnu tools build them in). The newer cygwin is +much smarter, doing automatic selective downloads - which the +author's firewall messes up.
+ +You may want to make cygwin tools accessible from command +prompts so
+ +Start->Settings->ControlPanel + System|Environment + Add Variable PATH + Value C:\cygwin\cygwin-b20\H-i586-cygwin32\BIN+ +
You need to configure DevStudio to use cygwin.
+ +In DevStudio:
+ +Tools->Options->Directories + Show Directories For Executable files + Add C:\cygwin\bin+ +
Then use winzip or gunzip to extract all of CxxNtSrc.tgz:
+ +double click in Explorer on CxxNtSrc.tgz + Yes to decompress archive to temporary file + Wait a few moments + Actions...->Extract + All Files, to e.g. C:\CxxGrammar, use Folder names, Extract + Close Winzip+ +
Double click in Explorer on grammar.dsw + If prompted to browse for a SourceSafe project Click No. + If prompted to attempt SourceSafe connection in another session click No. + Select your preferred configuration (Win32 Debug is default) + Select FileView|grammar Files->Targets->executable + <Ctrl>F7 + after a few seconds everything is built+ +
DevStudio reports 0 errors and 1 warnings
+ +Build : warning : failed to (or don't know how to) build 'C:\CxxGrammar\Targets\executable'+ +
The warning is an artefact of fake build targets
+ +Everything in DevStudio is compiled using a makefile.gmake +target which is selected for a <CTRL>F7 in the Workspace +window. Steer clear of the standard DevStudio F7 which builds all +targets: backup then clean then executables then realclean then +test etc. No harm is done but it takes a long time.
+ +Last updated 28 July, 2001.
+ +