27 March 2000 Release 2.22 Notes for New Users of PCCTS Version 1.33MR22
35
(AND X (... (OR X Y) ... )) => (AND X (... ... ))
(AND X) => X
(OR X) => X
Debugging Tips for New Users of
PCCTS
#146. A syntax error with quotation marks on separate lines means a problem with newline
line 1: syntax error at "
" missing ID
#147. Use the
ANTLR
­gd switch to debug via rule trace
#148. Use the
ANTLR
­gs switch to generate code with symbolic names for token tests
#149. How to track
DLG
results
If the pre-processor symbol
DEBUG_LEXER
is defined when
DLG
LexerBase is compiled it will include code to assist
in debugging your lexer. To turn on the debug output:
previousDebugValue=lexer.debugLexer(newDebugValue);
A value of 1 enables the debug output while a value of 0 disables output.
#150. For complex problems use traceOption and traceGuessOption to control trace output
Switches and Options
#151. Use
ANTLR
­gx switch to suppress regeneration of the
DLG
code and recompilation of
DLG
Lexer.cpp
It is possible to maintain separate grammar files for the
DLG
definitions of #tokens and the
ANTLR
definition of rules
so that the
DLG
related code (and routines having dependence on tokens.h) need not be re-compiled just because of a
change in a rule's action.
#152. Can't use an interactive scanner (
ANTLR
­gk option) with
ANTLR
infinite lookahead
#153. To make
DLG
case insensitive use the
DLG
­ci switch
The analyzer does not change the text, it just ignores case when matching it against the regular expressions.
#154. Use
ANTLR
option -glms to convert Microsoft file names like "..\foo.g" to "../foo.g" in generated files
#155. Use
ANTLR
option -treport
number
to locate alternatives using a lot of CPU time to resolve
It can be difficult to determine which alternatives are causing
PCCTS
to work hard to resolve an ambiguity. In some
cases the ambiguity is successfully resolved after much CPU time so there is no message at all.
A rough measure of the amount of work being performed which is independent of the CPU speed and system load is
the number of tnodes created. Using "-info t" gives information about the total number of tnodes created and the
peak number of tnodes.
Tree Nodes: peak 1300k created 1416k lost 0
It also puts in the generated C or C++ file the number of tnodes created for a rule (at the end of the rule). However
this information is not sufficient to locate the alternatives within a rule which are causing the creation of tnodes.
Using:
antlr -treport 100000 ....
causes antlr to list on stdout any alternatives which require the creation of more than 100,000 tnodes, along with the
lookahead sets for those alternatives.
#156. The
ANTLR
option -info ( p - predicate, t - tnodes, m - monitor, f - follow set, o - orphans)
The
ANTLR
-info options may be combined and may appear in any order:
antlr -info ptm -CC -gt -mrhoist on mygrammar.g