27 March 2000 Release 2.22 Notes for New Users of PCCTS Version 1.33MR22
42
#174. Subclassing
DLG
InputStream
To subclass
DLG
InputStream requires
DLG
LexerBase which is dependent on
ANTLR
TokenType. However the values
of the
ANTLR
TokenType may not be known at the time. The workaround is to define a dummy
ANTLR
TokenType in
the header file for your subclass. Because enum definitions have only file scope, this should not cause a problem as
long as all files which include your class use the same size int to represent the enum.
Changes From The Original 1.33 Which Are Not Part of Any Other Section
A complete log of all but the most trivial changes are distributed in the
PCCTS
kits. The most recent changes are in
CHANGES_FROM_133.TXT.
Changes prior to 1.33MR13 are in
CHANGES_FROM_133_BEFORE_MR13.TXT
. Finally, for those
who don't have the endurance to read these files, there is a
CHANGES_SUMMARY.TXT
which contains only the most
interesting parts of those files. The following items are based on this last file.
#175. Use
#first <<...>
to place references to precompiled header files at the beginning of generated files
#176. Use
DLG
LexerBase::reset() to reset the input stream when parsing the input stream multiple times.
#177. Error counters are:
ANTLR
Parser::syntaxErrCount and
DLG
LexerBase::lexErrCount
These counters are
not
reset to zero by
ANTLR
Parser::init().
#178. Use "
class MyParser : public MyBaseParser ... {
" to specify your own parser base class
The information following the ":" is copied to the class declaration for MyParser. The constructor of the base class
(e.g. MyBaseParser) must have the same signature as
ANTLR
Parser.
#179. Use
#FirstSetSymbol(
symbol_name
)
to generate symbol for first set of an alternative
The set can be tested using:
if (set_el(token->getType(),
symbol_name
)) {...}
A follow set can be generated by placing the #FirstSetSymbol operator after the block of interest:
rr : (rule_a | rule_b) #FirstSetSymbol(ab_follow) () ;
#180. Use
-preamble
and
-preamble_first
to insert macro code at the start of each rule or block
The antlr option -preamble causes
ANTLR
to insert the code "
BLOCK_PREAMBLE"
at the start of each rule and
block.
The option -preamble_first inserts the code "
BLOCK_PREAMBLE_FIRST(PreambleFirst_
number
)"
where
the symbol
PreambleFirst_
number
is equivalent to the first set defined by the #FirstSetSymbol described
above.
#181. Preprocessor option
ZZDEFER_FETCH
to defer token fetch for C++ mode
When the
ANTLR
Parser class is built with the pre-processor option ZZDEFER_FETCH defined, the fetch of new
tokens by consume() is deferred until LA(i) or LT(i) is called. This is useful in cases where there is a potential for a
deadlock between a supplier of data which is waiting for the parser to ask for more data and the parser which is
waiting for another token because of prefetching.
The defer fetch feature cannot be used with the standard tracein() and traceout() routines because they display
information from a prefetched token. The function isDeferFetchEnabled() tests whether this feature is enabled.
#182. Exception handling
There were significant problems in the handling of exceptions in 1.33 vanilla. The general problem is that it can
only process one level of exception handler. For example, a named exception handler, an exception handler for an
alternative, or an exception for a subrule always went to the rule's exception handler if there was no "catch" which
matched the exception.
Now the exception handlers properly nest. If an exception handler does not have a matching "catch" then the
nextmost outer exception handler is checked for an appropriate "catch" clause, and so on until an exception handler
with an appropriate "catch" is found.