27 March 2000 Release 2.22 Notes for New Users of PCCTS Version 1.33MR22
49
#13. How to convert a failed validation predicate into a signal for treatment by parser exception handling
See files notes/sim/*
This program intercepts a failed validation predicate in order to pass a signal back up the call tree. The example
includes code which takes the signal returned by the start rule and invokes the default handler
This example is not as clean as I would like because of the difficulty of adding new behavior to a parser class.
#14. How to use Vern Paxson's flex with
PCCTS
in C++ mode by inheritance from
ANTLR
TokenStream
See files example.flex and flexLexer.* in notes/flex/*
#15. Using the GNU gperf (generate perfect hashing function) with
PCCTS
See files in notes/gperfex/*
The scanner generated by
DLG
can be very large. For grammars which contain a large number of keywords it might
make sense to the use of the GNU program "gperf". The gperf programs attempts to generate a "minimal perfect
hash function" for testing whether an argument is among a fixed set of strings such as those used in the reserved
words of languages it has a large number of options to specify space/time trade-offs and the style of the code
generated (e.g. C++ vs. C, case sensitivity, arrays vs. case statements, etc.).
As a test I found that a grammar with 25 keywords caused
DLG
to generate a file
DLG
Lexer.cpp with 22,000
characters. Changing the lexical analysis code to use gperf resulted in a file
DLG
Lexer.cpp that was 2,800
characters. The file generated by gperf was about 3,000 characters.
The gperf program was originally written by Douglas C. Schmidt. It is based on an algorithm developed by Keith
Bostic. The gperf program is covered by the GNU General Public License. I do not know what restrictions there are
on the output of gperf. The source code can be found in comp.sources.unix, volume 20.
Among the many
FTP
sites with comp.sources.unix here are two:
ftp.cis.ohio-state.edu/pub/comp.sources.unix/Volume20/gperf
ftp.informatik.tu-muenchen.de/pub/comp/usenet/comp.sources.unix/gperf
#16. Multiple files managed as a single token stream
See files in notes/nested/*
This example manages a file which may have an #include statement as a single stream of tokens.