summaryrefslogtreecommitdiffstats
path: root/EdkCompatibilityPkg/Other
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
commit3eb9473ea9a949badfe06ae61d2d3fcfa53651c7 (patch)
treee9d8c368dbb1e58794b2c00acefe4bbad270f8c4 /EdkCompatibilityPkg/Other
parent30d4a0c7ec19938196b1308006b990e0945150da (diff)
downloadedk2-3eb9473ea9a949badfe06ae61d2d3fcfa53651c7.tar.gz
edk2-3eb9473ea9a949badfe06ae61d2d3fcfa53651c7.tar.bz2
edk2-3eb9473ea9a949badfe06ae61d2d3fcfa53651c7.zip
Add in the 1st version of ECP.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Other')
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt1766
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt3666
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt2049
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt184
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README171
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exebin0 -> 286720 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exebin0 -> 73728 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exebin0 -> 135168 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp815
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h358
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp244
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h119
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp82
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h88
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h305
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp345
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h106
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h51
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h215
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp100
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h53
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h98
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp188
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp268
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h197
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h104
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp662
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h142
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h71
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h788
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c345
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h115
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h46
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c58
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h48
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h1
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h499
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h128
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h1168
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h37
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.libbin0 -> 158702 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.libbin0 -> 83612 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h10
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h350
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp118
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw29
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp124
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw29
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat11
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp105
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.libbin0 -> 158702 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.libbin0 -> 83612 bytes
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h8
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h26
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h110
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h72
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h61
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h172
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h52
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h46
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h45
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp151
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c834
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c100
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile21
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp130
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c140
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c169
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c123
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c78
77 files changed, 18864 insertions, 0 deletions
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt
new file mode 100644
index 0000000000..2954da97cf
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt
@@ -0,0 +1,1766 @@
+=======================================================================
+List of Implemented Fixes and Changes for Maintenance Releases of PCCTS
+
+
+ For a summary of the most significant changes see CHANGES_SUMMARY.TXT
+
+=======================================================================
+
+ DISCLAIMER
+
+ The software and these notes are provided "as is". They may include
+ typographical or technical errors and their authors disclaims all
+ liability of any kind or nature for damages due to error, fault,
+ defect, or deficiency regardless of cause. All warranties of any
+ kind, either express or implied, including, but not limited to, the
+ implied warranties of merchantability and fitness for a particular
+ purpose are disclaimed.
+
+
+ -------------------------------------------------------
+ Note: Items #153 to #1 are now in a separate file named
+ CHANGES_FROM_133_BEFORE_MR13.txt
+ -------------------------------------------------------
+
+#261. (Changed in MR19) Defer token fetch for C++ mode
+
+ Item #216 has been revised to indicate that use of the defer fetch
+ option (ZZDEFER_FETCH) requires dlg option -i.
+
+#260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes.
+
+ ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg
+ generated lexers. The default value has been raised to 32,000 and
+ the value used by antlr, dlg, and sorcerer has also been raised to
+ 32,000.
+
+#259. (MR22) Default function arguments in C++ mode.
+
+ If a rule is declared:
+
+ rr [int i = 0] : ....
+
+ then the declaration generated by pccts resembles:
+
+ void rr(int i = 0);
+
+ however, the definition must omit the default argument:
+
+ void rr(int i) {...}
+
+ In the past the default value was not omitted. In MR22
+ the generated code resembles:
+
+ void rr(int i /* = 0 */ ) {...}
+
+ Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de)
+
+#258. (MR22) Using a base class for your parser
+
+ In item #102 (MR10) the class statement was extended to allow one
+ to specify a base class other than ANTLRParser for the generated
+ parser. It turned out that this was less than useful because
+ the constructor still specified ANTLRParser as the base class.
+
+ The class statement now uses the first identifier appearing after
+ the ":" as the name of the base class. For example:
+
+ class MyParser : public FooParser {
+
+ Generates in MyParser.h:
+
+ class MyParser : public FooParser {
+
+ Generates in MyParser.cpp something that resembles:
+
+ MyParser::MyParser(ANTLRTokenBuffer *input) :
+ FooParser(input,1,0,0,4)
+ {
+ token_tbl = _token_tbl;
+ traceOptionValueDefault=1; // MR10 turn trace ON
+ }
+
+ The base class must constructor must have a signature similar to
+ that of ANTLRParser.
+
+#257. (MR21a) Removed dlg statement that -i has no effect in C++ mode.
+
+ This was incorrect.
+
+#256. (MR21a) Malformed syntax graph causes crash after error message.
+
+ In the past, certain kinds of errors in the very first grammar
+ element could cause the construction of a malformed graph
+ representing the grammar. This would eventually result in a
+ fatal internal error. The code has been changed to be more
+ resistant to this particular error.
+
+#255. (MR21a) ParserBlackBox(FILE* f)
+
+ This constructor set openByBlackBox to the wrong value.
+
+ Reported by Kees Bakker (kees_bakker@tasking.nl).
+
+#254. (MR21a) Reporting syntax error at end-of-file
+
+ When there was a syntax error at the end-of-file the syntax
+ error routine would substitute "<eof>" for the programmer's
+ end-of-file symbol. This substitution is now done only when
+ the programmer does not define his own end-of-file symbol
+ or the symbol begins with the character "@".
+
+ Reported by Kees Bakker (kees_bakker@tasking.nl).
+
+#253. (MR21) Generation of block preamble (-preamble and -preamble_first)
+
+ The antlr option -preamble causes antlr to insert the code
+ BLOCK_PREAMBLE at the start of each rule and block. It does
+ not insert code before rules references, token references, or
+ actions. By properly defining the macro BLOCK_PREAMBLE the
+ user can generate code which is specific to the start of blocks.
+
+ The antlr option -preamble_first is similar, but inserts the
+ code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol
+ PreambleFirst_123 is equivalent to the first set defined by
+ the #FirstSetSymbol described in Item #248.
+
+ I have not investigated how these options interact with guess
+ mode (syntactic predicates).
+
+#252. (MR21) Check for null pointer in trace routine
+
+ When some trace options are used when the parser is generated
+ without the trace enabled, the current rule name may be a
+ NULL pointer. A guard was added to check for this in
+ restoreState.
+
+ Reported by Douglas E. Forester (dougf@projtech.com).
+
+#251. (MR21) Changes to #define zzTRACE_RULES
+
+ The macro zzTRACE_RULES was being use to pass information to
+ AParser.h. If this preprocessor symbol was not properly
+ set the first time AParser.h was #included, the declaration
+ of zzTRACEdata would be omitted (it is used by the -gd option).
+ Subsequent #includes of AParser.h would be skipped because of
+ the #ifdef guard, so the declaration of zzTracePrevRuleName would
+ never be made. The result was that proper compilation was very
+ order dependent.
+
+ The declaration of zzTRACEdata was made unconditional and the
+ problem of removing unused declarations will be left to optimizers.
+
+ Diagnosed by Douglas E. Forester (dougf@projtech.com).
+
+#250. (MR21) Option for EXPERIMENTAL change to error sets for blocks
+
+ The antlr option -mrblkerr turns on an experimental feature
+ which is supposed to provide more accurate syntax error messages
+ for k=1, ck=1 grammars. When used with k>1 or ck>1 grammars the
+ behavior should be no worse than the current behavior.
+
+ There is no problem with the matching of elements or the computation
+ of prediction expressions in pccts. The task is only one of listing
+ the most appropriate tokens in the error message. The error sets used
+ in pccts error messages are approximations of the exact error set when
+ optional elements in (...)* or (...)+ are involved. While entirely
+ correct, the error messages are sometimes not 100% accurate.
+
+ There is also a minor philosophical issue. For example, suppose the
+ grammar expects the token to be an optional A followed by Z, and it
+ is X. X, of course, is neither A nor Z, so an error message is appropriate.
+ Is it appropriate to say "Expected Z" ? It is correct, it is accurate,
+ but it is not complete.
+
+ When k>1 or ck>1 the problem of providing the exactly correct
+ list of tokens for the syntax error messages ends up becoming
+ equivalent to evaluating the prediction expression for the
+ alternatives twice. However, for k=1 ck=1 grammars the prediction
+ expression can be computed easily and evaluated cheaply, so I
+ decided to try implementing it to satisfy a particular application.
+ This application uses the error set in an interactive command language
+ to provide prompts which list the alternatives available at that
+ point in the parser. The user can then enter additional tokens to
+ complete the command line. To do this required more accurate error
+ sets then previously provided by pccts.
+
+ In some cases the default pccts behavior may lead to more robust error
+ recovery or clearer error messages then having the exact set of tokens.
+ This is because (a) features like -ge allow the use of symbolic names for
+ certain sets of tokens, so having extra tokens may simply obscure things
+ and (b) the error set is use to resynchronize the parser, so a good
+ choice is sometimes more important than having the exact set.
+
+ Consider the following example:
+
+ Note: All examples code has been abbreviated
+ to the absolute minimum in order to make the
+ examples concise.
+
+ star1 : (A)* Z;
+
+ The generated code resembles:
+
+ old new (with -mrblkerr)
+ ------------- --------------------
+ for (;;) { for (;;) {
+ match(A); match(A);
+ } }
+ match(Z); if (! A and ! Z) then
+ FAIL(...{A,Z}...);
+ }
+ match(Z);
+
+
+ With input X
+ old message: Found X, expected Z
+ new message: Found X, expected A, Z
+
+ For the example:
+
+ star2 : (A|B)* Z;
+
+ old new (with -mrblkerr)
+ ------------- --------------------
+ for (;;) { for (;;) {
+ if (!A and !B) break; if (!A and !B) break;
+ if (...) { if (...) {
+ <same ...> <same ...>
+ } }
+ else { else {
+ FAIL(...{A,B,Z}...) FAIL(...{A,B}...);
+ } }
+ } }
+ match(B); if (! A and ! B and !Z) then
+ FAIL(...{A,B,Z}...);
+ }
+ match(B);
+
+ With input X
+ old message: Found X, expected Z
+ new message: Found X, expected A, B, Z
+ With input A X
+ old message: Found X, expected Z
+ new message: Found X, expected A, B, Z
+
+ This includes the choice of looping back to the
+ star block.
+
+ The code for plus blocks:
+
+ plus1 : (A)+ Z;
+
+ The generated code resembles:
+
+ old new (with -mrblkerr)
+ ------------- --------------------
+ do { do {
+ match(A); match(A);
+ } while (A) } while (A)
+ match(Z); if (! A and ! Z) then
+ FAIL(...{A,Z}...);
+ }
+ match(Z);
+
+ With input A X
+ old message: Found X, expected Z
+ new message: Found X, expected A, Z
+
+ This includes the choice of looping back to the
+ plus block.
+
+ For the example:
+
+ plus2 : (A|B)+ Z;
+
+ old new (with -mrblkerr)
+ ------------- --------------------
+ do { do {
+ if (A) { <same>
+ match(A); <same>
+ } else if (B) { <same>
+ match(B); <same>
+ } else { <same>
+ if (cnt > 1) break; <same>
+ FAIL(...{A,B,Z}...) FAIL(...{A,B}...);
+ } }
+ cnt++; <same>
+ } }
+
+ match(Z); if (! A and ! B and !Z) then
+ FAIL(...{A,B,Z}...);
+ }
+ match(B);
+
+ With input X
+ old message: Found X, expected A, B, Z
+ new message: Found X, expected A, B
+ With input A X
+ old message: Found X, expected Z
+ new message: Found X, expected A, B, Z
+
+ This includes the choice of looping back to the
+ star block.
+
+#249. (MR21) Changes for DEC/VMS systems
+
+ Jean-François Piéronne (jfp@altavista.net) has updated some
+ VMS related command files and fixed some minor problems related
+ to building pccts under the DEC/VMS operating system. For DEC/VMS
+ users the most important differences are:
+
+ a. Revised makefile.vms
+ b. Revised genMMS for genrating VMS style makefiles.
+
+#248. (MR21) Generate symbol for first set of an alternative
+
+ pccts can generate a symbol which represents the tokens which may
+ appear at the start of a block:
+
+ rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ;
+
+ This will generate the symbol rr_FirstSet of type SetWordType with
+ elements Foo and Bar set. The bits can be tested using code similar
+ to the following:
+
+ if (set_el(Foo, &rr_FirstSet)) { ...
+
+ This can be combined with the C array zztokens[] or the C++ routine
+ tokenName() to get the print name of the token in the first set.
+
+ The size of the set is given by the newly added enum SET_SIZE, a
+ protected member of the generated parser's class. The number of
+ elements in the generated set will not be exactly equal to the
+ value of SET_SIZE because of synthetic tokens created by #tokclass,
+ #errclass, the -ge option, and meta-tokens such as epsilon, and
+ end-of-file.
+
+ The #FirstSetSymbol must appear immediately before a block
+ such as (...)+, (...)*, and {...}, and (...). It may not appear
+ immediately before a token, a rule reference, or action. However
+ a token or rule reference can be enclosed in a (...) in order to
+ make the use of #pragma FirstSetSymbol legal.
+
+ rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo; // Illegal
+
+ rr_ok : #FirstSetSymbol(rr_ok_FirstSet) (Foo); // Legal
+
+ Do not confuse FirstSetSymbol sets with the sets used for testing
+ lookahead. The sets used for FirstSetSymbol have one element per bit,
+ so the number of bytes is approximately the largest token number
+ divided by 8. The sets used for testing lookahead store 8 lookahead
+ sets per byte, so the length of the array is approximately the largest
+ token number.
+
+ If there is demand, a similar routine for follow sets can be added.
+
+#247. (MR21) Misleading error message on syntax error for optional elements.
+
+ Prior to MR21, tokens which were optional did not appear in syntax
+ error messages if the block which immediately followed detected a
+ syntax error.
+
+ Consider the following grammar which accepts Number, Word, and Other:
+
+ rr : {Number} Word;
+
+ For this rule the code resembles:
+
+ if (LA(1) == Number) {
+ match(Number);
+ consume();
+ }
+ match(Word);
+
+ Prior to MR21, the error message for input "$ a" would be:
+
+ line 1: syntax error at "$" missing Word
+
+ With MR21 the message will be:
+
+ line 1: syntax error at "$" expecting Word, Number.
+
+ The generate code resembles:
+
+ if ( (LA(1)==Number) ) {
+ zzmatch(Number);
+ consume();
+ }
+ else {
+ if ( (LA(1)==Word) ) {
+ /* nothing */
+ }
+ else {
+ FAIL(... message for both Number and Word ...);
+ }
+ }
+ match(Word);
+
+ The code generated for optional blocks in MR21 is slightly longer
+ than the previous versions, but it should give better error messages.
+
+ The code generated for:
+
+ { a | b | c }
+
+ should now be *identical* to:
+
+ ( a | b | c | )
+
+ which was not the case prior to MR21.
+
+ Reported by Sue Marvin (sue@siara.com).
+
+#246. (Changed in MR21) Use of $(MAKE) for calls to make
+
+ Calls to make from the makefiles were replaced with $(MAKE)
+ because of problems when using gmake.
+
+ Reported with fix by Sunil K.Vallamkonda (sunil@siara.com).
+
+#245. (Changed in MR21) Changes to genmk
+
+ The following command line options have been added to genmk:
+
+ -cfiles ...
+
+ To add a user's C or C++ files into makefile automatically.
+ The list of files must be enclosed in apostrophes. This
+ option may be specified multiple times.
+
+ -compiler ...
+
+ The name of the compiler to use for $(CCC) or $(CC). The
+ default in C++ mode is "CC". The default in C mode is "cc".
+
+ -pccts_path ...
+
+ The value for $(PCCTS), the pccts directory. The default
+ is /usr/local/pccts.
+
+ Contributed by Tomasz Babczynski (t.babczynski@ict.pwr.wroc.pl).
+
+#244. (Changed in MR21) Rename variable "not" in antlr.g
+
+ When antlr.g is compiled with a C++ compiler, a variable named
+ "not" causes problems. Reported by Sinan Karasu
+ (sinan.karasu@boeing.com).
+
+#243 (Changed in MR21) Replace recursion with iteration in zzfree_ast
+
+ Another refinement to zzfree_ast in ast.c to limit recursion.
+
+ NAKAJIMA Mutsuki (muc@isr.co.jp).
+
+
+#242. (Changed in MR21) LineInfoFormatStr
+
+ Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h.
+
+#241. (Changed in MR21) Changed macro PURIFY to a no-op
+
+ ***********************
+ *** NOT IMPLEMENTED ***
+ ***********************
+
+ The PURIFY macro was changed to a no-op because it was causing
+ problems when passing C++ objects.
+
+ The old definition:
+
+ #define PURIFY(r,s) memset((char *) &(r),'\\0',(s));
+
+ The new definition:
+
+ #define PURIFY(r,s) /* nothing */
+#endif
+
+#240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE
+
+ Added test for NULL token pointer.
+
+ Suggested by Peter Keller (keller@ebi.ac.uk)
+
+#239. (Changed in MR21) C++ mode AParser::traceGuessFail
+
+ If tracing is turned on when the code has been generated
+ without trace code, a failed guess generates a trace report
+ even though there are no other trace reports. This
+ make the behavior consistent with other parts of the
+ trace system.
+
+ Reported by David Wigg (wiggjd@sbu.ac.uk).
+
+#238. (Changed in MR21) Namespace version #include files
+
+ Changed reference from CStdio to cstdio (and other
+ #include file names) in the namespace version of pccts.
+ Should have known better.
+
+#237. (Changed in MR21) ParserBlackBox(FILE*)
+
+ In the past, ParserBlackBox would close the FILE in the dtor
+ even though it was not opened by ParserBlackBox. The problem
+ is that there were two constructors, one which accepted a file
+ name and did an fopen, the other which accepted a FILE and did
+ not do an fopen. There is now an extra member variable which
+ remembers whether ParserBlackBox did the open or not.
+
+ Suggested by Mike Percy (mpercy@scires.com).
+
+#236. (Changed in MR21) tmake now reports down pointer problem
+
+ When ASTBase::tmake attempts to update the down pointer of
+ an AST it checks to see if the down pointer is NULL. If it
+ is not NULL it does not do the update and returns NULL.
+ An attempt to update the down pointer is almost always a
+ result of a user error. This can lead to difficult to find
+ problems during tree construction.
+
+ With this change, the routine calls a virtual function
+ reportOverwriteOfDownPointer() which calls panic to
+ report the problem. Users who want the old behavior can
+ redefined the virtual function in their AST class.
+
+ Suggested by Sinan Karasu (sinan.karasu@boeing.com)
+
+#235. (Changed in MR21) Made ANTLRParser::resynch() virtual
+
+ Suggested by Jerry Evans (jerry@swsl.co.uk).
+
+#234. (Changed in MR21) Implicit int for function return value
+
+ ATokenBuffer:bufferSize() did not specify a type for the
+ return value.
+
+ Reported by Hai Vo-Ba (hai@fc.hp.com).
+
+#233. (Changed in MR20) Converted to MSVC 6.0
+
+ Due to external circumstances I have had to convert to MSVC 6.0
+ The MSVC 5.0 project files (.dsw and .dsp) have been retained as
+ xxx50.dsp and xxx50.dsw. The MSVC 6.0 files are named xxx60.dsp
+ and xxx60.dsw (where xxx is the related to the directory/project).
+
+#232. (Changed in MR20) Make setwd bit vectors protected in parser.h
+
+ The access for the setwd array in the parser header was not
+ specified. As a result, it would depend on the code which
+ preceded it. In MR20 it will always have access "protected".
+
+ Reported by Piotr Eljasiak (eljasiak@zt.gdansk.tpsa.pl).
+
+#231. (Changed in MR20) Error in token buffer debug code.
+
+ When token buffer debugging is selected via the pre-processor
+ symbol DEBUG_TOKENBUFFER there is an erroneous check in
+ AParser.cpp:
+
+ #ifdef DEBUG_TOKENBUFFER
+ if (i >= inputTokens->bufferSize() ||
+ inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */
+ ...
+ #endif
+
+ Reported by David Wigg (wiggjd@sbu.ac.uk).
+
+#230. (Changed in MR20) Fixed problem with #define for -gd option
+
+ There was an error in setting zzTRACE_RULES for the -gd (trace) option.
+
+ Reported by Gary Funck (gary@intrepid.com).
+
+#229. (Changed in MR20) Additional "const" for literals
+
+ "const" was added to the token name literal table.
+ "const" was added to some panic() and similar routine
+
+#228. (Changed in MR20) dlg crashes on "()"
+
+ The following token defintion will cause DLG to crash.
+
+ #token "()"
+
+ When there is a syntax error in a regular expression
+ many of the dlg routines return a structure which has
+ null pointers. When this is accessed by callers it
+ generates the crash.
+
+ I have attempted to fix the more common cases.
+
+ Reported by Mengue Olivier (dolmen@bigfoot.com).
+
+#227. (Changed in MR20) Array overwrite
+
+ Steveh Hand (sassth@unx.sas.com) reported a problem which
+ was traced to a temporary array which was not properly
+ resized for deeply nested blocks. This has been fixed.
+
+#226. (Changed in MR20) -pedantic conformance
+
+ G. Hobbelt (i_a@mbh.org) and THM made many, many minor
+ changes to create prototypes for all the functions and
+ bring antlr, dlg, and sorcerer into conformance with
+ the gcc -pedantic option.
+
+ This may require uses to add pccts/h/pcctscfg.h to some
+ files or makefiles in order to have __USE_PROTOS defined.
+
+#225 (Changed in MR20) AST stack adjustment in C mode
+
+ The fix in #214 for AST stack adjustment in C mode missed
+ some cases.
+
+ Reported with fix by Ger Hobbelt (i_a@mbh.org).
+
+#224 (Changed in MR20) LL(1) and LL(2) with #pragma approx
+
+ This may take a record for the oldest, most trival, lexical
+ error in pccts. The regular expressions for LL(1) and LL(2)
+ lacked an escape for the left and right parenthesis.
+
+ Reported by Ger Hobbelt (i_a@mbh.org).
+
+#223 (Changed in MR20) Addition of IBM_VISUAL_AGE directory
+
+ Build files for antlr, dlg, and sorcerer under IBM Visual Age
+ have been contributed by Anton Sergeev (ags@mlc.ru). They have
+ been placed in the pccts/IBM_VISUAL_AGE directory.
+
+#222 (Changed in MR20) Replace __STDC__ with __USE_PROTOS
+
+ Most occurrences of __STDC__ replaced with __USE_PROTOS due to
+ complaints from several users.
+
+#221 (Changed in MR20) Added #include for DLexerBase.h to PBlackBox.
+
+ Added #include for DLexerBase.h to PBlackBox.
+
+#220 (Changed in MR19) strcat arguments reversed in #pred parse
+
+ The arguments to strcat are reversed when creating a print
+ name for a hash table entry for use with #pred feature.
+
+ Problem diagnosed and fix reported by Scott Harrington
+ (seh4@ix.netcom.com).
+
+#219. (Changed in MR19) C Mode routine zzfree_ast
+
+ Changes to reduce use of recursion for AST trees with only right
+ links or only left links in the C mode routine zzfree_ast.
+
+ Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp).
+
+#218. (Changed in MR19) Changes to support unsigned char in C mode
+
+ Changes to antlr.h and err.h to fix omissions in use of zzchar_t
+
+ Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp).
+
+#217. (Changed in MR19) Error message when dlg -i and -CC options selected
+
+ *** This change was rescinded by item #257 ***
+
+ The parsers generated by pccts in C++ mode are not able to support the
+ interactive lexer option (except, perhaps, when using the deferred fetch
+ parser option.(Item #216).
+
+ DLG now warns when both -i and -CC are selected.
+
+ This warning was suggested by David Venditti (07751870267-0001@t-online.de).
+
+#216. (Changed in MR19) Defer token fetch for C++ mode
+
+ Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de)
+
+ Normally, pccts keeps the lookahead token buffer completely filled.
+ This requires max(k,ck) tokens of lookahead. For some applications
+ this can cause deadlock problems. For example, there may be cases
+ when the parser can't tell when the input has been completely consumed
+ until the parse is complete, but the parse can't be completed because
+ the input routines are waiting for additional tokens to fill the
+ lookahead buffer.
+
+ When the ANTLRParser 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.
+
+ To test whether this option has been built into the ANTLRParser class
+ use "isDeferFetchEnabled()".
+
+ Using the -gd trace option with the default tracein() and traceout()
+ routines will defeat the effort to defer the fetch because the
+ trace routines print out information about the lookahead token at
+ the start of the rule.
+
+ Because the tracein and traceout routines are virtual it is
+ easy to redefine them in your parser:
+
+ class MyParser {
+ <<
+ virtual void tracein(ANTLRChar * ruleName)
+ { fprintf(stderr,"Entering: %s\n", ruleName); }
+ virtual void traceout(ANTLRChar * ruleName)
+ { fprintf(stderr,"Leaving: %s\n", ruleName); }
+ >>
+
+ The originals for those routines are pccts/h/AParser.cpp
+
+ This requires use of the dlg option -i (interactive lexer).
+
+ This is experimental. The interaction with guess mode (syntactic
+ predicates)is not known.
+
+#215. (Changed in MR19) Addition of reset() to DLGLexerBase
+
+ There was no obvious way to reset the lexer for reuse. The
+ reset() method now does this.
+
+ Suggested by David Venditti (07751870267-0001@t-online.de).
+
+#214. (Changed in MR19) C mode: Adjust AST stack pointer at exit
+
+ In C mode the AST stack pointer needs to be reset if there will
+ be multiple calls to the ANTLRx macros.
+
+ Reported with fix by Paul D. Smith (psmith@baynetworks.com).
+
+#213. (Changed in MR18) Fatal error with -mrhoistk (k>1 hoisting)
+
+ When rearranging code I forgot to un-comment a critical line of
+ code that handles hoisting of predicates with k>1 lookahead. This
+ is now fixed.
+
+ Reported by Reinier van den Born (reinier@vnet.ibm.com).
+
+#212. (Changed in MR17) Mac related changes by Kenji Tanaka
+
+ Kenji Tanaka (kentar@osa.att.ne.jp) has made a number of changes for
+ Macintosh users.
+
+ a. The following Macintosh MPW files aid in installing pccts on Mac:
+
+ pccts/MPW_Read_Me
+
+ pccts/install68K.mpw
+ pccts/installPPC.mpw
+
+ pccts/antlr/antlr.r
+ pccts/antlr/antlr68K.make
+ pccts/antlr/antlrPPC.make
+
+ pccts/dlg/dlg.r
+ pccts/dlg/dlg68K.make
+ pccts/dlg/dlgPPC.make
+
+ pccts/sorcerer/sor.r
+ pccts/sorcerer/sor68K.make
+ pccts/sorcerer/sorPPC.make
+
+ They completely replace the previous Mac installation files.
+
+ b. The most significant is a change in the MAC_FILE_CREATOR symbol
+ in pcctscfg.h:
+
+ old: #define MAC_FILE_CREATOR 'MMCC' /* Metrowerks C/C++ Text files */
+ new: #define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */
+
+ c. Added calls to special_fopen_actions() where necessary.
+
+#211. (Changed in MR16a) C++ style comment in dlg
+
+ This has been fixed.
+
+#210. (Changed in MR16a) Sor accepts \r\n, \r, or \n for end-of-line
+
+ A user requested that Sorcerer be changed to accept other forms
+ of end-of-line.
+
+#209. (Changed in MR16) Name of files changed.
+
+ Old: CHANGES_FROM_1.33
+ New: CHANGES_FROM_133.txt
+
+ Old: KNOWN_PROBLEMS
+ New: KNOWN_PROBLEMS.txt
+
+#208. (Changed in MR16) Change in use of pccts #include files
+
+ There were problems with MS DevStudio when mixing Sorcerer and
+ PCCTS in the same source file. The problem is caused by the
+ redefinition of setjmp in the MS header file setjmp.h. In
+ setjmp.h the pre-processor symbol setjmp was redefined to be
+ _setjmp. A later effort to execute #include <setjmp.h> resulted
+ in an effort to #include <_setjmp.h>. I'm not sure whether this
+ is a bug or a feature. In any case, I decided to fix it by
+ avoiding the use of pre-processor symbols in #include statements
+ altogether. This has the added benefit of making pre-compiled
+ headers work again.
+
+ I've replaced statements:
+
+ old: #include PCCTS_SETJMP_H
+ new: #include "pccts_setjmp.h"
+
+ Where pccts_setjmp.h contains:
+
+ #ifndef __PCCTS_SETJMP_H__
+ #define __PCCTS_SETJMP_H__
+
+ #ifdef PCCTS_USE_NAMESPACE_STD
+ #include <Csetjmp>
+ #else
+ #include <setjmp.h>
+ #endif
+
+ #endif
+
+ A similar change has been made for other standard header files
+ required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc.
+
+ Reported by Jeff Vincent (JVincent@novell.com) and Dale Davis
+ (DalDavis@spectrace.com).
+
+#207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff]
+
+ dlg will report that this is an invalid range.
+
+ Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):
+
+ I think this problem is not specific to unsigned chars
+ because dlg reports no error for the range [\0x00-\0xfe].
+
+ I've found that information on range is kept in field
+ letter (unsigned char) of Attrib struct. Unfortunately
+ the letter value internally is for some reasons increased
+ by 1, so \0xff is represented here as 0.
+
+ That's why dlg complains about the range [\0x00-\0xff] in
+ dlg_p.g:
+
+ if ($$.letter > $2.letter) {
+ error("invalid range ", zzline);
+ }
+
+ The fix is:
+
+ if ($$.letter > $2.letter && 255 != $$2.letter) {
+ error("invalid range ", zzline);
+ }
+
+#206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor
+
+ The ANTLRParser destructor now frees zzFAILtext.
+
+ Problem and fix reported by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#205. (Changed in MR16) DLGStringReset argument now const
+
+ Changed: void DLGStringReset(DLGChar *s) {...}
+ To: void DLGStringReset(const DLGChar *s) {...}
+
+ Suggested by Dale Davis (daldavis@spectrace.com)
+
+#204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h
+
+ Reported by Oleg Dashevskii (olegdash@my-dejanews.com).
+
+#203. (Changed in MR15) Addition of sorcerer to distribution kit
+
+ I have finally caved in to popular demand. The pccts 1.33mr15
+ kit will include sorcerer. The separate sorcerer kit will be
+ discontinued.
+
+#202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit
+
+ Previously there was one workspace that contained projects for
+ all three parts of pccts: antlr, dlg, and sorcerer. Now each
+ part (and directory) has its own workspace/project and there
+ is an additional workspace/project to build a library from the
+ .cpp files in the pccts/h directory.
+
+ The library build will create pccts_debug.lib or pccts_release.lib
+ according to the configuration selected.
+
+ If you don't want to build pccts 1.33MR15 you can download a
+ ready-to-run kit for win32 from http://www.polhode.com/win32.zip.
+ The ready-to-run for win32 includes executables, a pre-built static
+ library for the .cpp files in the pccts/h directory, and a sample
+ application
+
+ You will need to define the environment variable PCCTS to point to
+ the root of the pccts directory hierarchy.
+
+#201. (Changed in MR15) Several fixes by K.J. Cummings (cummings@peritus.com)
+
+ Generation of SETJMP rather than SETJMP_H in gen.c.
+
+ (Sor B19) Declaration of ref_vars_inits for ref_var_inits in
+ pccts/sorcerer/sorcerer.h.
+
+#200. (Changed in MR15) Remove operator=() in AToken.h
+
+ User reported that WatCom couldn't handle use of
+ explicit operator =(). Replace with equivalent
+ using cast operator.
+
+#199. (Changed in MR15) Don't allow use of empty #tokclass
+
+ Change antlr.g to disallow empty #tokclass sets.
+
+ Reported by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#198. Revised ANSI C grammar due to efforts by Manuel Kessler
+
+ Manuel Kessler (mlkessler@cip.physik.uni-wuerzburg.de)
+
+ Allow trailing ... in function parameter lists.
+ Add bit fields.
+ Allow old-style function declarations.
+ Support cv-qualified pointers.
+ Better checking of combinations of type specifiers.
+ Release of memory for local symbols on scope exit.
+ Allow input file name on command line as well as by redirection.
+
+ and other miscellaneous tweaks.
+
+ This is not part of the pccts distribution kit. It must be
+ downloaded separately from:
+
+ http://www.polhode.com/ansi_mr15.zip
+
+#197. (Changed in MR14) Resetting the lookahead buffer of the parser
+
+ Explanation and fix by Sinan Karasu (sinan.karasu@boeing.com)
+
+ Consider the code used to prime the lookahead buffer LA(i)
+ of the parser when init() is called:
+
+ void
+ ANTLRParser::
+ prime_lookahead()
+ {
+ int i;
+ for(i=1;i<=LLk; i++) consume();
+ dirty=0;
+ //lap = 0; // MR14 - Sinan Karasu (sinan.karusu@boeing.com)
+ //labase = 0; // MR14
+ labase=lap; // MR14
+ }
+
+ When the parser is instantiated, lap=0,labase=0 is set.
+
+ The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is
+ computed. Therefore, lap(before the loop) == lap (after the loop).
+
+ Now the only problem comes in when one does an init() of the parser
+ after an Eof has been seen. At that time, lap could be non zero.
+ Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2,
+ then
+
+ consume()
+ {
+ NLA = inputTokens->getToken()->getType();
+ dirty--;
+ lap = (lap+1)&(LLk-1);
+ }
+
+ or expanding NLA,
+
+ token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType();
+ dirty--;
+ lap = (lap+1)&(LLk-1);
+
+ so now we prime locations 1 and 2. In prime_lookahead it used to set
+ lap=0 and labase=0. Now, the next token will be read from location 0,
+ NOT 1 as it should have been.
+
+ This was never caught before, because if a parser is just instantiated,
+ then lap and labase are 0, the offending assignment lines are
+ basically no-ops, since the for loop wraps around back to 0.
+
+#196. (Changed in MR14) Problems with "(alpha)? beta" guess
+
+ Consider the following syntactic predicate in a grammar
+ with 2 tokens of lookahead (k=2 or ck=2):
+
+ rule : ( alpha )? beta ;
+ alpha : S t ;
+ t : T U
+ | T
+ ;
+ beta : S t Z ;
+
+ When antlr computes the prediction expression with one token
+ of lookahead for alts 1 and 2 of rule t it finds an ambiguity.
+
+ Because the grammar has a lookahead of 2 it tries to compute
+ two tokens of lookahead for alts 1 and 2 of t. Alt 1 clearly
+ has a lookahead of (T U). Alt 2 is one token long so antlr
+ tries to compute the follow set of alt 2, which means finding
+ the things which can follow rule t in the context of (alpha)?.
+ This cannot be computed, because alpha is only part of a rule,
+ and antlr can't tell what part of beta is matched by alpha and
+ what part remains to be matched. Thus it impossible for antlr
+ to properly determine the follow set of rule t.
+
+ Prior to 1.33MR14, the follow of (alpha)? was computed as
+ FIRST(beta) as a result of the internal representation of
+ guess blocks.
+
+ With MR14 the follow set will be the empty set for that context.
+
+ Normally, one expects a rule appearing in a guess block to also
+ appear elsewhere. When the follow context for this other use
+ is "ored" with the empty set, the context from the other use
+ results, and a reasonable follow context results. However if
+ there is *no* other use of the rule, or it is used in a different
+ manner then the follow context will be inaccurate - it was
+ inaccurate even before MR14, but it will be inaccurate in a
+ different way.
+
+ For the example given earlier, a reasonable way to rewrite the
+ grammar:
+
+ rule : ( alpha )? beta
+ alpha : S t ;
+ t : T U
+ | T
+ ;
+ beta : alpha Z ;
+
+ If there are no other uses of the rule appearing in the guess
+ block it will generate a test for EOF - a workaround for
+ representing a null set in the lookahead tests.
+
+ If you encounter such a problem you can use the -alpha option
+ to get additional information:
+
+ line 2: error: not possible to compute follow set for alpha
+ in an "(alpha)? beta" block.
+
+ With the antlr -alpha command line option the following information
+ is inserted into the generated file:
+
+ #if 0
+
+ Trace of references leading to attempt to compute the follow set of
+ alpha in an "(alpha)? beta" block. It is not possible for antlr to
+ compute this follow set because it is not known what part of beta has
+ already been matched by alpha and what part remains to be matched.
+
+ Rules which make use of the incorrect follow set will also be incorrect
+
+ 1 #token T alpha/2 line 7 brief.g
+ 2 end alpha alpha/3 line 8 brief.g
+ 2 end (...)? block at start/1 line 2 brief.g
+
+ #endif
+
+ At the moment, with the -alpha option selected the program marks
+ any rules which appear in the trace back chain (above) as rules with
+ possible problems computing follow set.
+
+ Reported by Greg Knapen (gregory.knapen@bell.ca).
+
+#195. (Changed in MR14) #line directive not at column 1
+
+ Under certain circunstances a predicate test could generate
+ a #line directive which was not at column 1.
+
+ Reported with fix by David Kågedal (davidk@lysator.liu.se)
+ (http://www.lysator.liu.se/~davidk/).
+
+#194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass
+
+ In C mode with the demand lookahead option there is a bug in the
+ code which handles matches for #tokclass (zzsetmatch and
+ zzsetmatch_wsig).
+
+ The bug causes the lookahead pointer to get out of synchronization
+ with the current token pointer.
+
+ The problem was reported with a fix by Ger Hobbelt (hobbelt@axa.nl).
+
+#193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD
+
+ The pcctscfg.h now contains the following definitions:
+
+ #ifdef PCCTS_USE_NAMESPACE_STD
+ #define PCCTS_STDIO_H <Cstdio>
+ #define PCCTS_STDLIB_H <Cstdlib>
+ #define PCCTS_STDARG_H <Cstdarg>
+ #define PCCTS_SETJMP_H <Csetjmp>
+ #define PCCTS_STRING_H <Cstring>
+ #define PCCTS_ASSERT_H <Cassert>
+ #define PCCTS_ISTREAM_H <istream>
+ #define PCCTS_IOSTREAM_H <iostream>
+ #define PCCTS_NAMESPACE_STD namespace std {}; using namespace std;
+ #else
+ #define PCCTS_STDIO_H <stdio.h>
+ #define PCCTS_STDLIB_H <stdlib.h>
+ #define PCCTS_STDARG_H <stdarg.h>
+ #define PCCTS_SETJMP_H <setjmp.h>
+ #define PCCTS_STRING_H <string.h>
+ #define PCCTS_ASSERT_H <assert.h>
+ #define PCCTS_ISTREAM_H <istream.h>
+ #define PCCTS_IOSTREAM_H <iostream.h>
+ #define PCCTS_NAMESPACE_STD
+ #endif
+
+ The runtime support in pccts/h uses these pre-processor symbols
+ consistently.
+
+ Also, antlr and dlg have been changed to generate code which uses
+ these pre-processor symbols rather than having the names of the
+ #include files hard-coded in the generated code.
+
+ This required the addition of "#include pcctscfg.h" to a number of
+ files in pccts/h.
+
+ It appears that this sometimes causes problems for MSVC 5 in
+ combination with the "automatic" option for pre-compiled headers.
+ In such cases disable the "automatic" pre-compiled headers option.
+
+ Suggested by Hubert Holin (Hubert.Holin@Bigfoot.com).
+
+#192. (Changed in MR14) Change setText() to accept "const ANTLRChar *"
+
+ Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *).
+ This allows literal strings to be used to initialize tokens. Since
+ the usual token implementation (ANTLRCommonToken) makes a copy of the
+ input string, this was an unnecessary limitation.
+
+ Suggested by Bob McWhirter (bob@netwrench.com).
+
+#191. (Changed in MR14) HP/UX aCC compiler compatibility problem
+
+ Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and
+ zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp.
+
+ Reported by David Cook (dcook@bmc.com).
+
+#190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem
+
+ Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp
+
+ Reported by David Cook (dcook@bmc.com).
+
+#189. (Changed in MR14) -gxt switch in C mode
+
+ The -gxt switch in C mode didn't work because of incorrect
+ initialization.
+
+ Reported by Sinan Karasu (sinan@boeing.com).
+
+#188. (Changed in MR14) Added pccts/h/DLG_stream_input.h
+
+ This is a DLG stream class based on C++ istreams.
+
+ Contributed by Hubert Holin (Hubert.Holin@Bigfoot.com).
+
+#187. (Changed in MR14) Rename config.h to pcctscfg.h
+
+ The PCCTS configuration file has been renamed from config.h to
+ pcctscfg.h. The problem with the original name is that it led
+ to name collisions when pccts parsers were combined with other
+ software.
+
+ All of the runtime support routines in pccts/h/* have been
+ changed to use the new name. Existing software can continue
+ to use pccts/h/config.h. The contents of pccts/h/config.h is
+ now just "#include "pcctscfg.h".
+
+ I don't have a record of the user who suggested this.
+
+#186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier
+
+ Classes in the C++ runtime support routines are now declared:
+
+ class DllExportPCCTS className ....
+
+ By default, the pre-processor symbol is defined as the empty
+ string. This if for use by MSVC++ users to create DLL classes.
+
+ Suggested by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase
+
+ Normally, the ASTBase class is derived from PCCTS_AST which contains
+ functions useful to Sorcerer. If these are not necessary then the
+ user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which
+ will cause the ASTBase class to replace references to PCCTS_AST with
+ references to ASTBase where necessary.
+
+ The class ASTDoublyLinkedBase will contain a pure virtual function
+ shallowCopy() that was formerly defined in class PCCTS_AST.
+
+ Suggested by Bob McWhirter (bob@netwrench.com).
+
+#184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h
+
+ Reported by Hubert Holin (Hubert.Holin@bigfoot.com).
+
+#183. (Changed in MR14) -f to specify file with names of grammar files
+
+ In DEC/VMS it is difficult to specify very long command lines.
+ The -f option allows one to place the names of the grammar files
+ in a data file in order to bypass limitations of the DEC/VMS
+ command language interpreter.
+
+ Addition supplied by Bernard Giroud (b_giroud@decus.ch).
+
+#182. (Changed in MR14) Output directory option for DEC/VMS
+
+ Fix some problems with the -o option under DEC/VMS.
+
+ Fix supplied by Bernard Giroud (b_giroud@decus.ch).
+
+#181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar()
+
+ Changed DLGStringInput to cast the character using (unsigned char)
+ so that languages with character codes greater than 127 work
+ without changes.
+
+ Suggested by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#180. (Added in MR14) ANTLRParser::getEofToken()
+
+ Added "ANTLRToken ANTLRParser::getEofToken() const" to match the
+ setEofToken routine.
+
+ Requested by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream
+
+ The BufFileInput class described in Item #142 neglected to release
+ the allocated buffer when an instance was destroyed.
+
+ Reported by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets
+
+ In 1.33 vanilla, and all maintenance releases prior to MR14
+ there is a bug in the handling of guess blocks which use the
+ "long" form:
+
+ (alpha)? beta
+
+ inside a (...)*, (...)+, or {...} block.
+
+ This problem does *not* apply to the case where beta is omitted
+ or when the syntactic predicate is on the leading edge of an
+ alternative.
+
+ The problem is that both alpha and beta are stored in the
+ syntax diagram, and that some analysis routines would fail
+ to skip the alpha portion when it was not on the leading edge.
+ Consider the following grammar with -ck 2:
+
+ r : ( (A)? B )* C D
+
+ | A B /* forces -ck 2 computation for old antlr */
+ /* reports ambig for alts 1 & 2 */
+
+ | B C /* forces -ck 2 computation for new antlr */
+ /* reports ambig for alts 1 & 3 */
+ ;
+
+ The prediction expression for the first alternative should be
+ LA(1)={B C} LA(2)={B C D}, but previous versions of antlr
+ would compute the prediction expression as LA(1)={A C} LA(2)={B D}
+
+ Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided
+ a very clear example of the problem and identified the probable cause.
+
+#177. (Changed in MR14) #tokdefs and #token with regular expression
+
+ In MR13 the change described by Item #162 caused an existing
+ feature of antlr to fail. Prior to the change it was possible
+ to give regular expression definitions and actions to tokens
+ which were defined via the #tokdefs directive.
+
+ This now works again.
+
+ Reported by Manfred Kogler (km@cast.uni-linz.ac.at).
+
+#176. (Changed in MR14) Support for #line in antlr source code
+
+ Note: this was implemented by Arpad Beszedes (beszedes@inf.u-szeged.hu).
+
+ In 1.33MR14 it is possible for a pre-processor to generate #line
+ directives in the antlr source and have those line numbers and file
+ names used in antlr error messages and in the #line directives
+ generated by antlr.
+
+ The #line directive may appear in the following forms:
+
+ #line ll "sss" xx xx ...
+
+ where ll represents a line number, "sss" represents the name of a file
+ enclosed in quotation marks, and xxx are arbitrary integers.
+
+ The following form (without "line") is not supported at the moment:
+
+ # ll "sss" xx xx ...
+
+ The result:
+
+ zzline
+
+ is replaced with ll from the # or #line directive
+
+ FileStr[CurFile]
+
+ is updated with the contents of the string (if any)
+ following the line number
+
+ Note
+ ----
+ The file-name string following the line number can be a complete
+ name with a directory-path. Antlr generates the output files from
+ the input file name (by replacing the extension from the file-name
+ with .c or .cpp).
+
+ If the input file (or the file-name from the line-info) contains
+ a path:
+
+ "../grammar.g"
+
+ the generated source code will be placed in "../grammar.cpp" (i.e.
+ in the parent directory). This is inconvenient in some cases
+ (even the -o switch can not be used) so the path information is
+ removed from the #line directive. Thus, if the line-info was
+
+ #line 2 "../grammar.g"
+
+ then the current file-name will become "grammar.g"
+
+ In this way, the generated source code according to the grammar file
+ will always be in the current directory, except when the -o switch
+ is used.
+
+#175. (Changed in MR14) Bug when guess block appears at start of (...)*
+
+ In 1.33 vanilla and all maintenance releases prior to 1.33MR14
+ there is a bug when a guess block appears at the start of a (...)+.
+ Consider the following k=1 (ck=1) grammar:
+
+ rule :
+ ( (STAR)? ZIP )* ID ;
+
+ Prior to 1.33MR14, the generated code resembled:
+
+ ...
+ zzGUESS_BLOCK
+ while ( 1 ) {
+ if ( ! LA(1)==STAR) break;
+ zzGUESS
+ if ( !zzrv ) {
+ zzmatch(STAR);
+ zzCONSUME;
+ zzGUESS_DONE
+ zzmatch(ZIP);
+ zzCONSUME;
+ ...
+
+ Note that the routine uses STAR for the prediction expression
+ rather than ZIP. With 1.33MR14 the generated code resembles:
+
+ ...
+ while ( 1 ) {
+ if ( ! LA(1)==ZIP) break;
+ ...
+
+ This problem existed only with (...)* blocks and was caused
+ by the slightly more complicate graph which represents (...)*
+ blocks. This caused the analysis routine to compute the first
+ set for the alpha part of the "(alpha)? beta" rather than the
+ beta part.
+
+ Both (...)+ and {...} blocks handled the guess block correctly.
+
+ Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided
+ a very clear example of the problem and identified the probable cause.
+
+#174. (Changed in MR14) Bug when action precedes syntactic predicate
+
+ In 1.33 vanilla, and all maintenance releases prior to MR14,
+ there was a bug when a syntactic predicate was immediately
+ preceded by an action. Consider the following -ck 2 grammar:
+
+ rule :
+ <<int i;>>
+ (alpha)? beta C
+ | A B
+ ;
+
+ alpha : A ;
+ beta : A B;
+
+ Prior to MR14, the code generated for the first alternative
+ resembled:
+
+ ...
+ zzGUESS
+ if ( !zzrv && LA(1)==A && LA(2)==A) {
+ alpha();
+ zzGUESS_DONE
+ beta();
+ zzmatch(C);
+ zzCONSUME;
+ } else {
+ ...
+
+ The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly
+ wrong because LA(2) should be matched to B (first[2] of beta is {B}).
+
+ With 1.33MR14 the prediction expression is:
+
+ ...
+ if ( !zzrv && LA(1)==A && LA(2)==B) {
+ alpha();
+ zzGUESS_DONE
+ beta();
+ zzmatch(C);
+ zzCONSUME;
+ } else {
+ ...
+
+ This will only affect users in which alpha is shorter than
+ than max(k,ck) and there is an action immediately preceding
+ the syntactic predicate.
+
+ This problem was reported by reported by Arpad Beszedes
+ (beszedes@inf.u-szeged.hu) who provided a very clear example
+ of the problem and identified the presence of the init-action
+ as the likely culprit.
+
+#173. (Changed in MR13a) -glms for Microsoft style filenames with -gl
+
+ With the -gl option antlr generates #line directives using the
+ exact name of the input files specified on the command line.
+ An oddity of the Microsoft C and C++ compilers is that they
+ don't accept file names in #line directives containing "\"
+ even though these are names from the native file system.
+
+ With -glms option, the "\" in file names appearing in #line
+ directives is replaced with a "/" in order to conform to
+ Microsoft compiler requirements.
+
+ Reported by Erwin Achermann (erwin.achermann@switzerland.org).
+
+#172. (Changed in MR13) \r\n in antlr source counted as one line
+
+ Some MS software uses \r\n to indicate a new line. Antlr
+ now recognizes this in counting lines.
+
+ Reported by Edward L. Hepler (elh@ece.vill.edu).
+
+#171. (Changed in MR13) #tokclass L..U now allowed
+
+ The following is now allowed:
+
+ #tokclass ABC { A..B C }
+
+ Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)
+
+#170. (Changed in MR13) Suppression for predicates with lookahead depth >1
+
+ In MR12 the capability for suppression of predicates with lookahead
+ depth=1 was introduced. With MR13 this had been extended to
+ predicates with lookahead depth > 1 and released for use by users
+ on an experimental basis.
+
+ Consider the following grammar with -ck 2 and the predicate in rule
+ "a" with depth 2:
+
+ r1 : (ab)* "@"
+ ;
+
+ ab : a
+ | b
+ ;
+
+ a : (A B)? => <<p(LATEXT(2))>>? A B C
+ ;
+
+ b : A B C
+ ;
+
+ Normally, the predicate would be hoisted into rule r1 in order to
+ determine whether to call rule "ab". However it should *not* be
+ hoisted because, even if p is false, there is a valid alternative
+ in rule b. With "-mrhoistk on" the predicate will be suppressed.
+
+ If "-info p" command line option is present the following information
+ will appear in the generated code:
+
+ while ( (LA(1)==A)
+ #if 0
+
+ Part (or all) of predicate with depth > 1 suppressed by alternative
+ without predicate
+
+ pred << p(LATEXT(2))>>?
+ depth=k=2 ("=>" guard) rule a line 8 t1.g
+ tree context:
+ (root = A
+ B
+ )
+
+ The token sequence which is suppressed: ( A B )
+ The sequence of references which generate that sequence of tokens:
+
+ 1 to ab r1/1 line 1 t1.g
+ 2 ab ab/1 line 4 t1.g
+ 3 to b ab/2 line 5 t1.g
+ 4 b b/1 line 11 t1.g
+ 5 #token A b/1 line 11 t1.g
+ 6 #token B b/1 line 11 t1.g
+
+ #endif
+
+ A slightly more complicated example:
+
+ r1 : (ab)* "@"
+ ;
+
+ ab : a
+ | b
+ ;
+
+ a : (A B)? => <<p(LATEXT(2))>>? (A B | D E)
+ ;
+
+ b : <<q(LATEXT(2))>>? D E
+ ;
+
+
+ In this case, the sequence (D E) in rule "a" which lies behind
+ the guard is used to suppress the predicate with context (D E)
+ in rule b.
+
+ while ( (LA(1)==A || LA(1)==D)
+ #if 0
+
+ Part (or all) of predicate with depth > 1 suppressed by alternative
+ without predicate
+
+ pred << q(LATEXT(2))>>?
+ depth=k=2 rule b line 11 t2.g
+ tree context:
+ (root = D
+ E
+ )
+
+ The token sequence which is suppressed: ( D E )
+ The sequence of references which generate that sequence of tokens:
+
+ 1 to ab r1/1 line 1 t2.g
+ 2 ab ab/1 line 4 t2.g
+ 3 to a ab/1 line 4 t2.g
+ 4 a a/1 line 8 t2.g
+ 5 #token D a/1 line 8 t2.g
+ 6 #token E a/1 line 8 t2.g
+
+ #endif
+ &&
+ #if 0
+
+ pred << p(LATEXT(2))>>?
+ depth=k=2 ("=>" guard) rule a line 8 t2.g
+ tree context:
+ (root = A
+ B
+ )
+
+ #endif
+
+ (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) {
+ ab();
+ ...
+
+#169. (Changed in MR13) Predicate test optimization for depth=1 predicates
+
+ When the MR12 generated a test of a predicate which had depth 1
+ it would use the depth >1 routines, resulting in correct but
+ inefficient behavior. In MR13, a bit test is used.
+
+#168. (Changed in MR13) Token expressions in context guards
+
+ The token expressions appearing in context guards such as:
+
+ (A B)? => <<test(LT(1))>>? someRule
+
+ are computed during an early phase of antlr processing. As
+ a result, prior to MR13, complex expressions such as:
+
+ ~B
+ L..U
+ ~L..U
+ TokClassName
+ ~TokClassName
+
+ were not computed properly. This resulted in incorrect
+ context being computed for such expressions.
+
+ In MR13 these context guards are verified for proper semantics
+ in the initial phase and then re-evaluated after complex token
+ expressions have been computed in order to produce the correct
+ behavior.
+
+ Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu).
+
+#167. (Changed in MR13) ~L..U
+
+ Prior to MR13, the complement of a token range was
+ not properly computed.
+
+#166. (Changed in MR13) token expression L..U
+
+ The token U was represented as an unsigned char, restricting
+ the use of L..U to cases where U was assigned a token number
+ less than 256. This is corrected in MR13.
+
+#165. (Changed in MR13) option -newAST
+
+ To create ASTs from an ANTLRTokenPtr antlr usually calls
+ "new AST(ANTLRTokenPtr)". This option generates a call
+ to "newAST(ANTLRTokenPtr)" instead. This allows a user
+ to define a parser member function to create an AST object.
+
+ Similar changes for ASTBase::tmake and ASTBase::link were not
+ thought necessary since they do not create AST objects, only
+ use existing ones.
+
+#164. (Changed in MR13) Unused variable _astp
+
+ For many compilations, we have lived with warnings about
+ the unused variable _astp. It turns out that this varible
+ can *never* be used because the code which references it was
+ commented out.
+
+ This investigation was sparked by a note from Erwin Achermann
+ (erwin.achermann@switzerland.org).
+
+#163. (Changed in MR13) Incorrect makefiles for testcpp examples
+
+ All the examples in pccts/testcpp/* had incorrect definitions
+ in the makefiles for the symbol "CCC". Instead of CCC=CC they
+ had CC=$(CCC).
+
+ There was an additional problem in testcpp/1/test.g due to the
+ change in ANTLRToken::getText() to a const member function
+ (Item #137).
+
+ Reported by Maurice Mass (maas@cuci.nl).
+
+#162. (Changed in MR13) Combining #token with #tokdefs
+
+ When it became possible to change the print-name of a
+ #token (Item #148) it became useful to give a #token
+ statement whose only purpose was to giving a print name
+ to the #token. Prior to this change this could not be
+ combined with the #tokdefs feature.
+
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h
+
+#160. (Changed in MR13) Omissions in list of names for remap.h
+
+ When a user selects the -gp option antlr creates a list
+ of macros in remap.h to rename some of the standard
+ antlr routines from zzXXX to userprefixXXX.
+
+ There were number of omissions from the remap.h name
+ list related to the new trace facility. This was reported,
+ along with a fix, by Bernie Solomon (bernard@ug.eds.com).
+
+#159. (Changed in MR13) Violations of classic C rules
+
+ There were a number of violations of classic C style in
+ the distribution kit. This was reported, along with fixes,
+ by Bernie Solomon (bernard@ug.eds.com).
+
+#158. (Changed in MR13) #header causes problem for pre-processors
+
+ A user who runs the C pre-processor on antlr source suggested
+ that another syntax be allowed. With MR13 such directives
+ such as #header, #pragma, etc. may be written as "\#header",
+ "\#pragma", etc. For escaping pre-processor directives inside
+ a #header use something like the following:
+
+ \#header
+ <<
+ \#include <stdio.h>
+ >>
+
+#157. (Fixed in MR13) empty error sets for rules with infinite recursion
+
+ When the first set for a rule cannot be computed due to infinite
+ left recursion and it is the only alternative for a block then
+ the error set for the block would be empty. This would result
+ in a fatal error.
+
+ Reported by Darin Creason (creason@genedax.com)
+
+#156. (Changed in MR13) DLGLexerBase::getToken() now public
+
+#155. (Changed in MR13) Context behind predicates can suppress
+
+ With -mrhoist enabled the context behind a guarded predicate can
+ be used to suppress other predicates. Consider the following grammar:
+
+ r0 : (r1)+;
+
+ r1 : rp
+ | rq
+ ;
+ rp : <<p LATEXT(1)>>? B ;
+ rq : (A)? => <<q LATEXT(1)>>? (A|B);
+
+ In earlier versions both predicates "p" and "q" would be hoisted into
+ rule r0. With MR12c predicate p is suppressed because the context which
+ follows predicate q includes "B" which can "cover" predicate "p". In
+ other words, in trying to decide in r0 whether to call r1, it doesn't
+ really matter whether p is false or true because, either way, there is
+ a valid choice within r1.
+
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>
+
+ A common error, even among experienced pccts users, is to code
+ an init-action to inhibit hoisting rather than a leading action.
+ An init-action does not inhibit hoisting.
+
+ This was coded:
+
+ rule1 : <<;>> rule2
+
+ This is what was meant:
+
+ rule1 : <<;>> <<;>> rule2
+
+ With MR13, the user can code:
+
+ rule1 : <<;>> <<nohoist>> rule2
+
+ The following will give an error message:
+
+ rule1 : <<nohoist>> rule2
+
+ If the <<nohoist>> appears as an init-action rather than a leading
+ action an error message is issued. The meaning of an init-action
+ containing "nohoist" is unclear: does it apply to just one
+ alternative or to all alternatives ?
+
+
+
+
+
+
+
+
+ -------------------------------------------------------
+ Note: Items #153 to #1 are now in a separate file named
+ CHANGES_FROM_133_BEFORE_MR13.txt
+ -------------------------------------------------------
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt
new file mode 100644
index 0000000000..5e2c020964
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt
@@ -0,0 +1,3666 @@
+
+ ------------------------------------------------------------
+ This is the second part of a two part file.
+ This is a list of changes to pccts 1.33 prior to MR13
+ For more recent information see CHANGES_FROM_133.txt
+ ------------------------------------------------------------
+
+ DISCLAIMER
+
+ The software and these notes are provided "as is". They may include
+ typographical or technical errors and their authors disclaims all
+ liability of any kind or nature for damages due to error, fault,
+ defect, or deficiency regardless of cause. All warranties of any
+ kind, either express or implied, including, but not limited to, the
+ implied warranties of merchantability and fitness for a particular
+ purpose are disclaimed.
+
+
+#153. (Changed in MR12b) Bug in computation of -mrhoist suppression set
+
+ Consider the following grammar with k=1 and "-mrhoist on":
+
+ r1 : (A)? => ((p>>? x /* l1 */
+ | r2 /* l2 */
+ ;
+ r2 : A /* l4 */
+ | (B)? => <<q>>? y /* l5 */
+ ;
+
+ In earlier versions the mrhoist routine would see that both l1 and
+ l2 contained predicates and would assume that this prevented either
+ from acting to suppress the other predicate. In the example above
+ it didn't realize the A at line l4 is capable of suppressing the
+ predicate at l1 even though alt l2 contains (indirectly) a predicate.
+
+ This is fixed in MR12b.
+
+ Reported by Reinier van den Born (reinier@vnet.ibm.com)
+
+#153. (Changed in MR12a) Bug in computation of -mrhoist suppression set
+
+ An oversight similar to that described in Item #152 appeared in
+ the computation of the set that "covered" a predicate. If a
+ predicate expression included a term such as p=AND(q,r) the context
+ of p was taken to be context(q) & context(r), when it should have
+ been context(q) | context(r). This is fixed in MR12a.
+
+#152. (Changed in MR12) Bug in generation of predicate expressions
+
+ The primary purpose for MR12 is to make quite clear that MR11 is
+ obsolete and to fix the bug related to predicate expressions.
+
+ In MR10 code was added to optimize the code generated for
+ predicate expression tests. Unfortunately, there was a
+ significant oversight in the code which resulted in a bug in
+ the generation of code for predicate expression tests which
+ contained predicates combined using AND:
+
+ r0 : (r1)* "@" ;
+ r1 : (AAA)? => <<p LATEXT(1)>>? r2 ;
+ r2 : (BBB)? => <<q LATEXT(1)>>? Q
+ | (BBB)? => <<r LATEXT(1)>>? Q
+ ;
+
+ In MR11 (and MR10 when using "-mrhoist on") the code generated
+ for r0 to predict r1 would be equivalent to:
+
+ if ( LA(1)==Q &&
+ (LA(1)==AAA && LA(1)==BBB) &&
+ ( p && ( q || r )) ) {
+
+ This is incorrect because it expresses the idea that LA(1)
+ *must* be AAA in order to attempt r1, and *must* be BBB to
+ attempt r2. The result was that r1 became unreachable since
+ both condition can not be simultaneously true.
+
+ The general philosophy of code generation for predicates
+ can be summarized as follows:
+
+ a. If the context is true don't enter an alt
+ for which the corresponding predicate is false.
+
+ If the context is false then it is okay to enter
+ the alt without evaluating the predicate at all.
+
+ b. A predicate created by ORing of predicates has
+ context which is the OR of their individual contexts.
+
+ c. A predicate created by ANDing of predicates has
+ (surprise) context which is the OR of their individual
+ contexts.
+
+ d. Apply these rules recursively.
+
+ e. Remember rule (a)
+
+ The correct code should express the idea that *if* LA(1) is
+ AAA then p must be true to attempt r1, but if LA(1) is *not*
+ AAA then it is okay to attempt r1, provided that *if* LA(1) is
+ BBB then one of q or r must be true.
+
+ if ( LA(1)==Q &&
+ ( !(LA(1)==AAA || LA(1)==BBB) ||
+ ( ! LA(1) == AAA || p) &&
+ ( ! LA(1) == BBB || q || r ) ) ) {
+
+ I believe this is fixed in MR12.
+
+ Reported by Reinier van den Born (reinier@vnet.ibm.com)
+
+#151a. (Changed in MR12) ANTLRParser::getLexer()
+
+ As a result of several requests, I have added public methods to
+ get a pointer to the lexer belonging to a parser.
+
+ ANTLRTokenStream *ANTLRParser::getLexer() const
+
+ Returns a pointer to the lexer being used by the
+ parser. ANTLRTokenStream is the base class of
+ DLGLexer
+
+ ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const
+
+ Returns a pointer to the lexer being used by the
+ ANTLRTokenBuffer. ANTLRTokenStream is the base
+ class of DLGLexer
+
+ You must manually cast the ANTLRTokenStream to your program's
+ lexer class. Because the name of the lexer's class is not fixed.
+ Thus it is impossible to incorporate it into the DLGLexerBase
+ class.
+
+#151b.(Changed in MR12) ParserBlackBox member getLexer()
+
+ The template class ParserBlackBox now has a member getLexer()
+ which returns a pointer to the lexer.
+
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public
+
+ See Item #127 for more information.
+
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)
+
+ If there is more than one rule which is not referenced by any
+ other rule then all such rules are listed. This is useful for
+ alerting one to rules which are not used, but which can still
+ contribute to ambiguity. For example:
+
+ start : a Z ;
+ unused: a A ;
+ a : (A)+ ;
+
+ will cause an ambiguity report for rule "a" which will be
+ difficult to understand if the user forgets about rule "unused"
+ simply because it is not used in the grammar.
+
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl
+
+ In a #token statement like the following:
+
+ #token Plus "\+"
+
+ the string "Plus" appears in the zztokens array (C mode) and
+ token_tbl (C++ mode). This string is used in most error
+ messages. In MR11 one has the option of using some other string,
+ (e.g. "+") in those tables.
+
+ In MR11 one can write:
+
+ #token Plus ("+") "\+"
+ #token RP ("(") "\("
+ #token COM ("comment begin") "/\*"
+
+ A #token statement is allowed to appear in more than one #lexclass
+ with different regular expressions. However, the token name appears
+ only once in the zztokens/token_tbl array. This means that only
+ one substitute can be specified for a given #token name. The second
+ attempt to define a substitute name (different from the first) will
+ result in an error message.
+
+#147. (Changed in MR11) Bug in follow set computation
+
+ There is a bug in 1.33 vanilla and all maintenance releases
+ prior to MR11 in the computation of the follow set. The bug is
+ different than that described in Item #82 and probably more
+ common. It was discovered in the ansi.g grammar while testing
+ the "ambiguity aid" (Item #119). The search for a bug started
+ when the ambiguity aid was unable to discover the actual source
+ of an ambiguity reported by antlr.
+
+ The problem appears when an optimization of the follow set
+ computation is used inappropriately. The result is that the
+ follow set used is the "worst case". In other words, the error
+ can lead to false reports of ambiguity. The good news is that
+ if you have a grammar in which you have addressed all reported
+ ambiguities you are ok. The bad news is that you may have spent
+ time fixing ambiguities that were not real, or used k=2 when
+ ck=2 might have been sufficient, and so on.
+
+ The following grammar demonstrates the problem:
+
+ ------------------------------------------------------------
+ expr : ID ;
+
+ start : stmt SEMI ;
+
+ stmt : CASE expr COLON
+ | expr SEMI
+ | plain_stmt
+ ;
+
+ plain_stmt : ID COLON ;
+ ------------------------------------------------------------
+
+ When compiled with k=1 and ck=2 it will report:
+
+ warning: alts 2 and 3 of the rule itself ambiguous upon
+ { IDENTIFIER }, { COLON }
+
+ When antlr analyzes "stmt" it computes the first[1] set of all
+ alternatives. It finds an ambiguity between alts 2 and 3 for ID.
+ It then computes the first[2] set for alternatives 2 and 3 to resolve
+ the ambiguity. In computing the first[2] set of "expr" (which is
+ only one token long) it needs to determine what could follow "expr".
+ Under a certain combination of circumstances antlr forgets that it
+ is trying to analyze "stmt" which can only be followed by SEMI and
+ adds to the first[2] set of "expr" the "global" follow set (including
+ "COLON") which could follow "expr" (under other conditions) in the
+ phrase "CASE expr COLON".
+
+#146. (Changed in MR11) Option -treport for locating "difficult" alts
+
+ 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 peformed 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.
+
+ The following is a trivial case from the ansi.g grammar which shows
+ the format of the report. This report might be of more interest
+ in cases where 1,000,000 tuples were created to resolve the ambiguity.
+
+ -------------------------------------------------------------------------
+ There were 0 tuples whose ambiguity could not be resolved
+ by full lookahead
+ There were 157 tnodes created to resolve ambiguity between:
+
+ Choice 1: statement/2 line 475 file ansi.g
+ Choice 2: statement/3 line 476 file ansi.g
+
+ Intersection of lookahead[1] sets:
+
+ IDENTIFIER
+
+ Intersection of lookahead[2] sets:
+
+ LPARENTHESIS COLON AMPERSAND MINUS
+ STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT
+ NOT SIZEOF OCTALINT DECIMALINT
+ HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER
+ STRING CHARACTER
+ -------------------------------------------------------------------------
+
+#145. (Documentation) Generation of Expression Trees
+
+ Item #99 was misleading because it implied that the optimization
+ for tree expressions was available only for trees created by
+ predicate expressions and neglected to mention that it required
+ the use of "-mrhoist on". The optimization applies to tree
+ expressions created for grammars with k>1 and for predicates with
+ lookahead depth >1.
+
+ In MR11 the optimized version is always used so the -mrhoist on
+ option need not be specified.
+
+#144. (Changed in MR11) Incorrect test for exception group
+
+ In testing for a rule's exception group the label a pointer
+ is compared against '\0'. The intention is "*pointer".
+
+ Reported by Jeffrey C. Fried (Jeff@Fried.net).
+
+#143. (Changed in MR11) Optional ";" at end of #token statement
+
+ Fixes problem of:
+
+ #token X "x"
+
+ <<
+ parser action
+ >>
+
+ Being confused with:
+
+ #token X "x" <<lexical action>>
+
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream
+
+ Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class
+ BufFileInput derived from DLGInputStream which provides a
+ function lookahead(char *string) to test characters in the
+ input stream more than one character ahead.
+
+ The default amount of lookahead is specified by the constructor
+ and defaults to 8 characters. This does *not* include the one
+ character of lookahead maintained internally by DLG in member "ch"
+ and which is not available for testing via BufFileInput::lookahead().
+
+ This is a useful class for overcoming the one-character-lookahead
+ limitation of DLG without resorting to a lexer capable of
+ backtracking (like flex) which is not integrated with antlr as is
+ DLG.
+
+ There are no restrictions on copying or using BufFileInput.* except
+ that the authorship and related information must be retained in the
+ source code.
+
+ The class is located in pccts/h/BufFileInput.* of the kit.
+
+#141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume()
+
+ A debug aid has been added to file ANTLRParser::consume() in
+ file AParser.cpp:
+
+ #ifdef ZZDEBUG_CONSUME_ACTION
+ zzdebug_consume_action();
+ #endif
+
+ Suggested by Sramji Ramanathan (ps@kumaran.com).
+
+#140. (Changed in MR11) #pred to define predicates
+
+ +---------------------------------------------------+
+ | Note: Assume "-prc on" for this entire discussion |
+ +---------------------------------------------------+
+
+ A problem with predicates is that each one is regarded as
+ unique and capable of disambiguating cases where two
+ alternatives have identical lookahead. For example:
+
+ rule : <<pred(LATEXT(1))>>? A
+ | <<pred(LATEXT(1))>>? A
+ ;
+
+ will not cause any error messages or warnings to be issued
+ by earlier versions of pccts. To compare the text of the
+ predicates is an incomplete solution.
+
+ In 1.33MR11 I am introducing the #pred statement in order to
+ solve some problems with predicates. The #pred statement allows
+ one to give a symbolic name to a "predicate literal" or a
+ "predicate expression" in order to refer to it in other predicate
+ expressions or in the rules of the grammar.
+
+ The predicate literal associated with a predicate symbol is C
+ or C++ code which can be used to test the condition. A
+ predicate expression defines a predicate symbol in terms of other
+ predicate symbols using "!", "&&", and "||". A predicate symbol
+ can be defined in terms of a predicate literal, a predicate
+ expression, or *both*.
+
+ When a predicate symbol is defined with both a predicate literal
+ and a predicate expression, the predicate literal is used to generate
+ code, but the predicate expression is used to check for two
+ alternatives with identical predicates in both alternatives.
+
+ Here are some examples of #pred statements:
+
+ #pred IsLabel <<isLabel(LATEXT(1))>>?
+ #pred IsLocalVar <<isLocalVar(LATEXT(1))>>?
+ #pred IsGlobalVar <<isGlobalVar(LATEXT(1)>>?
+ #pred IsVar <<isVar(LATEXT(1))>>? IsLocalVar || IsGlobalVar
+ #pred IsScoped <<isScoped(LATEXT(1))>>? IsLabel || IsLocalVar
+
+ I hope that the use of EBNF notation to describe the syntax of the
+ #pred statement will not cause problems for my readers (joke).
+
+ predStatement : "#pred"
+ CapitalizedName
+ (
+ "<<predicate_literal>>?"
+ | "<<predicate_literal>>?" predOrExpr
+ | predOrExpr
+ )
+ ;
+
+ predOrExpr : predAndExpr ( "||" predAndExpr ) * ;
+
+ predAndExpr : predPrimary ( "&&" predPrimary ) * ;
+
+ predPrimary : CapitalizedName
+ | "!" predPrimary
+ | "(" predOrExpr ")"
+ ;
+
+ What is the purpose of this nonsense ?
+
+ To understand how predicate symbols help, you need to realize that
+ predicate symbols are used in two different ways with two different
+ goals.
+
+ a. Allow simplification of predicates which have been combined
+ during predicate hoisting.
+
+ b. Allow recognition of identical predicates which can't disambiguate
+ alternatives with common lookahead.
+
+ First we will discuss goal (a). Consider the following rule:
+
+ rule0: rule1
+ | ID
+ | ...
+ ;
+
+ rule1: rule2
+ | rule3
+ ;
+
+ rule2: <<isX(LATEXT(1))>>? ID ;
+ rule3: <<!isX(LATEXT(1)>>? ID ;
+
+ When the predicates in rule2 and rule3 are combined by hoisting
+ to create a prediction expression for rule1 the result is:
+
+ if ( LA(1)==ID
+ && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...
+
+ This is inefficient, but more importantly, can lead to false
+ assumptions that the predicate expression distinguishes the rule1
+ alternative with some other alternative with lookahead ID. In
+ MR11 one can write:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+
+ ...
+
+ rule2: <<IsX>>? ID ;
+ rule3: <<!IsX>>? ID ;
+
+ During hoisting MR11 recognizes this as a special case and
+ eliminates the predicates. The result is a prediction
+ expression like the following:
+
+ if ( LA(1)==ID ) { rule1(); ...
+
+ Please note that the following cases which appear to be equivalent
+ *cannot* be simplified by MR11 during hoisting because the hoisting
+ logic only checks for a "!" in the predicate action, not in the
+ predicate expression for a predicate symbol.
+
+ *Not* equivalent and is not simplified during hoisting:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+ #pred NotX <<!isX(LATEXT(1))>>?
+ ...
+ rule2: <<IsX>>? ID ;
+ rule3: <<NotX>>? ID ;
+
+ *Not* equivalent and is not simplified during hoisting:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+ #pred NotX !IsX
+ ...
+ rule2: <<IsX>>? ID ;
+ rule3: <<NotX>>? ID ;
+
+ Now we will discuss goal (b).
+
+ When antlr discovers that there is a lookahead ambiguity between
+ two alternatives it attempts to resolve the ambiguity by searching
+ for predicates in both alternatives. In the past any predicate
+ would do, even if the same one appeared in both alternatives:
+
+ rule: <<p(LATEXT(1))>>? X
+ | <<p(LATEXT(1))>>? X
+ ;
+
+ The #pred statement is a start towards solving this problem.
+ During ambiguity resolution (*not* predicate hoisting) the
+ predicates for the two alternatives are expanded and compared.
+ Consider the following example:
+
+ #pred Upper <<isUpper(LATEXT(1))>>?
+ #pred Lower <<isLower(LATEXT(1))>>?
+ #pred Alpha <<isAlpha(LATEXT(1))>>? Upper || Lower
+
+ rule0: rule1
+ | <<Alpha>>? ID
+ ;
+
+ rule1:
+ | rule2
+ | rule3
+ ...
+ ;
+
+ rule2: <<Upper>>? ID;
+ rule3: <<Lower>>? ID;
+
+ The definition of #pred Alpha expresses:
+
+ a. to test the predicate use the C code "isAlpha(LATEXT(1))"
+
+ b. to analyze the predicate use the information that
+ Alpha is equivalent to the union of Upper and Lower,
+
+ During ambiguity resolution the definition of Alpha is expanded
+ into "Upper || Lower" and compared with the predicate in the other
+ alternative, which is also "Upper || Lower". Because they are
+ identical MR11 will report a problem.
+
+ -------------------------------------------------------------------------
+ t10.g, line 5: warning: the predicates used to disambiguate rule rule0
+ (file t10.g alt 1 line 5 and alt 2 line 6)
+ are identical when compared without context and may have no
+ resolving power for some lookahead sequences.
+ -------------------------------------------------------------------------
+
+ If you use the "-info p" option the output file will contain:
+
+ +----------------------------------------------------------------------+
+ |#if 0 |
+ | |
+ |The following predicates are identical when compared without |
+ | lookahead context information. For some ambiguous lookahead |
+ | sequences they may not have any power to resolve the ambiguity. |
+ | |
+ |Choice 1: rule0/1 alt 1 line 5 file t10.g |
+ | |
+ | The original predicate for choice 1 with available context |
+ | information: |
+ | |
+ | OR expr |
+ | |
+ | pred << Upper>>? |
+ | depth=k=1 rule rule2 line 14 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | pred << Lower>>? |
+ | depth=k=1 rule rule3 line 15 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | The predicate for choice 1 after expansion (but without context |
+ | information): |
+ | |
+ | OR expr |
+ | |
+ | pred << isUpper(LATEXT(1))>>? |
+ | depth=k=1 rule line 1 t10.g |
+ | |
+ | pred << isLower(LATEXT(1))>>? |
+ | depth=k=1 rule line 2 t10.g |
+ | |
+ | |
+ |Choice 2: rule0/2 alt 2 line 6 file t10.g |
+ | |
+ | The original predicate for choice 2 with available context |
+ | information: |
+ | |
+ | pred << Alpha>>? |
+ | depth=k=1 rule rule0 line 6 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | The predicate for choice 2 after expansion (but without context |
+ | information): |
+ | |
+ | OR expr |
+ | |
+ | pred << isUpper(LATEXT(1))>>? |
+ | depth=k=1 rule line 1 t10.g |
+ | |
+ | pred << isLower(LATEXT(1))>>? |
+ | depth=k=1 rule line 2 t10.g |
+ | |
+ | |
+ |#endif |
+ +----------------------------------------------------------------------+
+
+ The comparison of the predicates for the two alternatives takes
+ place without context information, which means that in some cases
+ the predicates will be considered identical even though they operate
+ on disjoint lookahead sets. Consider:
+
+ #pred Alpha
+
+ rule1: <<Alpha>>? ID
+ | <<Alpha>>? Label
+ ;
+
+ Because the comparison of predicates takes place without context
+ these will be considered identical. The reason for comparing
+ without context is that otherwise it would be necessary to re-evaluate
+ the entire predicate expression for each possible lookahead sequence.
+ This would require more code to be written and more CPU time during
+ grammar analysis, and it is not yet clear whether anyone will even make
+ use of the new #pred facility.
+
+ A temporary workaround might be to use different #pred statements
+ for predicates you know have different context. This would avoid
+ extraneous warnings.
+
+ The above example might be termed a "false positive". Comparison
+ without context will also lead to "false negatives". Consider the
+ following example:
+
+ #pred Alpha
+ #pred Beta
+
+ rule1: <<Alpha>>? A
+ | rule2
+ ;
+
+ rule2: <<Alpha>>? A
+ | <<Beta>>? B
+ ;
+
+ The predicate used for alt 2 of rule1 is (Alpha || Beta). This
+ appears to be different than the predicate Alpha used for alt1.
+ However, the context of Beta is B. Thus when the lookahead is A
+ Beta will have no resolving power and Alpha will be used for both
+ alternatives. Using the same predicate for both alternatives isn't
+ very helpful, but this will not be detected with 1.33MR11.
+
+ To properly handle this the predicate expression would have to be
+ evaluated for each distinct lookahead context.
+
+ To determine whether two predicate expressions are identical is
+ difficult. The routine may fail to identify identical predicates.
+
+ The #pred feature also compares predicates to see if a choice between
+ alternatives which is resolved by a predicate which makes the second
+ choice unreachable. Consider the following example:
+
+ #pred A <<A(LATEXT(1)>>?
+ #pred B <<B(LATEXT(1)>>?
+ #pred A_or_B A || B
+
+ r : s
+ | t
+ ;
+ s : <<A_or_B>>? ID
+ ;
+ t : <<A>>? ID
+ ;
+
+ ----------------------------------------------------------------------------
+ t11.g, line 5: warning: the predicate used to disambiguate the
+ first choice of rule r
+ (file t11.g alt 1 line 5 and alt 2 line 6)
+ appears to "cover" the second predicate when compared without context.
+ The second predicate may have no resolving power for some lookahead
+ sequences.
+ ----------------------------------------------------------------------------
+
+#139. (Changed in MR11) Problem with -gp in C++ mode
+
+ The -gp option to add a prefix to rule names did not work in
+ C++ mode. This has been fixed.
+
+ Reported by Alexey Demakov (demakov@kazbek.ispras.ru).
+
+#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems
+
+ Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for
+ building antlr and dlg with Win95/NT development tools that
+ are not based on MSVC5. They are pccts/antlr/AntlrMS.mak and
+ pccts/dlg/DlgMS.mak.
+
+ The first line of the makefiles require a definition of PCCTS_HOME.
+
+ These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*
+ supplied by Jeff Vincent (JVincent@novell.com).
+
+#137. (Changed in MR11) Token getType(), getText(), getLine() const members
+
+ --------------------------------------------------------------------
+ If you use ANTLRCommonToken this change probably does not affect you.
+ --------------------------------------------------------------------
+
+ For a long time it has bothered me that these accessor functions
+ in ANTLRAbstractToken were not const member functions. I have
+ refrained from changing them because it require users to modify
+ existing token class definitions which are derived directly
+ from ANTLRAbstractToken. I think it is now time.
+
+ For those who are not used to C++, a "const member function" is a
+ member function which does not modify its own object - the thing
+ to which "this" points. This is quite different from a function
+ which does not modify its arguments
+
+ Most token definitions based on ANTLRAbstractToken have something like
+ the following in order to create concrete definitions of the pure
+ virtual methods in ANTLRAbstractToken:
+
+ class MyToken : public ANTLRAbstractToken {
+ ...
+ ANTLRTokenType getType() {return _type; }
+ int getLine() {return _line; }
+ ANTLRChar * getText() {return _text; }
+ ...
+ }
+
+ The required change is simply to put "const" following the function
+ prototype in the header (.h file) and the definition file (.cpp if
+ it is not inline):
+
+ class MyToken : public ANTLRAbstractToken {
+ ...
+ ANTLRTokenType getType() const {return _type; }
+ int getLine() const {return _line; }
+ ANTLRChar * getText() const {return _text; }
+ ...
+ }
+
+ This was originally proposed a long time ago by Bruce
+ Guenter (bruceg@qcc.sk.ca).
+
+#136. (Changed in MR11) Added getLength() to ANTLRCommonToken
+
+ Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken
+ now have a member function:
+
+ int getLength() const { return strlen(getText()) }
+
+ Suggested by Sramji Ramanathan (ps@kumaran.com).
+
+#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k
+
+#134a. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
+
+ There is a typographical error in the definition of BITWISEOREQ:
+
+ #token BITWISEOREQ "!=" should be "\|="
+
+ When this change is combined with the bugfix to the follow set cache
+ problem (Item #147) and a minor rearrangement of the grammar
+ (Item #134b) it becomes a k=1 ck=2 grammar.
+
+#134b. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
+
+ The following changes were made in the ansi.g grammar (along with
+ using -mrhoist on):
+
+ ansi.g
+ ======
+ void tracein(char *) ====> void tracein(const char *)
+ void traceout(char *) ====> void traceout(const char *)
+
+ <LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?
+ ====> <<isTypeName(LT(1)->getText())>>?
+
+ <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
+ isTypeName(LT(2)->getText()) : 1>>?
+ ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
+
+ <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
+ isTypeName(LT(2)->getText()) : 1>>?
+ ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
+
+ added to init(): traceOptionValueDefault=0;
+ added to init(): traceOption(-1);
+
+ change rule "statement":
+
+ statement
+ : plain_label_statement
+ | case_label_statement
+ | <<;>> expression SEMICOLON
+ | compound_statement
+ | selection_statement
+ | iteration_statement
+ | jump_statement
+ | SEMICOLON
+ ;
+
+ plain_label_statement
+ : IDENTIFIER COLON statement
+ ;
+
+ case_label_statement
+ : CASE constant_expression COLON statement
+ | DEFAULT COLON statement
+ ;
+
+ support.cpp
+ ===========
+ void tracein(char *) ====> void tracein(const char *)
+ void traceout(char *) ====> void traceout(const char *)
+
+ added to tracein(): ANTLRParser::tracein(r); // call superclass method
+ added to traceout(): ANTLRParser::traceout(r); // call superclass method
+
+ Makefile
+ ========
+ added to AFLAGS: -mrhoist on -prc on
+
+#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser
+
+ In checking T.J. Parr's ANSI C grammar for compatibility with
+ 1.33MR11 discovered that it was inconvenient to have the
+ trace facilities with protected access.
+
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts
+
+ Prior to 1.33MR11, there would be no ambiguity warning when the
+ very same predicate was used to disambiguate both alternatives:
+
+ test: ref B
+ | ref C
+ ;
+
+ ref : <<pred(LATEXT(1)>>? A
+
+ In 1.33MR11 this will cause the warning:
+
+ warning: the predicates used to disambiguate rule test
+ (file v98.g alt 1 line 1 and alt 2 line 2)
+ are identical and have no resolving power
+
+ ----------------- Note -----------------
+
+ This is different than the following case
+
+ test: <<pred(LATEXT(1))>>? A B
+ | <<pred(LATEXT(1)>>? A C
+ ;
+
+ In this case there are two distinct predicates
+ which have exactly the same text. In the first
+ example there are two references to the same
+ predicate. The problem represented by this
+ grammar will be addressed later.
+
+#131. (Changed in 1.33MR11) Case insensitive command line options
+
+ Command line switches like "-CC" and keywords like "on", "off",
+ and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.
+
+#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string
+
+ The ANTLR_VERSION was not an integer, making it difficult to
+ perform conditional compilation based on the antlr version.
+
+ Henceforth, ANTLR_VERSION will be:
+
+ (base_version * 10000) + release number
+
+ thus 1.33MR11 will be: 133*100+11 = 13311
+
+ Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).
+
+#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h
+
+ The following code is now inserted into <parserName>.h amd
+ stdpccts.h:
+
+ #ifndef ANTLR_VERSION
+ #define ANTLR_VERSION 13311
+ #endif
+
+ Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)
+
+#128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+
+
+ Prior to 1.33MR11, the following grammar would generate
+ redundant tests for the "while" condition.
+
+ rule2 : (<<pred>>? X)+ X
+ | B
+ ;
+
+ The code would resemble:
+
+ if (LA(1)==X) {
+ if (pred) {
+ do {
+ if (!pred) {zzfailed_pred(" pred");}
+ zzmatch(X); zzCONSUME;
+ } while (LA(1)==X && pred && pred);
+ } else {...
+
+ With 1.33MR11 the redundant predicate test is omitted.
+
+#127. (Changed in 1.33MR11)
+
+ Count Syntax Errors Count DLG Errors
+ ------------------- ----------------
+
+ C++ mode ANTLRParser:: DLGLexerBase::
+ syntaxErrCount lexErrCount
+ C mode zzSyntaxErrCount zzLexErrCount
+
+ The C mode variables are global and initialized to 0.
+ They are *not* reset to 0 automatically when antlr is
+ restarted.
+
+ The C++ mode variables are public. They are initialized
+ to 0 by the constructors. They are *not* reset to 0 by the
+ ANTLRParser::init() method.
+
+ Suggested by Reinier van den Born (reinier@vnet.ibm.com).
+
+#126. (Changed in 1.33MR11) Addition of #first <<...>>
+
+ The #first <<...>> inserts the specified text in the output
+ files before any other #include statements required by pccts.
+ The only things before the #first text are comments and
+ a #define ANTLR_VERSION.
+
+ Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin
+ Zoltan (alexin@inf.u-szeged.hu).
+
+#125. (Changed in 1.33MR11) Lookahead for (guard)? && <<p>>? predicates
+
+ When implementing the new style of guard predicate (Item #113)
+ in 1.33MR10 I decided to temporarily ignore the problem of
+ computing the "narrowest" lookahead context.
+
+ Consider the following k=1 grammar:
+
+ start : a
+ | b
+ ;
+
+ a : (A)? && <<pred1(LATEXT(1))>>? ab ;
+ b : (B)? && <<pred2(LATEXT(1))>>? ab ;
+
+ ab : A | B ;
+
+ In MR10 the context for both "a" and "b" was {A B} because this is
+ the first set of rule "ab". Normally, this is not a problem because
+ the predicate which follows the guard inhibits any ambiguity report
+ by antlr.
+
+ In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}.
+
+#124. A Note on the New "&&" Style Guarded Predicates
+
+ I've been asked several times, "What is the difference between
+ the old "=>" style guard predicates and the new style "&&" guard
+ predicates, and how do you choose one over the other" ?
+
+ The main difference is that the "=>" does not apply the
+ predicate if the context guard doesn't match, whereas
+ the && form always does. What is the significance ?
+
+ If you have a predicate which is not on the "leading edge"
+ it is cannot be hoisted. Suppose you need a predicate that
+ looks at LA(2). You must introduce it manually. The
+ classic example is:
+
+ castExpr :
+ LP typeName RP
+ | ....
+ ;
+
+ typeName : <<isTypeName(LATEXT(1))>>? ID
+ | STRUCT ID
+ ;
+
+ The problem is that isTypeName() isn't on the leading edge
+ of typeName, so it won't be hoisted into castExpr to help
+ make a decision on which production to choose.
+
+ The *first* attempt to fix it is this:
+
+ castExpr :
+ <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ Unfortunately, this won't work because it ignores
+ the problem of STRUCT. The solution is to apply
+ isTypeName() in castExpr if LA(2) is an ID and
+ don't apply it when LA(2) is STRUCT:
+
+ castExpr :
+ (LP ID)? => <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ In conclusion, the "=>" style guarded predicate is
+ useful when:
+
+ a. the tokens required for the predicate
+ are not on the leading edge
+ b. there are alternatives in the expression
+ selected by the predicate for which the
+ predicate is inappropriate
+
+ If (b) were false, then one could use a simple
+ predicate (assuming "-prc on"):
+
+ castExpr :
+ <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ typeName : <<isTypeName(LATEXT(1))>>? ID
+ ;
+
+ So, when do you use the "&&" style guarded predicate ?
+
+ The new-style "&&" predicate should always be used with
+ predicate context. The context guard is in ADDITION to
+ the automatically computed context. Thus it useful for
+ predicates which depend on the token type for reasons
+ other than context.
+
+ The following example is contributed by Reinier van den Born
+ (reinier@vnet.ibm.com).
+
+ +-------------------------------------------------------------------------+
+ | This grammar has two ways to call functions: |
+ | |
+ | - a "standard" call syntax with parens and comma separated args |
+ | - a shell command like syntax (no parens and spacing separated args) |
+ | |
+ | The former also allows a variable to hold the name of the function, |
+ | the latter can also be used to call external commands. |
+ | |
+ | The grammar (simplified) looks like this: |
+ | |
+ | fun_call : ID "(" { expr ("," expr)* } ")" |
+ | /* ID is function name */ |
+ | | "@" ID "(" { expr ("," expr)* } ")" |
+ | /* ID is var containing fun name */ |
+ | ; |
+ | |
+ | command : ID expr* /* ID is function name */ |
+ | | path expr* /* path is external command name */ |
+ | ; |
+ | |
+ | path : ID /* left out slashes and such */ |
+ | | "@" ID /* ID is environment var */ |
+ | ; |
+ | |
+ | expr : .... |
+ | | "(" expr ")"; |
+ | |
+ | call : fun_call |
+ | | command |
+ | ; |
+ | |
+ | Obviously the call is wildly ambiguous. This is more or less how this |
+ | is to be resolved: |
+ | |
+ | A call begins with an ID or an @ followed by an ID. |
+ | |
+ | If it is an ID and if it is an ext. command name -> command |
+ | if followed by a paren -> fun_call |
+ | otherwise -> command |
+ | |
+ | If it is an @ and if the ID is a var name -> fun_call |
+ | otherwise -> command |
+ | |
+ | One can implement these rules quite neatly using && predicates: |
+ | |
+ | call : ("@" ID)? && <<isVarName(LT(2))>>? fun_call |
+ | | (ID)? && <<isExtCmdName>>? command |
+ | | (ID "(")? fun_call |
+ | | command |
+ | ; |
+ | |
+ | This can be done better, so it is not an ideal example, but it |
+ | conveys the principle. |
+ +-------------------------------------------------------------------------+
+
+#123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h
+
+ The return value of operators in ANTLRTokenPtr:
+
+ changed: unsigned ... operator !=(...)
+ to: int ... operator != (...)
+ changed: unsigned ... operator ==(...)
+ to: int ... operator == (...)
+
+ Suggested by R.A. Nelson (cowboy@VNET.IBM.COM)
+
+#122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode
+
+ void DLGFileReset(FILE *f) { input = f; found_eof = 0; }
+ void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }
+
+ Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)
+
+#121. (Changed in 1.33MR11) Another attempt to fix -o (output dir) option
+
+ Another attempt is made to improve the -o option of antlr, dlg,
+ and sorcerer. This one by JVincent (JVincent@novell.com).
+
+ The current rule:
+
+ a. If -o is not specified than any explicit directory
+ names are retained.
+
+ b. If -o is specified than the -o directory name overrides any
+ explicit directory names.
+
+ c. The directory name of the grammar file is *not* stripped
+ to create the main output file. However it is stil subject
+ to override by the -o directory name.
+
+#120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr
+
+ Added option 0 (e.g. "-info 0") which is a noop.
+
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars
+
+ The user can ask for additional information on ambiguities reported
+ by antlr to stdout. At the moment, only one ambiguity report can
+ be created in an antlr run.
+
+ This feature is enabled using the "-aa" (Ambiguity Aid) option.
+
+ The following options control the reporting of ambiguities:
+
+ -aa ruleName Selects reporting by name of rule
+ -aa lineNumber Selects reporting by line number
+ (file name not compared)
+
+ -aam Selects "multiple" reporting for a token
+ in the intersection set of the
+ alternatives.
+
+ For instance, the token ID may appear dozens
+ of times in various paths as the program
+ explores the rules which are reachable from
+ the point of an ambiguity. With option -aam
+ every possible path the search program
+ encounters is reported.
+
+ Without -aam only the first encounter is
+ reported. This may result in incomplete
+ information, but the information may be
+ sufficient and much shorter.
+
+ -aad depth Selects the depth of the search.
+ The default value is 1.
+
+ The number of paths to be searched, and the
+ size of the report can grow geometrically
+ with the -ck value if a full search for all
+ contributions to the source of the ambiguity
+ is explored.
+
+ The depth represents the number of tokens
+ in the lookahead set which are matched against
+ the set of ambiguous tokens. A depth of 1
+ means that the search stops when a lookahead
+ sequence of just one token is matched.
+
+ A k=1 ck=6 grammar might generate 5,000 items
+ in a report if a full depth 6 search is made
+ with the Ambiguity Aid. The source of the
+ problem may be in the first token and obscured
+ by the volume of data - I hesitate to call
+ it information.
+
+ When the user selects a depth > 1, the search
+ is first performed at depth=1 for both
+ alternatives, then depth=2 for both alternatives,
+ etc.
+
+ Sample output for rule grammar in antlr.g itself:
+
+ +---------------------------------------------------------------------+
+ | Ambiguity Aid |
+ | |
+ | Choice 1: grammar/70 line 632 file a.g |
+ | Choice 2: grammar/82 line 644 file a.g |
+ | |
+ | Intersection of lookahead[1] sets: |
+ | |
+ | "\}" "class" "#errclass" "#tokclass" |
+ | |
+ | Choice:1 Depth:1 Group:1 ("#errclass") |
+ | 1 in (...)* block grammar/70 line 632 a.g |
+ | 2 to error grammar/73 line 635 a.g |
+ | 3 error error/1 line 894 a.g |
+ | 4 #token "#errclass" error/2 line 895 a.g |
+ | |
+ | Choice:1 Depth:1 Group:2 ("#tokclass") |
+ | 2 to tclass grammar/74 line 636 a.g |
+ | 3 tclass tclass/1 line 937 a.g |
+ | 4 #token "#tokclass" tclass/2 line 938 a.g |
+ | |
+ | Choice:1 Depth:1 Group:3 ("class") |
+ | 2 to class_def grammar/75 line 637 a.g |
+ | 3 class_def class_def/1 line 669 a.g |
+ | 4 #token "class" class_def/3 line 671 a.g |
+ | |
+ | Choice:1 Depth:1 Group:4 ("\}") |
+ | 2 #token "\}" grammar/76 line 638 a.g |
+ | |
+ | Choice:2 Depth:1 Group:5 ("#errclass") |
+ | 1 in (...)* block grammar/83 line 645 a.g |
+ | 2 to error grammar/93 line 655 a.g |
+ | 3 error error/1 line 894 a.g |
+ | 4 #token "#errclass" error/2 line 895 a.g |
+ | |
+ | Choice:2 Depth:1 Group:6 ("#tokclass") |
+ | 2 to tclass grammar/94 line 656 a.g |
+ | 3 tclass tclass/1 line 937 a.g |
+ | 4 #token "#tokclass" tclass/2 line 938 a.g |
+ | |
+ | Choice:2 Depth:1 Group:7 ("class") |
+ | 2 to class_def grammar/95 line 657 a.g |
+ | 3 class_def class_def/1 line 669 a.g |
+ | 4 #token "class" class_def/3 line 671 a.g |
+ | |
+ | Choice:2 Depth:1 Group:8 ("\}") |
+ | 2 #token "\}" grammar/96 line 658 a.g |
+ +---------------------------------------------------------------------+
+
+ For a linear lookahead set ambiguity (where k=1 or for k>1 but
+ when all lookahead sets [i] with i<k all have degree one) the
+ reports appear in the following order:
+
+ for (depth=1 ; depth <= "-aad depth" ; depth++) {
+ for (alternative=1; alternative <=2 ; alternative++) {
+ while (matches-are-found) {
+ group++;
+ print-report
+ };
+ };
+ };
+
+ For reporting a k-tuple ambiguity, the reports appear in the
+ following order:
+
+ for (depth=1 ; depth <= "-aad depth" ; depth++) {
+ while (matches-are-found) {
+ for (alternative=1; alternative <=2 ; alternative++) {
+ group++;
+ print-report
+ };
+ };
+ };
+
+ This is because matches are generated in different ways for
+ linear lookahead and k-tuples.
+
+#118. (Changed in 1.33MR11) DEC VMS makefile and VMS related changes
+
+ Revised makefiles for DEC/VMS operating system for antlr, dlg,
+ and sorcerer.
+
+ Reduced names of routines with external linkage to less than 32
+ characters to conform to DEC/VMS linker limitations.
+
+ Jean-Francois Pieronne discovered problems with dlg and antlr
+ due to the VMS linker not being case sensitive for names with
+ external linkage. In dlg the problem was with "className" and
+ "ClassName". In antlr the problem was with "GenExprSets" and
+ "genExprSets".
+
+ Added genmms, a version of genmk for the DEC/VMS version of make.
+ The source is in directory pccts/support/DECmms.
+
+ All VMS contributions by Jean-Francois Pieronne (jfp@iname.com).
+
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code
+
+ The hoisting of predicates into rules to create prediction
+ expressions is a problem in antlr. Consider the following
+ example (k=1 with -prc on):
+
+ start : (a)* "@" ;
+ a : b | c ;
+ b : <<isUpper(LATEXT(1))>>? A ;
+ c : A ;
+
+ Prior to 1.33MR10 the code generated for "start" would resemble:
+
+ while {
+ if (LA(1)==A &&
+ (!LA(1)==A || isUpper())) {
+ a();
+ }
+ };
+
+ This code is wrong because it makes rule "c" unreachable from
+ "start". The essence of the problem is that antlr fails to
+ recognize that there can be a valid alternative within "a" even
+ when the predicate <<isUpper(LATEXT(1))>>? is false.
+
+ In 1.33MR10 with -mrhoist the hoisting of the predicate into
+ "start" is suppressed because it recognizes that "c" can
+ cover all the cases where the predicate is false:
+
+ while {
+ if (LA(1)==A) {
+ a();
+ }
+ };
+
+ With the antlr "-info p" switch the user will receive information
+ about the predicate suppression in the generated file:
+
+ --------------------------------------------------------------
+ #if 0
+
+ Hoisting of predicate suppressed by alternative without predicate.
+ The alt without the predicate includes all cases where
+ the predicate is false.
+
+ WITH predicate: line 7 v1.g
+ WITHOUT predicate: line 7 v1.g
+
+ The context set for the predicate:
+
+ A
+
+ The lookahead set for the alt WITHOUT the semantic predicate:
+
+ A
+
+ The predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 9 v1.g
+ set context:
+ A
+ tree context: null
+
+ Chain of referenced rules:
+
+ #0 in rule start (line 5 v1.g) to rule a
+ #1 in rule a (line 7 v1.g)
+
+ #endif
+ --------------------------------------------------------------
+
+ A predicate can be suppressed by a combination of alternatives
+ which, taken together, cover a predicate:
+
+ start : (a)* "@" ;
+
+ a : b | ca | cb | cc ;
+
+ b : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;
+
+ ca : A ;
+ cb : B ;
+ cc : C ;
+
+ Consider a more complex example in which "c" covers only part of
+ a predicate:
+
+ start : (a)* "@" ;
+
+ a : b
+ | c
+ ;
+
+ b : <<isUpper(LATEXT(1))>>?
+ ( A
+ | X
+ );
+
+ c : A
+ ;
+
+ Prior to 1.33MR10 the code generated for "start" would resemble:
+
+ while {
+ if ( (LA(1)==A || LA(1)==X) &&
+ (! (LA(1)==A || LA(1)==X) || isUpper()) {
+ a();
+ }
+ };
+
+ With 1.33MR10 and -mrhoist the predicate context is restricted to
+ the non-covered lookahead. The code resembles:
+
+ while {
+ if ( (LA(1)==A || LA(1)==X) &&
+ (! (LA(1)==X) || isUpper()) {
+ a();
+ }
+ };
+
+ With the antlr "-info p" switch the user will receive information
+ about the predicate restriction in the generated file:
+
+ --------------------------------------------------------------
+ #if 0
+
+ Restricting the context of a predicate because of overlap
+ in the lookahead set between the alternative with the
+ semantic predicate and one without
+ Without this restriction the alternative without the predicate
+ could not be reached when input matched the context of the
+ predicate and the predicate was false.
+
+ WITH predicate: line 11 v4.g
+ WITHOUT predicate: line 12 v4.g
+
+ The original context set for the predicate:
+
+ A X
+
+ The lookahead set for the alt WITHOUT the semantic predicate:
+
+ A
+
+ The intersection of the two sets
+
+ A
+
+ The original predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 15 v4.g
+ set context:
+ A X
+ tree context: null
+
+ The new (modified) form of the predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 15 v4.g
+ set context:
+ X
+ tree context: null
+
+ #endif
+ --------------------------------------------------------------
+
+ The bad news about -mrhoist:
+
+ (a) -mrhoist does not analyze predicates with lookahead
+ depth > 1.
+
+ (b) -mrhoist does not look past a guarded predicate to
+ find context which might cover other predicates.
+
+ For these cases you might want to use syntactic predicates.
+ When a semantic predicate fails during guess mode the guess
+ fails and the next alternative is tried.
+
+ Limitation (a) is illustrated by the following example:
+
+ start : (stmt)* EOF ;
+
+ stmt : cast
+ | expr
+ ;
+ cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
+
+ expr : LP ID RP ;
+
+ This is not much different from the first example, except that
+ it requires two tokens of lookahead context to determine what
+ to do. This predicate is NOT suppressed because the current version
+ is unable to handle predicates with depth > 1.
+
+ A predicate can be combined with other predicates during hoisting.
+ In those cases the depth=1 predicates are still handled. Thus,
+ in the following example the isUpper() predicate will be suppressed
+ by line #4 when hoisted from "bizarre" into "start", but will still
+ be present in "bizarre" in order to predict "stmt".
+
+ start : (bizarre)* EOF ; // #1
+ // #2
+ bizarre : stmt // #3
+ | A // #4
+ ;
+
+ stmt : cast
+ | expr
+ ;
+
+ cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
+
+ expr : LP ID RP ;
+ | <<isUpper(LATEXT(1))>>? A
+
+ Limitation (b) is illustrated by the following example of a
+ context guarded predicate:
+
+ rule : (A)? <<p>>? // #1
+ (A // #2
+ |B // #3
+ ) // #4
+ | <<q>> B // #5
+ ;
+
+ Recall that this means that when the lookahead is NOT A then
+ the predicate "p" is ignored and it attempts to match "A|B".
+ Ideally, the "B" at line #3 should suppress predicate "q".
+ However, the current version does not attempt to look past
+ the guard predicate to find context which might suppress other
+ predicates.
+
+ In some cases -mrhoist will lead to the reporting of ambiguities
+ which were not visible before:
+
+ start : (a)* "@";
+ a : bc | d;
+ bc : b | c ;
+
+ b : <<isUpper(LATEXT(1))>>? A;
+ c : A ;
+
+ d : A ;
+
+ In this case there is a true ambiguity in "a" between "bc" and "d"
+ which can both match "A". Without -mrhoist the predicate in "b"
+ is hoisted into "a" and there is no ambiguity reported. However,
+ with -mrhoist, the predicate in "b" is suppressed by "c" (as it
+ should be) making the ambiguity in "a" apparent.
+
+ The motivations for these changes were hoisting problems reported
+ by Reinier van den Born (reinier@vnet.ibm.com) and several others.
+
+#116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *)
+
+ The prototype for C++ mode routine tracein (and traceout) has changed from
+ "char *" to "const char *".
+
+#115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode
+
+ The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig
+ neglected to consider guess mode. When control passed to the rule's
+ parse exception handler the routine would exit without ever closing the
+ guess block. This would lead to unpredictable behavior.
+
+ In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be
+ identical.
+
+#114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes
+
+ There was a slight difference in the way C and C++ mode resynchronized
+ following a parsing error. The C routine would sometimes skip an extra
+ token before attempting to resynchronize.
+
+ The C routine was changed to match the C++ routine.
+
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr
+
+ The existing context guarded predicate:
+
+ rule : (guard)? => <<p>>? expr
+ | next_alternative
+ ;
+
+ generates code which resembles:
+
+ if (lookahead(expr) && (!guard || pred)) {
+ expr()
+ } else ....
+
+ This is not suitable for some applications because it allows
+ expr() to be invoked when the predicate is false. This is
+ intentional because it is meant to mimic automatically computed
+ predicate context.
+
+ The new context guarded predicate uses the guard information
+ differently because it has a different goal. Consider:
+
+ rule : (guard)? && <<p>>? expr
+ | next_alternative
+ ;
+
+ The new style of context guarded predicate is equivalent to:
+
+ rule : <<guard==true && pred>>? expr
+ | next_alternative
+ ;
+
+ It generates code which resembles:
+
+ if (lookahead(expr) && guard && pred) {
+ expr();
+ } else ...
+
+ Both forms of guarded predicates severely restrict the form of
+ the context guard: it can contain no rule references, no
+ (...)*, no (...)+, and no {...}. It may contain token and
+ token class references, and alternation ("|").
+
+ Addition for 1.33MR11: in the token expression all tokens must
+ be at the same height of the token tree:
+
+ (A ( B | C))? && ... is ok (all height 2)
+ (A ( B | ))? && ... is not ok (some 1, some 2)
+ (A B C D | E F G H)? && ... is ok (all height 4)
+ (A B C D | E )? && ... is not ok (some 4, some 1)
+
+ This restriction is required in order to properly compute the lookahead
+ set for expressions like:
+
+ rule1 : (A B C)? && <<pred>>? rule2 ;
+ rule2 : (A|X) (B|Y) (C|Z);
+
+ This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)
+
+#112. (Changed in 1.33MR10) failed validation predicate in C guess mode
+
+ John Lilley (jlilley@empathy.com) suggested that failed validation
+ predicates abort a guess rather than reporting a failed error.
+ This was installed in C++ mode (Item #4). Only now was it noticed
+ that the fix was never installed for C mode.
+
+#111. (Changed in 1.33MR10) moved zzTRACEIN to before init action
+
+ When the antlr -gd switch is present antlr generates calls to
+ zzTRACEIN at the start of a rule and zzTRACEOUT at the exit
+ from a rule. Prior to 1.33MR10 Tthe call to zzTRACEIN was
+ after the init-action, which could cause confusion because the
+ init-actions were reported with the name of the enclosing rule,
+ rather than the active rule.
+
+#110. (Changed in 1.33MR10) antlr command line copied to generated file
+
+ The antlr command line is now copied to the generated file near
+ the start.
+
+#109. (Changed in 1.33MR10) improved trace information
+
+ The quality of the trace information provided by the "-gd"
+ switch has been improved significantly. Here is an example
+ of the output from a test program. It shows the rule name,
+ the first token of lookahead, the call depth, and the guess
+ status:
+
+ exit rule gusxx {"?"} depth 2
+ enter rule gusxx {"?"} depth 2
+ enter rule gus1 {"o"} depth 3 guessing
+ guess done - returning to rule gus1 {"o"} at depth 3
+ (guess mode continues - an enclosing guess is still active)
+ guess done - returning to rule gus1 {"Z"} at depth 3
+ (guess mode continues - an enclosing guess is still active)
+ exit rule gus1 {"Z"} depth 3 guessing
+ guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)
+ enter rule gus1 {"o"} depth 3
+ guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)
+ guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)
+ exit rule gus1 {"Z"} depth 3
+ line 1: syntax error at "Z" missing SC
+ ...
+
+ Rule trace reporting is controlled by the value of the integer
+ [zz]traceOptionValue: when it is positive tracing is enabled,
+ otherwise it is disabled. Tracing during guess mode is controlled
+ by the value of the integer [zz]traceGuessOptionValue. When
+ it is positive AND [zz]traceOptionValue is positive rule trace
+ is reported in guess mode.
+
+ The values of [zz]traceOptionValue and [zz]traceGuessOptionValue
+ can be adjusted by subroutine calls listed below.
+
+ Depending on the presence or absence of the antlr -gd switch
+ the variable [zz]traceOptionValueDefault is set to 0 or 1. When
+ the parser is initialized or [zz]traceReset() is called the
+ value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.
+ The value of [zz]traceGuessOptionValue is always initialzed to 1,
+ but, as noted earlier, nothing will be reported unless
+ [zz]traceOptionValue is also positive.
+
+ When the parser state is saved/restored the value of the trace
+ variables are also saved/restored. If a restore causes a change in
+ reporting behavior from on to off or vice versa this will be reported.
+
+ When the -gd option is selected, the macro "#define zzTRACE_RULES"
+ is added to appropriate output files.
+
+ C++ mode
+ --------
+ int traceOption(int delta)
+ int traceGuessOption(int delta)
+ void traceReset()
+ int traceOptionValueDefault
+
+ C mode
+ --------
+ int zzTraceOption(int delta)
+ int zzTraceGuessOption(int delta)
+ void zzTraceReset()
+ int zzTraceOptionValueDefault
+
+ The argument "delta" is added to the traceOptionValue. To
+ turn on trace when inside a particular rule one:
+
+ rule : <<traceOption(+1);>>
+ (
+ rest-of-rule
+ )
+ <<traceOption(-1);>>
+ ; /* fail clause */ <<traceOption(-1);>>
+
+ One can use the same idea to turn *off* tracing within a
+ rule by using a delta of (-1).
+
+ An improvement in the rule trace was suggested by Sramji
+ Ramanathan (ps@kumaran.com).
+
+#108. A Note on Deallocation of Variables Allocated in Guess Mode
+
+ NOTE
+ ------------------------------------------------------
+ This mechanism only works for heap allocated variables
+ ------------------------------------------------------
+
+ The rewrite of the trace provides the machinery necessary
+ to properly free variables or undo actions following a
+ failed guess.
+
+ The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded
+ as part of the zzGUESS macro. When a guess is opened
+ the value of zzrv is 0. When a longjmp() is executed to
+ undo the guess, the value of zzrv will be 1.
+
+ The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded
+ as part of the zzGUESS_DONE macro. This is executed
+ whether the guess succeeds or fails as part of closing
+ the guess.
+
+ The guessSeq is a sequence number which is assigned to each
+ guess and is incremented by 1 for each guess which becomes
+ active. It is needed by the user to associate the start of
+ a guess with the failure and/or completion (closing) of a
+ guess.
+
+ Guesses are nested. They must be closed in the reverse
+ of the order that they are opened.
+
+ In order to free memory used by a variable during a guess
+ a user must write a routine which can be called to
+ register the variable along with the current guess sequence
+ number provided by the zzUSER_GUESS_HOOK macro. If the guess
+ fails, all variables tagged with the corresponding guess
+ sequence number should be released. This is ugly, but
+ it would require a major rewrite of antlr 1.33 to use
+ some mechanism other than setjmp()/longjmp().
+
+ The order of calls for a *successful* guess would be:
+
+ zzUSER_GUESS_HOOK(guessSeq,0);
+ zzUSER_GUESS_DONE_HOOK(guessSeq);
+
+ The order of calls for a *failed* guess would be:
+
+ zzUSER_GUESS_HOOK(guessSeq,0);
+ zzUSER_GUESS_HOOK(guessSeq,1);
+ zzUSER_GUESS_DONE_HOOK(guessSeq);
+
+ The default definitions of these macros are empty strings.
+
+ Here is an example in C++ mode. The zzUSER_GUESS_HOOK and
+ zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine
+ can be used without change in both C and C++ versions.
+
+ ----------------------------------------------------------------------
+ <<
+
+ #include "AToken.h"
+
+ typedef ANTLRCommonToken ANTLRToken;
+
+ #include "DLGLexer.h"
+
+ int main() {
+
+ {
+ DLGFileInput in(stdin);
+ DLGLexer lexer(&in,2000);
+ ANTLRTokenBuffer pipe(&lexer,1);
+ ANTLRCommonToken aToken;
+ P parser(&pipe);
+
+ lexer.setToken(&aToken);
+ parser.init();
+ parser.start();
+ };
+
+ fclose(stdin);
+ fclose(stdout);
+ return 0;
+ }
+
+ >>
+
+ <<
+ char *s=NULL;
+
+ #undef zzUSER_GUESS_HOOK
+ #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);
+ #undef zzUSER_GUESS_DONE_HOOK
+ #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2);
+
+ void myGuessHook(int guessSeq,int zzrv) {
+ if (zzrv == 0) {
+ fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);
+ } else if (zzrv == 1) {
+ free (s);
+ s=NULL;
+ fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);
+ } else if (zzrv == 2) {
+ free (s);
+ s=NULL;
+ fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);
+ };
+ }
+
+ >>
+
+ #token A "a"
+ #token "[\t \ \n]" <<skip();>>
+
+ class P {
+
+ start : (top)+
+ ;
+
+ top : (which) ? <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>
+ | other <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>
+ ; <<if (s != NULL) free(s); s=NULL; >>
+
+ which : which2
+ ;
+
+ which2 : which3
+ ;
+ which3
+ : (label)? <<fprintf(stderr,"%s is a label\n",s);>>
+ | (global)? <<fprintf(stderr,"%s is a global\n",s);>>
+ | (exclamation)? <<fprintf(stderr,"%s is an exclamation\n",s);>>
+ ;
+
+ label : <<s=strdup(LT(1)->getText());>> A ":" ;
+
+ global : <<s=strdup(LT(1)->getText());>> A "::" ;
+
+ exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;
+
+ other : <<s=strdup(LT(1)->getText());>> "other" ;
+
+ }
+ ----------------------------------------------------------------------
+
+ This is a silly example, but illustrates the idea. For the input
+ "a ::" with tracing enabled the output begins:
+
+ ----------------------------------------------------------------------
+ enter rule "start" depth 1
+ enter rule "top" depth 2
+ User hook: starting guess #1
+ enter rule "which" depth 3 guessing
+ enter rule "which2" depth 4 guessing
+ enter rule "which3" depth 5 guessing
+ User hook: starting guess #2
+ enter rule "label" depth 6 guessing
+ guess failed
+ User hook: failed guess #2
+ guess done - returning to rule "which3" at depth 5 (guess mode continues
+ - an enclosing guess is still active)
+ User hook: ending guess #2
+ User hook: starting guess #3
+ enter rule "global" depth 6 guessing
+ exit rule "global" depth 6 guessing
+ guess done - returning to rule "which3" at depth 5 (guess mode continues
+ - an enclosing guess is still active)
+ User hook: ending guess #3
+ enter rule "global" depth 6 guessing
+ exit rule "global" depth 6 guessing
+ exit rule "which3" depth 5 guessing
+ exit rule "which2" depth 4 guessing
+ exit rule "which" depth 3 guessing
+ guess done - returning to rule "top" at depth 2 (guess mode ends)
+ User hook: ending guess #1
+ enter rule "which" depth 3
+ .....
+ ----------------------------------------------------------------------
+
+ Remember:
+
+ (a) Only init-actions are executed during guess mode.
+ (b) A rule can be invoked multiple times during guess mode.
+ (c) If the guess succeeds the rule will be called once more
+ without guess mode so that normal actions will be executed.
+ This means that the init-action might need to distinguish
+ between guess mode and non-guess mode using the variable
+ [zz]guessing.
+
+#107. (Changed in 1.33MR10) construction of ASTs in guess mode
+
+ Prior to 1.33MR10, when using automatic AST construction in C++
+ mode for a rule, an AST would be constructed for elements of the
+ rule even while in guess mode. In MR10 this no longer occurs.
+
+#106. (Changed in 1.33MR10) guess variable confusion
+
+ In C++ mode a guess which failed always restored the parser state
+ using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10,
+ C mode required an explicit call to zzGUESS_DONE after the
+ call to zzGUESS_FAIL.
+
+ Consider:
+
+ rule : (alpha)? beta
+ | ...
+ ;
+
+ The generated code resembles:
+
+ zzGUESS
+ if (!zzrv && LA(1)==ID) { <==== line #1
+ alpha
+ zzGUESS_DONE
+ beta
+ } else {
+ if (! zzrv) zzGUESS_DONE <==== line #2a
+ ....
+
+ However, in some cases line #2 was rendered:
+
+ if (guessing) zzGUESS_DONE <==== line #2b
+
+ This would work for simple test cases, but would fail in
+ some cases where there was a guess while another guess was active.
+ One kind of failure would be to match up the zzGUESS_DONE at line
+ #2b with the "outer" guess which was still active. The outer
+ guess would "succeed" when only the inner guess should have
+ succeeded.
+
+ In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and
+ and C++ mode should be identical.
+
+ The same problem appears in 1.33 vanilla in some places. For
+ example:
+
+ start : { (sub)? } ;
+
+ or:
+
+ start : (
+ B
+ | ( sub )?
+ | C
+ )+
+ ;
+
+ generates incorrect code.
+
+ The general principle is:
+
+ (a) use [zz]guessing only when deciding between a call to zzFAIL
+ or zzGUESS_FAIL
+
+ (b) use zzrv in all other cases
+
+ This problem was discovered while testing changes to item #105.
+ I believe this is now fixed. My apologies.
+
+#105. (Changed in 1.33MR10) guess block as single alt of (...)+
+
+ Prior to 1.33MR10 the following constructs:
+
+ rule_plus : (
+ (sub)?
+ )+
+ ;
+
+ rule_star : (
+ (sub)?
+ )*
+ ;
+
+ generated incorrect code for the guess block (which could result
+ in runtime errors) because of an incorrect optimization of a
+ block with only a single alternative.
+
+ The fix caused some changes to the fix described in Item #49
+ because there are now three code generation sequences for (...)+
+ blocks containing a guess block:
+
+ a. single alternative which is a guess block
+ b. multiple alternatives in which the last is a guess block
+ c. all other cases
+
+ Forms like "rule_star" can have unexpected behavior when there
+ is a syntax error: if the subrule "sub" is not matched *exactly*
+ then "rule_star" will consume no tokens.
+
+ Reported by Esa Pulkkinen (esap@cs.tut.fi).
+
+#104. (Changed in 1.33MR10) -o option for dlg
+
+ There was problem with the code added by item #74 to handle the
+ -o option of dlg. This should fix it.
+
+#103. (Changed in 1.33MR10) ANDed semantic predicates
+
+ Rescinded.
+
+ The optimization was a mistake.
+ The resulting problem is described in Item #150.
+
+#102. (Changed in 1.33MR10) allow "class parser : .... {"
+
+ The syntax of the class statement ("class parser-name {")
+ has been extended to allow for the specification of base
+ classes. An arbirtrary number of tokens may now appear
+ between the class name and the "{". They are output
+ again when the class declaration is generated. For
+ example:
+
+ class Parser : public MyBaseClassANTLRparser {
+
+ This was suggested by a user, but I don't have a record
+ of who it was.
+
+#101. (Changed in 1.33MR10) antlr -info command line switch
+
+ -info
+
+ p - extra predicate information in generated file
+
+ t - information about tnode use:
+ at the end of each rule in generated file
+ summary on stderr at end of program
+
+ m - monitor progress
+ prints name of each rule as it is started
+ flushes output at start of each rule
+
+ f - first/follow set information to stdout
+
+ 0 - no operation (added in 1.33MR11)
+
+ The options may be combined and may appear in any order.
+ For example:
+
+ antlr -info ptm -CC -gt -mrhoist on mygrammar.g
+
+#100a. (Changed in 1.33MR10) Predicate tree simplification
+
+ When the same predicates can be referenced in more than one
+ alternative of a block large predicate trees can be formed.
+
+ The difference that these optimizations make is so dramatic
+ that I have decided to use it even when -mrhoist is not selected.
+
+ Consider the following grammar:
+
+ start : ( all )* ;
+
+ all : a
+ | d
+ | e
+ | f
+ ;
+
+ a : c A B
+ | c A C
+ ;
+
+ c : <<AAA(LATEXT(2))>>?
+ ;
+
+ d : <<BBB(LATEXT(2))>>? B C
+ ;
+
+ e : <<CCC(LATEXT(2))>>? B C
+ ;
+
+ f : e X Y
+ ;
+
+ In rule "a" there is a reference to rule "c" in both alternatives.
+ The length of the predicate AAA is k=2 and it can be followed in
+ alternative 1 only by (A B) while in alternative 2 it can be
+ followed only by (A C). Thus they do not have identical context.
+
+ In rule "all" the alternatives which refer to rules "e" and "f" allow
+ elimination of the duplicate reference to predicate CCC.
+
+ The table below summarized the kind of simplification performed by
+ 1.33MR10. In the table, X and Y stand for single predicates
+ (not trees).
+
+ (OR X (OR Y (OR Z))) => (OR X Y Z)
+ (AND X (AND Y (AND Z))) => (AND X Y Z)
+
+ (OR X (... (OR X Y) ... )) => (OR X (... Y ... ))
+ (AND X (... (AND X Y) ... )) => (AND X (... Y ... ))
+ (OR X (... (AND X Y) ... )) => (OR X (... ... ))
+ (AND X (... (OR X Y) ... )) => (AND X (... ... ))
+
+ (AND X) => X
+ (OR X) => X
+
+ In a test with a complex grammar for a real application, a predicate
+ tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".
+
+ In 1.33MR10 there is a greater effort to release memory used
+ by predicates once they are no longer in use.
+
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests
+
+ The following optimizations require that -mrhoist be selected.
+
+ It is relatively easy to optimize the code generated for predicate
+ gates when they are of the form:
+
+ (AND X Y Z ...)
+ or (OR X Y Z ...)
+
+ where X, Y, Z, and "..." represent individual predicates (leaves) not
+ predicate trees.
+
+ If the predicate is an AND the contexts of the X, Y, Z, etc. are
+ ANDed together to create a single Tree context for the group and
+ context tests for the individual predicates are suppressed:
+
+ --------------------------------------------------
+ Note: This was incorrect. The contexts should be
+ ORed together. This has been fixed. A more
+ complete description is available in item #152.
+ ---------------------------------------------------
+
+ Optimization 1: (AND X Y Z ...)
+
+ Suppose the context for Xtest is LA(1)==LP and the context for
+ Ytest is LA(1)==LP && LA(2)==ID.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||
+ ( (! LA(1)==LP || Xtest) &&
+ (! (LA(1)==LP || LA(2)==ID) || Xtest)
+ )) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...
+
+ Optimization 2: (OR X Y Z ...) with identical contexts
+
+ Suppose the context for Xtest is LA(1)==ID and for Ytest
+ the context is also LA(1)==ID.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==ID || LA(1)==ID) ||
+ (LA(1)==ID && Xtest) ||
+ (LA(1)==ID && Ytest) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ (! LA(1)==ID) || (Xtest || Ytest) {...
+
+ Optimization 3: (OR X Y Z ...) with distinct contexts
+
+ Suppose the context for Xtest is LA(1)==ID and for Ytest
+ the context is LA(1)==LP.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==ID || LA(1)==LP) ||
+ (LA(1)==ID && Xtest) ||
+ (LA(1)==LP && Ytest) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ (zzpf=0,
+ (LA(1)==ID && (zzpf=1) && Xtest) ||
+ (LA(1)==LP && (zzpf=1) && Ytest) ||
+ !zzpf) {
+
+ These may appear to be of similar complexity at first,
+ but the non-optimized version contains two tests of each
+ context while the optimized version contains only one
+ such test, as well as eliminating some of the inverted
+ logic (" !(...) || ").
+
+ Optimization 4: Computation of predicate gate trees
+
+ When generating code for the gates of predicate expressions
+ antlr 1.33 vanilla uses a recursive procedure to generate
+ "&&" and "||" expressions for testing the lookahead. As each
+ layer of the predicate tree is exposed a new set of "&&" and
+ "||" expressions on the lookahead are generated. In many
+ cases the lookahead being tested has already been tested.
+
+ With -mrhoist a lookahead tree is computed for the entire
+ lookahead expression. This means that predicates with identical
+ context or context which is a subset of another predicate's
+ context disappear.
+
+ This is especially important for predicates formed by rules
+ like the following:
+
+ uppperCaseVowel : <<isUpperCase(LATEXT(1))>>? vowel;
+ vowel: : <<isVowel(LATEXT(1))>>? LETTERS;
+
+ These predicates are combined using AND since both must be
+ satisfied for rule upperCaseVowel. They have identical
+ context which makes this optimization very effective.
+
+ The affect of Items #100a and #100b together can be dramatic. In
+ a very large (but real world) grammar one particular predicate
+ expression was reduced from an (unreadable) 50 predicate leaves,
+ 195 LA(1) terms, and 5500 characters to an (easily comprehensible)
+ 3 predicate leaves (all different) and a *single* LA(1) term.
+
+#99. (Changed in 1.33MR10) Code generation for expression trees
+
+ Expression trees are used for k>1 grammars and predicates with
+ lookahead depth >1. This optimization must be enabled using
+ "-mrhoist on". (Clarification added for 1.33MR11).
+
+ In the processing of expression trees, antlr can generate long chains
+ of token comparisons. Prior to 1.33MR10 there were many redundant
+ parenthesis which caused problems for compilers which could handle
+ expressions of only limited complexity. For example, to test an
+ expression tree (root R A B C D), antlr would generate something
+ resembling:
+
+ (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D)))))
+
+ If there were twenty tokens to test then there would be twenty
+ parenthesis at the end of the expression.
+
+ In 1.33MR10 the generated code for tree expressions resembles:
+
+ (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D))
+
+ For "complex" expressions the output is indented to reflect the LA
+ number being tested:
+
+ (LA(1)==R
+ && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D
+ || LA(2)==E || LA(2)==F)
+ || LA(1)==S
+ && (LA(2)==G || LA(2)==H))
+
+
+ Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl),
+
+#98. (Changed in 1.33MR10) Option "-info p"
+
+ When the user selects option "-info p" the program will generate
+ detailed information about predicates. If the user selects
+ "-mrhoist on" additional detail will be provided explaining
+ the promotion and suppression of predicates. The output is part
+ of the generated file and sandwiched between #if 0/#endif statements.
+
+ Consider the following k=1 grammar:
+
+ start : ( all ) * ;
+
+ all : ( a
+ | b
+ )
+ ;
+
+ a : c B
+ ;
+
+ c : <<LATEXT(1)>>?
+ | B
+ ;
+
+ b : <<LATEXT(1)>>? X
+ ;
+
+ Below is an excerpt of the output for rule "start" for the three
+ predicate options (off, on, and maintenance release style hoisting).
+
+ For those who do not wish to use the "-mrhoist on" option for code
+ generation the option can be used in a "diagnostic" mode to provide
+ valuable information:
+
+ a. where one should insert null actions to inhibit hoisting
+ b. a chain of rule references which shows where predicates are
+ being hoisted
+
+ ======================================================================
+ Example of "-info p" with "-mrhoist on"
+ ======================================================================
+ #if 0
+
+ Hoisting of predicate suppressed by alternative without predicate.
+ The alt without the predicate includes all cases where the
+ predicate is false.
+
+ WITH predicate: line 11 v36.g
+ WITHOUT predicate: line 12 v36.g
+
+ The context set for the predicate:
+
+ B
+
+ The lookahead set for alt WITHOUT the semantic predicate:
+
+ B
+
+ The predicate:
+
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ B
+ tree context: null
+
+ Chain of referenced rules:
+
+ #0 in rule start (line 1 v36.g) to rule all
+ #1 in rule all (line 3 v36.g) to rule a
+ #2 in rule a (line 8 v36.g) to rule c
+ #3 in rule c (line 11 v36.g)
+
+ #endif
+ &&
+ #if 0
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ X
+ tree context: null
+
+ #endif
+ ======================================================================
+ Example of "-info p" with the default -prc setting ( "-prc off")
+ ======================================================================
+ #if 0
+
+ OR
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ nil
+ tree context: null
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ nil
+ tree context: null
+
+ #endif
+ ======================================================================
+ Example of "-info p" with "-prc on" and "-mrhoist off"
+ ======================================================================
+ #if 0
+
+ OR
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ B
+ tree context: null
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ X
+ tree context: null
+
+ #endif
+ ======================================================================
+
+#97. (Fixed in 1.33MR10) "Predicate applied for more than one ... "
+
+ In 1.33 vanilla, the grammar listed below produced this message for
+ the first alternative (only) of rule "b":
+
+ warning: predicate applied for >1 lookahead 1-sequences
+ [you may only want one lookahead 1-sequence to apply.
+ Try using a context guard '(...)? =>'
+
+ In 1.33MR10 the message is issued for both alternatives.
+
+ top : (a)*;
+ a : b | c ;
+
+ b : <<PPP(LATEXT(1))>>? ( AAA | BBB )
+ | <<QQQ(LATEXT(1))>>? ( XXX | YYY )
+ ;
+
+ c : AAA | XXX;
+
+#96. (Fixed in 1.33MR10) Guard predicates ignored when -prc off
+
+ Prior to 1.33MR10, guard predicate code was not generated unless
+ "-prc on" was selected.
+
+ This was incorrect, since "-prc off" (the default) is supposed to
+ disable only AUTOMATIC computation of predicate context, not the
+ programmer specified context supplied by guard predicates.
+
+#95. (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck)
+
+ Prior to 1.33MR10, predicate guards were computed to k tokens rather
+ than max(k,ck). Consider the following grammar:
+
+ a : ( A B C)? => <<AAA(LATEXT(1))>>? (A|X) (B|Y) (C|Z) ;
+
+ The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on"
+ for the predicate in "a" resembles:
+
+ if ( (! LA(1)==A) || AAA(LATEXT(1))) {...
+
+ With 1.33MR10 and the same options the code resembles:
+
+ if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {...
+
+#94. (Fixed in 1.33MR10) Predicates followed by rule references
+
+ Prior to 1.33MR10, a semantic predicate which referenced a token
+ which was off the end of the rule caused an incomplete context
+ to be computed (with "-prc on") for the predicate under some circum-
+ stances. In some cases this manifested itself as illegal C code
+ (e.g. "LA(2)==[Ep](1)" in the k=2 examples below:
+
+ all : ( a ) *;
+
+ a : <<AAA(LATEXT(2))>>? ID X
+ | <<BBB(LATEXT(2))>>? Y
+ | Z
+ ;
+
+ This might also occur when the semantic predicate was followed
+ by a rule reference which was shorter than the length of the
+ semantic predicate:
+
+ all : ( a ) *;
+
+ a : <<AAA(LATEXT(2))>>? ID X
+ | <<BBB(LATEXT(2))>>? y
+ | Z
+ ;
+
+ y : Y ;
+
+ Depending on circumstance, the resulting context might be too
+ generous because it was too short, or too restrictive because
+ of missing alternatives.
+
+#93. (Changed in 1.33MR10) Definition of Purify macro
+
+ Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition
+ for the Purify macro:
+
+ #define PURIFY(r, s) memset((char *) &(r), '\0', (s));
+
+ Note: This may not be the right thing to do for C++ objects that
+ have constructors. Reported by Bonny Rais (bonny@werple.net.au).
+
+ For those cases one should #define PURIFY to an empty macro in the
+ #header or #first actions.
+
+#92. (Fixed in 1.33MR10) Guarded predicates and hoisting
+
+ When a guarded predicate participates in hoisting it is linked into
+ a predicate expression tree. Prior to 1.33MR10 this link was never
+ cleared and the next time the guard was used to construct a new
+ tree the link could contain a spurious reference to another element
+ which had previosly been joined to it in the semantic predicate tree.
+
+ For example:
+
+ start : ( all ) *;
+ all : ( a | b ) ;
+
+ start2 : ( all2 ) *;
+ all2 : ( a ) ;
+
+ a : (A)? => <<AAA(LATEXT(1))>>? A ;
+ b : (B)? => <<BBB(LATEXT(1))>>? B ;
+
+ Prior to 1.33MR10 the code for "start2" would include a spurious
+ reference to the BBB predicate which was left from constructing
+ the predicate tree for rule "start" (i.e. or(AAA,BBB) ).
+
+ In 1.33MR10 this problem is avoided by cloning the original guard
+ each time it is linked into a predicate tree.
+
+#91. (Changed in 1.33MR10) Extensive changes to semantic pred hoisting
+
+ ============================================
+ This has been rendered obsolete by Item #117
+ ============================================
+
+#90. (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck)
+
+ There is a bug in antlr 1.33 vanilla and all maintenance releases
+ prior to 1.33MR10 which allows semantic predicates to reference
+ an LT(i) or LATEXT(i) where i is larger than max(k,ck). When
+ this occurs antlr will attempt to mark the ith element of an array
+ in which there are only max(k,ck) elements. The result cannot
+ be predicted.
+
+ Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error
+ in 1.33MR10.
+
+#89. Rescinded
+
+#88. (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode
+
+ Consider the behavior of a semantic predicate during guess mode:
+
+ rule : a:A (
+ <<test($a)>>? b:B
+ | c:C
+ );
+
+ Prior to MR10 the assignment of the token or attribute to
+ $a did not occur during guess mode, which would cause the
+ semantic predicate to misbehave because $a would be null.
+
+ In 1.33MR10 a semantic predicate with a reference to an
+ element label (such as $a) forces the assignment to take
+ place even in guess mode.
+
+ In order to work, this fix REQUIRES use of the $label format
+ for token pointers and attributes referenced in semantic
+ predicates.
+
+ The fix does not apply to semantic predicates using the
+ numeric form to refer to attributes (e.g. <<test($1)>>?).
+ The user will receive a warning for this case.
+
+ Reported by Rob Trout (trout@mcs.cs.kent.edu).
+
+#87. (Fixed in 1.33MR10) Malformed guard predicates
+
+ Context guard predicates may contain only references to
+ tokens. They may not contain references to (...)+ and
+ (...)* blocks. This is now checked. This replaces the
+ fatal error message in item #78 with an appropriate
+ (non-fatal) error messge.
+
+ In theory, context guards should be allowed to reference
+ rules. However, I have not had time to fix this.
+ Evaluation of the guard takes place before all rules have
+ been read, making it difficult to resolve a forward reference
+ to rule "zzz" - it hasn't been read yet ! To postpone evaluation
+ of the guard until all rules have been read is too much
+ for the moment.
+
+#86. (Fixed in 1.33MR10) Unequal set size in set_sub
+
+ Routine set_sub() in pccts/support/set/set.h did not work
+ correctly when the sets were of unequal sizes. Rewrote
+ set_equ to make it simpler and remove unnecessary and
+ expensive calls to set_deg(). This routine was not used
+ in 1.33 vanila.
+
+#85. (Changed in 1.33MR10) Allow redefinition of MaxNumFiles
+
+ Raised the maximum number of input files to 99 from 20.
+ Put a #ifndef/#endif around the "#define MaxNumFiles 99".
+
+#84. (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE
+
+ Initialize zzBadTok to NULL in zzRULE macro of AParser.h.
+ in order to get rid of warning messages.
+
+#83. (Fixed in 1.33MR10) False warnings with -w2 for #tokclass
+
+ When -w2 is selected antlr gives inappropriate warnings about
+ #tokclass names not having any associated regular expressions.
+ Since a #tokclass is not a "real" token it will never have an
+ associated regular expression and there should be no warning.
+
+ Reported by Derek Pappas (derek.pappas@eng.sun.com)
+
+#82. (Fixed in 1.33MR10) Computation of follow sets with multiple cycles
+
+ Reinier van den Born (reinier@vnet.ibm.com) reported a problem
+ in the computation of follow sets by antlr. The problem (bug)
+ exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10.
+
+ The problem involves the computation of follow sets when there are
+ cycles - rules which have mutual references. I believe the problem
+ is restricted to cases where there is more than one cycle AND
+ elements of those cycles have rules in common. Even when this
+ occurs it may not affect the code generated - but it might. It
+ might also lead to undetected ambiguities.
+
+ There were no changes in antlr or dlg output from the revised version.
+
+ The following fragment demonstates the problem by giving different
+ follow sets (option -pa) for var_access when built with k=1 and ck=2 on
+ 1.33 vanilla and 1.33MR10:
+
+ echo_statement : ECHO ( echo_expr )*
+ ;
+
+ echo_expr : ( command )?
+ | expression
+ ;
+
+ command : IDENTIFIER
+ { concat }
+ ;
+
+ expression : operand ( OPERATOR operand )*
+ ;
+
+ operand : value
+ | START command END
+ ;
+
+ value : concat
+ | TYPE operand
+ ;
+
+ concat : var_access { CONCAT value }
+ ;
+
+ var_access : IDENTIFIER { INDEX }
+
+ ;
+#81. (Changed in 1.33MR10) C mode use of attributes and ASTs
+
+ Reported by Isaac Clark (irclark@mindspring.com).
+
+ C mode code ignores attributes returned by rules which are
+ referenced using element labels when ASTs are enabled (-gt option).
+
+ 1. start : r:rule t:Token <<$start=$r;>>
+
+ The $r refrence will not work when combined with
+ the -gt option.
+
+ 2. start : t:Token <<$start=$t;>>
+
+ The $t reference works in all cases.
+
+ 3. start : rule <<$0=$1;>>
+
+ Numeric labels work in all cases.
+
+ With MR10 the user will receive an error message for case 1 when
+ the -gt option is used.
+
+#80. (Fixed in 1.33MR10) (...)? as last alternative of block
+
+ A construct like the following:
+
+ rule : a
+ | (b)?
+ ;
+
+ does not make sense because there is no alternative when
+ the guess block fails. This is now reported as a warning
+ to the user.
+
+ Previously, there was a code generation error for this case:
+ the guess block was not "closed" when the guess failed.
+ This could cause an infinite loop or other problems. This
+ is now fixed.
+
+ Example problem:
+
+ #header<<
+ #include <stdio.h>
+ #include "charptr.h"
+ >>
+
+ <<
+ #include "charptr.c"
+ main ()
+ {
+ ANTLR(start(),stdin);
+ }
+ >>
+
+ #token "[\ \t]+" << zzskip(); >>
+ #token "[\n]" << zzline++; zzskip(); >>
+
+ #token Word "[a-z]+"
+ #token Number "[0-9]+"
+
+
+ start : (test1)?
+ | (test2)?
+ ;
+ test1 : (Word Word Word Word)?
+ | (Word Word Word Number)?
+ ;
+ test2 : (Word Word Number Word)?
+ | (Word Word Number Number)?
+ ;
+
+ Test data which caused infinite loop:
+
+ a 1 a a
+
+#79. (Changed in 1.33MR10) Use of -fh with multiple parsers
+
+ Previously, antlr always used the pre-processor symbol
+ STDPCCTS_H as a gate for the file stdpccts.h. This
+ caused problems when there were multiple parsers defined
+ because they used the same gate symbol.
+
+ In 1.33MR10, the -fh filename is used to generate the
+ gate file for stdpccts.h. For instance:
+
+ antlr -fh std_parser1.h
+
+ generates the pre-processor symbol "STDPCCTS_std_parser1_H".
+
+ Reported by Ramanathan Santhanam (ps@kumaran.com).
+
+#78. (Changed in 1.33MR9) Guard predicates that refer to rules
+
+ ------------------------
+ Please refer to Item #87
+ ------------------------
+
+ Guard predicates are processed during an early phase
+ of antlr (during parsing) before all data structures
+ are completed.
+
+ There is an apparent bug in earlier versions of 1.33
+ which caused guard predicates which contained references
+ to rules (rather than tokens) to reference a structure
+ which hadn't yet been initialized.
+
+ In some cases (perhaps all cases) references to rules
+ in guard predicates resulted in the use of "garbage".
+
+#79. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
+
+ Previously, the maximum length file name was set
+ arbitrarily to 300 characters in antlr, dlg, and sorcerer.
+
+ The config.h file now attempts to define the maximum length
+ filename using _MAX_PATH from stdlib.h before falling back
+ to using the value 300.
+
+#78. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
+
+ Put #ifndef/#endif around definition of ZZLEXBUFSIZE in
+ antlr.
+
+#77. (Changed in 1.33MR9) Arithmetic overflow for very large grammars
+
+ In routine HandleAmbiguities() antlr attempts to compute the
+ number of possible elements in a set that is order of
+ number-of-tokens raised to the number-of-lookahead-tokens power.
+ For large grammars or large lookahead (e.g. -ck 7) this can
+ cause arithmetic overflow.
+
+ With 1.33MR9, arithmetic overflow in this computation is reported
+ the first time it happens. The program continues to run and
+ the program branches based on the assumption that the computed
+ value is larger than any number computed by counting actual cases
+ because 2**31 is larger than the number of bits in most computers.
+
+ Before 1.33MR9 overflow was not reported. The behavior following
+ overflow is not predictable by anyone but the original author.
+
+ NOTE
+
+ In 1.33MR10 the warning message is suppressed.
+ The code which detects the overflow allows the
+ computation to continue without an error. The
+ error message itself made made users worry.
+
+#76. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)
+
+ Jeff Vincent has convinced me to make ANTLRCommonToken and
+ ANTLRCommonNoRefCountToken use variable length strings
+ allocated from the heap rather than fixed length strings.
+ By suitable definition of setText(), the copy constructor,
+ and operator =() it is possible to maintain "copy" semantics.
+ By "copy" semantics I mean that when a token is copied from
+ an existing token it receives its own, distinct, copy of the
+ text allocated from the heap rather than simply a pointer
+ to the original token's text.
+
+ ============================================================
+ W * A * R * N * I * N * G
+ ============================================================
+
+ It is possible that this may cause problems for some users.
+ For those users I have included the old version of AToken.h as
+ pccts/h/AToken_traditional.h.
+
+#75. (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca)
+
+ Make DLGStringInput const correct. Since this is infrequently
+ subclassed, it should affect few users, I hope.
+
+#74. (Changed in 1.33MR9) -o (output directory) option
+
+ Antlr does not properly handle the -o output directory option
+ when the filename of the grammar contains a directory part. For
+ example:
+
+ antlr -o outdir pccts_src/myfile.g
+
+ causes antlr create a file called "outdir/pccts_src/myfile.cpp.
+ It SHOULD create outdir/myfile.cpp
+
+ The suggested code fix has been installed in antlr, dlg, and
+ Sorcerer.
+
+#73. (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist
+
+ ============================================
+ This has been rendered obsolete by Item #117
+ ============================================
+
+#72. (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX
+
+ The following methods in ANTLRParser were made virtual at
+ the request of S. Bochnak (S.Bochnak@microTool.com.pl):
+
+ saveState() and restoreState()
+ guess(), guess_fail(), and guess_done()
+
+#71. (Changed in 1.33MR9) Access to omitted command line argument
+
+ If a switch requiring arguments is the last thing on the
+ command line, and the argument is omitted, antlr would core.
+
+ antlr test.g -prc
+
+ instead of
+
+ antlr test.g -prc off
+
+#70. (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files
+
+ The following MSVC .dsp and .mak files for pccts and sorcerer
+ were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl)
+ and Jeff Vincent (JVincent@novell.com)
+
+ PCCTS Distribution Kit
+ ----------------------
+ pccts/PCCTSMSVC50.dsw
+
+ pccts/antlr/AntlrMSVC50.dsp
+ pccts/antlr/AntlrMSVC50.mak
+
+ pccts/dlg/DlgMSVC50.dsp
+ pccts/dlg/DlgMSVC50.mak
+
+ pccts/support/msvc.dsp
+
+ Sorcerer Distribution Kit
+ -------------------------
+ pccts/sorcerer/SorcererMSVC50.dsp
+ pccts/sorcerer/SorcererMSVC50.mak
+
+ pccts/sorcerer/lib/msvc.dsp
+
+#69. (Changed in 1.33MR9) Change "unsigned int" to plain "int"
+
+ Declaration of max_token_num in misc.c as "unsigned int"
+ caused comparison between signed and unsigned ints giving
+ warning message without any special benefit.
+
+#68. (Changed in 1.33MR9) Add void return for dlg internal_error()
+
+ Get rid of "no return value" message in internal_error()
+ in file dlg/support.c and dlg/dlg.h.
+
+#67. (Changed in Sor) sor.g: lisp() has no return value
+
+ Added a "void" for the return type.
+
+#66. (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif
+
+ A user needed to be able to change the ZZLEXBUFSIZE for
+ sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif
+
+#65. (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug
+
+ Jeff Vincent (JVincent@novell.com) found that deepCopy()
+ made new copies of only the direct descendents. No new
+ copies were made of sibling nodes, Sibling pointers are
+ set to zero by shallowCopy().
+
+ PCCTS_AST::deepCopy() has been changed to make a
+ deep copy in the traditional sense.
+
+ The deepCopy() routine depends on the behavior of
+ shallowCopy(). In all sor examples I've found,
+ shallowCopy() zeroes the right and down pointers.
+
+ Original Tree Original deepCopy() Revised deepCopy
+ ------------- ------------------- ----------------
+ a->b->c A A
+ | | |
+ d->e->f D D->E->F
+ | | |
+ g->h->i G G->H->I
+ | |
+ j->k J->K
+
+ While comparing deepCopy() for C++ mode with ast_dup for
+ C mode I found a problem with ast_dup().
+
+ Routine ast_dup() has been changed to make a deep copy
+ in the traditional sense.
+
+ Original Tree Original ast_dup() Revised ast_dup()
+ ------------- ------------------- ----------------
+ a->b->c A->B->C A
+ | | |
+ d->e->f D->E->F D->E->F
+ | | |
+ g->h->i G->H->I G->H->I
+ | | |
+ j->k J->K J->K
+
+
+ I believe this affects transform mode sorcerer programs only.
+
+#64. (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable()
+
+#63. (Changed in 1.33MR8) h/charptr.h does not zero pointer after free
+
+ The charptr.h routine now zeroes the pointer after free().
+
+ Reported by Jens Tingleff (jensting@imaginet.fr)
+
+#62. (Changed in 1.33MR8) ANTLRParser::resynch had static variable
+
+ The static variable "consumed" in ANTLRParser::resynch was
+ changed into an instance variable of the class with the
+ name "resynchConsumed".
+
+ Reported by S.Bochnak@microTool.com.pl
+
+#61. (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values
+
+ Previously, the following code would cause antlr to core when
+ it tried to generate code for rule1 because rule2 had no return
+ values ("upward inheritance"):
+
+ rule1 : <<int i; int j>>
+ rule2 > [i,j]
+ ;
+
+ rule2 : Anything ;
+
+ Reported by S.Bochnak@microTool.com.pl
+
+ Verified correct operation of antlr MR8 when missing or extra
+ inheritance arguments for all combinations. When there are
+ missing or extra arguments code will still be generated even
+ though this might cause the invocation of a subroutine with
+ the wrong number of arguments.
+
+#60. (Changed in 1.33MR7) Major changes to 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.
+
+ In 1.33MR7 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.
+
+ There are still undesirable features in the way exception
+ handlers are implemented, but I do not have time to fix them
+ at the moment:
+
+ The exception handlers for alternatives are outside the
+ block containing the alternative. This makes it impossible
+ to access variables declared in a block or to resume the
+ parse by "falling through". The parse can still be easily
+ resumed in other ways, but not in the most natural fashion.
+
+ This results in an inconsistentcy between named exception
+ handlers and exception handlers for alternatives. When
+ an exception handler for an alternative "falls through"
+ it goes to the nextmost outer handler - not the "normal
+ action".
+
+ A major difference between 1.33MR7 and 1.33 vanilla is
+ the default action after an exception is caught:
+
+ 1.33 Vanilla
+ ------------
+ In 1.33 vanilla the signal value is set to zero ("NoSignal")
+ and the code drops through to the code following the exception.
+ For named exception handlers this is the "normal action".
+ For alternative exception handlers this is the rule's handler.
+
+ 1.33MR7
+ -------
+ In 1.33MR7 the signal value is NOT automatically set to zero.
+
+ There are two cases:
+
+ For named exception handlers: if the signal value has been
+ set to zero the code drops through to the "normal action".
+
+ For all other cases the code branches to the nextmost outer
+ exception handler until it reaches the handler for the rule.
+
+ The following macros have been defined for convenience:
+
+ C/C++ Mode Name
+ --------------------
+ (zz)suppressSignal
+ set signal & return signal arg to 0 ("NoSignal")
+ (zz)setSignal(intValue)
+ set signal & return signal arg to some value
+ (zz)exportSignal
+ copy the signal value to the return signal arg
+
+ I'm not sure why PCCTS make a distinction between the local
+ signal value and the return signal argument, but I'm loathe
+ to change the code. The burden of copying the local signal
+ value to the return signal argument can be given to the
+ default signal handler, I suppose.
+
+#59. (Changed in 1.33MR7) Prototypes for some functions
+
+ Added prototypes for the following functions to antlr.h
+
+ zzconsumeUntil()
+ zzconsumeUntilToken()
+
+#58. (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h
+
+#57. (Changed in 1.33MR7) Format of #line directive
+
+ Previously, the -gl directive for line 1234 would
+ resemble: "# 1234 filename.g". This caused problems
+ for some compilers/pre-processors. In MR7 it generates
+ "#line 1234 filename.g".
+
+#56. (Added in 1.33MR7) Jan Mikkelsen <janm@zeta.org.au>
+
+ Move PURIFY macro invocaton to after rule's init action.
+
+#55. (Fixed in 1.33MR7) Unitialized variables in ANTLRParser
+
+ Member variables inf_labase and inf_last were not initialized.
+ (See item #50.)
+
+#54. (Fixed in 1.33MR6) Brad Schick (schick@interacess.com)
+
+ Previously, the following constructs generated the same
+ code:
+
+ rule1 : (A B C)?
+ | something-else
+ ;
+
+ rule2 : (A B C)? ()
+ | something-else
+ ;
+
+ In all versions of pccts rule1 guesses (A B C) and then
+ consume all three tokens if the guess succeeds. In MR6
+ rule2 guesses (A B C) but consumes NONE of the tokens
+ when the guess succeeds because "()" matches epsilon.
+
+#53. (Explanation for 1.33MR6) What happens after an exception is caught ?
+
+ The Book is silent about what happens after an exception
+ is caught.
+
+ The following code fragment prints "Error Action" followed
+ by "Normal Action".
+
+ test : Word ex:Number <<printf("Normal Action\n");>>
+ exception[ex]
+ catch NoViableAlt:
+ <<printf("Error Action\n");>>
+ ;
+
+ The reason for "Normal Action" is that the normal flow of the
+ program after a user-written exception handler is to "drop through".
+ In the case of an exception handler for a rule this results in
+ the exection of a "return" statement. In the case of an
+ exception handler attached to an alternative, rule, or token
+ this is the code that would have executed had there been no
+ exception.
+
+ The user can achieve the desired result by using a "return"
+ statement.
+
+ test : Word ex:Number <<printf("Normal Action\n");>>
+ exception[ex]
+ catch NoViableAlt:
+ <<printf("Error Action\n"); return;>>
+ ;
+
+ The most powerful mechanism for recovery from parse errors
+ in pccts is syntactic predicates because they provide
+ backtracking. Exceptions allow "return", "break",
+ "consumeUntil(...)", "goto _handler", "goto _fail", and
+ changing the _signal value.
+
+#52. (Fixed in 1.33MR6) Exceptions without syntactic predicates
+
+ The following generates bad code in 1.33 if no syntactic
+ predicates are present in the grammar.
+
+ test : Word ex:Number <<printf("Normal Action\n");>>
+ exception[ex]
+ catch NoViableAlt:
+ <<printf("Error Action\n");>>
+
+ There is a reference to a guess variable. In C mode
+ this causes a compiler error. In C++ mode it generates
+ an extraneous check on member "guessing".
+
+ In MR6 correct code is generated for both C and C++ mode.
+
+#51. (Added to 1.33MR6) Exception operator "@" used without exceptions
+
+ In MR6 added a warning when the exception operator "@" is
+ used and no exception group is defined. This is probably
+ a case where "\@" or "@" is meant.
+
+#50. (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no)
+ http://www.candleweb.no/~gunnar/
+
+ Routines zzsave_antlr_state and zzrestore_antlr_state don't
+ save and restore all the data needed when switching states.
+
+ Suggested patch applied to antlr.h and err.h for MR6.
+
+#49. (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com)
+
+ Generated code failed to turn off guess mode when leaving a
+ (...)+ block which contained a guess block. The result was
+ an infinite loop. For example:
+
+ rule : (
+ (x)?
+ | y
+ )+
+
+ Suggested code fix implemented in MR6. Replaced
+
+ ... else if (zzcnt>1) break;
+
+ with:
+
+ C++ mode:
+ ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;};
+ C mode:
+ ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;};
+
+#48. (Fixed in 1.33MR6) Invalid exception element causes core
+
+ A label attached to an invalid construct can cause
+ pccts to crash while processing the exception associated
+ with the label. For example:
+
+ rule : t:(B C)
+ exception[t] catch MismatchedToken: <<printf(...);>>
+
+ Version MR6 generates the message:
+
+ reference in exception handler to undefined label 't'
+
+#47. (Fixed in 1.33MR6) Manuel Ornato
+
+ Under some circumstances involving a k >1 or ck >1
+ grammar and a loop block (i.e. (...)* ) pccts will
+ fail to detect a syntax error and loop indefinitely.
+ The problem did not exist in 1.20, but has existed
+ from 1.23 to the present.
+
+ Fixed in MR6.
+
+ ---------------------------------------------------
+ Complete test program
+ ---------------------------------------------------
+ #header<<
+ #include <stdio.h>
+ #include "charptr.h"
+ >>
+
+ <<
+ #include "charptr.c"
+ main ()
+ {
+ ANTLR(global(),stdin);
+ }
+ >>
+
+ #token "[\ \t]+" << zzskip(); >>
+ #token "[\n]" << zzline++; zzskip(); >>
+
+ #token B "b"
+ #token C "c"
+ #token D "d"
+ #token E "e"
+ #token LP "\("
+ #token RP "\)"
+
+ #token ANTLREOF "@"
+
+ global : (
+ (E liste)
+ | liste
+ | listed
+ ) ANTLREOF
+ ;
+
+ listeb : LP ( B ( B | C )* ) RP ;
+ listec : LP ( C ( B | C )* ) RP ;
+ listed : LP ( D ( B | C )* ) RP ;
+ liste : ( listeb | listec )* ;
+
+ ---------------------------------------------------
+ Sample data causing infinite loop
+ ---------------------------------------------------
+ e (d c)
+ ---------------------------------------------------
+
+#46. (Fixed in 1.33MR6) Robert Richter
+ (Robert.Richter@infotech.tu-chemnitz.de)
+
+ This item from the list of known problems was
+ fixed by item #18 (below).
+
+#45. (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com)
+
+ The dependency scanner in VC++ mistakenly sees a
+ reference to an MPW #include file even though properly
+ #ifdef/#endif in config.h. The suggested workaround
+ has been implemented:
+
+ #ifdef MPW
+ .....
+ #define MPW_CursorCtl_Header <CursorCtl.h>
+ #include MPW_CursorCtl_Header
+ .....
+ #endif
+
+#44. (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c
+
+ Added (char *) cast for systems where malloc returns "void *".
+
+#43. (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca)
+
+ Add setLeft() and setUp methods to ASTDoublyLinkedBase
+ for symmetry with setRight() and setDown() methods.
+
+#42. (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca)
+
+ C++ style comment in antlr.c corrected.
+
+#41. (Added in 1.33MR6) antlr -stdout
+
+ Using "antlr -stdout ..." forces the text that would
+ normally go to the grammar.c or grammar.cpp file to
+ stdout.
+
+#40. (Added in 1.33MR6) antlr -tab to change tab stops
+
+ Using "antlr -tab number ..." changes the tab stops
+ for the grammar.c or grammar.cpp file. The number
+ must be between 0 and 8. Using 0 gives tab characters,
+ values between 1 and 8 give the appropriate number of
+ space characters.
+
+#39. (Fixed in 1.33MR5) Jan Mikkelsen <janm@zeta.org.au>
+
+ Commas in function prototype still not correct under
+ some circumstances. Suggested code fix installed.
+
+#38. (Fixed in 1.33MR5) ANTLRTokenBuffer constructor
+
+ Have ANTLRTokenBuffer ctor initialize member "parser" to null.
+
+#37. (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca)
+
+ In ANTLRParser::FAIL(int k,...) released memory pointed to by
+ f[i] (as well as f itself. Should only free f itself.
+
+#36. (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu)
+
+ Neglected to properly declare isDLGmaxToken() when fixing problem
+ reported by Andreas Magnusson.
+
+ Undo "_retv=NULL;" change which caused problems for return values
+ from rules whose return values weren't pointers.
+
+ Failed to create bin directory if it didn't exist.
+
+#35. (Fixed in 1.33MR2) Andreas Magnusson
+(Andreas.Magnusson@mailbox.swipnet.se)
+
+ Repair bug introduced by 1.33MR1 for #tokdefs. The original fix
+ placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum
+ in order to fix a problem with an aggresive compiler assigning an 8
+ bit enum which might be too narrow. This caused #tokdefs to assume
+ that there were 9999 real tokens. The repair to the fix causes antlr to
+ ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file.
+
+#34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)
+
+ Previously there was no public function for changing the line
+ number maintained by the lexer.
+
+#33. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com)
+
+ Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE
+ in pccts/h/AParser.cpp.
+
+#32. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com)
+
+ In PCCTSAST.cpp lines 405 and 466: Change
+
+ free (t)
+ to
+ free ( (char *)t );
+
+ to match prototype.
+
+#31. (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer
+ Pointer to parser in DLGLexerBase
+
+ The ANTLRTokenBuffer class now contains a pointer to the
+ parser which is using it. This is established by the
+ ANTLRParser constructor calling ANTLRTokenBuffer::
+ setParser(ANTLRParser *p).
+
+ When ANTLRTokenBuffer::setParser(ANTLRParser *p) is
+ called it saves the pointer to the parser and then
+ calls ANTLRTokenStream::setParser(ANTLRParser *p)
+ so that the lexer can also save a pointer to the
+ parser.
+
+ There is also a function getParser() in each class
+ with the obvious purpose.
+
+ It is possible that these functions will return NULL
+ under some circumstances (e.g. a non-DLG lexer is used).
+
+#30. (Added to 1.33MR1) function tokenName(int token) standard
+
+ The generated parser class now includes the
+ function:
+
+ static const ANTLRChar * tokenName(int token)
+
+ which returns a pointer to the "name" corresponding
+ to the token.
+
+ The base class (ANTLRParser) always includes the
+ member function:
+
+ const ANTLRChar * parserTokenName(int token)
+
+ which can be accessed by objects which have a pointer
+ to an ANTLRParser, but do not know the name of the
+ parser class (e.g. ANTLRTokenBuffer and DLGLexerBase).
+
+#29. (Added to 1.33MR1) Debugging DLG lexers
+
+ If the pre-processor symbol DEBUG_LEXER is defined
+ then DLexerBase will include code for printing out
+ key information about tokens which are recognized.
+
+ The debug feature of the lexer is controlled by:
+
+ int previousDebugValue=lexer.debugLexer(newValue);
+
+ a value of 0 disables output
+ a value of 1 enables output
+
+ Even if the lexer debug code is compiled into DLexerBase
+ it must be enabled before any output is generated. For
+ example:
+
+ DLGFileInput in(stdin);
+ MyDLG lexer(&in,2000);
+
+ lexer.setToken(&aToken);
+
+ #if DEBUG_LEXER
+ lexer.debugLexer(1); // enable debug information
+ #endif
+
+#28. (Added to 1.33MR1) More control over DLG header
+
+ Version 1.33MR1 adds the following directives to PCCTS
+ for C++ mode:
+
+ #lexprefix <<source code>>
+
+ Adds source code to the DLGLexer.h file
+ after the #include "DLexerBase.h" but
+ before the start of the class definition.
+
+ #lexmember <<source code>>
+
+ Adds source code to the DLGLexer.h file
+ as part of the DLGLexer class body. It
+ appears immediately after the start of
+ the class and a "public: statement.
+
+#27. (Fixed in 1.33MR1) Comments in DLG actions
+
+ Previously, DLG would not recognize comments as a special case.
+ Thus, ">>" in the comments would cause errors. This is fixed.
+
+#26. (Fixed in 1.33MR1) Removed static variables from error routines
+
+ Previously, the existence of statically allocated variables
+ in some of the parser's member functions posed a danger when
+ there was more than one parser active.
+
+ Replaced with dynamically allocated/freed variables in 1.33MR1.
+
+#25. (Fixed in 1.33MR1) Use of string literals in semantic predicates
+
+ Previously, it was not possible to place a string literal in
+ a semantic predicate because it was not properly "stringized"
+ for the report of a failed predicate.
+
+#24. (Fixed in 1.33MR1) Continuation lines for semantic predicates
+
+ Previously, it was not possible to continue semantic
+ predicates across a line because it was not properly
+ "stringized" for the report of a failed predicate.
+
+ rule : <<ifXYZ()>>?[ a very
+ long statement ]
+
+#23. (Fixed in 1.33MR1) {...} envelope for failed semantic predicates
+
+ Previously, there was a code generation error for failed
+ semantic predicates:
+
+ rule : <<xyz()>>?[ stmt1; stmt2; ]
+
+ which generated code which resembled:
+
+ if (! xyz()) stmt1; stmt2;
+
+ It now puts the statements in a {...} envelope:
+
+ if (! xyz()) { stmt1; stmt2; };
+
+#22. (Fixed in 1.33MR1) Continuation of #token across lines using "\"
+
+ Previously, it was not possible to continue a #token regular
+ expression across a line. The trailing "\" and newline caused
+ a newline to be inserted into the regular expression by DLG.
+
+ Fixed in 1.33MR1.
+
+#21. (Fixed in 1.33MR1) Use of ">>" (right shift operator in DLG actions
+
+ It is now possible to use the C++ right shift operator ">>"
+ in DLG actions by using the normal escapes:
+
+ #token "shift-right" << value=value \>\> 1;>>
+
+#20. (Version 1.33/19-Jan-97 Karl Eccleson <karle@microrobotics.co.uk>
+ P.A. Keller (P.A.Keller@bath.ac.uk)
+
+ There is a problem due to using exceptions with the -gh option.
+
+ Suggested fix now in 1.33MR1.
+
+#19. (Fixed in 1.33MR1) Tom Piscotti and John Lilley
+
+ There were problems suppressing messages to stdin and stdout
+ when running in a window environment because some functions
+ which uses fprint were not virtual.
+
+ Suggested change now in 1.33MR1.
+
+ I believe all functions containing error messages (excluding those
+ indicating internal inconsistency) have been placed in functions
+ which are virtual.
+
+#18. (Version 1.33/ 22-Nov-96) John Bair (jbair@iftime.com)
+
+ Under some combination of options a required "return _retv" is
+ not generated.
+
+ Suggested fix now in 1.33MR1.
+
+#17. (Version 1.33/3-Sep-96) Ron House (house@helios.usq.edu.au)
+
+ The routine ASTBase::predorder_action omits two "tree->"
+ prefixes, which results in the preorder_action belonging
+ to the wrong node to be invoked.
+
+ Suggested fix now in 1.33MR1.
+
+#16. (Version 1.33/7-Jun-96) Eli Sternheim <eli@interhdl.com>
+
+ Routine consumeUntilToken() does not check for end-of-file
+ condition.
+
+ Suggested fix now in 1.33MR1.
+
+#15. (Version 1.33/8 Apr 96) Asgeir Olafsson <olafsson@cstar.ac.com>
+
+ Problem with tree duplication of doubly linked ASTs in ASTBase.cpp.
+
+ Suggested fix now in 1.33MR1.
+
+#14. (Version 1.33/28-Feb-96) Andreas.Magnusson@mailbox.swipnet.se
+
+ Problem with definition of operator = (const ANTLRTokenPtr rhs).
+
+ Suggested fix now in 1.33MR1.
+
+#13. (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com)
+
+ Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in
+ block with destructors.
+
+ Apparently fixed. Can't locate "goto".
+
+#12. (Version 1.33/10-Nov-95) Minor problems with 1.33 code
+
+ The following items have been fixed in 1.33MR1:
+
+ 1. pccts/antlr/main.c line 142
+
+ "void" appears in classic C code
+
+ 2. no makefile in support/genmk
+
+ 3. EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS
+
+ pccts/h/PCCTSAST.cpp
+ pccts/h/DLexerBase.cpp
+ pccts/testcpp/6/test.g
+
+ 4. use of "signed int" isn't accepted by AT&T cfront
+
+ pccts/h/PCCTSAST.h line 42
+
+ 5. in call to ANTLRParser::FAIL the var arg err_k is passed as
+ "int" but is declared "unsigned int".
+
+ 6. I believe that a failed validation predicate still does not
+ get put in a "{...}" envelope, despite the release notes.
+
+ 7. The #token ">>" appearing in the DLG grammar description
+ causes DLG to generate the string literal "\>\>" which
+ is non-conforming and will cause some compilers to
+ complain (scan.c function act10 line 143 of source code).
+
+#11. (Version 1.32b6) Dave Kuhlman (dkuhlman@netcom.com)
+
+ Problem with file close in gen.c. Already fixed in 1.33.
+
+#10. (Version 1.32b6/29-Aug-95)
+
+ pccts/antlr/main.c contains a C++ style comments on lines 149
+ and 176 which causes problems for most C compilers.
+
+ Already fixed in 1.33.
+
+#9. (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h"
+
+ The file pccts/h/dlgauto.h should probably contain a #include
+ "config.h" as it uses the #define symbol __USE_PROTOS.
+
+ Added to 1.33MR1.
+
+#8. (Version 1.32b4/6-Mar-95) Michael T. Richter (mtr@igs.net)
+
+ In C++ output mode anonymous tokens from in-line regular expressions
+ can create enum values which are too wide for the datatype of the enum
+ assigned by the C++ compiler.
+
+ Fixed in 1.33MR1.
+
+#7. (Version 1.32b4/6-Mar-95) C++ does not imply __STDC__
+
+ In err.h the combination of # directives assumes that a C++
+ compiler has __STDC__ defined. This is not necessarily true.
+
+ This problem also appears in the use of __USE_PROTOS which
+ is appropriate for both Standard C and C++ in antlr/gen.c
+ and antlr/lex.c
+
+ Fixed in 1.33MR1.
+
+#6. (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType"
+
+ Already fixed in 1.33.
+
+#5. (23-Jan-95) Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil
+
+ The fail action following a semantic predicate is not enclosed in
+ "{...}". This can lead to problems when the fail action contains
+ more than one statement.
+
+ Fixed in 1.33MR1.
+
+#4 . (Version 1.33/31-Mar-96) jlilley@empathy.com (John Lilley)
+
+ Put briefly, a semantic predicate ought to abort a guess if it fails.
+
+ Correction suggested by J. Lilley has been added to 1.33MR1.
+
+#3 . (Version 1.33) P.A.Keller@bath.ac.uk
+
+ Extra commas are placed in the K&R style argument list for rules
+ when using both exceptions and ASTs.
+
+ Fixed in 1.33MR1.
+
+#2. (Version 1.32b6/2-Oct-95) Brad Schick <schick@interaccess.com>
+
+ Construct #[] generates zzastnew() in C++ mode.
+
+ Already fixed in 1.33.
+
+#1. (Version 1.33) Bob Bailey (robert@oakhill.sps.mot.com)
+
+ Previously, config.h assumed that all PC systems required
+ "short" file names. The user can now override that
+ assumption with "#define LONGFILENAMES".
+
+ Added to 1.33MR1.
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt
new file mode 100644
index 0000000000..91defae169
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt
@@ -0,0 +1,2049 @@
+======================================================================
+
+ CHANGES_SUMMARY.TXT
+
+ A QUICK overview of changes from 1.33 in reverse order
+
+ A summary of additions rather than bug fixes and minor code changes.
+
+ Numbers refer to items in CHANGES_FROM_133*.TXT
+ which may contain additional information.
+
+ DISCLAIMER
+
+ The software and these notes are provided "as is". They may include
+ typographical or technical errors and their authors disclaims all
+ liability of any kind or nature for damages due to error, fault,
+ defect, or deficiency regardless of cause. All warranties of any
+ kind, either express or implied, including, but not limited to, the
+ implied warranties of merchantability and fitness for a particular
+ purpose are disclaimed.
+
+======================================================================
+
+#258. You can specify a user-defined base class for your parser
+
+ The base class must constructor must have a signature similar to
+ that of ANTLRParser.
+
+#253. Generation of block preamble (-preamble and -preamble_first)
+
+ The antlr option -preamble causes antlr to insert the code
+ BLOCK_PREAMBLE at the start of each rule and block.
+
+ The antlr option -preamble_first is similar, but inserts the
+ code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol
+ PreambleFirst_123 is equivalent to the first set defined by
+ the #FirstSetSymbol described in Item #248.
+
+#248. Generate symbol for first set of an alternative
+
+ rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ;
+
+#216. Defer token fetch for C++ mode
+
+ When the ANTLRParser 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.
+
+#215. Use reset() to reset DLGLexerBase
+#188. Added pccts/h/DLG_stream_input.h
+#180. Added ANTLRParser::getEofToken()
+#173. -glms for Microsoft style filenames with -gl
+#170. Suppression for predicates with lookahead depth >1
+
+ Consider the following grammar with -ck 2 and the predicate in rule
+ "a" with depth 2:
+
+ r1 : (ab)* "@"
+ ;
+
+ ab : a
+ | b
+ ;
+
+ a : (A B)? => <<p(LATEXT(2))>>? A B C
+ ;
+
+ b : A B C
+ ;
+
+ Normally, the predicate would be hoisted into rule r1 in order to
+ determine whether to call rule "ab". However it should *not* be
+ hoisted because, even if p is false, there is a valid alternative
+ in rule b. With "-mrhoistk on" the predicate will be suppressed.
+
+ If "-info p" command line option is present the following information
+ will appear in the generated code:
+
+ while ( (LA(1)==A)
+ #if 0
+
+ Part (or all) of predicate with depth > 1 suppressed by alternative
+ without predicate
+
+ pred << p(LATEXT(2))>>?
+ depth=k=2 ("=>" guard) rule a line 8 t1.g
+ tree context:
+ (root = A
+ B
+ )
+
+ The token sequence which is suppressed: ( A B )
+ The sequence of references which generate that sequence of tokens:
+
+ 1 to ab r1/1 line 1 t1.g
+ 2 ab ab/1 line 4 t1.g
+ 3 to b ab/2 line 5 t1.g
+ 4 b b/1 line 11 t1.g
+ 5 #token A b/1 line 11 t1.g
+ 6 #token B b/1 line 11 t1.g
+
+ #endif
+
+ A slightly more complicated example:
+
+ r1 : (ab)* "@"
+ ;
+
+ ab : a
+ | b
+ ;
+
+ a : (A B)? => <<p(LATEXT(2))>>? (A B | D E)
+ ;
+
+ b : <<q(LATEXT(2))>>? D E
+ ;
+
+
+ In this case, the sequence (D E) in rule "a" which lies behind
+ the guard is used to suppress the predicate with context (D E)
+ in rule b.
+
+ while ( (LA(1)==A || LA(1)==D)
+ #if 0
+
+ Part (or all) of predicate with depth > 1 suppressed by alternative
+ without predicate
+
+ pred << q(LATEXT(2))>>?
+ depth=k=2 rule b line 11 t2.g
+ tree context:
+ (root = D
+ E
+ )
+
+ The token sequence which is suppressed: ( D E )
+ The sequence of references which generate that sequence of tokens:
+
+ 1 to ab r1/1 line 1 t2.g
+ 2 ab ab/1 line 4 t2.g
+ 3 to a ab/1 line 4 t2.g
+ 4 a a/1 line 8 t2.g
+ 5 #token D a/1 line 8 t2.g
+ 6 #token E a/1 line 8 t2.g
+
+ #endif
+ &&
+ #if 0
+
+ pred << p(LATEXT(2))>>?
+ depth=k=2 ("=>" guard) rule a line 8 t2.g
+ tree context:
+ (root = A
+ B
+ )
+
+ #endif
+
+ (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) {
+ ab();
+ ...
+
+#165. (Changed in MR13) option -newAST
+
+ To create ASTs from an ANTLRTokenPtr antlr usually calls
+ "new AST(ANTLRTokenPtr)". This option generates a call
+ to "newAST(ANTLRTokenPtr)" instead. This allows a user
+ to define a parser member function to create an AST object.
+
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h
+
+#158. (Changed in MR13) #header causes problem for pre-processors
+
+ A user who runs the C pre-processor on antlr source suggested
+ that another syntax be allowed. With MR13 such directives
+ such as #header, #pragma, etc. may be written as "\#header",
+ "\#pragma", etc. For escaping pre-processor directives inside
+ a #header use something like the following:
+
+ \#header
+ <<
+ \#include <stdio.h>
+ >>
+
+#155. (Changed in MR13) Context behind predicates can suppress
+
+ With -mrhoist enabled the context behind a guarded predicate can
+ be used to suppress other predicates. Consider the following grammar:
+
+ r0 : (r1)+;
+
+ r1 : rp
+ | rq
+ ;
+ rp : <<p LATEXT(1)>>? B ;
+ rq : (A)? => <<q LATEXT(1)>>? (A|B);
+
+ In earlier versions both predicates "p" and "q" would be hoisted into
+ rule r0. With MR12c predicate p is suppressed because the context which
+ follows predicate q includes "B" which can "cover" predicate "p". In
+ other words, in trying to decide in r0 whether to call r1, it doesn't
+ really matter whether p is false or true because, either way, there is
+ a valid choice within r1.
+
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>
+
+ A common error, even among experienced pccts users, is to code
+ an init-action to inhibit hoisting rather than a leading action.
+ An init-action does not inhibit hoisting.
+
+ This was coded:
+
+ rule1 : <<;>> rule2
+
+ This is what was meant:
+
+ rule1 : <<;>> <<;>> rule2
+
+ With MR13, the user can code:
+
+ rule1 : <<;>> <<nohoist>> rule2
+
+ The following will give an error message:
+
+ rule1 : <<nohoist>> rule2
+
+ If the <<nohoist>> appears as an init-action rather than a leading
+ action an error message is issued. The meaning of an init-action
+ containing "nohoist" is unclear: does it apply to just one
+ alternative or to all alternatives ?
+
+#151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer()
+
+ You must manually cast the ANTLRTokenStream to your program's
+ lexer class. Because the name of the lexer's class is not fixed.
+ Thus it is impossible to incorporate it into the DLGLexerBase
+ class.
+
+#151b.(Changed in MR12) ParserBlackBox member getLexer()
+
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public
+
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)
+
+ If there is more than one rule which is not referenced by any
+ other rule then all such rules are listed. This is useful for
+ alerting one to rules which are not used, but which can still
+ contribute to ambiguity.
+
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl
+
+ One can write:
+
+ #token Plus ("+") "\+"
+ #token RP ("(") "\("
+ #token COM ("comment begin") "/\*"
+
+ The string in parenthesis will be used in syntax error messages.
+
+#146. (Changed in MR11) Option -treport for locating "difficult" alts
+
+ 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 peformed 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.
+
+ The following is a trivial case from the ansi.g grammar which shows
+ the format of the report. This report might be of more interest
+ in cases where 1,000,000 tuples were created to resolve the ambiguity.
+
+ -------------------------------------------------------------------------
+ There were 0 tuples whose ambiguity could not be resolved
+ by full lookahead
+ There were 157 tnodes created to resolve ambiguity between:
+
+ Choice 1: statement/2 line 475 file ansi.g
+ Choice 2: statement/3 line 476 file ansi.g
+
+ Intersection of lookahead[1] sets:
+
+ IDENTIFIER
+
+ Intersection of lookahead[2] sets:
+
+ LPARENTHESIS COLON AMPERSAND MINUS
+ STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT
+ NOT SIZEOF OCTALINT DECIMALINT
+ HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER
+ STRING CHARACTER
+ -------------------------------------------------------------------------
+
+#143. (Changed in MR11) Optional ";" at end of #token statement
+
+ Fixes problem of:
+
+ #token X "x"
+
+ <<
+ parser action
+ >>
+
+ Being confused with:
+
+ #token X "x" <<lexical action>>
+
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream
+
+ Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class
+ BufFileInput derived from DLGInputStream which provides a
+ function lookahead(char *string) to test characters in the
+ input stream more than one character ahead.
+ The class is located in pccts/h/BufFileInput.* of the kit.
+
+#140. #pred to define predicates
+
+ +---------------------------------------------------+
+ | Note: Assume "-prc on" for this entire discussion |
+ +---------------------------------------------------+
+
+ A problem with predicates is that each one is regarded as
+ unique and capable of disambiguating cases where two
+ alternatives have identical lookahead. For example:
+
+ rule : <<pred(LATEXT(1))>>? A
+ | <<pred(LATEXT(1))>>? A
+ ;
+
+ will not cause any error messages or warnings to be issued
+ by earlier versions of pccts. To compare the text of the
+ predicates is an incomplete solution.
+
+ In 1.33MR11 I am introducing the #pred statement in order to
+ solve some problems with predicates. The #pred statement allows
+ one to give a symbolic name to a "predicate literal" or a
+ "predicate expression" in order to refer to it in other predicate
+ expressions or in the rules of the grammar.
+
+ The predicate literal associated with a predicate symbol is C
+ or C++ code which can be used to test the condition. A
+ predicate expression defines a predicate symbol in terms of other
+ predicate symbols using "!", "&&", and "||". A predicate symbol
+ can be defined in terms of a predicate literal, a predicate
+ expression, or *both*.
+
+ When a predicate symbol is defined with both a predicate literal
+ and a predicate expression, the predicate literal is used to generate
+ code, but the predicate expression is used to check for two
+ alternatives with identical predicates in both alternatives.
+
+ Here are some examples of #pred statements:
+
+ #pred IsLabel <<isLabel(LATEXT(1))>>?
+ #pred IsLocalVar <<isLocalVar(LATEXT(1))>>?
+ #pred IsGlobalVar <<isGlobalVar(LATEXT(1)>>?
+ #pred IsVar <<isVar(LATEXT(1))>>? IsLocalVar || IsGlobalVar
+ #pred IsScoped <<isScoped(LATEXT(1))>>? IsLabel || IsLocalVar
+
+ I hope that the use of EBNF notation to describe the syntax of the
+ #pred statement will not cause problems for my readers (joke).
+
+ predStatement : "#pred"
+ CapitalizedName
+ (
+ "<<predicate_literal>>?"
+ | "<<predicate_literal>>?" predOrExpr
+ | predOrExpr
+ )
+ ;
+
+ predOrExpr : predAndExpr ( "||" predAndExpr ) * ;
+
+ predAndExpr : predPrimary ( "&&" predPrimary ) * ;
+
+ predPrimary : CapitalizedName
+ | "!" predPrimary
+ | "(" predOrExpr ")"
+ ;
+
+ What is the purpose of this nonsense ?
+
+ To understand how predicate symbols help, you need to realize that
+ predicate symbols are used in two different ways with two different
+ goals.
+
+ a. Allow simplification of predicates which have been combined
+ during predicate hoisting.
+
+ b. Allow recognition of identical predicates which can't disambiguate
+ alternatives with common lookahead.
+
+ First we will discuss goal (a). Consider the following rule:
+
+ rule0: rule1
+ | ID
+ | ...
+ ;
+
+ rule1: rule2
+ | rule3
+ ;
+
+ rule2: <<isX(LATEXT(1))>>? ID ;
+ rule3: <<!isX(LATEXT(1)>>? ID ;
+
+ When the predicates in rule2 and rule3 are combined by hoisting
+ to create a prediction expression for rule1 the result is:
+
+ if ( LA(1)==ID
+ && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...
+
+ This is inefficient, but more importantly, can lead to false
+ assumptions that the predicate expression distinguishes the rule1
+ alternative with some other alternative with lookahead ID. In
+ MR11 one can write:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+
+ ...
+
+ rule2: <<IsX>>? ID ;
+ rule3: <<!IsX>>? ID ;
+
+ During hoisting MR11 recognizes this as a special case and
+ eliminates the predicates. The result is a prediction
+ expression like the following:
+
+ if ( LA(1)==ID ) { rule1(); ...
+
+ Please note that the following cases which appear to be equivalent
+ *cannot* be simplified by MR11 during hoisting because the hoisting
+ logic only checks for a "!" in the predicate action, not in the
+ predicate expression for a predicate symbol.
+
+ *Not* equivalent and is not simplified during hoisting:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+ #pred NotX <<!isX(LATEXT(1))>>?
+ ...
+ rule2: <<IsX>>? ID ;
+ rule3: <<NotX>>? ID ;
+
+ *Not* equivalent and is not simplified during hoisting:
+
+ #pred IsX <<isX(LATEXT(1))>>?
+ #pred NotX !IsX
+ ...
+ rule2: <<IsX>>? ID ;
+ rule3: <<NotX>>? ID ;
+
+ Now we will discuss goal (b).
+
+ When antlr discovers that there is a lookahead ambiguity between
+ two alternatives it attempts to resolve the ambiguity by searching
+ for predicates in both alternatives. In the past any predicate
+ would do, even if the same one appeared in both alternatives:
+
+ rule: <<p(LATEXT(1))>>? X
+ | <<p(LATEXT(1))>>? X
+ ;
+
+ The #pred statement is a start towards solving this problem.
+ During ambiguity resolution (*not* predicate hoisting) the
+ predicates for the two alternatives are expanded and compared.
+ Consider the following example:
+
+ #pred Upper <<isUpper(LATEXT(1))>>?
+ #pred Lower <<isLower(LATEXT(1))>>?
+ #pred Alpha <<isAlpha(LATEXT(1))>>? Upper || Lower
+
+ rule0: rule1
+ | <<Alpha>>? ID
+ ;
+
+ rule1:
+ | rule2
+ | rule3
+ ...
+ ;
+
+ rule2: <<Upper>>? ID;
+ rule3: <<Lower>>? ID;
+
+ The definition of #pred Alpha expresses:
+
+ a. to test the predicate use the C code "isAlpha(LATEXT(1))"
+
+ b. to analyze the predicate use the information that
+ Alpha is equivalent to the union of Upper and Lower,
+
+ During ambiguity resolution the definition of Alpha is expanded
+ into "Upper || Lower" and compared with the predicate in the other
+ alternative, which is also "Upper || Lower". Because they are
+ identical MR11 will report a problem.
+
+ -------------------------------------------------------------------------
+ t10.g, line 5: warning: the predicates used to disambiguate rule rule0
+ (file t10.g alt 1 line 5 and alt 2 line 6)
+ are identical when compared without context and may have no
+ resolving power for some lookahead sequences.
+ -------------------------------------------------------------------------
+
+ If you use the "-info p" option the output file will contain:
+
+ +----------------------------------------------------------------------+
+ |#if 0 |
+ | |
+ |The following predicates are identical when compared without |
+ | lookahead context information. For some ambiguous lookahead |
+ | sequences they may not have any power to resolve the ambiguity. |
+ | |
+ |Choice 1: rule0/1 alt 1 line 5 file t10.g |
+ | |
+ | The original predicate for choice 1 with available context |
+ | information: |
+ | |
+ | OR expr |
+ | |
+ | pred << Upper>>? |
+ | depth=k=1 rule rule2 line 14 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | pred << Lower>>? |
+ | depth=k=1 rule rule3 line 15 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | The predicate for choice 1 after expansion (but without context |
+ | information): |
+ | |
+ | OR expr |
+ | |
+ | pred << isUpper(LATEXT(1))>>? |
+ | depth=k=1 rule line 1 t10.g |
+ | |
+ | pred << isLower(LATEXT(1))>>? |
+ | depth=k=1 rule line 2 t10.g |
+ | |
+ | |
+ |Choice 2: rule0/2 alt 2 line 6 file t10.g |
+ | |
+ | The original predicate for choice 2 with available context |
+ | information: |
+ | |
+ | pred << Alpha>>? |
+ | depth=k=1 rule rule0 line 6 t10.g |
+ | set context: |
+ | ID |
+ | |
+ | The predicate for choice 2 after expansion (but without context |
+ | information): |
+ | |
+ | OR expr |
+ | |
+ | pred << isUpper(LATEXT(1))>>? |
+ | depth=k=1 rule line 1 t10.g |
+ | |
+ | pred << isLower(LATEXT(1))>>? |
+ | depth=k=1 rule line 2 t10.g |
+ | |
+ | |
+ |#endif |
+ +----------------------------------------------------------------------+
+
+ The comparison of the predicates for the two alternatives takes
+ place without context information, which means that in some cases
+ the predicates will be considered identical even though they operate
+ on disjoint lookahead sets. Consider:
+
+ #pred Alpha
+
+ rule1: <<Alpha>>? ID
+ | <<Alpha>>? Label
+ ;
+
+ Because the comparison of predicates takes place without context
+ these will be considered identical. The reason for comparing
+ without context is that otherwise it would be necessary to re-evaluate
+ the entire predicate expression for each possible lookahead sequence.
+ This would require more code to be written and more CPU time during
+ grammar analysis, and it is not yet clear whether anyone will even make
+ use of the new #pred facility.
+
+ A temporary workaround might be to use different #pred statements
+ for predicates you know have different context. This would avoid
+ extraneous warnings.
+
+ The above example might be termed a "false positive". Comparison
+ without context will also lead to "false negatives". Consider the
+ following example:
+
+ #pred Alpha
+ #pred Beta
+
+ rule1: <<Alpha>>? A
+ | rule2
+ ;
+
+ rule2: <<Alpha>>? A
+ | <<Beta>>? B
+ ;
+
+ The predicate used for alt 2 of rule1 is (Alpha || Beta). This
+ appears to be different than the predicate Alpha used for alt1.
+ However, the context of Beta is B. Thus when the lookahead is A
+ Beta will have no resolving power and Alpha will be used for both
+ alternatives. Using the same predicate for both alternatives isn't
+ very helpful, but this will not be detected with 1.33MR11.
+
+ To properly handle this the predicate expression would have to be
+ evaluated for each distinct lookahead context.
+
+ To determine whether two predicate expressions are identical is
+ difficult. The routine may fail to identify identical predicates.
+
+ The #pred feature also compares predicates to see if a choice between
+ alternatives which is resolved by a predicate which makes the second
+ choice unreachable. Consider the following example:
+
+ #pred A <<A(LATEXT(1)>>?
+ #pred B <<B(LATEXT(1)>>?
+ #pred A_or_B A || B
+
+ r : s
+ | t
+ ;
+ s : <<A_or_B>>? ID
+ ;
+ t : <<A>>? ID
+ ;
+
+ ----------------------------------------------------------------------------
+ t11.g, line 5: warning: the predicate used to disambiguate the
+ first choice of rule r
+ (file t11.g alt 1 line 5 and alt 2 line 6)
+ appears to "cover" the second predicate when compared without context.
+ The second predicate may have no resolving power for some lookahead
+ sequences.
+ ----------------------------------------------------------------------------
+
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts
+
+ Prior to 1.33MR11, there would be no ambiguity warning when the
+ very same predicate was used to disambiguate both alternatives:
+
+ test: ref B
+ | ref C
+ ;
+
+ ref : <<pred(LATEXT(1)>>? A
+
+ In 1.33MR11 this will cause the warning:
+
+ warning: the predicates used to disambiguate rule test
+ (file v98.g alt 1 line 1 and alt 2 line 2)
+ are identical and have no resolving power
+
+ ----------------- Note -----------------
+
+ This is different than the following case
+
+ test: <<pred(LATEXT(1))>>? A B
+ | <<pred(LATEXT(1)>>? A C
+ ;
+
+ In this case there are two distinct predicates
+ which have exactly the same text. In the first
+ example there are two references to the same
+ predicate. The problem represented by this
+ grammar will be addressed later.
+
+
+#127. (Changed in 1.33MR11)
+
+ Count Syntax Errors Count DLG Errors
+ ------------------- ----------------
+
+ C++ mode ANTLRParser:: DLGLexerBase::
+ syntaxErrCount lexErrCount
+ C mode zzSyntaxErrCount zzLexErrCount
+
+ The C mode variables are global and initialized to 0.
+ They are *not* reset to 0 automatically when antlr is
+ restarted.
+
+ The C++ mode variables are public. They are initialized
+ to 0 by the constructors. They are *not* reset to 0 by the
+ ANTLRParser::init() method.
+
+ Suggested by Reinier van den Born (reinier@vnet.ibm.com).
+
+#126. (Changed in 1.33MR11) Addition of #first <<...>>
+
+ The #first <<...>> inserts the specified text in the output
+ files before any other #include statements required by pccts.
+ The only things before the #first text are comments and
+ a #define ANTLR_VERSION.
+
+ Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin
+ Zoltan (alexin@inf.u-szeged.hu).
+
+#124. A Note on the New "&&" Style Guarded Predicates
+
+ I've been asked several times, "What is the difference between
+ the old "=>" style guard predicates and the new style "&&" guard
+ predicates, and how do you choose one over the other" ?
+
+ The main difference is that the "=>" does not apply the
+ predicate if the context guard doesn't match, whereas
+ the && form always does. What is the significance ?
+
+ If you have a predicate which is not on the "leading edge"
+ it is cannot be hoisted. Suppose you need a predicate that
+ looks at LA(2). You must introduce it manually. The
+ classic example is:
+
+ castExpr :
+ LP typeName RP
+ | ....
+ ;
+
+ typeName : <<isTypeName(LATEXT(1))>>? ID
+ | STRUCT ID
+ ;
+
+ The problem is that isTypeName() isn't on the leading edge
+ of typeName, so it won't be hoisted into castExpr to help
+ make a decision on which production to choose.
+
+ The *first* attempt to fix it is this:
+
+ castExpr :
+ <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ Unfortunately, this won't work because it ignores
+ the problem of STRUCT. The solution is to apply
+ isTypeName() in castExpr if LA(2) is an ID and
+ don't apply it when LA(2) is STRUCT:
+
+ castExpr :
+ (LP ID)? => <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ In conclusion, the "=>" style guarded predicate is
+ useful when:
+
+ a. the tokens required for the predicate
+ are not on the leading edge
+ b. there are alternatives in the expression
+ selected by the predicate for which the
+ predicate is inappropriate
+
+ If (b) were false, then one could use a simple
+ predicate (assuming "-prc on"):
+
+ castExpr :
+ <<isTypeName(LATEXT(2))>>?
+ LP typeName RP
+ | ....
+ ;
+
+ typeName : <<isTypeName(LATEXT(1))>>? ID
+ ;
+
+ So, when do you use the "&&" style guarded predicate ?
+
+ The new-style "&&" predicate should always be used with
+ predicate context. The context guard is in ADDITION to
+ the automatically computed context. Thus it useful for
+ predicates which depend on the token type for reasons
+ other than context.
+
+ The following example is contributed by Reinier van den Born
+ (reinier@vnet.ibm.com).
+
+ +-------------------------------------------------------------------------+
+ | This grammar has two ways to call functions: |
+ | |
+ | - a "standard" call syntax with parens and comma separated args |
+ | - a shell command like syntax (no parens and spacing separated args) |
+ | |
+ | The former also allows a variable to hold the name of the function, |
+ | the latter can also be used to call external commands. |
+ | |
+ | The grammar (simplified) looks like this: |
+ | |
+ | fun_call : ID "(" { expr ("," expr)* } ")" |
+ | /* ID is function name */ |
+ | | "@" ID "(" { expr ("," expr)* } ")" |
+ | /* ID is var containing fun name */ |
+ | ; |
+ | |
+ | command : ID expr* /* ID is function name */ |
+ | | path expr* /* path is external command name */ |
+ | ; |
+ | |
+ | path : ID /* left out slashes and such */ |
+ | | "@" ID /* ID is environment var */ |
+ | ; |
+ | |
+ | expr : .... |
+ | | "(" expr ")"; |
+ | |
+ | call : fun_call |
+ | | command |
+ | ; |
+ | |
+ | Obviously the call is wildly ambiguous. This is more or less how this |
+ | is to be resolved: |
+ | |
+ | A call begins with an ID or an @ followed by an ID. |
+ | |
+ | If it is an ID and if it is an ext. command name -> command |
+ | if followed by a paren -> fun_call |
+ | otherwise -> command |
+ | |
+ | If it is an @ and if the ID is a var name -> fun_call |
+ | otherwise -> command |
+ | |
+ | One can implement these rules quite neatly using && predicates: |
+ | |
+ | call : ("@" ID)? && <<isVarName(LT(2))>>? fun_call |
+ | | (ID)? && <<isExtCmdName>>? command |
+ | | (ID "(")? fun_call |
+ | | command |
+ | ; |
+ | |
+ | This can be done better, so it is not an ideal example, but it |
+ | conveys the principle. |
+ +-------------------------------------------------------------------------+
+
+#122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode
+
+ void DLGFileReset(FILE *f) { input = f; found_eof = 0; }
+ void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }
+
+ Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)
+
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars
+
+ The user can ask for additional information on ambiguities reported
+ by antlr to stdout. At the moment, only one ambiguity report can
+ be created in an antlr run.
+
+ This feature is enabled using the "-aa" (Ambiguity Aid) option.
+
+ The following options control the reporting of ambiguities:
+
+ -aa ruleName Selects reporting by name of rule
+ -aa lineNumber Selects reporting by line number
+ (file name not compared)
+
+ -aam Selects "multiple" reporting for a token
+ in the intersection set of the
+ alternatives.
+
+ For instance, the token ID may appear dozens
+ of times in various paths as the program
+ explores the rules which are reachable from
+ the point of an ambiguity. With option -aam
+ every possible path the search program
+ encounters is reported.
+
+ Without -aam only the first encounter is
+ reported. This may result in incomplete
+ information, but the information may be
+ sufficient and much shorter.
+
+ -aad depth Selects the depth of the search.
+ The default value is 1.
+
+ The number of paths to be searched, and the
+ size of the report can grow geometrically
+ with the -ck value if a full search for all
+ contributions to the source of the ambiguity
+ is explored.
+
+ The depth represents the number of tokens
+ in the lookahead set which are matched against
+ the set of ambiguous tokens. A depth of 1
+ means that the search stops when a lookahead
+ sequence of just one token is matched.
+
+ A k=1 ck=6 grammar might generate 5,000 items
+ in a report if a full depth 6 search is made
+ with the Ambiguity Aid. The source of the
+ problem may be in the first token and obscured
+ by the volume of data - I hesitate to call
+ it information.
+
+ When the user selects a depth > 1, the search
+ is first performed at depth=1 for both
+ alternatives, then depth=2 for both alternatives,
+ etc.
+
+ Sample output for rule grammar in antlr.g itself:
+
+ +---------------------------------------------------------------------+
+ | Ambiguity Aid |
+ | |
+ | Choice 1: grammar/70 line 632 file a.g |
+ | Choice 2: grammar/82 line 644 file a.g |
+ | |
+ | Intersection of lookahead[1] sets: |
+ | |
+ | "\}" "class" "#errclass" "#tokclass" |
+ | |
+ | Choice:1 Depth:1 Group:1 ("#errclass") |
+ | 1 in (...)* block grammar/70 line 632 a.g |
+ | 2 to error grammar/73 line 635 a.g |
+ | 3 error error/1 line 894 a.g |
+ | 4 #token "#errclass" error/2 line 895 a.g |
+ | |
+ | Choice:1 Depth:1 Group:2 ("#tokclass") |
+ | 2 to tclass grammar/74 line 636 a.g |
+ | 3 tclass tclass/1 line 937 a.g |
+ | 4 #token "#tokclass" tclass/2 line 938 a.g |
+ | |
+ | Choice:1 Depth:1 Group:3 ("class") |
+ | 2 to class_def grammar/75 line 637 a.g |
+ | 3 class_def class_def/1 line 669 a.g |
+ | 4 #token "class" class_def/3 line 671 a.g |
+ | |
+ | Choice:1 Depth:1 Group:4 ("\}") |
+ | 2 #token "\}" grammar/76 line 638 a.g |
+ | |
+ | Choice:2 Depth:1 Group:5 ("#errclass") |
+ | 1 in (...)* block grammar/83 line 645 a.g |
+ | 2 to error grammar/93 line 655 a.g |
+ | 3 error error/1 line 894 a.g |
+ | 4 #token "#errclass" error/2 line 895 a.g |
+ | |
+ | Choice:2 Depth:1 Group:6 ("#tokclass") |
+ | 2 to tclass grammar/94 line 656 a.g |
+ | 3 tclass tclass/1 line 937 a.g |
+ | 4 #token "#tokclass" tclass/2 line 938 a.g |
+ | |
+ | Choice:2 Depth:1 Group:7 ("class") |
+ | 2 to class_def grammar/95 line 657 a.g |
+ | 3 class_def class_def/1 line 669 a.g |
+ | 4 #token "class" class_def/3 line 671 a.g |
+ | |
+ | Choice:2 Depth:1 Group:8 ("\}") |
+ | 2 #token "\}" grammar/96 line 658 a.g |
+ +---------------------------------------------------------------------+
+
+ For a linear lookahead set ambiguity (where k=1 or for k>1 but
+ when all lookahead sets [i] with i<k all have degree one) the
+ reports appear in the following order:
+
+ for (depth=1 ; depth <= "-aad depth" ; depth++) {
+ for (alternative=1; alternative <=2 ; alternative++) {
+ while (matches-are-found) {
+ group++;
+ print-report
+ };
+ };
+ };
+
+ For reporting a k-tuple ambiguity, the reports appear in the
+ following order:
+
+ for (depth=1 ; depth <= "-aad depth" ; depth++) {
+ while (matches-are-found) {
+ for (alternative=1; alternative <=2 ; alternative++) {
+ group++;
+ print-report
+ };
+ };
+ };
+
+ This is because matches are generated in different ways for
+ linear lookahead and k-tuples.
+
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code
+
+ The hoisting of predicates into rules to create prediction
+ expressions is a problem in antlr. Consider the following
+ example (k=1 with -prc on):
+
+ start : (a)* "@" ;
+ a : b | c ;
+ b : <<isUpper(LATEXT(1))>>? A ;
+ c : A ;
+
+ Prior to 1.33MR10 the code generated for "start" would resemble:
+
+ while {
+ if (LA(1)==A &&
+ (!LA(1)==A || isUpper())) {
+ a();
+ }
+ };
+
+ This code is wrong because it makes rule "c" unreachable from
+ "start". The essence of the problem is that antlr fails to
+ recognize that there can be a valid alternative within "a" even
+ when the predicate <<isUpper(LATEXT(1))>>? is false.
+
+ In 1.33MR10 with -mrhoist the hoisting of the predicate into
+ "start" is suppressed because it recognizes that "c" can
+ cover all the cases where the predicate is false:
+
+ while {
+ if (LA(1)==A) {
+ a();
+ }
+ };
+
+ With the antlr "-info p" switch the user will receive information
+ about the predicate suppression in the generated file:
+
+ --------------------------------------------------------------
+ #if 0
+
+ Hoisting of predicate suppressed by alternative without predicate.
+ The alt without the predicate includes all cases where
+ the predicate is false.
+
+ WITH predicate: line 7 v1.g
+ WITHOUT predicate: line 7 v1.g
+
+ The context set for the predicate:
+
+ A
+
+ The lookahead set for the alt WITHOUT the semantic predicate:
+
+ A
+
+ The predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 9 v1.g
+ set context:
+ A
+ tree context: null
+
+ Chain of referenced rules:
+
+ #0 in rule start (line 5 v1.g) to rule a
+ #1 in rule a (line 7 v1.g)
+
+ #endif
+ --------------------------------------------------------------
+
+ A predicate can be suppressed by a combination of alternatives
+ which, taken together, cover a predicate:
+
+ start : (a)* "@" ;
+
+ a : b | ca | cb | cc ;
+
+ b : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;
+
+ ca : A ;
+ cb : B ;
+ cc : C ;
+
+ Consider a more complex example in which "c" covers only part of
+ a predicate:
+
+ start : (a)* "@" ;
+
+ a : b
+ | c
+ ;
+
+ b : <<isUpper(LATEXT(1))>>?
+ ( A
+ | X
+ );
+
+ c : A
+ ;
+
+ Prior to 1.33MR10 the code generated for "start" would resemble:
+
+ while {
+ if ( (LA(1)==A || LA(1)==X) &&
+ (! (LA(1)==A || LA(1)==X) || isUpper()) {
+ a();
+ }
+ };
+
+ With 1.33MR10 and -mrhoist the predicate context is restricted to
+ the non-covered lookahead. The code resembles:
+
+ while {
+ if ( (LA(1)==A || LA(1)==X) &&
+ (! (LA(1)==X) || isUpper()) {
+ a();
+ }
+ };
+
+ With the antlr "-info p" switch the user will receive information
+ about the predicate restriction in the generated file:
+
+ --------------------------------------------------------------
+ #if 0
+
+ Restricting the context of a predicate because of overlap
+ in the lookahead set between the alternative with the
+ semantic predicate and one without
+ Without this restriction the alternative without the predicate
+ could not be reached when input matched the context of the
+ predicate and the predicate was false.
+
+ WITH predicate: line 11 v4.g
+ WITHOUT predicate: line 12 v4.g
+
+ The original context set for the predicate:
+
+ A X
+
+ The lookahead set for the alt WITHOUT the semantic predicate:
+
+ A
+
+ The intersection of the two sets
+
+ A
+
+ The original predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 15 v4.g
+ set context:
+ A X
+ tree context: null
+
+ The new (modified) form of the predicate:
+
+ pred << isUpper(LATEXT(1))>>?
+ depth=k=1 rule b line 15 v4.g
+ set context:
+ X
+ tree context: null
+
+ #endif
+ --------------------------------------------------------------
+
+ The bad news about -mrhoist:
+
+ (a) -mrhoist does not analyze predicates with lookahead
+ depth > 1.
+
+ (b) -mrhoist does not look past a guarded predicate to
+ find context which might cover other predicates.
+
+ For these cases you might want to use syntactic predicates.
+ When a semantic predicate fails during guess mode the guess
+ fails and the next alternative is tried.
+
+ Limitation (a) is illustrated by the following example:
+
+ start : (stmt)* EOF ;
+
+ stmt : cast
+ | expr
+ ;
+ cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
+
+ expr : LP ID RP ;
+
+ This is not much different from the first example, except that
+ it requires two tokens of lookahead context to determine what
+ to do. This predicate is NOT suppressed because the current version
+ is unable to handle predicates with depth > 1.
+
+ A predicate can be combined with other predicates during hoisting.
+ In those cases the depth=1 predicates are still handled. Thus,
+ in the following example the isUpper() predicate will be suppressed
+ by line #4 when hoisted from "bizarre" into "start", but will still
+ be present in "bizarre" in order to predict "stmt".
+
+ start : (bizarre)* EOF ; // #1
+ // #2
+ bizarre : stmt // #3
+ | A // #4
+ ;
+
+ stmt : cast
+ | expr
+ ;
+
+ cast : <<isTypename(LATEXT(2))>>? LP ID RP ;
+
+ expr : LP ID RP ;
+ | <<isUpper(LATEXT(1))>>? A
+
+ Limitation (b) is illustrated by the following example of a
+ context guarded predicate:
+
+ rule : (A)? <<p>>? // #1
+ (A // #2
+ |B // #3
+ ) // #4
+ | <<q>> B // #5
+ ;
+
+ Recall that this means that when the lookahead is NOT A then
+ the predicate "p" is ignored and it attempts to match "A|B".
+ Ideally, the "B" at line #3 should suppress predicate "q".
+ However, the current version does not attempt to look past
+ the guard predicate to find context which might suppress other
+ predicates.
+
+ In some cases -mrhoist will lead to the reporting of ambiguities
+ which were not visible before:
+
+ start : (a)* "@";
+ a : bc | d;
+ bc : b | c ;
+
+ b : <<isUpper(LATEXT(1))>>? A;
+ c : A ;
+
+ d : A ;
+
+ In this case there is a true ambiguity in "a" between "bc" and "d"
+ which can both match "A". Without -mrhoist the predicate in "b"
+ is hoisted into "a" and there is no ambiguity reported. However,
+ with -mrhoist, the predicate in "b" is suppressed by "c" (as it
+ should be) making the ambiguity in "a" apparent.
+
+ The motivations for these changes were hoisting problems reported
+ by Reinier van den Born (reinier@vnet.ibm.com) and several others.
+
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr
+
+ The existing context guarded predicate:
+
+ rule : (guard)? => <<p>>? expr
+ | next_alternative
+ ;
+
+ generates code which resembles:
+
+ if (lookahead(expr) && (!guard || pred)) {
+ expr()
+ } else ....
+
+ This is not suitable for some applications because it allows
+ expr() to be invoked when the predicate is false. This is
+ intentional because it is meant to mimic automatically computed
+ predicate context.
+
+ The new context guarded predicate uses the guard information
+ differently because it has a different goal. Consider:
+
+ rule : (guard)? && <<p>>? expr
+ | next_alternative
+ ;
+
+ The new style of context guarded predicate is equivalent to:
+
+ rule : <<guard==true && pred>>? expr
+ | next_alternative
+ ;
+
+ It generates code which resembles:
+
+ if (lookahead(expr) && guard && pred) {
+ expr();
+ } else ...
+
+ Both forms of guarded predicates severely restrict the form of
+ the context guard: it can contain no rule references, no
+ (...)*, no (...)+, and no {...}. It may contain token and
+ token class references, and alternation ("|").
+
+ Addition for 1.33MR11: in the token expression all tokens must
+ be at the same height of the token tree:
+
+ (A ( B | C))? && ... is ok (all height 2)
+ (A ( B | ))? && ... is not ok (some 1, some 2)
+ (A B C D | E F G H)? && ... is ok (all height 4)
+ (A B C D | E )? && ... is not ok (some 4, some 1)
+
+ This restriction is required in order to properly compute the lookahead
+ set for expressions like:
+
+ rule1 : (A B C)? && <<pred>>? rule2 ;
+ rule2 : (A|X) (B|Y) (C|Z);
+
+ This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)
+
+#109. (Changed in 1.33MR10) improved trace information
+
+ The quality of the trace information provided by the "-gd"
+ switch has been improved significantly. Here is an example
+ of the output from a test program. It shows the rule name,
+ the first token of lookahead, the call depth, and the guess
+ status:
+
+ exit rule gusxx {"?"} depth 2
+ enter rule gusxx {"?"} depth 2
+ enter rule gus1 {"o"} depth 3 guessing
+ guess done - returning to rule gus1 {"o"} at depth 3
+ (guess mode continues - an enclosing guess is still active)
+ guess done - returning to rule gus1 {"Z"} at depth 3
+ (guess mode continues - an enclosing guess is still active)
+ exit rule gus1 {"Z"} depth 3 guessing
+ guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)
+ enter rule gus1 {"o"} depth 3
+ guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)
+ guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)
+ exit rule gus1 {"Z"} depth 3
+ line 1: syntax error at "Z" missing SC
+ ...
+
+ Rule trace reporting is controlled by the value of the integer
+ [zz]traceOptionValue: when it is positive tracing is enabled,
+ otherwise it is disabled. Tracing during guess mode is controlled
+ by the value of the integer [zz]traceGuessOptionValue. When
+ it is positive AND [zz]traceOptionValue is positive rule trace
+ is reported in guess mode.
+
+ The values of [zz]traceOptionValue and [zz]traceGuessOptionValue
+ can be adjusted by subroutine calls listed below.
+
+ Depending on the presence or absence of the antlr -gd switch
+ the variable [zz]traceOptionValueDefault is set to 0 or 1. When
+ the parser is initialized or [zz]traceReset() is called the
+ value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.
+ The value of [zz]traceGuessOptionValue is always initialzed to 1,
+ but, as noted earlier, nothing will be reported unless
+ [zz]traceOptionValue is also positive.
+
+ When the parser state is saved/restored the value of the trace
+ variables are also saved/restored. If a restore causes a change in
+ reporting behavior from on to off or vice versa this will be reported.
+
+ When the -gd option is selected, the macro "#define zzTRACE_RULES"
+ is added to appropriate output files.
+
+ C++ mode
+ --------
+ int traceOption(int delta)
+ int traceGuessOption(int delta)
+ void traceReset()
+ int traceOptionValueDefault
+
+ C mode
+ --------
+ int zzTraceOption(int delta)
+ int zzTraceGuessOption(int delta)
+ void zzTraceReset()
+ int zzTraceOptionValueDefault
+
+ The argument "delta" is added to the traceOptionValue. To
+ turn on trace when inside a particular rule one:
+
+ rule : <<traceOption(+1);>>
+ (
+ rest-of-rule
+ )
+ <<traceOption(-1);>>
+ ; /* fail clause */ <<traceOption(-1);>>
+
+ One can use the same idea to turn *off* tracing within a
+ rule by using a delta of (-1).
+
+ An improvement in the rule trace was suggested by Sramji
+ Ramanathan (ps@kumaran.com).
+
+#108. A Note on Deallocation of Variables Allocated in Guess Mode
+
+ NOTE
+ ------------------------------------------------------
+ This mechanism only works for heap allocated variables
+ ------------------------------------------------------
+
+ The rewrite of the trace provides the machinery necessary
+ to properly free variables or undo actions following a
+ failed guess.
+
+ The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded
+ as part of the zzGUESS macro. When a guess is opened
+ the value of zzrv is 0. When a longjmp() is executed to
+ undo the guess, the value of zzrv will be 1.
+
+ The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded
+ as part of the zzGUESS_DONE macro. This is executed
+ whether the guess succeeds or fails as part of closing
+ the guess.
+
+ The guessSeq is a sequence number which is assigned to each
+ guess and is incremented by 1 for each guess which becomes
+ active. It is needed by the user to associate the start of
+ a guess with the failure and/or completion (closing) of a
+ guess.
+
+ Guesses are nested. They must be closed in the reverse
+ of the order that they are opened.
+
+ In order to free memory used by a variable during a guess
+ a user must write a routine which can be called to
+ register the variable along with the current guess sequence
+ number provided by the zzUSER_GUESS_HOOK macro. If the guess
+ fails, all variables tagged with the corresponding guess
+ sequence number should be released. This is ugly, but
+ it would require a major rewrite of antlr 1.33 to use
+ some mechanism other than setjmp()/longjmp().
+
+ The order of calls for a *successful* guess would be:
+
+ zzUSER_GUESS_HOOK(guessSeq,0);
+ zzUSER_GUESS_DONE_HOOK(guessSeq);
+
+ The order of calls for a *failed* guess would be:
+
+ zzUSER_GUESS_HOOK(guessSeq,0);
+ zzUSER_GUESS_HOOK(guessSeq,1);
+ zzUSER_GUESS_DONE_HOOK(guessSeq);
+
+ The default definitions of these macros are empty strings.
+
+ Here is an example in C++ mode. The zzUSER_GUESS_HOOK and
+ zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine
+ can be used without change in both C and C++ versions.
+
+ ----------------------------------------------------------------------
+ <<
+
+ #include "AToken.h"
+
+ typedef ANTLRCommonToken ANTLRToken;
+
+ #include "DLGLexer.h"
+
+ int main() {
+
+ {
+ DLGFileInput in(stdin);
+ DLGLexer lexer(&in,2000);
+ ANTLRTokenBuffer pipe(&lexer,1);
+ ANTLRCommonToken aToken;
+ P parser(&pipe);
+
+ lexer.setToken(&aToken);
+ parser.init();
+ parser.start();
+ };
+
+ fclose(stdin);
+ fclose(stdout);
+ return 0;
+ }
+
+ >>
+
+ <<
+ char *s=NULL;
+
+ #undef zzUSER_GUESS_HOOK
+ #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);
+ #undef zzUSER_GUESS_DONE_HOOK
+ #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2);
+
+ void myGuessHook(int guessSeq,int zzrv) {
+ if (zzrv == 0) {
+ fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);
+ } else if (zzrv == 1) {
+ free (s);
+ s=NULL;
+ fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);
+ } else if (zzrv == 2) {
+ free (s);
+ s=NULL;
+ fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);
+ };
+ }
+
+ >>
+
+ #token A "a"
+ #token "[\t \ \n]" <<skip();>>
+
+ class P {
+
+ start : (top)+
+ ;
+
+ top : (which) ? <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>
+ | other <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>
+ ; <<if (s != NULL) free(s); s=NULL; >>
+
+ which : which2
+ ;
+
+ which2 : which3
+ ;
+ which3
+ : (label)? <<fprintf(stderr,"%s is a label\n",s);>>
+ | (global)? <<fprintf(stderr,"%s is a global\n",s);>>
+ | (exclamation)? <<fprintf(stderr,"%s is an exclamation\n",s);>>
+ ;
+
+ label : <<s=strdup(LT(1)->getText());>> A ":" ;
+
+ global : <<s=strdup(LT(1)->getText());>> A "::" ;
+
+ exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;
+
+ other : <<s=strdup(LT(1)->getText());>> "other" ;
+
+ }
+ ----------------------------------------------------------------------
+
+ This is a silly example, but illustrates the idea. For the input
+ "a ::" with tracing enabled the output begins:
+
+ ----------------------------------------------------------------------
+ enter rule "start" depth 1
+ enter rule "top" depth 2
+ User hook: starting guess #1
+ enter rule "which" depth 3 guessing
+ enter rule "which2" depth 4 guessing
+ enter rule "which3" depth 5 guessing
+ User hook: starting guess #2
+ enter rule "label" depth 6 guessing
+ guess failed
+ User hook: failed guess #2
+ guess done - returning to rule "which3" at depth 5 (guess mode continues
+ - an enclosing guess is still active)
+ User hook: ending guess #2
+ User hook: starting guess #3
+ enter rule "global" depth 6 guessing
+ exit rule "global" depth 6 guessing
+ guess done - returning to rule "which3" at depth 5 (guess mode continues
+ - an enclosing guess is still active)
+ User hook: ending guess #3
+ enter rule "global" depth 6 guessing
+ exit rule "global" depth 6 guessing
+ exit rule "which3" depth 5 guessing
+ exit rule "which2" depth 4 guessing
+ exit rule "which" depth 3 guessing
+ guess done - returning to rule "top" at depth 2 (guess mode ends)
+ User hook: ending guess #1
+ enter rule "which" depth 3
+ .....
+ ----------------------------------------------------------------------
+
+ Remember:
+
+ (a) Only init-actions are executed during guess mode.
+ (b) A rule can be invoked multiple times during guess mode.
+ (c) If the guess succeeds the rule will be called once more
+ without guess mode so that normal actions will be executed.
+ This means that the init-action might need to distinguish
+ between guess mode and non-guess mode using the variable
+ [zz]guessing.
+
+#101. (Changed in 1.33MR10) antlr -info command line switch
+
+ -info
+
+ p - extra predicate information in generated file
+
+ t - information about tnode use:
+ at the end of each rule in generated file
+ summary on stderr at end of program
+
+ m - monitor progress
+ prints name of each rule as it is started
+ flushes output at start of each rule
+
+ f - first/follow set information to stdout
+
+ 0 - no operation (added in 1.33MR11)
+
+ The options may be combined and may appear in any order.
+ For example:
+
+ antlr -info ptm -CC -gt -mrhoist on mygrammar.g
+
+#100a. (Changed in 1.33MR10) Predicate tree simplification
+
+ When the same predicates can be referenced in more than one
+ alternative of a block large predicate trees can be formed.
+
+ The difference that these optimizations make is so dramatic
+ that I have decided to use it even when -mrhoist is not selected.
+
+ Consider the following grammar:
+
+ start : ( all )* ;
+
+ all : a
+ | d
+ | e
+ | f
+ ;
+
+ a : c A B
+ | c A C
+ ;
+
+ c : <<AAA(LATEXT(2))>>?
+ ;
+
+ d : <<BBB(LATEXT(2))>>? B C
+ ;
+
+ e : <<CCC(LATEXT(2))>>? B C
+ ;
+
+ f : e X Y
+ ;
+
+ In rule "a" there is a reference to rule "c" in both alternatives.
+ The length of the predicate AAA is k=2 and it can be followed in
+ alternative 1 only by (A B) while in alternative 2 it can be
+ followed only by (A C). Thus they do not have identical context.
+
+ In rule "all" the alternatives which refer to rules "e" and "f" allow
+ elimination of the duplicate reference to predicate CCC.
+
+ The table below summarized the kind of simplification performed by
+ 1.33MR10. In the table, X and Y stand for single predicates
+ (not trees).
+
+ (OR X (OR Y (OR Z))) => (OR X Y Z)
+ (AND X (AND Y (AND Z))) => (AND X Y Z)
+
+ (OR X (... (OR X Y) ... )) => (OR X (... Y ... ))
+ (AND X (... (AND X Y) ... )) => (AND X (... Y ... ))
+ (OR X (... (AND X Y) ... )) => (OR X (... ... ))
+ (AND X (... (OR X Y) ... )) => (AND X (... ... ))
+
+ (AND X) => X
+ (OR X) => X
+
+ In a test with a complex grammar for a real application, a predicate
+ tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".
+
+ In 1.33MR10 there is a greater effort to release memory used
+ by predicates once they are no longer in use.
+
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests
+
+ The following optimizations require that -mrhoist be selected.
+
+ It is relatively easy to optimize the code generated for predicate
+ gates when they are of the form:
+
+ (AND X Y Z ...)
+ or (OR X Y Z ...)
+
+ where X, Y, Z, and "..." represent individual predicates (leaves) not
+ predicate trees.
+
+ If the predicate is an AND the contexts of the X, Y, Z, etc. are
+ ANDed together to create a single Tree context for the group and
+ context tests for the individual predicates are suppressed:
+
+ --------------------------------------------------
+ Note: This was incorrect. The contexts should be
+ ORed together. This has been fixed. A more
+ complete description is available in item #152.
+ ---------------------------------------------------
+
+ Optimization 1: (AND X Y Z ...)
+
+ Suppose the context for Xtest is LA(1)==LP and the context for
+ Ytest is LA(1)==LP && LA(2)==ID.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||
+ ( (! LA(1)==LP || Xtest) &&
+ (! (LA(1)==LP || LA(2)==ID) || Xtest)
+ )) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...
+
+ Optimization 2: (OR X Y Z ...) with identical contexts
+
+ Suppose the context for Xtest is LA(1)==ID and for Ytest
+ the context is also LA(1)==ID.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==ID || LA(1)==ID) ||
+ (LA(1)==ID && Xtest) ||
+ (LA(1)==ID && Ytest) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ (! LA(1)==ID) || (Xtest || Ytest) {...
+
+ Optimization 3: (OR X Y Z ...) with distinct contexts
+
+ Suppose the context for Xtest is LA(1)==ID and for Ytest
+ the context is LA(1)==LP.
+
+ Without the optimization the code would resemble:
+
+ if (lookaheadContext &&
+ ! (LA(1)==ID || LA(1)==LP) ||
+ (LA(1)==ID && Xtest) ||
+ (LA(1)==LP && Ytest) {...
+
+ With the -mrhoist optimization the code would resemble:
+
+ if (lookaheadContext &&
+ (zzpf=0,
+ (LA(1)==ID && (zzpf=1) && Xtest) ||
+ (LA(1)==LP && (zzpf=1) && Ytest) ||
+ !zzpf) {
+
+ These may appear to be of similar complexity at first,
+ but the non-optimized version contains two tests of each
+ context while the optimized version contains only one
+ such test, as well as eliminating some of the inverted
+ logic (" !(...) || ").
+
+ Optimization 4: Computation of predicate gate trees
+
+ When generating code for the gates of predicate expressions
+ antlr 1.33 vanilla uses a recursive procedure to generate
+ "&&" and "||" expressions for testing the lookahead. As each
+ layer of the predicate tree is exposed a new set of "&&" and
+ "||" expressions on the lookahead are generated. In many
+ cases the lookahead being tested has already been tested.
+
+ With -mrhoist a lookahead tree is computed for the entire
+ lookahead expression. This means that predicates with identical
+ context or context which is a subset of another predicate's
+ context disappear.
+
+ This is especially important for predicates formed by rules
+ like the following:
+
+ uppperCaseVowel : <<isUpperCase(LATEXT(1))>>? vowel;
+ vowel: : <<isVowel(LATEXT(1))>>? LETTERS;
+
+ These predicates are combined using AND since both must be
+ satisfied for rule upperCaseVowel. They have identical
+ context which makes this optimization very effective.
+
+ The affect of Items #100a and #100b together can be dramatic. In
+ a very large (but real world) grammar one particular predicate
+ expression was reduced from an (unreadable) 50 predicate leaves,
+ 195 LA(1) terms, and 5500 characters to an (easily comprehensible)
+ 3 predicate leaves (all different) and a *single* LA(1) term.
+
+#98. (Changed in 1.33MR10) Option "-info p"
+
+ When the user selects option "-info p" the program will generate
+ detailed information about predicates. If the user selects
+ "-mrhoist on" additional detail will be provided explaining
+ the promotion and suppression of predicates. The output is part
+ of the generated file and sandwiched between #if 0/#endif statements.
+
+ Consider the following k=1 grammar:
+
+ start : ( all ) * ;
+
+ all : ( a
+ | b
+ )
+ ;
+
+ a : c B
+ ;
+
+ c : <<LATEXT(1)>>?
+ | B
+ ;
+
+ b : <<LATEXT(1)>>? X
+ ;
+
+ Below is an excerpt of the output for rule "start" for the three
+ predicate options (off, on, and maintenance release style hoisting).
+
+ For those who do not wish to use the "-mrhoist on" option for code
+ generation the option can be used in a "diagnostic" mode to provide
+ valuable information:
+
+ a. where one should insert null actions to inhibit hoisting
+ b. a chain of rule references which shows where predicates are
+ being hoisted
+
+ ======================================================================
+ Example of "-info p" with "-mrhoist on"
+ ======================================================================
+ #if 0
+
+ Hoisting of predicate suppressed by alternative without predicate.
+ The alt without the predicate includes all cases where the
+ predicate is false.
+
+ WITH predicate: line 11 v36.g
+ WITHOUT predicate: line 12 v36.g
+
+ The context set for the predicate:
+
+ B
+
+ The lookahead set for alt WITHOUT the semantic predicate:
+
+ B
+
+ The predicate:
+
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ B
+ tree context: null
+
+ Chain of referenced rules:
+
+ #0 in rule start (line 1 v36.g) to rule all
+ #1 in rule all (line 3 v36.g) to rule a
+ #2 in rule a (line 8 v36.g) to rule c
+ #3 in rule c (line 11 v36.g)
+
+ #endif
+ &&
+ #if 0
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ X
+ tree context: null
+
+ #endif
+ ======================================================================
+ Example of "-info p" with the default -prc setting ( "-prc off")
+ ======================================================================
+ #if 0
+
+ OR
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ nil
+ tree context: null
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ nil
+ tree context: null
+
+ #endif
+ ======================================================================
+ Example of "-info p" with "-prc on" and "-mrhoist off"
+ ======================================================================
+ #if 0
+
+ OR
+ pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g
+
+ set context:
+ B
+ tree context: null
+
+ pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g
+
+ set context:
+ X
+ tree context: null
+
+ #endif
+ ======================================================================
+
+#60. (Changed in 1.33MR7) Major changes to 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.
+
+ In 1.33MR7 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.
+
+ There are still undesirable features in the way exception
+ handlers are implemented, but I do not have time to fix them
+ at the moment:
+
+ The exception handlers for alternatives are outside the
+ block containing the alternative. This makes it impossible
+ to access variables declared in a block or to resume the
+ parse by "falling through". The parse can still be easily
+ resumed in other ways, but not in the most natural fashion.
+
+ This results in an inconsistentcy between named exception
+ handlers and exception handlers for alternatives. When
+ an exception handler for an alternative "falls through"
+ it goes to the nextmost outer handler - not the "normal
+ action".
+
+ A major difference between 1.33MR7 and 1.33 vanilla is
+ the default action after an exception is caught:
+
+ 1.33 Vanilla
+ ------------
+ In 1.33 vanilla the signal value is set to zero ("NoSignal")
+ and the code drops through to the code following the exception.
+ For named exception handlers this is the "normal action".
+ For alternative exception handlers this is the rule's handler.
+
+ 1.33MR7
+ -------
+ In 1.33MR7 the signal value is NOT automatically set to zero.
+
+ There are two cases:
+
+ For named exception handlers: if the signal value has been
+ set to zero the code drops through to the "normal action".
+
+ For all other cases the code branches to the nextmost outer
+ exception handler until it reaches the handler for the rule.
+
+ The following macros have been defined for convenience:
+
+ C/C++ Mode Name
+ --------------------
+ (zz)suppressSignal
+ set signal & return signal arg to 0 ("NoSignal")
+ (zz)setSignal(intValue)
+ set signal & return signal arg to some value
+ (zz)exportSignal
+ copy the signal value to the return signal arg
+
+ I'm not sure why PCCTS make a distinction between the local
+ signal value and the return signal argument, but I'm loathe
+ to change the code. The burden of copying the local signal
+ value to the return signal argument can be given to the
+ default signal handler, I suppose.
+
+#53. (Explanation for 1.33MR6) What happens after an exception is caught ?
+
+ The Book is silent about what happens after an exception
+ is caught.
+
+ The following code fragment prints "Error Action" followed
+ by "Normal Action".
+
+ test : Word ex:Number <<printf("Normal Action\n");>>
+ exception[ex]
+ catch NoViableAlt:
+ <<printf("Error Action\n");>>
+ ;
+
+ The reason for "Normal Action" is that the normal flow of the
+ program after a user-written exception handler is to "drop through".
+ In the case of an exception handler for a rule this results in
+ the exection of a "return" statement. In the case of an
+ exception handler attached to an alternative, rule, or token
+ this is the code that would have executed had there been no
+ exception.
+
+ The user can achieve the desired result by using a "return"
+ statement.
+
+ test : Word ex:Number <<printf("Normal Action\n");>>
+ exception[ex]
+ catch NoViableAlt:
+ <<printf("Error Action\n"); return;>>
+ ;
+
+ The most powerful mechanism for recovery from parse errors
+ in pccts is syntactic predicates because they provide
+ backtracking. Exceptions allow "return", "break",
+ "consumeUntil(...)", "goto _handler", "goto _fail", and
+ changing the _signal value.
+
+#41. (Added in 1.33MR6) antlr -stdout
+
+ Using "antlr -stdout ..." forces the text that would
+ normally go to the grammar.c or grammar.cpp file to
+ stdout.
+
+#40. (Added in 1.33MR6) antlr -tab to change tab stops
+
+ Using "antlr -tab number ..." changes the tab stops
+ for the grammar.c or grammar.cpp file. The number
+ must be between 0 and 8. Using 0 gives tab characters,
+ values between 1 and 8 give the appropriate number of
+ space characters.
+
+#34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)
+
+ Previously there was no public function for changing the line
+ number maintained by the lexer.
+
+#28. (Added to 1.33MR1) More control over DLG header
+
+ Version 1.33MR1 adds the following directives to PCCTS
+ for C++ mode:
+
+ #lexprefix <<source code>>
+
+ Adds source code to the DLGLexer.h file
+ after the #include "DLexerBase.h" but
+ before the start of the class definition.
+
+ #lexmember <<source code>>
+
+ Adds source code to the DLGLexer.h file
+ as part of the DLGLexer class body. It
+ appears immediately after the start of
+ the class and a "public: statement.
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt
new file mode 100644
index 0000000000..352428ed0c
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt
@@ -0,0 +1,184 @@
+
+ =======================================================
+ Known Problems In PCCTS - Last revised 14 November 1998
+ =======================================================
+
+#14. Parsing bug in dlg
+
+ THM: I have been unable to reproduce this problem.
+
+ Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com).
+
+ The regular expression parser (in rexpr.c) fails while
+ trying to parse the following regular expression:
+
+ {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+
+
+ See my comment in the following excerpt from rexpr.c:
+
+ /*
+ * <regExpr> ::= <andExpr> ( '|' {<andExpr>} )*
+ *
+ * Return -1 if syntax error
+ * Return 0 if none found
+ * Return 1 if a regExrp was found
+ */
+ static
+ regExpr(g)
+ GraphPtr g;
+ {
+ Graph g1, g2;
+
+ if ( andExpr(&g1) == -1 )
+ {
+ return -1;
+ }
+
+ while ( token == '|' )
+ {
+ int a;
+ next();
+ a = andExpr(&g2);
+ if ( a == -1 ) return -1; /* syntax error below */
+ else if ( !a ) return 1; /* empty alternative */
+ g1 = BuildNFA_AorB(g1, g2);
+ }
+
+ if ( token!='\0' ) return -1;
+ *****
+ ***** It appears to fail here becuause token is 125 - the closing '}'
+ ***** If I change it to:
+ ***** if ( token!='\0' && token!='}' && token!= ')' ) return -1;
+ *****
+ ***** It succeeds, but I'm not sure this is the corrrect approach.
+ *****
+ *g = g1;
+ return 1;
+ }
+
+#13. dlg reports an invalid range for: [\0x00-\0xff]
+
+ Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):
+
+ Fixed in MR16.
+
+#12. Strings containing comment actions
+
+ Sequences that looked like C style comments appearing in string
+ literals are improperly parsed by antlr/dlg.
+
+ << fprintf(out," /* obsolete */ ");
+
+ For this case use:
+
+ << fprintf(out," \/\* obsolete \*\/ ");
+
+ Reported by K.J. Cummings (cummings@peritus.com).
+
+#11. User hook for deallocation of variables on guess fail
+
+ The mechanism outlined in Item #108 works only for
+ heap allocated variables.
+
+#10. Label re-initialization in ( X {y:Y} )*
+
+ If a label assignment is optional and appears in a
+ (...)* or (...)+ block it will not be reset to NULL
+ when it is skipped by a subsequent iteration.
+
+ Consider the example:
+
+ ( X { y:Y })* Z
+
+ with input:
+
+ X Y X Z
+
+ The first time through the block Y will be matched and
+ y will be set to point to the token. On the second
+ iteration of the (...)* block there is no match for Y.
+ But y will not be reset to NULL, as the user might
+ expect, it will contain a reference to the Y that was
+ matched in the first iteration.
+
+ The work-around is to manually reset y:
+
+ ( X << y = NULL; >> { y:Y } )* Z
+
+ or
+
+ ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z
+
+ Reported by Jeff Vincent (JVincent@novell.com).
+
+#9. PCCTAST.h PCCTSAST::setType() is a noop
+
+#8. #tokdefs with ~Token and .
+
+ THM: I have been unable to reproduce this problem.
+
+ When antlr uses #tokdefs to define tokens the fields of
+ #errclass and #tokclass do not get properly defined.
+ When it subsequently attempts to take the complement of
+ the set of tokens (using ~Token or .) it can refer to
+ tokens which don't have names, generating a fatal error.
+
+#7. DLG crashes on some invalid inputs
+
+ THM: In MR20 have fixed the most common cases.
+
+ The following token defintion will cause DLG to crash.
+
+ #token "()"
+
+ Reported by Mengue Olivier (dolmen@bigfoot.com).
+
+#6. On MS systems \n\r is treated as two new lines
+
+ Fixed.
+
+#5. Token expressions in #tokclass
+
+ #errclass does not support TOK1..TOK2 or ~TOK syntax.
+ #tokclass does not support ~TOKEN syntax
+
+ A workaround for #errclass TOK1..TOK2 is to use a
+ #tokclass.
+
+ Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)
+
+#4. A #tokdef must appear "early" in the grammar file.
+
+ The "early" section of the grammar file is the only
+ place where the following directives may appear:
+
+ #header
+ #first
+ #tokdefs
+ #parser
+
+ Any other kind of statement signifiies the end of the
+ "early" section.
+
+#3. Use of PURIFY macro for C++ mode
+
+ Item #93 of the CHANGES_FROM_1.33 describes the use of
+ the PURIFY macro to zero arguments to be passed by
+ upward inheritance.
+
+ #define PURIFY(r, s) memset((char *) &(r), '\0', (s));
+
+ This may not be the right thing to do for C++ objects that
+ have constructors. Reported by Bonny Rais (bonny@werple.net.au).
+
+ For those cases one should #define PURIFY to be an empty macro
+ in the #header or #first actions.
+
+#2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80.
+
+#1. The quality of support for systems with 8.3 file names leaves
+ much to be desired. Since the kit is distributed using the
+ long file names and the make file uses long file names it requires
+ some effort to generate. This will probably not be changed due
+ to the large number of systems already written using the long
+ file names.
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README
new file mode 100644
index 0000000000..84e0312686
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README
@@ -0,0 +1,171 @@
+---------------------------------------------------------------------------------
+README for pccts 1.33mr20 (Maintenance Release #20) release date 5 August 1999
+---------------------------------------------------------------------------------
+
+ Parr Research Corporation
+ with
+ Purdue University Electrical Engineering
+ and
+ University of Minnesota, AHPCRC
+
+ Terence Parr
+ Russell Quong
+ Will Cohen
+ Hank Dietz
+
+
+A central place for information about PCCTS 1.33 is:
+
+ http://www.polhode.com/pccts.html
+
+The maintenance release is available from:
+
+ http://www.polhode.com/pccts133mr.zip
+
+There is a ready-to-run version for win32 for Microsoft Visual Studio
+at the same site. It is available from:
+
+ http://www.polhode.com/win32.zip
+
+There is a newsgroup dedicated to pccts 1.33 and related topics:
+
+ comp.compilers.tools.pccts
+
+You may also want to register for the antlr-interest mailing list
+which is provided gratis by the following service:
+
+ http://www.onesite.com
+
+New users should visit http://www.polhode.com/pccts.html in
+order to get the following document:
+
+ "Notes For New Users of PCCTS"
+
+This is a Postscript file of about 40 pages which is extremely
+useful for someone starting out. It is a based on 1.33mr7 so is a
+little bit out-of-date. The section on semantic predicates is
+very out of date, but I have not had time to revise it.
+
+When you have a little more experience, be sure to review the
+following documents in the distribution kit:
+
+ CHANGES_FROM_133.txt
+ CHANGES_FROM_133_BEFORE_MR13.txt
+ KNOWN_PROBLEMS.txt
+
+-------------------------------------------------------------------------
+ INSTALLATION (Unix)
+-------------------------------------------------------------------------
+0. Download http://www.polhode.com/pccts133mr.zip
+
+1. Unzip the distribution kit to your preferred location.
+
+2. cd to the main pccts directory.
+
+3. make
+
+ This will create:
+
+ antlr.exe
+ dlg.exe
+ sorcerer.exe
+ genmk.exe
+
+4. Add pccts/bin to your path.
+
+5. To get an up-to-date list of program options execute the
+ program with no command line options. To get up-to-date
+ documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt
+ at:
+
+ http://www.polhode.com/pccts.html.
+
+6. You need not create a library. The makefile created by genmk
+ assumes that the files are not part of a library.
+
+ If you wish to create a library from elements of pccts/h:
+
+ If the first letter of the filename is lowercase (uppercase) it is
+ related to the code generated using the pccts C mode (C++ mode).
+ Some of the .c and .cpp files in the h directory are not meant to
+ be placed in a library and will not compile because they are meant
+ to be #include in pccts generated files which are grammar specific.
+
+ For C++ users place the following elements in the library:
+
+ AParser.cpp
+ ASTBase.cpp
+ ATokenBuffer.cpp
+ BufFileInput.cpp (optional)
+ DLexerBase.cpp
+ PCCTSAST.cpp
+ SList.cpp
+
+-------------------------------------------------------------------------
+ INSTALLATION (Win32)
+-------------------------------------------------------------------------
+
+I've tried to keep the win32 kit to the minimum necessary to get
+up and running. The complete kit contains additional information
+(some historical), source code, and DevStudio projects for
+rebuilding pccts from the source code.
+
+The kit is now distributed with both MSVC 5 and MSVC6 style projects.
+
+0. Download http://www.polhode.com/win32.zip.
+
+ You may also wish to download:
+
+ http://www.polhode.com/CHANGES_FROM_133.txt
+ http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt
+ http://www.polhode.com/KNOWN_PROBLEMS.txt
+
+1. Unzip the distribution kit to your preferred location.
+
+ This will create:
+
+ a pccts directory tree
+ pccts/bin/*.exe
+ pccts/lib/*.lib
+ pccts/h/*
+ sorcerer/lib/*
+ sorcerer/h/*
+
+ an example directory tree
+ example\calcAST\*
+ example\simple\*
+
+2. Define the environment variable PCCTS to point to the main
+ pccts directory.
+
+3. Try building the simple project: example\simple\simple50.dsw
+ or simple60.dsw.
+
+4. Try building the complex project: example\calcAST\calcAST50.dsw
+ or calcAST60.dsw.
+
+-------------------------------------------------------------------------
+ INSTALLATION (DEC/VMS)
+-------------------------------------------------------------------------
+
+DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net)
+
+0. Download http://www.polhode.com/pccts133mr.zip
+
+1. Unzip the distribution kit to your preferred location.
+
+2. set default to the main pccts directory.
+
+3. @makefile.vms
+
+ This will create in directory [.bin]:
+
+ antlr.exe
+ dlg.exe
+ sorcerer.exe
+ genmk.exe
+
+5. To get an up-to-date list of program options execute the
+ program with no command line options. To get up-to-date
+ documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt
+ at http://www.polhode.com/pccts.html.
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe
new file mode 100644
index 0000000000..a2bfa1f4f0
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe
new file mode 100644
index 0000000000..166f8b705f
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe
new file mode 100644
index 0000000000..9b343359b2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp
new file mode 100644
index 0000000000..13b91e5f57
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp
@@ -0,0 +1,815 @@
+/* ANTLRParser.C
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#include "pccts_stdlib.h"
+#include "pccts_stdarg.h"
+#include "pccts_string.h"
+#include "pccts_stdio.h"
+
+PCCTS_NAMESPACE_STD
+
+/* I have to put this here due to C++ limitation
+ * that you can't have a 'forward' decl for enums.
+ * I hate C++!!!!!!!!!!!!!!!
+ * Of course, if I could use real templates, this would go away.
+ */
+// MR1
+// MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the
+// MR1 ANTLRTokenType enum
+// MR1
+
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999}; // MR1
+
+#define ANTLR_SUPPORT_CODE
+
+#include ATOKEN_H
+#include ATOKENBUFFER_H
+#include APARSER_H
+
+static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000; /* MR14 */
+static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000; /* MR14 */
+
+ /* L o o k a h e a d M a c r o s */
+
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte;
+ * we only use 8 bits of it.
+ */
+SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = {
+ 0x00000001, 0x00000002, 0x00000004, 0x00000008,
+ 0x00000010, 0x00000020, 0x00000040, 0x00000080
+};
+
+char ANTLRParser::eMsgBuffer[500] = "";
+
+ANTLRParser::
+~ANTLRParser()
+{
+ delete [] token_type;
+ delete [] zzFAILtext; // MR16 Manfred Kogler
+}
+
+ANTLRParser::
+ANTLRParser(ANTLRTokenBuffer *_inputTokens,
+ int k,
+ int use_inf_look,
+ int dlook,
+ int ssize)
+{
+ LLk = k;
+ can_use_inf_look = use_inf_look;
+/* MR14 */ if (dlook != 0) {
+/* MR14 */ panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode");
+/* MR14 */
+/* MR14 */ };
+ demand_look = 0; /* demand_look = dlook; */
+ bsetsize = ssize;
+ guessing = 0;
+ token_tbl = NULL;
+ eofToken = (ANTLRTokenType)1;
+
+ // allocate lookahead buffer
+ token_type = new ANTLRTokenType[LLk];
+ lap = 0;
+ labase = 0;
+#ifdef ZZDEFER_FETCH
+ stillToFetch = 0; // MR19
+#endif
+ dirty = 0;
+ inf_labase = 0; // MR7
+ inf_last = 0; // MR7
+ /* prime lookahead buffer, point to inputTokens */
+ this->inputTokens = _inputTokens;
+ this->inputTokens->setMinTokens(k);
+ _inputTokens->setParser(this); // MR1
+ resynchConsumed=1; // MR8
+ zzFAILtext=NULL; // MR9
+ traceOptionValueDefault=0; // MR10
+ traceReset(); // MR10
+ zzGuessSeq=0; // MR10
+ syntaxErrCount=0; // MR11
+}
+
+void ANTLRParser::init()
+{
+ prime_lookahead();
+ resynchConsumed=1; // MR8
+ traceReset(); // MR10
+}
+
+void ANTLRParser::traceReset()
+{
+ traceOptionValue=traceOptionValueDefault;
+ traceGuessOptionValue=1;
+ traceCurrentRuleName=NULL;
+ traceDepth=0;
+}
+
+int ANTLRParser::
+guess(ANTLRParserState *st)
+{
+ saveState(st);
+ guessing = 1;
+ return setjmp(guess_start.state);
+}
+
+void ANTLRParser::
+saveState(ANTLRParserState *buf)
+{
+ buf->guess_start = guess_start;
+ buf->guessing = guessing;
+ buf->inf_labase = inf_labase;
+ buf->inf_last = inf_last;
+ buf->dirty = dirty;
+ buf->traceOptionValue=traceOptionValue; /* MR10 */
+ buf->traceGuessOptionValue=traceGuessOptionValue; /* MR10 */
+ buf->traceCurrentRuleName=traceCurrentRuleName; /* MR10 */
+ buf->traceDepth=traceDepth; /* MR10 */
+}
+
+void ANTLRParser::
+restoreState(ANTLRParserState *buf)
+{
+ int i;
+ int prevTraceOptionValue;
+
+ guess_start = buf->guess_start;
+ guessing = buf->guessing;
+ inf_labase = buf->inf_labase;
+ inf_last = buf->inf_last;
+ dirty = buf->dirty;
+
+ // restore lookahead buffer from k tokens before restored TokenBuffer position
+ // if demand_look, then I guess we don't look backwards for these tokens.
+ for (i=1; i<=LLk; i++) token_type[i-1] =
+ inputTokens->bufferedToken(i-LLk)->getType();
+ lap = 0;
+ labase = 0;
+
+ /* MR10 */
+
+ prevTraceOptionValue=traceOptionValue;
+ traceOptionValue=buf->traceOptionValue;
+ if ( (prevTraceOptionValue > 0) !=
+ (traceOptionValue > 0)) {
+ if (traceCurrentRuleName != NULL) { /* MR21 */
+ if (traceOptionValue > 0) {
+ fprintf(stderr,
+ "trace enable restored in rule %s depth %d\n",
+ traceCurrentRuleName,
+ traceDepth);
+ };
+ if (traceOptionValue <= 0) {
+ fprintf(stderr,
+ "trace disable restored in rule %s depth %d\n",
+ traceCurrentRuleName, /* MR21 */
+ traceDepth);
+ };
+ }
+ };
+ traceGuessOptionValue=buf->traceGuessOptionValue;
+ traceCurrentRuleName=buf->traceCurrentRuleName;
+ traceDepth=buf->traceDepth;
+ traceGuessDone(buf);
+}
+
+/* Get the next symbol from the input stream; put it into lookahead buffer;
+ * fill token_type[] fast reference cache also. NLA is the next place where
+ * a lookahead ANTLRAbstractToken should go.
+ */
+void ANTLRParser::
+consume()
+{
+
+#ifdef ZZDEBUG_CONSUME_ACTION
+ zzdebug_consume_action();
+#endif
+
+// MR19 V.H. Simonis
+// Defer Fetch feature
+// Moves action of consume() into LA() function
+
+#ifdef ZZDEFER_FETCH
+ stillToFetch++;
+#else
+ NLA = inputTokens->getToken()->getType();
+ dirty--;
+ lap = (lap+1)&(LLk-1);
+#endif
+
+}
+
+_ANTLRTokenPtr ANTLRParser::
+LT(int i)
+{
+
+// MR19 V.H. Simonis
+// Defer Fetch feature
+// Moves action of consume() into LA() function
+
+#ifdef ZZDEFER_FETCH
+ undeferFetch();
+#endif
+
+#ifdef DEBUG_TOKENBUFFER
+ if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */
+ {
+ char buf[2000]; /* MR20 Was "static" */
+ sprintf(buf, "The minimum number of tokens you requested that the\nANTLRTokenBuffer buffer is not enough to satisfy your\nLT(%d) request; increase 'k' argument to constructor for ANTLRTokenBuffer\n", i);
+ panic(buf);
+ }
+#endif
+ return inputTokens->bufferedToken(i-LLk);
+}
+
+void
+ANTLRParser::
+look(int k)
+{
+ int i, c = k - (LLk-dirty);
+ for (i=1; i<=c; i++) consume();
+}
+
+/* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK);
+ */
+void
+ANTLRParser::
+prime_lookahead()
+{
+ int i;
+ for(i=1;i<=LLk; i++) consume();
+ dirty=0;
+ // lap = 0; // MR14 Sinan Karasu (sinan.karasu@boeing.com)
+ // labase = 0; // MR14
+ labase=lap; // MR14
+}
+
+/* check to see if the current input symbol matches '_t'.
+ * During NON demand lookahead mode, dirty will always be 0 and
+ * hence the extra code for consuming tokens in _match is never
+ * executed; the same routine can be used for both modes.
+ */
+int ANTLRParser::
+_match(ANTLRTokenType _t, ANTLRChar **MissText,
+ ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,
+ SetWordType **MissSet)
+{
+ if ( dirty==LLk ) {
+ consume();
+ }
+ if ( LA(1)!=_t ) {
+ *MissText=NULL;
+ *MissTok= _t; *BadTok = LT(1);
+ *MissSet=NULL;
+ return 0;
+ }
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+ return 1;
+}
+
+/* check to see if the current input symbol matches '_t'.
+ * Used during exception handling.
+ */
+int ANTLRParser::
+_match_wsig(ANTLRTokenType _t)
+{
+ if ( dirty==LLk ) {
+ consume();
+ }
+ if ( LA(1)!=_t ) return 0;
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+ return 1;
+}
+
+/* check to see if the current input symbol matches any token in a set.
+ * During NON demand lookahead mode, dirty will always be 0 and
+ * hence the extra code for consuming tokens in _match is never
+ * executed; the same routine can be used for both modes.
+ */
+int ANTLRParser::
+_setmatch(SetWordType *tset, ANTLRChar **MissText,
+ ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,
+ SetWordType **MissSet)
+{
+ if ( dirty==LLk ) {
+ consume();
+ }
+ if ( !set_el(LA(1), tset) ) {
+ *MissText=NULL;
+ *MissTok= (ANTLRTokenType)0; *BadTok=LT(1);
+ *MissSet=tset;
+ return 0;
+ }
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+ return 1;
+}
+
+int ANTLRParser::
+_setmatch_wsig(SetWordType *tset)
+{
+ if ( dirty==LLk ) {
+ consume();
+ }
+ if ( !set_el(LA(1), tset) ) return 0;
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+ return 1;
+}
+
+ /* Exception handling routines */
+//
+// 7-Apr-97 133MR1
+// Change suggested by Eli Sternheim (eli@interhdl.com)
+//
+void ANTLRParser::
+consumeUntil(SetWordType *st)
+{
+ ANTLRTokenType tmp; // MR1
+ const int Eof=1; // MR1
+ while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); } // MR1
+}
+
+//
+// 7-Apr-97 133MR1
+// Change suggested by Eli Sternheim (eli@interhdl.com)
+//
+void ANTLRParser::
+consumeUntilToken(int t)
+{
+ int tmp; // MR1
+ const int Eof=1; // MR1
+ while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); } // MR1
+}
+
+
+ /* Old error stuff */
+
+void ANTLRParser::
+resynch(SetWordType *wd,SetWordType mask)
+{
+
+/* MR8 S.Bochnak@microtool.com.pl */
+/* MR8 Change file scope static "consumed" to instance var */
+
+ /* if you enter here without having consumed a token from last resynch
+ * force a token consumption.
+ */
+/* MR8 */ if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;}
+
+ /* if current token is in resynch set, we've got what we wanted */
+
+/* MR8 */ if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;}
+
+ /* scan until we find something in the resynch set */
+
+ while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();}
+
+/* MR8 */ resynchConsumed=1;
+}
+
+/* standard error reporting function that assumes DLG-based scanners;
+ * you should redefine in subclass to change it or if you use your
+ * own scanner.
+ */
+void ANTLRParser::
+syn(_ANTLRTokenPtr tok, ANTLRChar *egroup, SetWordType *eset,
+ ANTLRTokenType etok, int k)
+{
+ int line;
+
+ line = LT(1)->getLine();
+
+ syntaxErrCount++; /* MR11 */
+ fprintf(stderr, "line %d: syntax error at \"%s\"",
+ line,
+ (LA(1)==eofToken && LT(1)->getText()[0] == '@')?
+ "<eof>":LT(1)->getText() /* MR21a */);
+ if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
+ if ( k==1 ) fprintf(stderr, " missing");
+ else
+ {
+ fprintf(stderr, "; \"%s\" not", LT(1)->getText());
+ if ( set_deg(eset)>1 ) fprintf(stderr, " in");
+ }
+ if ( set_deg(eset)>0 ) edecode(eset);
+ else fprintf(stderr, " %s", token_tbl[etok]);
+ if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
+ fprintf(stderr, "\n");
+}
+
+/* is b an element of set p? */
+int ANTLRParser::
+set_el(ANTLRTokenType b, SetWordType *p)
+{
+ return( p[DIVWORD(b)] & bitmask[MODWORD(b)] );
+}
+
+int ANTLRParser::
+set_deg(SetWordType *a)
+{
+ /* Fast compute degree of a set... the number
+ of elements present in the set. Assumes
+ that all word bits are used in the set
+ */
+ register SetWordType *p = a;
+ register SetWordType *endp = &(a[bsetsize]);
+ register int degree = 0;
+
+ if ( a == NULL ) return 0;
+ while ( p < endp )
+ {
+ register SetWordType t = *p;
+ register SetWordType *b = &(bitmask[0]);
+ do {
+ if (t & *b) ++degree;
+ } while (++b < &(bitmask[sizeof(SetWordType)*8]));
+ p++;
+ }
+
+ return(degree);
+}
+
+void ANTLRParser::
+edecode(SetWordType *a)
+{
+ register SetWordType *p = a;
+ register SetWordType *endp = &(p[bsetsize]);
+ register unsigned e = 0;
+
+ if ( set_deg(a)>1 ) fprintf(stderr, " {");
+ do {
+ register SetWordType t = *p;
+ register SetWordType *b = &(bitmask[0]);
+ do {
+ if ( t & *b ) fprintf(stderr, " %s", token_tbl[e]);
+ e++;
+ } while (++b < &(bitmask[sizeof(SetWordType)*8]));
+ } while (++p < endp);
+ if ( set_deg(a)>1 ) fprintf(stderr, " }");
+}
+
+/* input looks like:
+ * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk)
+ * where the zzMiss stuff is set here to the token that did not match
+ * (and which set wasn't it a member of).
+ */
+
+// MR9 29-Sep-97 Stan Bochnak (S.Bochnak@microTool.com.pl)
+// MR9 Original fix to static allocated text didn't
+// MR9 work because a pointer to it was passed back
+// MR9 to caller. Replace with instance variable.
+
+const int SETWORDCOUNT=20;
+
+void
+ANTLRParser::FAIL(int k, ...)
+{
+//
+// MR1 10-Apr-97
+//
+
+ if (zzFAILtext == NULL) zzFAILtext=new char [1000]; // MR9
+ SetWordType **f=new SetWordType *[SETWORDCOUNT]; // MR1 // MR9
+ SetWordType **miss_set;
+ ANTLRChar **miss_text;
+ _ANTLRTokenPtr *bad_tok;
+ ANTLRChar **bad_text;
+//
+// 7-Apr-97 133MR1
+// err_k is passed as a "int *", not "unsigned *"
+//
+ int *err_k; // MR1
+ int i;
+ va_list ap;
+
+ va_start(ap, k);
+
+ zzFAILtext[0] = '\0';
+ if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer");
+ for (i=1; i<=k; i++) /* collect all lookahead sets */
+ {
+ f[i-1] = va_arg(ap, SetWordType *);
+ }
+ for (i=1; i<=k; i++) /* look for offending token */
+ {
+ if ( i>1 ) strcat(zzFAILtext, " ");
+ strcat(zzFAILtext, LT(i)->getText());
+ if ( !set_el(LA(i), f[i-1]) ) break;
+ }
+ miss_set = va_arg(ap, SetWordType **);
+ miss_text = va_arg(ap, ANTLRChar **);
+ bad_tok = va_arg(ap, _ANTLRTokenPtr *);
+ bad_text = va_arg(ap, ANTLRChar **);
+ err_k = va_arg(ap, int *); // MR1
+ if ( i>k )
+ {
+ /* bad; lookahead is permutation that cannot be matched,
+ * but, the ith token of lookahead is valid at the ith position
+ * (The old LL sub 1 (k) versus LL(k) parsing technique)
+ */
+ *miss_set = NULL;
+ *miss_text = LT(1)->getText();
+ *bad_tok = LT(1);
+ *bad_text = (*bad_tok)->getText();
+ *err_k = k;
+//
+// MR4 20-May-97 erroneously deleted contents of f[]
+// MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca)
+// MR1 10-Apr-97 release temporary storage
+//
+ delete [] f; // MR1
+ return; // MR1
+ }
+/* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
+ *miss_set = f[i-1];
+ *miss_text = zzFAILtext;
+ *bad_tok = LT(i);
+ *bad_text = (*bad_tok)->getText();
+ if ( i==1 ) *err_k = 1;
+ else *err_k = k;
+//
+// MR4 20-May-97 erroneously deleted contents of f[]
+// MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca)
+// MR1 10-Apr-97 release temporary storage
+//
+ delete [] f; // MR1
+ return; // MR1
+}
+
+int ANTLRParser::
+_match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows)
+{
+ if ( dirty==LLk ) consume();
+
+ if ( LA(1)!=tokenWanted )
+ {
+ syntaxErrCount++; /* MR11 */
+ fprintf(stderr,
+ "line %d: syntax error at \"%s\" missing %s\n",
+ LT(1)->getLine(),
+ (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */
+ token_tbl[tokenWanted]);
+ consumeUntil( whatFollows );
+ return 0;
+ }
+ else {
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+/* if ( !demand_look ) consume(); */
+ return 1;
+ }
+}
+
+
+int ANTLRParser::
+_setmatch_wdfltsig(SetWordType *tokensWanted,
+ ANTLRTokenType tokenTypeOfSet,
+ SetWordType *whatFollows)
+{
+ if ( dirty==LLk ) consume();
+ if ( !set_el(LA(1), tokensWanted) )
+ {
+ syntaxErrCount++; /* MR11 */
+ fprintf(stderr,
+ "line %d: syntax error at \"%s\" missing %s\n",
+ LT(1)->getLine(),
+ (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */
+ token_tbl[tokenTypeOfSet]);
+ consumeUntil( whatFollows );
+ return 0;
+ }
+ else {
+ dirty++;
+ labase = (labase+1)&(LLk-1); // labase maintained even if !demand look
+/* if ( !demand_look ) consume(); */
+ return 1;
+ }
+}
+
+char *ANTLRParser::
+eMsgd(char *err,int d)
+{
+ sprintf(eMsgBuffer, err, d); // dangerous, but I don't care
+ return eMsgBuffer;
+}
+
+char *ANTLRParser::
+eMsg(char *err, char *s)
+{
+ sprintf(eMsgBuffer, err, s);
+ return eMsgBuffer;
+}
+
+char *ANTLRParser::
+eMsg2(char *err,char *s, char *t)
+{
+ sprintf(eMsgBuffer, err, s, t);
+ return eMsgBuffer;
+}
+
+void ANTLRParser::
+panic(const char *msg) // MR20 const
+{
+ fprintf(stderr, "ANTLR panic: %s\n", msg);
+ exit(PCCTS_EXIT_FAILURE); // MR1
+}
+
+const ANTLRChar *ANTLRParser:: // MR1
+parserTokenName(int tok) { // MR1
+ return token_tbl[tok]; // MR1
+} // MR1
+
+void ANTLRParser::traceGuessDone(const ANTLRParserState *state) {
+
+ int doIt=0;
+
+ if (traceCurrentRuleName == NULL) return;
+
+ if (traceOptionValue <= 0) {
+ doIt=0;
+ } else if (traceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",
+ state->traceCurrentRuleName,
+ LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
+ state->traceDepth);
+ if (state->guessing != 0) {
+ fprintf(stderr," (guess mode continues - an enclosing guess is still active)");
+ } else {
+ fprintf(stderr," (guess mode ends)");
+ };
+ fprintf(stderr,"\n");
+ };
+}
+
+void ANTLRParser::traceGuessFail() {
+
+ int doIt=0;
+
+ if (traceCurrentRuleName == NULL) return; /* MR21 */
+
+ if (traceOptionValue <= 0) {
+ doIt=0;
+ } else if (guessing && traceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"guess failed\n");
+ };
+}
+
+/* traceOption:
+ zero value turns off trace
+*/
+
+void ANTLRParser::tracein(const ANTLRChar * rule) {
+
+ int doIt=0;
+
+ traceDepth++;
+ traceCurrentRuleName=rule;
+
+ if (traceOptionValue <= 0) {
+ doIt=0;
+ } else if (guessing && traceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"enter rule %s {\"%s\"} depth %d",
+ rule,
+ LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
+ traceDepth);
+ if (guessing) fprintf(stderr," guessing");
+ fprintf(stderr,"\n");
+ };
+ return;
+}
+
+void ANTLRParser::traceout(const ANTLRChar * rule) {
+
+ int doIt=0;
+
+ traceDepth--;
+
+ if (traceOptionValue <= 0) {
+ doIt=0;
+ } else if (guessing && traceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"exit rule %s {\"%s\"} depth %d",
+ rule,
+ LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
+ traceDepth+1);
+ if (guessing) fprintf(stderr," guessing");
+ fprintf(stderr,"\n");
+ };
+}
+
+int ANTLRParser::traceOption(int delta) {
+
+ int prevValue=traceOptionValue;
+
+ traceOptionValue=traceOptionValue+delta;
+
+ if (traceCurrentRuleName != NULL) {
+ if (prevValue <= 0 && traceOptionValue > 0) {
+ fprintf(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
+ };
+ if (prevValue > 0 && traceOptionValue <= 0) {
+ fprintf(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
+ };
+ };
+
+ return prevValue;
+}
+
+int ANTLRParser::traceGuessOption(int delta) {
+
+ int prevValue=traceGuessOptionValue;
+
+ traceGuessOptionValue=traceGuessOptionValue+delta;
+
+ if (traceCurrentRuleName != NULL) {
+ if (prevValue <= 0 && traceGuessOptionValue > 0) {
+ fprintf(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
+ };
+ if (prevValue > 0 && traceGuessOptionValue <= 0) {
+ fprintf(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
+ };
+ };
+ return prevValue;
+}
+
+// MR19 V.H. Simonis Defer Fetch feature
+
+void ANTLRParser::undeferFetch()
+{
+
+#ifdef ZZDEFER_FETCH
+ if (stillToFetch) {
+ for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) {
+ NLA = inputTokens->getToken()->getType();
+ dirty--;
+ lap = (lap+1)&(LLk-1);
+ }
+ stillToFetch = 0;
+ }
+#else
+ return;
+#endif
+
+}
+
+int ANTLRParser::isDeferFetchEnabled()
+{
+#ifdef ZZDEFER_FETCH
+ return 1;
+#else
+ return 0;
+#endif
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h
new file mode 100644
index 0000000000..85fe921ebb
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h
@@ -0,0 +1,358 @@
+/* ANTLRParser.h
+ *
+ * Define the generic ANTLRParser superclass, which is subclassed to
+ * define an actual parser.
+ *
+ * Before entry into this file: ANTLRTokenType must be set.
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef APARSER_H_GATE
+#define APARSER_H_GATE
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_setjmp.h"
+
+PCCTS_NAMESPACE_STD
+
+#include ATOKEN_H
+#include ATOKENBUFFER_H
+
+#ifdef ZZCAN_GUESS
+#ifndef ZZINF_LOOK
+#define ZZINF_LOOK
+#endif
+#endif
+
+
+#define NLA (token_type[lap&(LLk-1)])/* --> next LA */
+
+typedef unsigned char SetWordType;
+
+/* Define external bit set stuff (for SetWordType) */
+#define EXT_WORDSIZE (sizeof(char)*8)
+#define EXT_LOGWORDSIZE 3
+
+ /* s y n t a c t i c p r e d i c a t e s t u f f */
+
+#ifndef zzUSER_GUESS_HOOK
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)
+#endif
+
+#ifndef zzUSER_GUESS_DONE_HOOK
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)
+#endif
+
+/* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */
+
+#define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen)
+#ifndef zzUSER_GUESS_FAIL_HOOK
+#define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq)
+#endif
+
+
+typedef struct _zzjmp_buf {
+ jmp_buf state;
+ } zzjmp_buf;
+
+/* these need to be macros not member functions */
+#define zzGUESS_BLOCK ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen;
+#define zzNON_GUESS_MODE if ( !guessing )
+#define zzGUESS_FAIL guess_fail();
+
+/* Note: zzGUESS_DONE does not execute longjmp() */
+
+#define zzGUESS_DONE {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }
+#define zzGUESS saveState(&zzst); \
+ guessing = 1; \
+ zzGuessSeqFrozen = ++zzGuessSeq; \
+ _marker = inputTokens->mark(); \
+ zzrv = setjmp(guess_start.state); \
+ zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \
+ if ( zzrv ) zzGUESS_DONE
+
+#define zzTRACEdata const ANTLRChar *zzTracePrevRuleName = NULL;
+
+#ifndef zzTRACEIN
+#define zzTRACEIN(r) zzTracePrevRuleName=traceCurrentRuleName;tracein(r);
+#endif
+#ifndef zzTRACEOUT
+#define zzTRACEOUT(r) traceout(r);traceCurrentRuleName=zzTracePrevRuleName;
+#endif
+
+ /* a n t l r p a r s e r d e f */
+
+struct ANTLRParserState {
+ /* class variables */
+ zzjmp_buf guess_start;
+ int guessing;
+
+ int inf_labase;
+ int inf_last;
+
+ int dirty;
+
+ int traceOptionValue; // MR10
+ int traceGuessOptionValue; // MR10
+ const ANTLRChar *traceCurrentRuleName; // MR10
+ int traceDepth; // MR10
+
+};
+
+/* notes:
+ *
+ * multiple inheritance is a cool way to include what stuff is needed
+ * in this structure (like guess stuff). however, i'm not convinced that
+ * multiple inheritance works correctly on all platforms. not that
+ * much space is used--just include all possibly useful members.
+ *
+ * the class should also be a template with arguments for the lookahead
+ * depth and so on. that way, more than one parser can be defined (as
+ * each will probably have different lookahead requirements). however,
+ * am i sure that templates work? no, i'm not sure.
+ *
+ * no attributes are maintained and, hence, the 'asp' variable is not
+ * needed. $i can still be referenced, but it refers to the token
+ * associated with that rule element. question: where are the token's
+ * stored if not on the software stack? in local variables created
+ * and assigned to by antlr.
+ */
+class ANTLRParser {
+protected:
+ /* class variables */
+ static SetWordType bitmask[sizeof(SetWordType)*8];
+ static char eMsgBuffer[500];
+
+protected:
+ int LLk; // number of lookahead symbols (old LL_K)
+ int demand_look;
+ ANTLRTokenType eofToken; // when do I stop during resynch()s
+ int bsetsize; // size of bitsets created by ANTLR in
+ // units of SetWordType
+
+ ANTLRTokenBuffer *inputTokens; //place to get input tokens
+
+ zzjmp_buf guess_start; // where to jump back to upon failure
+ int guessing; // if guessing (using (...)? predicate)
+
+ // infinite lookahead stuff
+ int can_use_inf_look; // set by subclass (generated by ANTLR)
+ int inf_lap;
+ int inf_labase;
+ int inf_last;
+ int *_inf_line;
+
+ const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const
+
+ int dirty; // used during demand lookahead
+
+ ANTLRTokenType *token_type; // fast reference cache of token.getType()
+// ANTLRLightweightToken **token; // the token with all its attributes
+ int lap;
+ int labase;
+#ifdef ZZDEFER_FETCH
+ int stillToFetch; // MR19 V.H. Simonis
+#endif
+
+private:
+ void fill_inf_look();
+
+protected:
+ virtual void guess_fail() { // MR9 27-Sep-97 make virtual
+ traceGuessFail(); // MR10
+ longjmp(guess_start.state, 1); } // MR9
+ virtual void guess_done(ANTLRParserState *st) { // MR9 27-Sep-97 make virtual
+ restoreState(st); } // MR9
+ virtual int guess(ANTLRParserState *); // MR9 27-Sep-97 make virtual
+ void look(int);
+ int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,
+ _ANTLRTokenPtr *, SetWordType **);
+ int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,
+ _ANTLRTokenPtr *, SetWordType **);
+ int _match_wsig(ANTLRTokenType);
+ int _setmatch_wsig(SetWordType *);
+ virtual void consume();
+ virtual void resynch(SetWordType *wd,SetWordType mask); // MR21
+ void prime_lookahead();
+ virtual void tracein(const ANTLRChar *r); // MR10
+ virtual void traceout(const ANTLRChar *r); // MR10
+ static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);} // x % EXT_WORDSIZE // MR9
+ static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;} // x / EXT_WORDSIZE // MR9
+ int set_deg(SetWordType *);
+ int set_el(ANTLRTokenType, SetWordType *);
+ virtual void edecode(SetWordType *); // MR1
+ virtual void FAIL(int k, ...); // MR1
+ int traceOptionValue; // MR10
+ int traceGuessOptionValue; // MR10
+ const ANTLRChar *traceCurrentRuleName; // MR10
+ int traceDepth; // MR10
+ void traceReset(); // MR10
+ virtual void traceGuessFail(); // MR10
+ virtual void traceGuessDone(const ANTLRParserState *); // MR10
+ int zzGuessSeq; // MR10
+
+public:
+ ANTLRParser(ANTLRTokenBuffer *,
+ int k=1,
+ int use_inf_look=0,
+ int demand_look=0,
+ int bsetsize=1);
+ virtual ~ANTLRParser();
+
+ virtual void init();
+
+ ANTLRTokenType LA(int i)
+ {
+//
+// MR14 demand look will always be 0 for C++ mode
+//
+//// return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :
+//// token_type[(lap+(i)-1)&(LLk-1)];
+
+// MR19 V.H. Simonis Defer fetch feature
+
+#ifdef ZZDEFER_FETCH
+ undeferFetch();
+#endif
+ return token_type[(lap+(i)-1)&(LLk-1)];
+ }
+ _ANTLRTokenPtr LT(int i);
+
+ void setEofToken(ANTLRTokenType t) { eofToken = t; }
+ ANTLRTokenType getEofToken() const { return eofToken; } // MR14
+
+ void noGarbageCollectTokens() { inputTokens->noGarbageCollectTokens(); }
+ void garbageCollectTokens() { inputTokens->garbageCollectTokens(); }
+
+ virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,
+ SetWordType *eset, ANTLRTokenType etok, int k);
+ virtual void saveState(ANTLRParserState *); // MR9 27-Sep-97 make virtual
+ virtual void restoreState(ANTLRParserState *); // MR9 27-Sep-97 make virtual
+
+ virtual void panic(const char *msg); // MR20 const
+ static char *eMsgd(char *,int);
+ static char *eMsg(char *,char *);
+ static char *eMsg2(char *,char *,char *);
+
+ void consumeUntil(SetWordType *st);
+ void consumeUntilToken(int t);
+
+ virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,
+ ANTLRTokenType tokenTypeOfSet,
+ SetWordType *whatFollows);
+ virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,
+ SetWordType *whatFollows);
+
+ const ANTLRChar * parserTokenName(int tok); // MR1
+
+ int traceOptionValueDefault; // MR11
+ int traceOption(int delta); // MR11
+ int traceGuessOption(int delta); // MR11
+
+// MR8 5-Aug-97 S.Bochnak@microtool.com.pl
+// MR8 Move resynch static local variable
+// MR8 to class instance
+
+ int syntaxErrCount; // MR12
+ ANTLRTokenStream *getLexer() const { // MR12
+ return inputTokens ? inputTokens->getLexer() : 0; } // MR12
+protected: // MR8
+ int resynchConsumed; // MR8
+ char *zzFAILtext; // workarea required by zzFAIL // MR9
+ void undeferFetch(); // MR19 V.H. Simonis
+ int isDeferFetchEnabled(); // MR19 V.H. Simonis
+};
+
+#define zzmatch(_t) \
+ if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \
+ (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;
+
+#define zzmatch_wsig(_t,handler) \
+ if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}
+
+#define zzsetmatch(_ts) \
+ if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \
+ (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;
+
+#define zzsetmatch_wsig(_ts, handler) \
+ if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}
+
+/* For the dflt signal matchers, a FALSE indicates that an error occurred
+ * just like the other matchers, but in this case, the routine has already
+ * recovered--we do NOT want to consume another token. However, when
+ * the match was successful, we do want to consume hence _signal=0 so that
+ * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;"
+ * preamble.
+ */
+#define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \
+ if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \
+ _signal = MismatchedToken;
+
+#define zzmatch_wdfltsig(tokenWanted, whatFollows) \
+ if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken;
+
+
+// MR1 10-Apr-97 zzfailed_pred() macro does not backtrack
+// MR1 in guess mode.
+// MR1 Identification and correction due to J. Lilley
+
+#ifndef zzfailed_pred
+#define zzfailed_pred(_p) \
+ if (guessing) { \
+ zzGUESS_FAIL; \
+ } else { \
+ fprintf(stdout,"line %d: semantic error; failed predicate: '%s'\n", \
+ LT(1)->getLine(), _p); \
+ }
+#endif
+
+#define zzRULE \
+ SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0; \
+ _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)""; \
+ int zzErrk=1,zzpf=0; \
+ zzTRACEdata \
+ ANTLRChar *zzMissText=(ANTLRChar *)"";
+
+#endif
+
+ /* S t a n d a r d E x c e p t i o n S i g n a l s */
+
+#define NoSignal 0
+#define MismatchedToken 1
+#define NoViableAlt 2
+#define NoSemViableAlt 3
+
+/* MR7 Allow more control over signalling */
+/* by adding "Unwind" and "SetSignal" */
+
+#define Unwind 4
+#define setSignal(newValue) *_retsignal=_signal=(newValue)
+#define suppressSignal *_retsignal=_signal=0
+#define exportSignal *_retsignal=_signal
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp
new file mode 100644
index 0000000000..433a26075e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp
@@ -0,0 +1,244 @@
+/* Abstract syntax tree manipulation functions
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_stdarg.h"
+
+PCCTS_NAMESPACE_STD
+
+#define ANTLR_SUPPORT_CODE
+
+#include "ASTBase.h"
+
+/* ensure that tree manipulation variables are current after a rule
+ * reference
+ */
+void
+ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
+{
+ if ( *_sibling == NULL ) return;
+ if ( *_root == NULL ) *_root = *_sibling;
+ else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;
+ if ( *_tail==NULL ) *_tail = *_sibling;
+ while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;
+}
+
+/* add a child node to the current sibling list */
+void
+ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
+{
+ if ( *_tail != NULL ) (*_tail)->_right = this;
+ else {
+ *_sibling = this;
+ if ( *_root != NULL ) (*_root)->_down = *_sibling;
+ }
+ *_tail = this;
+ if ( *_root == NULL ) *_root = *_sibling;
+}
+
+/* make a new AST node. Make the newly-created
+ * node the root for the current sibling list. If a root node already
+ * exists, make the newly-created node the root of the current root.
+ */
+void
+ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)
+{
+ if ( *_root != NULL )
+ if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;
+ *_root = this;
+ (*_root)->_down = *_sibling;
+}
+
+/* Apply preorder_action(), etc.. to root then each sibling */
+//
+// 7-Apr-97 133MR1
+// Fix suggested by Ron House (house@helios.usq.edu.au)
+//
+void
+ASTBase::preorder()
+{
+ ASTBase *tree = this;
+
+ while ( tree!= NULL )
+ {
+ if ( tree->_down != NULL ) {
+ tree->preorder_before_action(); // MR1
+ };
+ tree->preorder_action();
+ if ( tree->_down!=NULL )
+ {
+ tree->_down->preorder();
+ tree->preorder_after_action(); // MR1
+ }
+ tree = tree->_right;
+ }
+}
+
+/* free all AST nodes in tree; apply func to each before freeing */
+void
+ASTBase::destroy()
+{
+ ASTBase* tree = this;
+ while (tree) {
+ if (tree->_down) tree->_down->destroy();
+
+ ASTBase* cur = tree;
+ tree = tree->_right;
+ delete cur;
+ }
+}
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually siblins lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ */
+ASTBase *
+ASTBase::tmake(ASTBase *root, ...)
+{
+ va_list ap;
+ register ASTBase *child, *sibling=NULL, *tail, *w;
+
+ va_start(ap, root);
+
+ if ( root != NULL )
+ if ( root->_down != NULL ) {
+ root->reportOverwriteOfDownPointer(); /* MR21 Report problem which almost always an error */
+ return NULL;
+ }
+ child = va_arg(ap, ASTBase *);
+ while ( child != NULL )
+ {
+ for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */
+ if ( sibling == NULL ) {sibling = child; tail = w;}
+ else {tail->_right = child; tail = w;}
+ child = va_arg(ap, ASTBase *);
+ }
+ if ( root==NULL ) root = sibling;
+ else root->_down = sibling;
+ va_end(ap);
+ return root;
+}
+
+#ifndef PCCTS_NOT_USING_SOR
+
+/* tree duplicate */
+// forgot to check for NULL this (TJP July 23,1995)
+ASTBase *
+ASTBase::dup()
+{
+ ASTBase *u, *t=this;
+
+ if ( t == NULL ) return NULL;
+/*
+ u = new ASTBase;
+ *u = *t;
+*/
+ u = (ASTBase *)this->shallowCopy();
+ if ( t->_right!=NULL ) u->_right = t->_right->dup();
+ else u->_right = NULL;
+ if ( t->_down!=NULL ) u->_down = t->_down->dup();
+ else u->_down = NULL;
+ return u;
+}
+#endif
+
+//
+// 7-Apr-97 133MR1
+// Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)
+//
+/* tree duplicate */
+
+#ifndef PCCTS_NOT_USING_SOR
+
+ASTBase *
+ASTDoublyLinkedBase::dup()
+{
+ ASTDoublyLinkedBase *u, *t=this;
+
+ if ( t == NULL ) return NULL;
+ u = (ASTDoublyLinkedBase *)this->shallowCopy();
+ u->_up = NULL; /* set by calling invocation */
+ u->_left = NULL;
+ if (t->_right!=NULL) { // MR1
+ u->_right=t->_right->dup(); // MR1
+ ((ASTDoublyLinkedBase *)u->_right)->_left = u; // MR1
+ } else { // MR1
+ u->_right = NULL; // MR1
+ }; // MR1
+ if (t->_down!=NULL) { // MR1
+ u->_down = t->_down->dup(); // MR1
+ ((ASTDoublyLinkedBase *)u->_down)->_up = u; // MR1
+ } else { // MR1
+ u->_down = NULL; // MR1
+ }; // MR1
+ return u;
+}
+
+#endif
+
+/*
+ * Set the 'up', and 'left' pointers of all nodes in 't'.
+ * Initial call is double_link(your_tree, NULL, NULL).
+ */
+void
+ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)
+{
+ ASTDoublyLinkedBase *t = this;
+
+ t->_left = (ASTDoublyLinkedBase *) left;
+ t->_up = (ASTDoublyLinkedBase *) up;
+ if (t->_down != NULL)
+ ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);
+ if (t->_right != NULL)
+ ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);
+}
+
+// MR21 ASTBase::reportOverwriteOfDownPointer
+
+void ASTBase::reportOverwriteOfDownPointer()
+{
+ panic("Attempt to overwrite down pointer in ASTBase::tmake");
+}
+
+// MR21 ASTBase::panic
+
+void ASTBase::panic(const char *msg)
+{
+ fprintf(stderr,"ASTBase panic: %s\n", msg);
+ exit(PCCTS_EXIT_FAILURE);
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h
new file mode 100644
index 0000000000..a5b3116a54
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h
@@ -0,0 +1,119 @@
+/* Abstract syntax tree
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ASTBase_H
+#define ASTBase_H
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+#ifndef PCCTS_NOT_USING_SOR
+#include "PCCTSAST.h"
+#endif
+
+/*
+ * Notes:
+ *
+ * To specify a copy constructor, subclass one of these classes and
+ * give the copy constructor. To use dup(), you must define shallowCopy().
+ * shallowCopy() can use either a copy constructor or just copy the node
+ * itself.
+ */
+
+#ifdef PCCTS_NOT_USING_SOR
+class DllExportPCCTS ASTBase {
+#else
+class DllExportPCCTS ASTBase : public PCCTS_AST {
+#endif
+
+protected:
+ ASTBase *_right, *_down;
+
+public:
+
+#ifdef PCCTS_NOT_USING_SOR
+ ASTBase *right() { return _right; }
+ ASTBase *down() { return _down; }
+ void setRight(ASTBase *t) { _right = (ASTBase *)t; }
+ void setDown(ASTBase *t) { _down = (ASTBase *)t; }
+#else
+ PCCTS_AST *right() { return _right; } // define the SORCERER interface
+ PCCTS_AST *down() { return _down; }
+ void setRight(PCCTS_AST *t) { _right = (ASTBase *)t; }
+ void setDown(PCCTS_AST *t) { _down = (ASTBase *)t; }
+#endif
+ ASTBase() { _right = _down = NULL; }
+ virtual ~ASTBase() { ; }
+#ifndef PCCTS_NOT_USING_SOR
+ virtual ASTBase *dup();
+#endif
+ void destroy();
+ void preorder();
+ static ASTBase *tmake(ASTBase *, ...);
+ static void link(ASTBase **, ASTBase **, ASTBase **);
+ void subchild(ASTBase **, ASTBase **, ASTBase **);
+ void subroot(ASTBase **, ASTBase **, ASTBase **);
+ virtual void preorder_action() { ; }
+ virtual void preorder_before_action() { printf(" ("); }
+ virtual void preorder_after_action() { printf(" )"); }
+ virtual void panic(const char *msg); /* MR21 */
+ virtual void reportOverwriteOfDownPointer(); /* MR21 */
+};
+
+class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {
+protected:
+ ASTDoublyLinkedBase *_left, *_up;
+
+public:
+ void double_link(ASTBase *left, ASTBase *up);
+
+#ifndef PCCTS_NOT_USING_SOR
+ virtual ASTBase *dup();
+#endif
+
+#ifdef PCCTS_NOT_USING_SOR
+ ASTBase *left() { return _left; }
+ ASTBase *up() { return _up; }
+ void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6
+ void setUp(ASTBase *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6
+#else
+ PCCTS_AST *left() { return _left; }
+ PCCTS_AST *up() { return _up; }
+ void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6
+ void setUp(PCCTS_AST *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6
+#endif
+
+};
+
+class AST; // announce that this class will be coming along shortly
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp
new file mode 100644
index 0000000000..88df14ba00
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp
@@ -0,0 +1,82 @@
+/* ATokPtr.C
+ *
+ * ANTLRToken MUST be defined before entry to this file.
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Written by Russell Quong June 30, 1995
+ * Adapted by Terence Parr to ANTLR stuff
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+PCCTS_NAMESPACE_STD
+
+#include "ATokPtr.h"
+
+void ANTLRTokenPtr::ref() const
+{
+ if (ptr_ != NULL) {
+ ptr_->ref();
+ }
+}
+
+void ANTLRTokenPtr::deref()
+{
+ if (ptr_ != NULL)
+ {
+ ptr_->deref();
+ if ( ptr_->nref()==0 )
+ {
+ delete ptr_;
+ ptr_ = NULL;
+ }
+ }
+}
+
+ANTLRTokenPtr::~ANTLRTokenPtr()
+{
+ deref();
+}
+
+//
+// 8-Apr-97 MR1 Make operator -> a const member function
+// as weall as some other member functions
+//
+void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1
+{
+ lhs.ref(); // protect against "xp = xp"; ie same underlying object
+ deref();
+ ptr_ = lhs.ptr_;
+}
+
+void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
+{
+ if (addr != NULL) {
+ addr->ref();
+ }
+ deref();
+ ptr_ = addr;
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h
new file mode 100644
index 0000000000..3e825f6be0
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h
@@ -0,0 +1,88 @@
+/* ATokPtr.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Written by Russell Quong June 30, 1995
+ * Adapted by Terence Parr to ANTLR stuff
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ATokPtr_h
+#define ATokPtr_h
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+
+PCCTS_NAMESPACE_STD
+
+// pointer to a reference counted object
+// robust in that an unused ANTLRTokenPtr can point to NULL.
+
+class ANTLRAbstractToken;
+
+class DllExportPCCTS ANTLRTokenPtr {
+public:
+ ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}
+ ANTLRTokenPtr(const ANTLRTokenPtr &lhs) {ptr_ = lhs.ptr_; lhs.ref();}
+ ~ANTLRTokenPtr();
+
+ // use ANTLRTokenPtr as a pointer to ANTLRToken
+//
+// 8-Apr-97 MR1 Make operator -> a const member function
+// as well as some other member functions
+//
+ ANTLRAbstractToken *operator-> () const { return ptr_; } // MR1
+//
+// 7-Apr-97 133MR1
+// Fix suggested by Andreas Magnusson
+// (Andreas.Magnusson@mailbox.swipnet.se)
+ void operator = (const ANTLRTokenPtr & lhs); // MR1
+ void operator = (ANTLRAbstractToken *addr);
+ int operator != (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int
+ { return this->ptr_ != q.ptr_; }
+ int operator == (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int
+ { return this->ptr_ == q.ptr_; }
+ int operator == (const ANTLRAbstractToken *addr) const // MR11
+ { return this->ptr_ == addr; }
+ int operator != (const ANTLRAbstractToken *addr) const // MR11
+ { return this->ptr_ != addr; }
+
+ void ref() const;
+ void deref();
+
+protected:
+ ANTLRAbstractToken *ptr_;
+};
+
+//typedef ANTLRTokenPtr _ANTLRTokenPtr;
+
+/*
+ * Since you cannot redefine operator->() to return one of the user's
+ * token object types, we must down cast. This is a drag. Here's
+ * a macro that helps. template: "mytoken(a-smart-ptr)->myfield".
+ */
+#define mytoken(tk) ((ANTLRToken *)(tk.operator->()))
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h
new file mode 100644
index 0000000000..ef14516ee6
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h
@@ -0,0 +1,305 @@
+/* ANTLRToken.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ATOKEN_H_GATE
+#define ATOKEN_H_GATE
+
+#include "pcctscfg.h"
+
+#include "pccts_string.h"
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+// MR9 RJV (JVincent@novell.com) Not needed for variable length strings
+
+//// MR9 #ifndef ANTLRCommonTokenTEXTSIZE
+//// MR9 #define ANTLRCommonTokenTEXTSIZE 100
+//// MR9 #endif
+
+
+/* must define what a char looks like; can make this a class too */
+typedef char ANTLRChar;
+
+/* D E F I N E S M A R T P O I N T E R S */
+
+//#include ATOKPTR_H not tested yet, leave out
+class ANTLRAbstractToken;
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;
+
+class ANTLRAbstractToken {
+public:
+ virtual ~ANTLRAbstractToken() {;}
+ virtual ANTLRTokenType getType() const = 0;
+ virtual void setType(ANTLRTokenType t) = 0;
+ virtual int getLine() const = 0;
+ virtual void setLine(int line) = 0;
+ virtual ANTLRChar *getText() const = 0;
+ virtual void setText(const ANTLRChar *) = 0;
+
+ /* This function will disappear when I can use templates */
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *text,
+ int line) = 0;
+
+ /* define to satisfy ANTLRTokenBuffer's need to determine whether or
+ not a token object can be destroyed. If nref()==0, no one has
+ a reference, and the object may be destroyed. This function defaults
+ to 1, hence, if you use deleteTokens() message with a token object
+ not derived from ANTLRCommonRefCountToken, the parser will compile
+ but will not delete objects after they leave the token buffer.
+ */
+
+ virtual unsigned nref() const { return 1; } // MR11
+ virtual void ref() {;}
+ virtual void deref() {;}
+
+ virtual void panic(const char *msg) // MR20 const
+ {
+ fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+};
+
+/* This class should be subclassed. It cannot store token type or text */
+
+class ANTLRRefCountToken : public ANTLRAbstractToken {
+public:
+#ifdef DBG_REFCOUNTTOKEN
+ static int ctor;
+ static int dtor;
+#endif
+protected:
+ unsigned refcnt_;
+#ifdef DBG_REFCOUNTTOKEN
+ char object[200];
+#endif
+
+public:
+ ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar *s)
+#ifndef DBG_REFCOUNTTOKEN
+ {
+ refcnt_ = 0;
+ }
+#else
+ {
+ ctor++;
+ refcnt_ = 0;
+ if ( t==1 ) sprintf(object,"tok_EOF");
+ else sprintf(object,"tok_%s",s);
+ fprintf(stderr, "ctor %s #%d\n",object,ctor);
+ }
+#endif
+ ANTLRRefCountToken()
+#ifndef DBG_REFCOUNTTOKEN
+ { refcnt_ = 0; }
+#else
+ {
+ ctor++;
+ refcnt_ = 0;
+ sprintf(object,"tok_blank");
+ fprintf(stderr, "ctor %s #%d\n",object,ctor);
+ }
+ virtual ~ANTLRRefCountToken()
+ {
+ dtor++;
+ if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n");
+ fprintf(stderr, "dtor %s #%d\n", object, dtor);
+ object[0]='\0';
+ }
+#endif
+
+ // reference counting stuff needed by ANTLRTokenPtr.
+ // User should not access these; for C++ language reasons, we had
+ // to make these public. Yuck.
+
+ void ref() { refcnt_++; }
+ void deref() { refcnt_--; }
+ unsigned nref() const { return refcnt_; } // MR11
+
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ panic("call to ANTLRRefCountToken::makeToken()\n");
+ return NULL;
+ }
+};
+
+class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {
+protected:
+ ANTLRTokenType _type;
+ int _line;
+ ANTLRChar *_text; // MR9 RJV
+
+public:
+ ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s)
+ { setType(t); _line = 0; _text = NULL; setText(s); }
+ ANTLRCommonNoRefCountToken()
+ { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }
+
+ ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string
+
+ ANTLRTokenType getType() const { return _type; }
+ void setType(ANTLRTokenType t) { _type = t; }
+ virtual int getLine() const { return _line; }
+ void setLine(int line) { _line = line; }
+ ANTLRChar *getText() const { return _text; }
+ int getLength() const { return strlen(getText()); } // MR11
+
+// MR9 RJV: Added code for variable length strings to setText()
+
+ void setText(const ANTLRChar *s)
+ { if (s != _text) {
+ if (_text) delete [] _text;
+ if (s != NULL) {
+ _text = new ANTLRChar[strlen(s)+1];
+ if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");
+ strcpy(_text,s);
+ } else {
+ _text = new ANTLRChar[1];
+ if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");
+ strcpy(_text,"");
+ };
+ };
+ }
+
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;
+ t->setType(tt); t->setText(txt); t->setLine(line);
+ return t;
+ }
+
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics
+
+ ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) :
+ ANTLRAbstractToken(from) {
+ setType(from._type);
+ setLine(from._line);
+ _text=NULL;
+ setText(from._text);
+ };
+
+// MR9 THM operator =() required when heap allocated string is used with copy semantics
+
+ virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) {
+
+////// MR15 WatCom can't hack use of operator =()
+////// Use this: *( (ANTRLAbstractToken *) this)=rhs;
+
+ *( (ANTLRAbstractToken *) this ) = rhs;
+
+ setType(rhs._type);
+ setLine(rhs._line);
+ setText(rhs._text);
+ return *this;
+ };
+};
+
+class ANTLRCommonToken : public ANTLRRefCountToken {
+protected:
+ ANTLRTokenType _type;
+ int _line;
+ ANTLRChar *_text; // MR9 RJV:Added
+
+public:
+ ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s)
+ { setType(t); _line = 0; _text = NULL; setText(s); } // MR9
+ ANTLRCommonToken()
+ { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); } // MR9
+
+ virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string
+
+ ANTLRTokenType getType() const { return _type; }
+ void setType(ANTLRTokenType t) { _type = t; }
+ virtual int getLine() const { return _line; }
+ void setLine(int line) { _line = line; }
+ ANTLRChar *getText() const { return _text; }
+ int getLength() const { return strlen(getText()); } // MR11
+
+// MR9 RJV: Added code for variable length strings to setText()
+
+ void setText(const ANTLRChar *s)
+ { if (s != _text) {
+ if (_text) delete [] _text;
+ if (s != NULL) {
+ _text = new ANTLRChar[strlen(s)+1];
+ if (_text == NULL) panic("ANTLRCommonToken::setText new failed");
+ strcpy(_text,s);
+ } else {
+ _text = new ANTLRChar[1];
+ if (_text == NULL) panic("ANTLRCommonToken::setText new failed");
+ strcpy(_text,"");
+ };
+ };
+ }
+
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);
+ t->setLine(line);
+ return t;
+ }
+
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics
+
+ ANTLRCommonToken (const ANTLRCommonToken& from) :
+ ANTLRRefCountToken(from) {
+ setType(from._type);
+ setLine(from._line);
+ _text=NULL;
+ setText(from._text);
+ };
+
+// MR9 THM operator =() required when heap allocated string is used with copy semantics
+
+ virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) {
+
+////// MR15 WatCom can't hack use of operator =()
+////// Use this instead: *( (ANTRLRRefCountToken *) this)=rhs;
+
+ *( (ANTLRRefCountToken *) this) = rhs;
+
+ setType(rhs._type);
+ setLine(rhs._line);
+ setText(rhs._text);
+ return *this;
+ };
+};
+
+// used for backward compatibility
+typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp
new file mode 100644
index 0000000000..a7b10c72d0
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp
@@ -0,0 +1,345 @@
+/* ANTLRTokenBuffer.C
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+typedef int ANTLRTokenType; // fool AToken.h into compiling
+
+class ANTLRParser; /* MR1 */
+
+#define ANTLR_SUPPORT_CODE
+
+#include "pcctscfg.h"
+
+#include ATOKENBUFFER_H
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;
+
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
+static unsigned char test[1000];
+#endif
+
+#ifdef DBG_REFCOUNTTOKEN
+int ANTLRCommonToken::ctor = 0;
+int ANTLRCommonToken::dtor = 0;
+#endif
+
+ANTLRTokenBuffer::
+ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */
+{
+ this->input = _input;
+ this->k = _k;
+ buffer_size = chunk_size = _chunk_size_formal;
+ buffer = (_ANTLRTokenPtr *)
+ calloc(chunk_size+1,sizeof(_ANTLRTokenPtr ));
+ if ( buffer == NULL ) {
+ panic("cannot alloc token buffer");
+ }
+ buffer++; // leave the first elem empty so tp-1 is valid ptr
+
+ tp = &buffer[0];
+ last = tp-1;
+ next = &buffer[0];
+ num_markers = 0;
+ end_of_buffer = &buffer[buffer_size-1];
+ // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))];
+ threshold = &buffer[(int)(buffer_size / 2)];
+ _deleteTokens = 1; // assume we delete tokens
+ parser=NULL; // MR5 - uninitialized reference
+}
+
+static void f() {;}
+ANTLRTokenBuffer::
+~ANTLRTokenBuffer()
+{
+ f();
+ // Delete all remaining tokens (from 0..last inclusive)
+ if ( _deleteTokens )
+ {
+ _ANTLRTokenPtr *z;
+ for (z=buffer; z<=last; z++)
+ {
+ (*z)->deref();
+// z->deref();
+#ifdef DBG_REFCOUNTTOKEN
+ fprintf(stderr, "##########dtor: deleting token '%s' (ref %d)\n",
+ ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());
+#endif
+ if ( (*z)->nref()==0 )
+ {
+ delete (*z);
+ }
+ }
+ }
+
+ if ( buffer!=NULL ) free((char *)(buffer-1));
+}
+
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
+#include "pccts_stdio.h"
+PCCTS_NAMESPACE_STD
+#endif
+
+_ANTLRTokenPtr ANTLRTokenBuffer::
+getToken()
+{
+ if ( tp <= last ) // is there any buffered lookahead still to be read?
+ {
+ return *tp++; // read buffered lookahead
+ }
+ // out of buffered lookahead, get some more "real"
+ // input from getANTLRToken()
+ if ( num_markers==0 )
+ {
+ if( next > threshold )
+ {
+#ifdef DBG_TBUF
+fprintf(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);
+#endif
+ makeRoom();
+ }
+ }
+ else {
+ if ( next > end_of_buffer )
+ {
+#ifdef DBG_TBUF
+fprintf(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size);
+#endif
+ extendBuffer();
+ }
+ }
+ *next = getANTLRToken();
+ (*next)->ref(); // say we have a copy of this pointer in buffer
+ last = next;
+ next++;
+ tp = last;
+ return *tp++;
+}
+
+void ANTLRTokenBuffer::
+rewind(int pos)
+{
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
+ fprintf(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]);
+ test[pos]--;
+#endif
+ tp = &buffer[pos];
+ num_markers--;
+}
+
+/*
+ * This function is used to specify that the token pointers read
+ * by the ANTLRTokenBuffer should be buffered up (to be reused later).
+ */
+int ANTLRTokenBuffer::
+mark()
+{
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
+ test[tp-buffer]++;
+ fprintf(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]);
+#endif
+ num_markers++;
+ return tp - buffer;
+}
+
+/*
+ * returns the token pointer n positions ahead.
+ * This implies that bufferedToken(1) gets the NEXT symbol of lookahead.
+ * This is used in conjunction with the ANTLRParser lookahead buffer.
+ *
+ * No markers are set or anything. A bunch of input is buffered--that's all.
+ * The tp pointer is left alone as the lookahead has not been advanced
+ * with getToken(). The next call to getToken() will find a token
+ * in the buffer and won't have to call getANTLRToken().
+ *
+ * If this is called before a consume() is done, how_many_more_i_need is
+ * set to 'n'.
+ */
+_ANTLRTokenPtr ANTLRTokenBuffer::
+bufferedToken(int n)
+{
+// int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1;
+ int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1;
+ // Make sure that at least n tokens are available in the buffer
+#ifdef DBG_TBUF
+ fprintf(stderr, "bufferedToken(%d)\n", n);
+#endif
+ for (int i=1; i<=how_many_more_i_need; i++)
+ {
+ if ( next > end_of_buffer ) // buffer overflow?
+ {
+ extendBuffer();
+ }
+ *next = getANTLRToken();
+ (*next)->ref(); // say we have a copy of this pointer in buffer
+ last = next;
+ next++;
+ }
+ return tp[n - 1];
+}
+
+/* If no markers are set, the none of the input needs to be saved (except
+ * for the lookahead Token pointers). We save only k-1 token pointers as
+ * we are guaranteed to do a getANTLRToken() right after this because otherwise
+ * we wouldn't have needed to extend the buffer.
+ *
+ * If there are markers in the buffer, we need to save things and so
+ * extendBuffer() is called.
+ */
+void ANTLRTokenBuffer::
+makeRoom()
+{
+#ifdef DBG_TBUF
+ fprintf(stderr, "in makeRoom.................\n");
+ fprintf(stderr, "num_markers==%d\n", num_markers);
+#endif
+/*
+ if ( num_markers == 0 )
+ {
+*/
+#ifdef DBG_TBUF
+ fprintf(stderr, "moving lookahead and resetting next\n");
+
+ _ANTLRTokenPtr *r;
+ fprintf(stderr, "tbuf = [");
+ for (r=buffer; r<=last; r++)
+ {
+ if ( *r==NULL ) fprintf(stderr, " xxx");
+ else fprintf(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());
+ }
+ fprintf(stderr, " ]\n");
+
+ fprintf(stderr,
+ "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer);
+#endif
+
+ // Delete all tokens from 0..last-(k-1) inclusive
+ if ( _deleteTokens )
+ {
+ _ANTLRTokenPtr *z;
+ for (z=buffer; z<=last-(k-1); z++)
+ {
+ (*z)->deref();
+// z->deref();
+#ifdef DBG_REFCOUNTTOKEN
+ fprintf(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n",
+ ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());
+#endif
+ if ( (*z)->nref()==0 )
+ {
+ delete (*z);
+ }
+ }
+ }
+
+ // reset the buffer to initial conditions, but move k-1 symbols
+ // to the beginning of buffer and put new input symbol at k
+ _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1;
+// ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1;
+#ifdef DBG_TBUF
+ fprintf(stderr, "lookahead buffer = [");
+#endif
+ for (int i=1; i<=(k-1); i++)
+ {
+ *p++ = *q++;
+#ifdef DBG_TBUF
+ fprintf(stderr,
+ " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());
+#endif
+ }
+#ifdef DBG_TBUF
+ fprintf(stderr, " ]\n");
+#endif
+ next = &buffer[k-1];
+ tp = &buffer[k-1]; // tp points to what will be filled in next
+ last = tp-1;
+#ifdef DBG_TBUF
+ fprintf(stderr,
+ "after: tp=%d, last=%d, next=%d\n",
+ tp-buffer, last-buffer, next-buffer);
+#endif
+/*
+ }
+ else {
+ extendBuffer();
+ }
+*/
+}
+
+/* This function extends 'buffer' by chunk_size and returns with all
+ * pointers at the same relative positions in the buffer (the buffer base
+ * address could have changed in realloc()) except that 'next' comes
+ * back set to where the next token should be stored. All other pointers
+ * are untouched.
+ */
+void
+ANTLRTokenBuffer::
+extendBuffer()
+{
+ int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer;
+#ifdef DBG_TBUF
+ fprintf(stderr, "extending physical buffer\n");
+#endif
+ buffer_size += chunk_size;
+ buffer = (_ANTLRTokenPtr *)
+ realloc((char *)(buffer-1),
+ (buffer_size+1)*sizeof(_ANTLRTokenPtr ));
+ if ( buffer == NULL ) {
+ panic("cannot alloc token buffer");
+ }
+ buffer++; // leave the first elem empty so tp-1 is valid ptr
+
+ tp = buffer + save_tp; // put the pointers back to same relative position
+ last = buffer + save_last;
+ next = buffer + save_next;
+ end_of_buffer = &buffer[buffer_size-1];
+ // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))];
+ threshold = &buffer[(int)(buffer_size / 2)];
+
+/*
+ // zero out new token ptrs so we'll know if something to delete in buffer
+ ANTLRAbstractToken **p = end_of_buffer-chunk_size+1;
+ for (; p<=end_of_buffer; p++) *p = NULL;
+*/
+}
+
+ANTLRParser * ANTLRTokenBuffer:: // MR1
+setParser(ANTLRParser *p) { // MR1
+ ANTLRParser *old=parser; // MR1
+ parser=p; // MR1
+ input->setParser(p); // MR1
+ return old; // MR1
+} // MR1
+ // MR1
+ANTLRParser * ANTLRTokenBuffer:: // MR1
+getParser() { // MR1
+ return parser; // MR1
+} // MR1
+
+/* to avoid having to link in another file just for the smart token ptr
+ * stuff, we include it here. Ugh.
+ */
+#include ATOKPTR_C
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h
new file mode 100644
index 0000000000..719e05944e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h
@@ -0,0 +1,106 @@
+/* ANTLRTokenBuffer.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ATOKENBUFFER_H_GATE
+#define ATOKENBUFFER_H_GATE
+
+#include "pcctscfg.h"
+
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+#include ATOKEN_H
+#include ATOKENSTREAM_H
+
+/*
+ * The parser is "attached" to an ANTLRTokenBuffer via interface
+ * functions: getToken() and bufferedToken(). The object that actually
+ * consumes characters and constructs tokens is connected to the
+ * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();
+ * where ANTLRTokenStream is really just a behavior (class with no data).
+ * C++ does not have this abstraction and hence we simply have come up
+ * with a fancy name for "void *". See the note in ANTLRTokenStream.h on
+ * the "behavior" of ANTLRTokenStream.
+ */
+
+class ANTLRParser; // MR1
+
+class DllExportPCCTS ANTLRTokenBuffer {
+protected:
+ ANTLRTokenStream *input; // where do I get tokens
+ int buffer_size;
+ int chunk_size;
+ int num_markers;
+ int k; // Need at least this many tokens in buffer
+ _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead
+ _ANTLRTokenPtr *tp; // pts into buffer; current token ptr
+ _ANTLRTokenPtr *last; // pts to last valid token in buffer
+ _ANTLRTokenPtr *next; // place to put token from getANTLRToken()
+ _ANTLRTokenPtr *end_of_buffer;
+ /* when you try to write a token past this and there are no markers
+ set, then move k-1 tokens back to the beginning of the buffer.
+ We want to stay away from the end of the buffer because we have
+ to extend it if a marker is set and we reach the end (we cannot
+ move tokens to the beginning of the buffer in this case).
+ */
+ _ANTLRTokenPtr *threshold;
+ unsigned char _deleteTokens;
+
+ // This function is filled in by the subclass; it initiates fetch of input
+ virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }
+ void makeRoom();
+ void extendBuffer();
+
+public:
+ ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);
+ virtual ~ANTLRTokenBuffer();
+ virtual _ANTLRTokenPtr getToken();
+ virtual void rewind(int pos);
+ virtual int mark();
+ virtual _ANTLRTokenPtr bufferedToken(int i);
+
+ void noGarbageCollectTokens() { _deleteTokens=0; }
+ void garbageCollectTokens() { _deleteTokens=1; }
+
+ virtual int bufferSize() { return buffer_size; }
+ virtual int minTokens() { return k; }
+ virtual void setMinTokens(int k_new) { k = k_new; }
+
+ virtual void panic(const char *msg) { exit(PCCTS_EXIT_FAILURE); } /* MR20 const */
+protected: // MR1
+ ANTLRParser *parser; // MR1
+public: // MR1
+ ANTLRParser *setParser(ANTLRParser *p); // MR1
+ ANTLRParser *getParser(); // MR1
+ ANTLRTokenStream *getLexer() const { // MR12
+ return input;} // MR12
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h
new file mode 100644
index 0000000000..a603707bfd
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h
@@ -0,0 +1,51 @@
+/* ANTLRTokenStream.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ATOKENSTREAM_H_GATE
+#define ATOKENSTREAM_H_GATE
+
+#include "pcctscfg.h"
+
+/* This is really a behavior or protocol; it merely indicates the behavior
+ * required of the input and output of an ANTLRTokenBuffer. You could
+ * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer
+ * with a type cast (in which case, your getANTLRToken() would have to
+ * explicitly cast the input pointer to your REAL type (typically your lexer)).
+ */
+
+class ANTLRParser; // MR1
+
+class DllExportPCCTS ANTLRTokenStream {
+public:
+ virtual _ANTLRTokenPtr getToken() = 0;
+ virtual ANTLRParser * setParser(ANTLRParser *p) {return 0; }; // MR12
+ virtual ANTLRParser * getParser() { return 0; }; // MR12
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h
new file mode 100644
index 0000000000..b4d69477bd
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h
@@ -0,0 +1,215 @@
+/* ANTLRToken.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ATOKEN_H_GATE
+#define ATOKEN_H_GATE
+
+#include "pcctscfg.h"
+
+#include "pccts_string.h"
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+#ifndef ANTLRCommonTokenTEXTSIZE
+#define ANTLRCommonTokenTEXTSIZE 100
+#endif
+
+/* must define what a char looks like; can make this a class too */
+typedef char ANTLRChar;
+
+/* D E F I N E S M A R T P O I N T E R S */
+
+#include "pcctscfg.h"
+
+//#include ATOKPTR_H not tested yet, leave out
+class ANTLRAbstractToken;
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;
+
+class DllExportPCCTS ANTLRAbstractToken {
+public:
+ virtual ~ANTLRAbstractToken() {;}
+ virtual ANTLRTokenType getType() = 0;
+ virtual void setType(ANTLRTokenType t) = 0;
+ virtual int getLine() = 0;
+ virtual void setLine(int line) = 0;
+ virtual ANTLRChar *getText() = 0;
+ virtual void setText(ANTLRChar *) = 0;
+
+ /* This function will disappear when I can use templates */
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *text,
+ int line) = 0;
+
+ /* define to satisfy ANTLRTokenBuffer's need to determine whether or
+ not a token object can be destroyed. If nref()==0, no one has
+ a reference, and the object may be destroyed. This function defaults
+ to 1, hence, if you use deleteTokens() message with a token object
+ not derived from ANTLRCommonRefCountToken, the parser will compile
+ but will not delete objects after they leave the token buffer.
+ */
+ virtual unsigned nref() { return 1; }
+ virtual void ref() {;}
+ virtual void deref() {;}
+
+ virtual void panic(char *msg)
+ {
+ fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+};
+
+/* This class should be subclassed. It cannot store token type or text */
+
+class DllExportPCCTS ANTLRRefCountToken : public ANTLRAbstractToken {
+public:
+#ifdef DBG_REFCOUNTTOKEN
+ static int ctor;
+ static int dtor;
+#endif
+protected:
+ unsigned refcnt_;
+#ifdef DBG_REFCOUNTTOKEN
+ char object[200];
+#endif
+
+public:
+ ANTLRRefCountToken(ANTLRTokenType t, ANTLRChar *s)
+#ifndef DBG_REFCOUNTTOKEN
+ {
+ refcnt_ = 0;
+ }
+#else
+ {
+ ctor++;
+ refcnt_ = 0;
+ if ( t==1 ) sprintf(object,"tok_EOF");
+ else sprintf(object,"tok_%s",s);
+ fprintf(stderr, "ctor %s #%d\n",object,ctor);
+ }
+#endif
+ ANTLRRefCountToken()
+#ifndef DBG_REFCOUNTTOKEN
+ { refcnt_ = 0; }
+#else
+ {
+ ctor++;
+ refcnt_ = 0;
+ sprintf(object,"tok_blank");
+ fprintf(stderr, "ctor %s #%d\n",object,ctor);
+ }
+ virtual ~ANTLRRefCountToken()
+ {
+ dtor++;
+ if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n");
+ fprintf(stderr, "dtor %s #%d\n", object, dtor);
+ object[0]='\0';
+ }
+#endif
+
+ // reference counting stuff needed by ANTLRTokenPtr.
+ // User should not access these; for C++ language reasons, we had
+ // to make these public. Yuck.
+ void ref() { refcnt_++; }
+ void deref() { refcnt_--; }
+ unsigned nref() { return refcnt_; }
+
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ panic("call to ANTLRRefCountToken::makeToken()\n");
+ return NULL;
+ }
+};
+
+class DllExportPCCTS ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {
+protected:
+ ANTLRTokenType _type;
+ int _line;
+ ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1];
+
+public:
+ ANTLRCommonNoRefCountToken(ANTLRTokenType t, ANTLRChar *s)
+ { setType(t); _line = 0; setText(s); }
+ ANTLRCommonNoRefCountToken()
+ { setType((ANTLRTokenType)0); _line = 0; setText(""); }
+
+ ANTLRTokenType getType() { return _type; }
+ void setType(ANTLRTokenType t) { _type = t; }
+ virtual int getLine() { return _line; }
+ void setLine(int line) { _line = line; }
+ ANTLRChar *getText() { return _text; }
+ void setText(ANTLRChar *s)
+ { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); }
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;
+ t->setType(tt); t->setText(txt); t->setLine(line);
+ return t;
+ }
+};
+
+class DllExportPCCTS ANTLRCommonToken : public ANTLRRefCountToken {
+protected:
+ ANTLRTokenType _type;
+ int _line;
+ ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1];
+
+public:
+ ANTLRCommonToken(ANTLRTokenType t, ANTLRChar *s) : ANTLRRefCountToken(t,s)
+ { setType(t); _line = 0; setText(s); }
+ ANTLRCommonToken()
+ { setType((ANTLRTokenType)0); _line = 0; setText(""); }
+ virtual ~ANTLRCommonToken() {;}
+
+ ANTLRTokenType getType() { return _type; }
+ void setType(ANTLRTokenType t) { _type = t; }
+ virtual int getLine() { return _line; }
+ void setLine(int line) { _line = line; }
+ ANTLRChar *getText() { return _text; }
+ void setText(ANTLRChar *s)
+ { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); }
+ virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
+ ANTLRChar *txt,
+ int line)
+ {
+ ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);
+ t->setLine(line);
+ return t;
+ }
+};
+
+// used for backward compatibility
+typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp
new file mode 100644
index 0000000000..99d08a42a4
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp
@@ -0,0 +1,100 @@
+// FILE: BufFileInput.cpp
+// AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru
+// CREATION: 26-JAN-1998
+// DESCRIPTION: File Input Stream with lookahead for Scanner.
+// See file BufFileInput.h for details
+
+// Change History:
+//
+// 22-Jun-1998 assert.h -> PCCTS_ASSERT_H
+// string.h -> PCCTS_STRING_H
+//
+// 28-May-1998 Add virtual destructor to release buffer.
+//
+// Add dummy definition for ANTLRTokenType
+// to allow compilation without knowing
+// token type codes.
+//
+// Manfred Kogler (km@cast.uni-linz.ac.at)
+// (1.33MR14)
+//
+// 20-Jul-1998 MR14a - Reorder initialization list for ctor.
+//
+
+enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 };
+
+#include "pcctscfg.h"
+#include "pccts_assert.h"
+#include "pccts_string.h"
+
+PCCTS_NAMESPACE_STD
+
+#include "BufFileInput.h"
+
+BufFileInput::BufFileInput( FILE *f, int buf_size )
+: input( f ),
+ buf( new int[buf_size] ),
+ size( buf_size ),
+ start( 0 ),
+ len( 0 )
+{
+}
+
+BufFileInput::~BufFileInput()
+{
+ delete [] buf;
+}
+
+int BufFileInput::nextChar( void )
+{
+ if( len > 0 )
+ {
+ // get char from buffer
+ int c = buf[start];
+
+ if( c != EOF )
+ {
+ start++; start %= size;
+ len--;
+ }
+ return c;
+ } else {
+ // get char from file
+ int c = getc( input );
+
+ if( c == EOF )
+ {
+ // if EOF - put it in the buffer as indicator
+ buf[start] = EOF;
+ len++;
+ }
+ return c;
+ }
+}
+
+int BufFileInput::lookahead( char* s )
+{
+ int l = strlen( s );
+
+ assert( 0 < l && l <= size );
+
+ while( len < l )
+ {
+ int c = getc( input );
+
+ buf[ (start+len) % size ] = c;
+
+ len++;
+
+ if( c == EOF ) return 0;
+ }
+
+ for( int i = 0; i < l; i++ )
+ {
+ if( s[i] != buf[ (start+i) % size ] ) return 0;
+ }
+ return 1;
+}
+
+// End of file BufFileInput.cpp
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h
new file mode 100644
index 0000000000..ea54c0ee26
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h
@@ -0,0 +1,53 @@
+// FILE: BufFileInput.h
+// AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru
+// CREATION: 26-JAN-1998
+// DESCRIPTION: File Input Stream with lookahead for Scanner
+// Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0
+
+// Change History:
+//
+// 28-May-1998 Add virtual destructor to release buffer
+// Manfred Kogler (km@cast.uni-linz.ac.at)
+// (1.33MR14)
+
+#ifndef BufFileInput_h
+#define BufFileInput_h
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+
+PCCTS_NAMESPACE_STD
+
+#include "DLexerBase.h"
+
+class DllExportPCCTS BufFileInput : public DLGInputStream
+{
+public:
+ // constructor
+ // f - input stream
+ // buf_size - size of buffer (maximal length for string in is_in)
+
+ BufFileInput(FILE *f, int buf_size = 8 );
+
+ virtual ~BufFileInput();
+
+ // gets next char from stream
+
+ virtual int nextChar( void );
+
+ // looks in stream and compares next l characters with s
+ // returns the result of comparision
+
+ int lookahead( char* s );
+
+private:
+ FILE *input; // input stream;
+ int* buf; // buffer
+ int size; // size of buffer
+ int start; // position of the first symbol in buffer
+ int len; // count of characters in buffers
+};
+
+#endif
+// end of file BufFileInput.h
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h
new file mode 100644
index 0000000000..39892bb899
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h
@@ -0,0 +1,98 @@
+
+/************************************************************/
+/* */
+/* Predefined char stream: Input from (c++) stream. */
+/* */
+/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998. */
+/* */
+/* This is completely free stuff, do whatever you want with */
+/* it (but then, I will take no responsability for whatever */
+/* may happen if you do either... caveat emptor!). */
+/* */
+/************************************************************/
+
+#ifndef _DLG_STREAM_INPUT_H
+#define _DLG_STREAM_INPUT_H
+
+#include "pccts_istream.h"
+
+PCCTS_NAMESPACE_STD
+
+#ifndef DLGX_H
+#include "DLexerBase.h"
+#endif
+
+
+// NOTES: The semantics of the copy constructor
+// and the affectation operator may be unwaranted...
+// and the stream may not be reset.
+//
+// It would have been so much nicer for nextChar()
+// to throw (of for the DLGInputStream to change status)
+// upon hiting EOF than to return an "int"...
+
+template <
+ class E,
+ class T = ::std::char_traits<E>
+ >
+class DLG_stream_input : public DLGInputStream
+{
+public:
+
+ DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)
+ : input(p_input_stream)
+ {
+ // nothing to do!
+ };
+
+ DLG_stream_input(const DLG_stream_input & a_recopier)
+ : input(a_recopier.input)
+ {
+ // nothing to do!
+ };
+
+ virtual ~DLG_stream_input()
+ {
+ this->purge(); // bloody templarized lookup...
+ };
+
+ DLG_stream_input operator = (const DLG_stream_input & a_affecter)
+ {
+ if (this != &a_affecter)
+ {
+ input = a_affecter.input;
+ }
+
+ return(*this);
+ };
+
+ virtual int nextChar()
+ {
+ E extracted_stuff;
+
+ input->get(extracted_stuff);
+
+ if (*input)
+ {
+ return(int(extracted_stuff));
+ }
+ else
+ {
+ return(EOF);
+ }
+ };
+
+protected:
+
+ ::std::basic_istream<E,T> * input;
+
+private:
+
+ void purge()
+ {
+ // nothing to do!
+ };
+};
+
+#endif /* _DLG_STREAM_INPUT_H */
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp
new file mode 100644
index 0000000000..003253bd3e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp
@@ -0,0 +1,188 @@
+/* DLexer.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#define ZZINC {if ( track_columns ) (++_endcol);}
+
+#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
+
+#define ZZNEWSTATE (newstate = dfa[state][cl])
+
+#ifndef ZZCOPY
+#define ZZCOPY \
+ /* Truncate matching buffer to size (not an error) */ \
+ if (nextpos < lastpos){ \
+ *(nextpos++) = ch; \
+ }else{ \
+ bufovf = 1; \
+ }
+#endif
+
+void DLGLexer::
+mode( int m )
+{
+ /* points to base of dfa table */
+ if (m<MAX_MODE){
+ automaton = m;
+ /* have to redo class since using different compression */
+ cl = ZZSHIFT(ch);
+ }else{
+ sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);
+ errstd(ebuf);
+ }
+}
+
+ANTLRTokenType DLGLexer::
+nextTokenType(void)
+{
+ register int state, newstate;
+ /* last space reserved for the null char */
+ register DLGChar *lastpos;
+ ANTLRTokenType tk;
+
+skip:
+ bufovf = 0;
+ lastpos = &_lextext[_bufsize-1];
+ nextpos = _lextext;
+ _begcol = _endcol+1;
+more:
+ _begexpr = nextpos;
+ if ( interactive ) {
+ /* interactive version of automaton */
+ /* if there is something in ch, process it */
+ state = newstate = dfa_base[automaton];
+ if (charfull){
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ while (alternatives[newstate]){
+ state = newstate;
+ ZZGETC;
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ /* figure out if last character really part of token */
+ if ((state != dfa_base[automaton]) && (newstate == DfaStates)){
+ charfull = 1;
+ --nextpos;
+ }else{
+ charfull = 0;
+ state = newstate;
+ }
+ *(nextpos) = '\0';
+ /* Able to transition out of start state to some non err state?*/
+ if ( state == dfa_base[automaton] ){
+ /* make sure doesn't get stuck */
+ advance();
+ }
+ }
+ else { /* non-interactive version of automaton */
+ if (!charfull)
+ advance();
+ else
+ ZZINC;
+ state = dfa_base[automaton];
+ while (ZZNEWSTATE != DfaStates) {
+ state = newstate;
+ ZZCOPY;
+ ZZGETC;
+ ZZINC;
+ }
+ charfull = 1;
+ if ( state == dfa_base[automaton] ){
+ if (nextpos < lastpos){
+ *(nextpos++) = ch;
+ }else{
+ bufovf = 1;
+ }
+ *nextpos = '\0';
+ /* make sure doesn't get stuck */
+ advance();
+ }else{
+ *nextpos = '\0';
+ }
+ }
+ if ( track_columns ) _endcol -= charfull;
+ _endexpr = nextpos -1;
+ add_erase = 0;
+#ifdef OLD
+ tk = (ANTLRTokenType)
+ (*actions[accepts[state]])(this); // must pass this manually
+ // actions is not a [] of pointers
+ // to member functions.
+#endif
+ tk = (this->*actions[accepts[state]])();
+
+// MR1
+// MR1 11-Apr-97 Help for tracking DLG results
+// MR1
+
+#ifdef DEBUG_LEXER
+
+/* MR1 */ if (debugLexerFlag) {
+/* MR1 */ if (parser != NULL) {
+/* MR1 */ printf("\ntoken name=%s",parser->parserTokenName(tk));
+/* MR1 */ } else {
+/* MR1 */ printf("\ntoken nnumber=%d",tk);
+/* MR1 */ };
+/* MR1 */ printf(" lextext=(%s) mode=%d",
+/* MR1 */ (_lextext[0]=='\n' && _lextext[1]==0) ?
+/* MR1 */ "newline" : _lextext,
+/* MR1 */ automaton);
+/* MR1 */ if (interactive && !charfull) {
+/* MR1 */ printf(" char=empty");
+/* MR1 */ } else {
+/* MR1 */ if (ch=='\n') {
+/* MR1 */ printf(" char=newline");
+/* MR1 */ } else {
+/* MR1 */ printf(" char=(%c)",ch);
+/* MR1 */ };
+/* MR1 */ };
+/* MR1 */ printf(" %s\n",
+/* MR1 */ (add_erase==1 ? "skip()" :
+/* MR1 */ add_erase==2 ? "more()" :
+/* MR1 */ ""));
+/* MR1 */ };
+
+#endif
+
+ switch (add_erase) {
+ case 1: goto skip;
+ case 2: goto more;
+ }
+ return tk;
+}
+
+void DLGLexer::
+advance()
+{
+ if ( input==NULL ) err_in();
+ ZZGETC; charfull = 1; ZZINC;
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp
new file mode 100644
index 0000000000..220a846a7c
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp
@@ -0,0 +1,268 @@
+/* DLGLexerBase.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+/* I have to put this here due to C++ limitation
+ * that you can't have a 'forward' decl for enums.
+ * I hate C++!!!!!!!!!!!!!!!
+ */
+
+// MR1
+// MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the
+// MR1 ANTLRTokenType enum
+// MR1
+
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE, // MR1
+ WITH_SOME_GOOD_IDEAS=9999}; // MR1
+
+#define ANTLR_SUPPORT_CODE
+
+#include "pcctscfg.h"
+#include DLEXERBASE_H
+
+DLGLexerBase::
+DLGLexerBase(DLGInputStream *in,
+ unsigned bufsize,
+ int _interactive,
+ int _track_columns)
+{
+ this->_bufsize = bufsize;
+ this->_lextext = new DLGChar[_bufsize];
+ if ( this->_lextext==NULL ) {
+ panic("text buffer is NULL");
+ }
+ this->_begexpr = this->_endexpr = NULL;
+ this->ch = this->bufovf = 0;
+ this->nextpos = NULL;
+ this->cl = 0;
+ this->add_erase = 0;
+ this->input = in;
+ this->_begcol = 0;
+ this->_endcol = 0;
+ this->_line = 1;
+ this->charfull = 0;
+ this->automaton = 0;
+ this->token_to_fill = NULL;
+ this->interactive = _interactive;
+ this->track_columns = _track_columns;
+ this->debugLexerFlag = 0; // MR1
+ this->parser = NULL; // MR1
+ this->lexErrCount=0; // MR11
+}
+
+// MR19 THM
+
+void DLGLexerBase::reset()
+{
+ this->charfull = 0;
+ this->_begcol = 0;
+ this->_endcol = 0;
+ this->automaton = 0;
+ this->_line=1;
+ this->lexErrCount=0;
+}
+
+void DLGLexerBase::
+setInputStream( DLGInputStream *in )
+{
+ this->input = in;
+ _line = 1;
+ charfull = 0;
+}
+
+/* saves dlg state, but not what feeds dlg (such as file position) */
+void DLGLexerBase::
+saveState(DLGState *state)
+{
+ state->input = input;
+ state->interactive = interactive;
+ state->track_columns = track_columns;
+ state->auto_num = automaton;
+ state->add_erase = add_erase;
+ state->lookc = ch;
+ state->char_full = charfull;
+ state->begcol = _begcol;
+ state->endcol = _endcol;
+ state->line = _line;
+ state->lextext = _lextext;
+ state->begexpr = _begexpr;
+ state->endexpr = _endexpr;
+ state->bufsize = _bufsize;
+ state->bufovf = bufovf;
+ state->nextpos = nextpos;
+ state->class_num = cl;
+ state->debugLexerFlag = debugLexerFlag; // MR1
+ state->parser = parser; // MR1
+}
+
+void DLGLexerBase::
+restoreState(DLGState *state)
+{
+ input = state->input;
+ interactive = state->interactive;
+ track_columns = state->track_columns;
+ automaton = state->auto_num;
+ add_erase = state->add_erase;
+ ch = state->lookc;
+ charfull = state->char_full;
+ _begcol = state->begcol;
+ _endcol = state->endcol;
+ _line = state->line;
+ _lextext = state->lextext;
+ _begexpr = state->begexpr;
+ _endexpr = state->endexpr;
+ _bufsize = state->bufsize;
+ bufovf = state->bufovf;
+ nextpos = state->nextpos;
+ cl = state->class_num;
+ debugLexerFlag = state->debugLexerFlag; // MR1
+ parser = state->parser; // MR1
+}
+
+/* erase what is currently in the buffer, and get a new reg. expr */
+void DLGLexerBase::
+skip()
+{
+ add_erase = 1;
+}
+
+/* don't erase what is in the lextext buffer, add on to it */
+void DLGLexerBase::
+more()
+{
+ add_erase = 2;
+}
+
+/* substitute c for the reg. expr last matched and is in the buffer */
+void DLGLexerBase::
+replchar(DLGChar c)
+{
+ /* can't allow overwriting null at end of string */
+ if (_begexpr < &_lextext[_bufsize-1]){
+ *_begexpr = c;
+ *(_begexpr+1) = '\0';
+ }
+ _endexpr = _begexpr;
+ nextpos = _begexpr + 1;
+}
+
+/* replace the string s for the reg. expr last matched and in the buffer */
+
+void DLGLexerBase::
+replstr(const DLGChar *s) /* MR20 const */
+{
+ register DLGChar *l= &_lextext[_bufsize -1];
+
+ nextpos = _begexpr;
+ if (s){
+ while ((nextpos <= l) && (*(nextpos++) = *(s++))){
+ /* empty */
+ }
+ /* correct for NULL at end of string */
+ nextpos--;
+ }
+ if ((nextpos <= l) && (*(--s) == 0)){
+ bufovf = 0;
+ }else{
+ bufovf = 1;
+ }
+ *(nextpos) = '\0';
+ _endexpr = nextpos - 1;
+}
+
+void DLGLexerBase::
+errstd(const char *s) /* MR20 const */
+{
+ lexErrCount++; /* MR11 */
+ fprintf(stderr,
+ "%s near line %d (text was '%s')\n",
+ ((s == NULL) ? "Lexical error" : s),
+ _line,_lextext);
+}
+
+int DLGLexerBase::
+err_in()
+{
+ fprintf(stderr,"No input stream, function, or string\n");
+ /* return eof to get out gracefully */
+ return EOF;
+}
+
+ANTLRTokenType DLGLexerBase::
+erraction()
+{
+ errstd("invalid token");
+ advance();
+ skip();
+ return (ANTLRTokenType) 0; // bogus, but satisfies compiler
+}
+
+_ANTLRTokenPtr DLGLexerBase::
+getToken()
+{
+ if ( token_to_fill==NULL ) panic("NULL token_to_fill");
+ ANTLRTokenType tt = nextTokenType();
+ _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line);
+ return tk;
+}
+
+void DLGLexerBase::
+panic(const char *msg) /* MR20 const */
+{
+ fprintf(stderr, "DLG panic: %s\n", msg);
+//
+// 7-Apr-97 133MR1
+//
+ exit(PCCTS_EXIT_FAILURE); // MR1
+}
+
+ANTLRParser * DLGLexerBase:: // MR1
+setParser(ANTLRParser *p) { // MR1
+ ANTLRParser *oldValue=parser; // MR1
+ parser=p; // MR1
+ return oldValue; // MR1
+} // MR1
+ // MR1
+ANTLRParser * DLGLexerBase:: // MR1
+getParser() { // MR1
+ return parser; // MR1
+} // MR1
+ // MR1
+int DLGLexerBase:: // MR1
+debugLexer(int newValue) { // MR1
+ int oldValue=debugLexerFlag; // MR1
+ debugLexerFlag=newValue; // MR1
+ return oldValue; // MR1
+} // MR1
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h
new file mode 100644
index 0000000000..d3f696fec3
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h
@@ -0,0 +1,197 @@
+/* DLGLexerBase.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef DLGX_H
+#define DLGX_H
+
+#include "pcctscfg.h"
+#include "pccts_stdio.h"
+
+PCCTS_NAMESPACE_STD
+
+#include ATOKEN_H
+#include ATOKENSTREAM_H
+
+class ANTLRParser; // MR1
+
+/* must define what a char looks like; can make this a class too */
+typedef char DLGChar;
+
+/* Can have it as a class too: (ack this looks weird; is it right?)
+class DllExportPCCTS DLGChar {
+private:
+ int c;
+public:
+ DLGChar(int ch) { c = ch; }
+ int atom() { return c; }
+};
+*/
+
+/* user must subclass this */
+class DllExportPCCTS DLGInputStream {
+public:
+ virtual int nextChar() = 0;
+};
+
+/* Predefined char stream: Input from FILE */
+class DllExportPCCTS DLGFileInput : public DLGInputStream {
+private:
+ int found_eof;
+ FILE *input;
+public:
+ DLGFileInput(FILE *f) { input = f; found_eof = 0; }
+ int nextChar() {
+ int c;
+ if ( found_eof ) return EOF;
+ else {
+ c=getc(input);
+ if ( c==EOF ) found_eof = 1;
+ return c;
+ }
+ }
+ void DLGFileReset(FILE *f) {input=f; found_eof = 0; }; // MR11
+};
+
+// MR9 Suggested by Bruce Guenter (bruceg@qcc.sk.ca)
+// MR9 Make DLGStringInput const correct
+
+/* Predefined char stream: Input from string */
+class DllExportPCCTS DLGStringInput : public DLGInputStream {
+private:
+ const DLGChar *input; // MR9
+ const DLGChar *p; // MR9
+public:
+ DLGStringInput(const DLGChar *s) { input = s; p = &input[0];} // MR9
+ int nextChar()
+ {
+ if (*p) return (int) (unsigned char) *p++; // MR14
+ else return EOF;
+ }
+
+ void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16
+};
+
+class DllExportPCCTS DLGState {
+public:
+ DLGInputStream *input;
+ int interactive;
+ int track_columns;
+ int auto_num;
+ int add_erase;
+ int lookc;
+ int char_full;
+ int begcol, endcol;
+ int line;
+ DLGChar *lextext, *begexpr, *endexpr;
+ int bufsize;
+ int bufovf;
+ DLGChar *nextpos;
+ int class_num;
+ int debugLexerFlag; // MR1
+ ANTLRParser *parser; // MR1
+};
+
+/* user must subclass this */
+class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {
+public:
+ virtual ANTLRTokenType erraction();
+
+protected:
+ DLGInputStream *input;
+ int interactive;
+ int track_columns;
+ DLGChar *_lextext; /* text of most recently matched token */
+ DLGChar *_begexpr; /* beginning of last reg expr recogn. */
+ DLGChar *_endexpr; /* beginning of last reg expr recogn. */
+ int _bufsize; /* number of characters in lextext */
+ int _begcol; /* column that first character of token is in*/
+ int _endcol; /* column that last character of token is in */
+ int _line; /* line current token is on */
+ int ch; /* character to determine next state */
+ int bufovf; /* indicates that buffer too small for text */
+ int charfull;
+ DLGChar *nextpos; /* points to next available position in lextext*/
+ int cl;
+ int automaton;
+ int add_erase;
+ DLGChar ebuf[70];
+ _ANTLRTokenPtr token_to_fill;
+
+ int debugLexerFlag; // MR1
+ ANTLRParser *parser; // MR1
+public:
+ virtual _ANTLRTokenPtr getToken(); // MR12 public
+ virtual void advance(void) = 0;
+ void skip(void); /* erase lextext, look for antoher token */
+ void more(void); /* keep lextext, look for another token */
+ void mode(int k); /* switch to automaton 'k' */
+ void saveState(DLGState *);
+ void restoreState(DLGState *);
+ virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */
+ void replchar(DLGChar c); /* replace last recognized reg. expr. with
+ a character */
+ void replstr(const DLGChar *s); /* replace last recognized reg. expr. with
+ a string */ /* MR20 const */
+ virtual int err_in(); // MR1
+ virtual void errstd(const char *); // MR1 MR20 const
+ int line() { return _line; }
+ void set_line(int newValue) { _line=newValue; }; // MR1
+ virtual void newline() { _line++; }
+ DLGChar *lextext() { return _lextext; }
+
+ int begcol() { return _begcol; }
+ int endcol() { return _endcol; }
+ void set_begcol(int a) { _begcol=a; }
+ void set_endcol(int a) { _endcol=a; }
+ DLGChar *begexpr() { return _begexpr; }
+ DLGChar *endexpr() { return _endexpr; }
+ int bufsize() { return _bufsize; }
+
+ void setToken(ANTLRAbstractToken *t) { token_to_fill = t; }
+
+ void setInputStream(DLGInputStream *);
+ DLGLexerBase(DLGInputStream *in,
+ unsigned bufsize=2000,
+ int interactive=0,
+ int track_columns=0);
+ void reset(); // MR19
+ virtual ~DLGLexerBase() { delete [] _lextext; }
+ virtual void panic(const char *msg); // MR1 MR20 const
+ void trackColumns() {
+ track_columns = 1;
+ this->_begcol = 0;
+ this->_endcol = 0;
+ };
+ virtual ANTLRParser *setParser(ANTLRParser *p); // MR1
+ virtual ANTLRParser *getParser(); // MR1
+ virtual int debugLexer(int value); // MR1
+ int lexErrCount; // MR12
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h
new file mode 100644
index 0000000000..47cc50b604
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h
@@ -0,0 +1,104 @@
+#ifndef PBLACKBOX_H
+#define PBLACKBOX_H
+
+/*
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#include "pccts_iostream.h"
+
+PCCTS_NAMESPACE_STD
+
+// MR20 Added #include for "DLexerBase.h"
+
+#include "DLexerBase.h"
+
+//
+// The default buffer size of the lexer is given by the
+// second argument of the lexer's ctor. It is optional
+// and defaults to 2000
+//
+
+template<class Lexer, class Parser, class Token>
+class DllExportPCCTS ParserBlackBox {
+protected:
+ DLGFileInput *in;
+ Lexer *scan;
+ _ANTLRTokenPtr tok;
+ ANTLRTokenBuffer *pipe;
+ Parser *_parser;
+ FILE *file;
+ int openByBlackBox; /* MR21 Don't close what we haven't opened */
+public:
+
+ ParserBlackBox(FILE *f)
+ {
+ openByBlackBox = 0; /* MR21a */
+ file = f;
+ in = new DLGFileInput(f);
+ scan = new Lexer(in);
+ pipe = new ANTLRTokenBuffer(scan);
+ tok = new Token;
+ scan->setToken(tok);
+ _parser = new Parser(pipe);
+ _parser->init();
+ }
+ ParserBlackBox(char *fname)
+ {
+ FILE *f = fopen(fname, "r");
+ if ( f==NULL ) {
+ openByBlackBox = 0;
+ cerr << "cannot open " << fname << "\n"; return;
+ }
+ else {
+ openByBlackBox = 1;
+ file = f;
+ in = new DLGFileInput(f);
+ scan = new Lexer(in);
+ pipe = new ANTLRTokenBuffer(scan);
+ tok = new Token;
+ scan->setToken(tok);
+ _parser = new Parser(pipe);
+ _parser->init();
+ }
+ }
+
+ ~ParserBlackBox()
+ {
+ delete in; delete scan; delete pipe; delete _parser; delete tok;
+ if (1 == openByBlackBox) {
+ fclose(file);
+ }
+ }
+
+ Parser *parser() { return _parser; }
+ Lexer *getLexer() { return scan; }
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp
new file mode 100644
index 0000000000..84a3a092ca
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp
@@ -0,0 +1,662 @@
+/*
+ * PCCTSAST.C
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B14 and ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * AHPCRC, University of Minnesota
+ * 1992-1998
+ */
+
+#define ANTLR_SUPPORT_CODE
+
+#include "pcctscfg.h"
+
+#include "PCCTSAST.h"
+#include "pccts_stdarg.h"
+
+PCCTS_NAMESPACE_STD
+
+#include <ctype.h>
+
+//#include "SList.h"
+
+ /* String Scanning/Parsing Stuff */
+
+const char *PCCTS_AST::scan_token_tbl[] = { /* MR20 const */
+ "invalid", /* 0 */
+ "LPAREN", /* 1 */
+ "RPAREN", /* 2 */
+ "PERCENT", /* 3 */
+ "INT", /* 4 */
+ "COLON", /* 5 */
+ "POUND", /* 6 */
+ "PERIOD", /* 7 */
+};
+
+void PCCTS_AST::
+addChild(PCCTS_AST *t)
+{
+ if ( t==NULL ) return;
+ PCCTS_AST *s = down();
+ if ( s!=NULL )
+ {
+ while ( s->right()!=NULL ) s = s->right();
+ s->setRight(t);
+ }
+ else
+ this->setDown(t);
+}
+
+void PCCTS_AST::
+lisp(FILE *f)
+{
+ if ( down() != NULL ) fprintf(f," (");
+ lisp_action(f);
+ if ( down()!=NULL ) down()->lisp(f);
+ if ( down() != NULL ) fprintf(f," )");
+ if ( right()!=NULL ) right()->lisp(f);
+}
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually sibling lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ *
+ * The down() and right() down/right pointers are used to make the tree.
+ */
+PCCTS_AST *PCCTS_AST::
+make(PCCTS_AST *rt, ...)
+{
+ va_list ap;
+ register PCCTS_AST *child, *sibling=NULL, *tail, *w;
+ PCCTS_AST *root;
+
+ va_start(ap, rt);
+ root = rt;
+
+ if ( root != NULL )
+ if ( root->down() != NULL ) return NULL;
+ child = va_arg(ap, PCCTS_AST *);
+ while ( child != NULL )
+ {
+ /* find end of child */
+ for (w=child; w->right()!=NULL; w=w->right()) {;}
+ if ( sibling == NULL ) {sibling = child; tail = w;}
+ else {tail->setRight(child); tail = w;}
+ child = va_arg(ap, PCCTS_AST *);
+ }
+ if ( root==NULL ) root = sibling;
+ else root->setDown(sibling);
+ va_end(ap);
+ return root;
+}
+
+/* The following push and pop routines are only used by ast_find_all() */
+
+void PCCTS_AST::
+_push(PCCTS_AST **st, int *sp, PCCTS_AST *e)
+{
+ (*sp)--;
+ require((*sp)>=0, "stack overflow");
+ st[(*sp)] = e;
+}
+
+PCCTS_AST *PCCTS_AST::
+_pop(PCCTS_AST **st, int *sp)
+{
+ PCCTS_AST *e = st[*sp];
+ (*sp)++;
+ require((*sp)<=MaxTreeStackDepth, "stack underflow");
+ return e;
+}
+
+/* Find all occurrences of u in t.
+ * 'cursor' must be initialized to 't'. It eventually
+ * returns NULL when no more occurrences of 'u' are found.
+ */
+PCCTS_AST *PCCTS_AST::
+ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor)
+{
+ PCCTS_AST *sib;
+ static PCCTS_AST *template_stack[MaxTreeStackDepth];
+ static int tsp = MaxTreeStackDepth;
+ static int nesting = 0;
+
+ if ( *cursor == NULL ) return NULL;
+ if ( *cursor!=this ) sib = *cursor;
+ else {
+ /* else, first time--start at top of template 't' */
+ tsp = MaxTreeStackDepth;
+ sib = this;
+ /* bottom of stack is always a NULL--"cookie" indicates "done" */
+ _push(template_stack, &tsp, NULL);
+ }
+
+keep_looking:
+ if ( sib==NULL ) /* hit end of sibling list */
+ {
+ sib = _pop(template_stack, &tsp);
+ if ( sib == NULL ) { *cursor = NULL; return NULL; }
+ }
+
+ if ( sib->type() != u->type() )
+ {
+ /* look for another match */
+ if ( sib->down()!=NULL )
+ {
+ if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
+ sib=sib->down();
+ goto keep_looking;
+ }
+ /* nothing below to try, try next sibling */
+ sib=sib->right();
+ goto keep_looking;
+ }
+
+ /* found a matching root node, try to match what's below */
+ if ( match_partial(sib, u) )
+ {
+ /* record sibling cursor so we can pick up next from there */
+ if ( sib->down()!=NULL )
+ {
+ if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
+ *cursor = sib->down();
+ }
+ else if ( sib->right()!=NULL ) *cursor = sib->right();
+ else *cursor = _pop(template_stack, &tsp);
+ return sib;
+ }
+
+ /* no match, keep searching */
+ if ( sib->down()!=NULL )
+ {
+ if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());
+ sib=sib->down();
+ }
+ else sib = sib->right(); /* else, try to right if zip below */
+ goto keep_looking;
+}
+
+/* are two trees exactly alike? */
+int PCCTS_AST::
+match(PCCTS_AST *u)
+{
+ PCCTS_AST *t = this;
+ PCCTS_AST *sib;
+
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
+ {
+ if ( sib->type() != u->type() ) return 0;
+ if ( sib->down()!=NULL )
+ if ( !sib->down()->match(u->down()) ) return 0;
+ }
+ return 1;
+}
+
+/* Is 'u' a subtree of 't' beginning at the root? */
+int PCCTS_AST::
+match_partial(PCCTS_AST *t, PCCTS_AST *u)
+{
+ PCCTS_AST *sib;
+
+ if ( u==NULL ) return 1;
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
+ {
+ if ( sib->type() != u->type() ) return 0;
+ if ( sib->down()!=NULL )
+ if ( !match_partial(sib->down(), u->down()) ) return 0;
+ }
+ return 1;
+}
+
+/* Walk the template tree 't' (matching against 'this'), filling in the
+ * 'labels' array, and setting 'n' according to how many labels were matched.
+ */
+int PCCTS_AST::
+scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n)
+{
+ ScanAST *sib;
+ PCCTS_AST *u = this;
+
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())
+ {
+ /* make sure tokens match; token of '0' means wildcard match */
+ if ( sib->type() != u->type() && sib->type()!=0 ) return 0;
+ /* we have a matched token here; set label pointers if exists */
+ if ( sib->label_num>0 )
+ {
+ require(labels!=NULL, "label found in template, but no array of labels");
+ (*n)++;
+ *(labels[sib->label_num-1]) = u;
+ }
+ /* match what's below if something there and current node is not wildcard */
+ if ( sib->down()!=NULL && sib->type()!=0 )
+ {
+ if ( sib->down()==NULL ) if ( u->down()!=NULL ) return 0; else return 1;
+ if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0;
+ }
+ }
+ return 1;
+}
+
+void PCCTS_AST::
+insert_after(PCCTS_AST *b)
+{
+ PCCTS_AST *end;
+ if ( b==NULL ) return;
+ /* find end of b's child list */
+ for (end=b; end->right()!=NULL; end=end->right()) {;}
+ end->setRight(this->right());
+ this->setRight(b);
+}
+
+void PCCTS_AST::
+append(PCCTS_AST *b)
+{
+ PCCTS_AST *end;
+ require(b!=NULL, "append: NULL input tree");
+ /* find end of child list */
+ for (end=this; end->right()!=NULL; end=end->right()) {;}
+ end->setRight(b);
+}
+
+PCCTS_AST *PCCTS_AST::
+tail()
+{
+ PCCTS_AST *end;
+ /* find end of child list */
+ for (end=this; end->right()!=NULL; end=end->right()) {;}
+ return end;
+}
+
+PCCTS_AST *PCCTS_AST::
+bottom()
+{
+ PCCTS_AST *end;
+ /* find end of child list */
+ for (end=this; end->down()!=NULL; end=end->down()) {;}
+ return end;
+}
+
+PCCTS_AST *PCCTS_AST::
+cut_between(PCCTS_AST *a, PCCTS_AST *b)
+{
+ PCCTS_AST *end, *ret;
+ if (a==NULL||b==NULL) return NULL;
+ /* find node pointing to b */
+ for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right())
+ {;}
+ if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected
+ end->setRight(NULL); /* don't want it point to 'b' anymore */
+ ret = a->right();
+ a->setRight(b);
+ return ret;
+}
+
+#ifdef NOT_YET
+SList *PCCTS_AST::
+to_slist()
+{
+ SList *list = new SList;
+ PCCTS_AST *p;
+
+ for (p=this; p!=NULL; p=p->right())
+ {
+ list->add(p);
+ }
+ return list;
+}
+#endif
+
+void PCCTS_AST::
+tfree()
+{
+ PCCTS_AST *t = this;
+ if ( t->down()!=NULL ) t->down()->tfree();
+ if ( t->right()!=NULL ) t->right()->tfree();
+ delete t;
+}
+
+int PCCTS_AST::
+nsiblings()
+{
+ PCCTS_AST *t = this;
+ int n=0;
+
+ while ( t!=NULL )
+ {
+ n++;
+ t = t->right();
+ }
+ return n;
+}
+
+PCCTS_AST *PCCTS_AST::
+sibling_index(int i)
+{
+ PCCTS_AST *t = this;
+ int j=1;
+ require(i>0, "sibling_index: i<=0");
+
+ while ( t!=NULL )
+ {
+ if ( j==i ) return t;
+ j++;
+ t = t->right();
+ }
+ return NULL;
+}
+
+/* Assume this is a root node of a tree--
+ * duplicate that node and what's below; ignore siblings of root node.
+ */
+
+// MR9 23-Sep-97 RJV
+// MR9
+// MR9 RJV: Original version only duplicated the node and down elements.
+// MR9 Made copies of the pointers to sibling.
+// MR9 Changed call "down()->deepCopy()" to "down()->deepCopyBushy()"
+// MR9
+
+PCCTS_AST *PCCTS_AST::
+deepCopy()
+{
+ PCCTS_AST *u = this->shallowCopy();
+ if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());
+ u->setRight(NULL);
+ return u;
+}
+
+/* Copy all nodes including siblings of root. */
+PCCTS_AST *PCCTS_AST::
+deepCopyBushy()
+{
+ PCCTS_AST *u = this->shallowCopy();
+ /* copy the rest of the tree */
+ if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());
+ if ( right()!=NULL ) u->setRight(right()->deepCopyBushy());
+ return u;
+}
+
+void PCCTS_AST::
+scanast_free(ScanAST *t)
+{
+ if ( t == NULL ) return;
+ scanast_free( t->down() );
+ scanast_free( t->right() );
+ free( (char *) t ); // MR1
+}
+
+/*
+ * scan
+ *
+ * This function is like scanf(): it attempts to match a template
+ * against an input tree. A variable number of tree pointers
+ * may be set according to the '%i' labels in the template string.
+ * For example:
+ *
+ * t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
+ * &w, &x, &y, &z);
+ *
+ * Naturally, you'd want this converted from
+ *
+ * t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",
+ * &w, &x, &y, &z);
+ *
+ * by SORCERER.
+ *
+ * This function call must be done withing a SORCERER file because SORCERER
+ * must convert the token references to the associated token number.
+ *
+ * This functions parses the template and creates trees which are then
+ * matched against the input tree. The labels are set as they are
+ * encountered; hence, partial matches may leave some pointers set
+ * and some NULL. This routines initializes all argument pointers to NULL
+ * at the beginning.
+ *
+ * This function returns the number of labels matched.
+ */
+int PCCTS_AST::
+ast_scan(char *templ, ...)
+{
+ va_list ap;
+ ScanAST *tmpl;
+ int n, i, found=0;
+ PCCTS_AST ***label_ptrs=NULL;
+
+ va_start(ap, templ);
+
+ /* make a ScanAST tree out of the template */
+ tmpl = stringparser_parse_scanast(templ, &n);
+
+ /* make an array out of the labels */
+ if ( n>0 )
+ {
+ label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **));
+ require(label_ptrs!=NULL, "scan: out of memory");
+ for (i=1; i<=n; i++)
+ {
+ label_ptrs[i-1] = va_arg(ap, PCCTS_AST **);
+ *(label_ptrs[i-1]) = NULL;
+ }
+ }
+
+ /* match the input tree against the template */
+ scanmatch(tmpl, label_ptrs, &found);
+
+ scanast_free(tmpl);
+ free( (char *) label_ptrs); // MR1
+
+ return found;
+}
+
+ScanAST *PCCTS_AST::
+new_scanast(int tok)
+{
+ ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));
+//
+// 7-Apr-97 133MR1
+//
+ if ( p == NULL ) { // MR1
+ fprintf(stderr, "out of mem\n"); // MR1
+ exit(PCCTS_EXIT_FAILURE); // MR1
+ }; // MR1
+ p->_token = tok;
+ return p;
+}
+
+ScanAST *PCCTS_AST::
+stringparser_parse_scanast(char *templ, int *num_labels)
+{
+ StringLexer lex;
+ StringParser parser;
+ ScanAST *t;
+
+ stringlexer_init(&lex, templ);
+ stringparser_init(&parser, &lex);
+ t = stringparser_parse_tree(&parser);
+ *num_labels = parser.num_labels;
+ return t;
+}
+
+void PCCTS_AST::
+stringparser_match(StringParser *parser, int token)
+{
+ if ( parser->token != token ) panic("bad tree in scan()");
+}
+
+/*
+ * Match a tree of the form:
+ * (root child1 child2 ... childn)
+ * or,
+ * node
+ *
+ * where the elements are integers or labeled integers.
+ */
+ScanAST *PCCTS_AST::
+stringparser_parse_tree(StringParser *parser)
+{
+ ScanAST *t=NULL, *root, *child, *last;
+
+ if ( parser->token != __POUND )
+ {
+ return stringparser_parse_element(parser);
+ }
+ stringparser_match(parser,__POUND);
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,__LPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root = stringparser_parse_element(parser);
+ while ( parser->token != __RPAREN )
+ {
+ child = stringparser_parse_element(parser);
+ if ( t==NULL ) { t = child; last = t; }
+ else { last->_right = child; last = child; }
+ }
+ stringparser_match(parser,__RPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root->_down = t;
+ return root;
+}
+
+ScanAST *PCCTS_AST::
+stringparser_parse_element(StringParser *parser)
+{
+ static char ebuf[100];
+ int label = 0;
+
+ if ( parser->token == __POUND )
+ {
+ return stringparser_parse_tree(parser);
+ }
+ if ( parser->token == __PERCENT )
+ {
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,__INT);
+ label = atoi(parser->lexer->text);
+ parser->num_labels++;
+ if ( label==0 ) panic("%%0 is an invalid label");
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,__COLON);
+ parser->token = stringscan_gettok(parser->lexer);
+ /* can label tokens and wildcards */
+ if ( parser->token != __INT && parser->token != __PERIOD )
+ panic("can only label tokens");
+ }
+ if ( parser->token == __INT )
+ {
+ ScanAST *p = new_scanast(atoi(parser->lexer->text));
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ if ( parser->token == __PERIOD )
+ {
+ ScanAST *p = new_scanast(0); /* token of 0 is wildcard */
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token));
+ panic(ebuf);
+ return NULL;
+}
+
+void PCCTS_AST::
+stringparser_init(StringParser *parser, StringLexer *input)
+{
+ parser->lexer = input;
+ parser->token = stringscan_gettok(parser->lexer);
+ parser->num_labels = 0;
+}
+
+void PCCTS_AST::
+stringlexer_init(StringLexer *scanner, char *input)
+{
+ scanner->text[0]='\0';
+ scanner->input = input;
+ scanner->p = input;
+ stringscan_advance(scanner);
+}
+
+void PCCTS_AST::
+stringscan_advance(StringLexer *scanner)
+{
+ if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF;
+ scanner->c = *(scanner->p)++;
+}
+
+int PCCTS_AST::
+stringscan_gettok(StringLexer *scanner)
+{
+ char *index = &scanner->text[0];
+ static char ebuf[100];
+
+ while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
+ if ( isdigit(scanner->c) )
+ {
+ int tok = __INT;
+ while ( isdigit(scanner->c) ) {
+ *index++ = scanner->c;
+ stringscan_advance(scanner);
+ }
+ *index = '\0';
+ return tok;
+ }
+ switch ( scanner->c )
+ {
+ case '#' : stringscan_advance(scanner); return __POUND;
+ case '(' : stringscan_advance(scanner); return __LPAREN;
+ case ')' : stringscan_advance(scanner); return __RPAREN;
+ case '%' : stringscan_advance(scanner); return __PERCENT;
+ case ':' : stringscan_advance(scanner); return __COLON;
+ case '.' : stringscan_advance(scanner); return __PERIOD;
+ case '\0' : return __StringScanEOF;
+ case __StringScanEOF : return __StringScanEOF;
+ default :
+ sprintf(ebuf, "invalid char in scan: '%c'", scanner->c);
+ panic(ebuf);
+ }
+ return __StringScanEOF; // never reached
+}
+
+const char *PCCTS_AST:: /* MR20 const */
+scan_token_str(int t)
+{
+ if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];
+ else if ( t==__StringScanEOF ) return "<end-of-string>";
+ else return "<invalid-token>";
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h
new file mode 100644
index 0000000000..c9fb597bef
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h
@@ -0,0 +1,142 @@
+/* Abstract syntax tree
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef PCCTSAST_H
+#define PCCTSAST_H
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+//class SList;
+
+#define StringScanMaxText 50
+#define MaxTreeStackDepth 400
+
+//
+// 7-Apr-97 133MR1 signed int not accepted by AT&T cfront
+//
+typedef struct stringlexer {
+ int c; // MR1
+ char *input;
+ char *p;
+ char text[StringScanMaxText];
+ } StringLexer;
+
+/* Define the structures needed for ast_scan() */
+typedef struct stringparser {
+ int token;
+ StringLexer *lexer;
+ int num_labels;
+ } StringParser;
+
+typedef struct _scanast {
+ struct _scanast *_right, *_down;
+ int _token;
+ int label_num;
+ int type() { return _token; }
+ struct _scanast *right() { return _right; }
+ struct _scanast *down() { return _down; }
+ } ScanAST;
+
+#define VALID_SCAN_TOKEN(t) (t>=__LPAREN && t<=__PERIOD)
+
+class DllExportPCCTS PCCTS_AST {
+protected:
+ static const char *scan_token_tbl[]; /* MR20 const */
+ enum {
+ __LPAREN=1,
+ __RPAREN=2,
+ __PERCENT=3,
+ __INT=4,
+ __COLON=5,
+ __POUND=6,
+ __PERIOD=7,
+ __StringScanEOF=-1};
+
+protected:
+ const char *scan_token_str(int t); /* MR20 const */
+ void stringlexer_init(StringLexer *scanner, char *input);
+ void stringparser_init(StringParser *, StringLexer *);
+ ScanAST *stringparser_parse_scanast(char *templ, int *n);
+ ScanAST *stringparser_parse_tree(StringParser *parser);
+ ScanAST *stringparser_parse_element(StringParser *parser);
+ void stringscan_advance(StringLexer *scanner);
+ int stringscan_gettok(StringLexer *scanner);
+ void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);
+ PCCTS_AST *_pop(PCCTS_AST **st, int *sp);
+ int match_partial(PCCTS_AST *t, PCCTS_AST *u);
+ int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);
+ void scanast_free(ScanAST *t);
+ ScanAST *new_scanast(int tok);
+ void stringparser_match(StringParser *parser, int type);
+ virtual PCCTS_AST *deepCopyBushy();
+
+public:
+ PCCTS_AST() {;}
+ virtual ~PCCTS_AST() {;}
+
+ /* This group must be defined for SORCERER to work correctly */
+ virtual PCCTS_AST *right() = 0;
+ virtual PCCTS_AST *down() = 0;
+ virtual void setRight(PCCTS_AST *t) = 0;
+ virtual void setDown(PCCTS_AST *t) = 0;
+// we define these so ANTLR doesn't have to
+ virtual int type() { return 0; }
+ virtual void setType(int t) {;}
+ virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}
+
+ /* These are not needed by ANTLR, but are support functions */
+ virtual PCCTS_AST *deepCopy(); // used by SORCERER in transform mode
+ virtual void addChild(PCCTS_AST *t);
+ virtual void lisp_action(FILE *f) {;}
+ virtual void lisp(FILE *f);
+ static PCCTS_AST *make(PCCTS_AST *rt, ...);
+ virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);
+ virtual int match(PCCTS_AST *u);
+ virtual void insert_after(PCCTS_AST *b);
+ virtual void append(PCCTS_AST *b);
+ virtual PCCTS_AST *tail();
+ virtual PCCTS_AST *bottom();
+ static PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);
+// virtual SList *to_slist();
+ virtual void tfree();
+ int ast_scan(char *templ, ...);
+ virtual int nsiblings();
+ virtual PCCTS_AST *sibling_index(int i);
+
+ void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */
+ virtual void panic(const char *err) // MR20 const
+ { fprintf(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
+};
+
+#endif /* PCCTSAST_H */
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h
new file mode 100644
index 0000000000..83578788c4
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h
@@ -0,0 +1,71 @@
+#ifndef SList_h
+#define SList_h
+
+/*
+ * SList.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * PCCTS 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1992-1998
+ */
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+PCCTS_NAMESPACE_STD
+
+#include "PCCTSAST.h"
+
+class PCCTS_AST;
+
+class SListNode {
+protected:
+ void *_elem; /* pointer to any kind of element */
+ SListNode *_next;
+public:
+ SListNode() {_elem=_next=NULL;}
+ virtual ~SListNode() {_elem=_next=NULL;}
+ void *elem() { return _elem; }
+ void setElem(void *e) { _elem = e; }
+ void setNext(SListNode *t) { _next = t; }
+ SListNode *next() { return _next; }
+};
+
+class SList {
+ SListNode *head, *tail;
+public:
+ SList() {head=tail=NULL;}
+ virtual ~SList() {head=tail=NULL;}
+ virtual void *iterate(SListNode **);
+ virtual void add(void *e);
+ virtual void lfree();
+ virtual PCCTS_AST *to_ast(SList list);
+ virtual void require(int e,char *err){ if ( !e ) panic(err); }
+ virtual void panic(char *err){ fprintf(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h
new file mode 100644
index 0000000000..01bda69abd
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h
@@ -0,0 +1,788 @@
+/* antlr.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ANTLR_H
+#define ANTLR_H
+
+#include "pcctscfg.h"
+
+#include "pccts_stdio.h"
+
+/* turn off warnings for unreferenced labels */
+
+#ifdef _MSC_VER
+#pragma warning(disable:4102)
+#endif
+
+/*
+ * Define all of the stack setup and manipulation of $i, #i variables.
+ *
+ * Notes:
+ * The type 'Attrib' must be defined before entry into this .h file.
+ */
+
+
+#ifdef __USE_PROTOS
+#include "pccts_stdlib.h"
+#else
+#ifdef VAXC
+#include <stdlib.h>
+#else
+#include <malloc.h>
+#endif
+#endif
+#include "pccts_string.h"
+
+#if 0
+#include "set.h"
+#endif
+
+
+typedef int ANTLRTokenType;
+typedef unsigned char SetWordType;
+
+typedef char ANTLRChar;
+
+ /* G u e s s S t u f f */
+
+#ifdef ZZCAN_GUESS
+#ifndef ZZINF_LOOK
+#define ZZINF_LOOK
+#endif
+#endif
+
+#ifdef ZZCAN_GUESS
+typedef struct _zzjmp_buf {
+ jmp_buf state;
+ } zzjmp_buf;
+#endif
+
+
+/* can make this a power of 2 for more efficient lookup */
+
+#ifndef ZZLEXBUFSIZE
+#define ZZLEXBUFSIZE 8000 /* MR22 raise from 2k to 8k */
+#endif
+
+#define zzOvfChk \
+ if ( zzasp <= 0 ) \
+ { \
+ fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \
+ exit(PCCTS_EXIT_FAILURE); \
+ }
+
+#ifndef ZZA_STACKSIZE
+#define ZZA_STACKSIZE 400
+#endif
+#ifndef ZZAST_STACKSIZE
+#define ZZAST_STACKSIZE 400
+#endif
+
+#ifndef zzfailed_pred
+#ifdef ZZCAN_GUESS
+#define zzfailed_pred(_p) \
+ if (zzguessing) { \
+ zzGUESS_FAIL; \
+ } else { \
+ fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); \
+ }
+#else
+#define zzfailed_pred(_p) \
+ fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p)
+#endif
+#endif
+
+/* MR19 zzchar_t additions */
+
+#ifdef LL_K
+#define LOOKAHEAD \
+ int zztokenLA[LL_K]; \
+ zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \
+ int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */
+#else
+#define LOOKAHEAD \
+ int zztoken;
+#endif
+
+#ifndef zzcr_ast
+#define zzcr_ast(ast,attr,tok,text)
+#endif
+
+#ifdef DEMAND_LOOK
+#define DemandLookData int zzdirty=1;
+#else
+#define DemandLookData
+#endif
+
+#ifndef zzUSER_GUESS_HOOK
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)
+#endif
+
+#ifndef zzUSER_GUESS_DONE_HOOK
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)
+#endif
+
+ /* S t a t e S t u f f */
+
+#ifdef ZZCAN_GUESS
+#define zzGUESS_BLOCK zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen;
+
+/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */
+
+#define zzGUESS zzsave_antlr_state(&zzst); \
+ zzguessing = 1; \
+ zzGuessSeqFrozen=++zzGuessSeq; \
+ zzrv = setjmp(zzguess_start.state); \
+ zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \
+ if (zzrv) zzGUESS_DONE;
+#ifdef zzTRACE_RULES
+#define zzGUESS_FAIL { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); }
+#else
+#define zzGUESS_FAIL longjmp(zzguess_start.state, 1)
+#endif
+
+/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */
+
+#define zzGUESS_DONE { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }
+#define zzNON_GUESS_MODE if ( !zzguessing )
+#define zzGuessData \
+ zzjmp_buf zzguess_start; \
+ int zzguessing;
+#else
+#define zzGUESS_BLOCK
+#define zzGUESS
+#define zzGUESS_FAIL
+#define zzGUESS_DONE
+#define zzNON_GUESS_MODE
+#define zzGuessData
+#endif
+
+typedef struct _zzantlr_state {
+#ifdef ZZCAN_GUESS
+ zzjmp_buf guess_start;
+ int guessing;
+#endif
+ int asp;
+ int ast_sp;
+#ifdef ZZINF_LOOK
+ int inf_lap; /* not sure we need to save this one */
+ int inf_labase;
+ int inf_last;
+
+/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
+/* MR6 Additional state needs to be saved/restored */
+/* MR6 Matching changes in err.h */
+
+ int *inf_tokens; /* MR6 */
+ char **inf_text; /* MR6 */
+ char *inf_text_buffer; /* MR6 */
+ int *inf_line; /* MR6 */
+#endif
+#ifdef DEMAND_LOOK
+ int dirty;
+#endif
+
+#ifdef LL_K
+ int tokenLA[LL_K];
+ char textLA[LL_K][ZZLEXBUFSIZE];
+ int lap;
+ int labase;
+#else
+ int token;
+ char text[ZZLEXBUFSIZE];
+#endif
+#ifdef zzTRACE_RULES
+ int traceOptionValue; /* MR10 */
+ int traceGuessOptionValue; /* MR10 */
+ char *traceCurrentRuleName; /* MR10 */
+ int traceDepth; /* MR10 */
+#endif
+
+ } zzantlr_state;
+
+#ifdef zzTRACE_RULES
+extern int zzTraceOptionValueDefault;
+extern int zzTraceOptionValue;
+extern int zzTraceGuessOptionValue;
+extern char *zzTraceCurrentRuleName;
+extern int zzTraceDepth;
+#endif
+
+extern int zzGuessSeq; /* MR10 */
+extern int zzSyntaxErrCount; /* MR11 */
+extern int zzLexErrCount; /* MR11 */
+
+ /* I n f i n i t e L o o k a h e a d */
+
+
+#ifdef ZZINF_LOOK
+#define InfLookData \
+ int *zzinf_tokens; \
+ char **zzinf_text; \
+ char *zzinf_text_buffer; \
+ int *zzinf_line; \
+ int zzinf_labase; \
+ int zzinf_last;
+#else
+#define InfLookData
+#endif
+
+#ifdef ZZINF_LOOK
+
+#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE
+#define ZZINF_DEF_TEXT_BUFFER_SIZE 20000
+#endif
+#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE
+#define ZZINF_DEF_TOKEN_BUFFER_SIZE 2000
+#endif
+/* WARNING!!!!!!
+ * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.
+ */
+#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE 5000
+#endif
+#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE
+#define ZZINF_BUFFER_TOKEN_CHUNK_SIZE 1000
+#endif
+
+#if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE ZZLEXBUFSIZE+5
+#endif
+
+/* make inf_look user-access macros */
+#ifdef LL_K
+#define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last)
+#define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)-LL_K+1]
+#define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)-LL_K+1]
+/* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out */
+#define ZZINF_LINE(i) zzinf_line[(zzinf_labase+i-1)-LL_K+1]
+#else
+#define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)) <= zzinf_last)
+#define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)]
+#define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)]
+#endif
+
+#define inf_zzgettok _inf_zzgettok()
+extern void _inf_zzgettok();
+
+#endif /* ZZINF_LOOK */
+
+
+#ifdef LL_K
+
+#ifdef __USE_PROTOS
+#define ANTLR_INFO \
+ Attrib zzempty_attr(void) {static Attrib a; return a;} \
+ Attrib zzconstr_attr(int _tok, char *_text) \
+ {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
+ int zzasp=ZZA_STACKSIZE; \
+ char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
+ Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
+ InfLookData \
+ zzGuessData
+#else
+#define ANTLR_INFO \
+ Attrib zzempty_attr() {static Attrib a; return a;} \
+ Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \
+ {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
+ int zzasp=ZZA_STACKSIZE; \
+ char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
+ Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
+ InfLookData \
+ zzGuessData
+#endif
+
+#else
+
+#ifdef __USE_PROTOS
+#define ANTLR_INFO \
+ Attrib zzempty_attr(void) {static Attrib a; return a;} \
+ Attrib zzconstr_attr(int _tok, char *_text) \
+ {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
+ int zzasp=ZZA_STACKSIZE; \
+ char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
+ Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
+ InfLookData \
+ zzGuessData
+#else
+#define ANTLR_INFO \
+ Attrib zzempty_attr() {static Attrib a; return a;} \
+ Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \
+ {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \
+ int zzasp=ZZA_STACKSIZE; \
+ char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
+ Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \
+ InfLookData \
+ zzGuessData
+#endif
+
+#endif /* LL_k */
+
+
+#ifdef ZZINF_LOOK
+
+#ifdef LL_K
+#ifdef DEMAND_LOOK
+#define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;}
+#else
+#define zzPrimeLookAhead {zzlap = zzlabase = 0; zzfill_inf_look();\
+ {int _i; for(_i=1;_i<=LL_K; _i++) \
+ {zzCONSUME;} zzlap = zzlabase = 0;}}
+#endif
+
+#else /* LL_K */
+
+#ifdef DEMAND_LOOK
+#define zzPrimeLookAhead zzfill_inf_look(); zzdirty=1
+#else
+#define zzPrimeLookAhead zzfill_inf_look(); inf_zzgettok
+
+#endif
+#endif /* LL_K */
+
+#else /* ZZINF_LOOK */
+
+#ifdef LL_K
+#ifdef DEMAND_LOOK
+#define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;}
+#else
+#define zzPrimeLookAhead {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++) \
+ {zzCONSUME;} zzlap = 0;}
+#endif
+
+#else
+
+#ifdef DEMAND_LOOK
+#define zzPrimeLookAhead zzdirty=1
+#else
+#define zzPrimeLookAhead zzgettok()
+#endif
+#endif /* LL_K */
+
+#endif /* ZZINF_LOOK */
+
+
+#ifdef LL_K
+#define zzenterANTLRs(s) \
+ zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;
+#define zzenterANTLRf(f) \
+ zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;
+#define zzenterANTLR(f) \
+ zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;
+#ifdef ZZINF_LOOK
+#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#else
+#define zzleaveANTLR(f)
+#define zzleaveANTLRf(f)
+#define zzleaveANTLRs(f)
+#endif
+
+#else
+
+#define zzenterANTLRs(s) \
+ {static char zztoktext[ZZLEXBUFSIZE]; \
+ zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}
+#define zzenterANTLRf(f) \
+ {static char zztoktext[ZZLEXBUFSIZE]; \
+ zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}
+#define zzenterANTLR(f) \
+ {static char zztoktext[ZZLEXBUFSIZE]; \
+ zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}
+#ifdef ZZINF_LOOK
+#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
+#else
+#define zzleaveANTLR(f)
+#define zzleaveANTLRf(f)
+#define zzleaveANTLRs(f)
+#endif
+
+#endif
+
+/* MR19 Paul D. Smith (psmith@baynetworks.com)
+ Need to adjust AST stack pointer at exit.
+ Referenced in ANTLRx macros.
+*/
+
+#ifdef GENAST
+#define ZZAST_ADJUST ++zzast_sp;
+#else
+#define ZZAST_ADJUST
+#endif
+
+#define ANTLR(st, f) zzbufsize = ZZLEXBUFSIZE; \
+ zzenterANTLR(f); \
+ { \
+ zzBLOCK(zztasp1); \
+ st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
+ /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
+ /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
+ zzEXIT_ANTLR(zztasp1 + 1); \
+ } \
+ zzleaveANTLR(f);
+
+#define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE; \
+ zzmode(_m); \
+ zzenterANTLR(f); \
+ { \
+ zzBLOCK(zztasp1); \
+ st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
+ /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
+ /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
+ zzEXIT_ANTLR(zztasp1 + 1); \
+ } \
+ zzleaveANTLR(f);
+
+#define ANTLRf(st, f) zzbufsize = ZZLEXBUFSIZE; \
+ zzenterANTLRf(f); \
+ { \
+ zzBLOCK(zztasp1); \
+ st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
+ /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
+ /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
+ zzEXIT_ANTLR(zztasp1 + 1); \
+ } \
+ zzleaveANTLRf(f);
+
+#define ANTLRs(st, s) zzbufsize = ZZLEXBUFSIZE; \
+ zzenterANTLRs(s); \
+ { \
+ zzBLOCK(zztasp1); \
+ st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
+ /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
+ /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
+ zzEXIT_ANTLR(zztasp1 + 1); \
+ } \
+ zzleaveANTLRs(s);
+
+#ifdef LL_K
+#define zztext (&(zztextLA[zzlap][0]))
+#else
+#define zztext zzlextext
+#endif
+
+
+ /* A r g u m e n t A c c e s s */
+
+#define zzaCur (zzaStack[zzasp])
+#define zzaRet (*zzaRetPtr)
+#define zzaArg(v,n) zzaStack[v-n]
+#define zzMakeAttr { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}
+#ifdef zzdef0
+#define zzMake0 { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}
+#else
+#define zzMake0 { zzOvfChk; --zzasp;}
+#endif
+#define zzaPush(_v) { zzOvfChk; zzaStack[--zzasp] = _v;}
+#ifndef zzd_attr
+#define zzREL(t) zzasp=(t); /* Restore state of stack */
+#else
+#define zzREL(t) for (; zzasp<(t); zzasp++) \
+ { zzd_attr(&(zzaStack[zzasp])); }
+#endif
+
+
+#define zzsetmatch(_es) \
+ if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;
+
+#ifdef ZZCAN_GUESS
+#define zzsetmatch_wsig(_es, handler) \
+ if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
+#else
+#define zzsetmatch_wsig(_es, handler) \
+ if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;}
+#endif
+
+#ifdef __USE_PROTOS
+extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **);
+extern int _zzsetmatch_wsig(SetWordType *);
+#else
+extern int _zzsetmatch();
+extern int _zzsetmatch_wsig();
+#endif
+
+#define zzmatch(_t) \
+ if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;
+
+#ifdef ZZCAN_GUESS
+#define zzmatch_wsig(_t,handler) \
+ if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
+#else
+#define zzmatch_wsig(_t,handler) \
+ if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;}
+#endif
+
+#ifdef __USE_PROTOS
+extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);
+extern int _zzmatch_wsig(int);
+#else
+extern int _zzmatch();
+extern int _zzmatch_wsig();
+#endif
+
+#define zzmatch_wdfltsig(_t,_f) \
+ if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken;
+#define zzsetmatch_wdfltsig(tw,tt,wf) \
+ if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken;
+
+#ifdef __USE_PROTOS
+extern int _zzmatch_wdfltsig(int, SetWordType *);
+extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted,
+ int tokenTypeOfSet,
+ SetWordType *whatFollows);
+#else
+extern int _zzmatch_wdfltsig();
+extern int _zzsetmatch_wdfltsig();
+#endif
+
+#ifdef GENAST
+#define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \
+ SetWordType *zzMissSet=NULL; int zzMissTok=0; \
+ int zzBadTok=0; char *zzBadText=""; \
+ int zzErrk=1,zzpf=0; \
+ zzTRACEdata \
+ char *zzMissText=""; zzASTVars
+#else
+#define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \
+ int zzBadTok=0; char *zzBadText=""; \
+ int zzErrk=1,zzpf=0; \
+ zzTRACEdata \
+ SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText=""
+#endif
+
+#ifdef GENAST
+#define zzBLOCK(i) int i = zzasp - 1; int zztsp = zzast_sp
+#define zzEXIT(i) zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); }
+#define zzEXIT_ANTLR(i) zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */
+#define zzLOOP(i) zzREL(i); zzastREL
+#else
+#define zzBLOCK(i) int i = zzasp - 1
+#define zzEXIT(i) zzREL(i)
+#define zzEXIT_ANTLR(i) zzREL(i) /* [i_a] added as we want this for the ANTLRx() macros */
+#define zzLOOP(i) zzREL(i)
+#endif
+
+#ifdef LL_K
+
+#ifdef DEMAND_LOOK
+#define LOOK(_k) {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++) \
+ zzCONSUME;}
+#define zzCONSUME {zzgettok(); zzdirty--; \
+ zzlap = (zzlap+1)&(LL_K-1); \
+ zzlextext = &(zztextLA[zzlap][0]);}
+#else
+#ifdef ZZINF_LOOK
+#define zzCONSUME {inf_zzgettok; \
+ zzlap = (zzlap+1)&(LL_K-1); \
+ zzlextext = &(zztextLA[zzlap][0]); \
+ }
+#else
+#define zzCONSUME {zzgettok(); \
+ zzlap = (zzlap+1)&(LL_K-1); \
+ zzlextext = &(zztextLA[zzlap][0]);}
+#endif /* ZZINF_LOOK */
+#endif /* DEMAND_LOOK */
+
+#else /* LL_K */
+
+#ifdef DEMAND_LOOK
+#define LOOK(_k) if ( zzdirty) zzCONSUME;
+#ifdef ZZINF_LOOK
+#define zzCONSUME inf_zzgettok; zzdirty=0;
+#else
+#define zzCONSUME zzgettok(); zzdirty=0;
+#endif /* ZZINF_LOOK */
+
+#else /* DEMAND_LOOK */
+
+#ifdef ZZINF_LOOK
+#define zzCONSUME inf_zzgettok
+#else
+#define zzCONSUME zzgettok();
+#endif
+
+#endif /* DEMAND_LOOK */
+
+#endif /* LL_K */
+
+#ifdef LL_K
+#define NLA zztokenLA[zzlap&(LL_K-1)] /* --> next LA */
+#define NLATEXT zztextLA[zzlap&(LL_K-1)] /* --> next text of LA */
+#ifdef DEMAND_LOOK
+#define LA(i) zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]
+#define LATEXT(i) (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))
+#else
+#define LA(i) zztokenLA[(zzlap+(i)-1)&(LL_K-1)]
+#define LATEXT(i) (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))
+#endif
+#else
+#define NLA zztoken
+#define NLATEXT zztext
+#define LA(i) zztoken
+#define LATEXT(i) zztext
+#endif
+
+
+ /* S t a n d a r d S i g n a l s */
+
+#define NoSignal 0
+#define MismatchedToken 1
+#define NoViableAlt 2
+#define NoSemViableAlt 3
+
+/* MR7 Allow more control over signalling */
+/* by adding "Unwind" and "zzsetSignal" */
+
+#define Unwind 4
+#define zzsetSignal(newValue) *_retsignal=_signal=(newValue)
+#define zzsuppressSignal *_retsignal=_signal=0
+#define zzexportSignal *_retsignal=_signal
+
+ /* F u n c t i o n T r a c i n g */
+
+#ifndef zzTRACE_RULES
+#define zzTRACEdata
+#else
+#ifndef zzTRACEdata
+#define zzTRACEdata ANTLRChar *zzTracePrevRuleName = NULL;
+#endif
+#endif
+
+#ifndef zzTRACEIN
+#define zzTRACEIN(r) zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r);
+#endif
+#ifndef zzTRACEOUT
+#define zzTRACEOUT(r) zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName;
+#endif
+
+/* MR19 zzchar_t additions */
+
+#ifndef zzchar_t
+#ifdef ZZWCHAR_T
+#define zzchar_t wchar_t
+#else
+#define zzchar_t char
+#endif
+#endif
+
+ /* E x t e r n D e f s */
+
+#ifdef __USE_PROTOS
+extern Attrib zzempty_attr(void);
+extern Attrib zzconstr_attr(int, char *);
+extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);
+extern int zzset_el(unsigned, SetWordType *);
+extern int zzset_deg(SetWordType *);
+extern void zzedecode(SetWordType *);
+extern void zzFAIL(int k, ...);
+extern void zzresynch(SetWordType *, SetWordType);
+extern void zzsave_antlr_state(zzantlr_state *);
+extern void zzrestore_antlr_state(zzantlr_state *);
+extern void zzfill_inf_look(void);
+extern void zzconsumeUntil(SetWordType *st); /* MR7 */
+extern void zzconsumeUntilToken(int t); /* MR7 */
+extern void zzTraceIn(char * ruleName); /* MR10 */
+extern void zzTraceOut(char * ruleName); /* MR10 */
+extern int zzTraceOption(int delta); /* MR10 */
+extern int zzTraceGuessOption(int delta); /* MR10 */
+extern void zzTraceReset(void); /* MR10 */
+extern void zzTraceGuessFail(void); /* MR10 */
+#ifdef EXCEPTION_HANDLING
+extern void zzdflthandlers(int, int *);
+#endif
+#else
+extern Attrib zzempty_attr();
+extern Attrib zzconstr_attr();
+extern void zzsyn();
+extern int zzset_el();
+extern int zzset_deg();
+extern void zzedecode();
+extern void zzFAIL();
+extern void zzresynch();
+extern void zzsave_antlr_state();
+extern void zzrestore_antlr_state();
+extern void zzfill_inf_look();
+extern void zzconsumeUntil(); /* MR7 */
+extern void zzconsumeUntilToken(); /* MR7 */
+extern void zzTraceIn(); /* MR10 */
+extern void zzTraceOut(); /* MR10 */
+extern int zzTraceOption(); /* MR10 */
+extern int zzTraceGuessOption(); /* MR10 */
+extern void zzTraceReset(); /* MR10 */
+extern void zzTraceGuessFail(); /* MR10 */
+#ifdef EXCEPTION_HANDLING
+extern void zzdflthandlers();
+#endif
+#endif
+
+ /* G l o b a l V a r i a b l e s */
+
+/* Define a parser; user should do a "#parser myname" in their grammar file */
+/*extern struct pccts_parser zzparser;*/
+
+extern char *zztokens[];
+#ifdef LL_K
+extern int zztokenLA[];
+extern zzchar_t zztextLA[][ZZLEXBUFSIZE];
+extern int zzlap;
+extern int zzlabase;
+#else
+extern int zztoken;
+#endif
+
+extern char zzStackOvfMsg[];
+extern int zzasp;
+extern Attrib zzaStack[];
+#ifdef ZZINF_LOOK
+extern int *zzinf_tokens;
+extern char **zzinf_text;
+extern char *zzinf_text_buffer;
+extern int *zzinf_line;
+extern int zzinf_labase;
+extern int zzinf_last;
+#endif
+#ifdef DEMAND_LOOK
+extern int zzdirty;
+#endif
+#ifdef ZZCAN_GUESS
+extern int zzguessing;
+extern zzjmp_buf zzguess_start;
+#endif
+
+/* Define global veriables that refer to values exported by the scanner.
+ * These declarations duplicate those in dlgdef.h, but are needed
+ * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.
+ */
+extern zzchar_t *zzlextext; /* text of most recently matched token */
+extern int zzbufsize; /* how long zzlextext is */
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c
new file mode 100644
index 0000000000..58db285d89
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c
@@ -0,0 +1,345 @@
+/* Abstract syntax tree manipulation functions
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#ifdef PCCTS_USE_STDARG
+#include "pccts_stdarg.h"
+#else
+#include <varargs.h>
+#endif
+
+/* ensure that tree manipulation variables are current after a rule
+ * reference
+ */
+
+void
+#ifdef __USE_PROTOS
+zzlink(AST **_root, AST **_sibling, AST **_tail)
+#else
+zzlink(_root, _sibling, _tail)
+AST **_root, **_sibling, **_tail;
+#endif
+{
+ if ( *_sibling == NULL ) return;
+ if ( *_root == NULL ) *_root = *_sibling;
+ else if ( *_root != *_sibling ) (*_root)->down = *_sibling;
+ if ( *_tail==NULL ) *_tail = *_sibling;
+ while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right;
+}
+
+AST *
+#ifdef __USE_PROTOS
+zzastnew(void)
+#else
+zzastnew()
+#endif
+{
+ AST *p = (AST *) calloc(1, sizeof(AST));
+ if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__);
+ return p;
+}
+
+/* add a child node to the current sibling list */
+void
+#ifdef __USE_PROTOS
+zzsubchild(AST **_root, AST **_sibling, AST **_tail)
+#else
+zzsubchild(_root, _sibling, _tail)
+AST **_root, **_sibling, **_tail;
+#endif
+{
+ AST *n;
+ zzNON_GUESS_MODE {
+ n = zzastnew();
+#ifdef DEMAND_LOOK
+ zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));
+#else
+ zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));
+#endif
+ zzastPush( n );
+ if ( *_tail != NULL ) (*_tail)->right = n;
+ else {
+ *_sibling = n;
+ if ( *_root != NULL ) (*_root)->down = *_sibling;
+ }
+ *_tail = n;
+ if ( *_root == NULL ) *_root = *_sibling;
+ }
+}
+
+/* make a new AST node. Make the newly-created
+ * node the root for the current sibling list. If a root node already
+ * exists, make the newly-created node the root of the current root.
+ */
+void
+#ifdef __USE_PROTOS
+zzsubroot(AST **_root, AST **_sibling, AST **_tail)
+#else
+zzsubroot(_root, _sibling, _tail)
+AST **_root, **_sibling, **_tail;
+#endif
+{
+ AST *n;
+ zzNON_GUESS_MODE {
+ n = zzastnew();
+#ifdef DEMAND_LOOK
+ zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));
+#else
+ zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));
+#endif
+ zzastPush( n );
+ if ( *_root != NULL )
+ if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root;
+ *_root = n;
+ (*_root)->down = *_sibling;
+ }
+}
+
+/* Apply function to root then each sibling
+ * example: print tree in child-sibling LISP-format (AST has token field)
+ *
+ * void show(tree)
+ * AST *tree;
+ * {
+ * if ( tree == NULL ) return;
+ * printf(" %s", zztokens[tree->token]);
+ * }
+ *
+ * void before() { printf(" ("); }
+ * void after() { printf(" )"); }
+ *
+ * LISPdump() { zzpre_ast(tree, show, before, after); }
+ *
+ */
+void
+#ifdef __USE_PROTOS
+zzpre_ast(
+ AST *tree,
+ void (*func)(AST *), /* apply this to each tree node */
+ void (*before)(AST *), /* apply this to root of subtree before preordering it */
+ void (*after)(AST *)) /* apply this to root of subtree after preordering it */
+#else
+zzpre_ast(tree, func, before, after)
+AST *tree;
+void (*func)(), /* apply this to each tree node */
+ (*before)(), /* apply this to root of subtree before preordering it */
+ (*after)(); /* apply this to root of subtree after preordering it */
+#endif
+{
+ while ( tree!= NULL )
+ {
+ if ( tree->down != NULL ) (*before)(tree);
+ (*func)(tree);
+ zzpre_ast(tree->down, func, before, after);
+ if ( tree->down != NULL ) (*after)(tree);
+ tree = tree->right;
+ }
+}
+
+/* free all AST nodes in tree; apply func to each before freeing */
+
+#if 0
+////void
+////#ifdef __USE_PROTOS
+////zzfree_ast(AST *tree)
+////#else
+////zzfree_ast(tree)
+////AST *tree;
+////#endif
+////{
+//// if ( tree == NULL ) return;
+//// zzfree_ast( tree->down );
+//// zzfree_ast( tree->right );
+//// zztfree( tree );
+////}
+#endif
+
+/*
+ MR19 Optimize freeing of the following structure to limit recursion
+ SAKAI Kiyotaka (ksakai@isr.co.jp)
+*/
+
+/*
+ NULL o
+ / \
+ NULL o
+ / \
+ NULL NULL
+*/
+
+/*
+ MR21 Another refinement to replace recursion with iteration
+ NAKAJIMA Mutsuki (muc@isr.co.jp).
+*/
+
+void
+#ifdef __USE_PROTOS
+zzfree_ast(AST *tree)
+#else
+zzfree_ast(tree)
+AST *tree;
+#endif
+{
+
+ AST *otree;
+
+ if (tree == NULL) return;
+
+ while (tree->down == NULL || tree->right == NULL) {
+
+ if (tree->down == NULL && tree->right == NULL) {
+ zztfree(tree);
+ return;
+ }
+
+ otree = tree;
+ if (tree->down == NULL) {
+ tree = tree->right;
+ } else {
+ tree = tree->down;
+ }
+ zztfree( otree );
+ }
+
+ while (tree != NULL) {
+ zzfree_ast(tree->down);
+ otree = tree;
+ tree = otree->right;
+ zztfree(otree);
+ }
+}
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually siblins lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ */
+#ifdef PCCTS_USE_STDARG
+AST *zztmake(AST *rt, ...)
+#else
+AST *zztmake(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w;
+ AST *root;
+
+#ifdef PCCTS_USE_STDARG
+ va_start(ap, rt);
+ root = rt;
+#else
+ va_start(ap);
+ root = va_arg(ap, AST *);
+#endif
+
+ if ( root != NULL )
+ if ( root->down != NULL ) return NULL;
+ child = va_arg(ap, AST *);
+ while ( child != NULL )
+ {
+ for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */
+ if ( sibling == NULL ) {sibling = child; tail = w;}
+ else {tail->right = child; tail = w;}
+ child = va_arg(ap, AST *);
+ }
+ if ( root==NULL ) root = sibling;
+ else root->down = sibling;
+ va_end(ap);
+ return root;
+}
+
+/* tree duplicate */
+AST *
+#ifdef __USE_PROTOS
+zzdup_ast(AST *t)
+#else
+zzdup_ast(t)
+AST *t;
+#endif
+{
+ AST *u;
+
+ if ( t == NULL ) return NULL;
+ u = zzastnew();
+ *u = *t;
+#ifdef zzAST_DOUBLE
+ u->up = NULL; /* set by calling invocation */
+ u->left = NULL;
+#endif
+ u->right = zzdup_ast(t->right);
+ u->down = zzdup_ast(t->down);
+#ifdef zzAST_DOUBLE
+ if ( u->right!=NULL ) u->right->left = u;
+ if ( u->down!=NULL ) u->down->up = u;
+#endif
+ return u;
+}
+
+void
+#ifdef __USE_PROTOS
+zztfree(AST *t)
+#else
+zztfree(t)
+AST *t;
+#endif
+{
+#ifdef zzd_ast
+ zzd_ast( t );
+#endif
+ free( t );
+}
+
+#ifdef zzAST_DOUBLE
+/*
+ * Set the 'up', and 'left' pointers of all nodes in 't'.
+ * Initial call is double_link(your_tree, NULL, NULL).
+ */
+void
+#ifdef __USE_PROTOS
+zzdouble_link(AST *t, AST *left, AST *up)
+#else
+zzdouble_link(t, left, up)
+AST *t, *left, *up;
+#endif
+{
+ if ( t==NULL ) return;
+ t->left = left;
+ t->up = up;
+ zzdouble_link(t->down, NULL, t);
+ zzdouble_link(t->right, t, up);
+}
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h
new file mode 100644
index 0000000000..dba8be25c5
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h
@@ -0,0 +1,115 @@
+/* Abstract syntax tree
+ *
+ * Macros, definitions
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ZZAST_H
+#define ZZAST_H
+
+#define zzastOvfChk \
+ if ( zzast_sp <= 0 ) \
+ { \
+ fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \
+ exit(PCCTS_EXIT_FAILURE); \
+ }
+
+#ifndef USER_DEFINED_AST
+#ifndef AST_FIELDS
+#define AST_FIELDS
+#endif
+
+typedef struct _ast {
+ struct _ast *right, *down;
+#ifdef zzAST_DOUBLE
+ struct _ast *left, *up;
+#endif
+ AST_FIELDS
+} AST;
+
+#else
+
+#ifdef zzAST_DOUBLE
+#define AST_REQUIRED_FIELDS struct _ast *right, *down, *left, *up;
+#else
+#define AST_REQUIRED_FIELDS struct _ast *right, *down;
+#endif
+
+#endif
+
+
+/* N o d e a c c e s s m a c r o s */
+#define zzchild(t) (((t)==NULL)? (AST *) NULL:(t->down)) /* MR19 */
+#define zzsibling(t) (((t)==NULL)? (AST *) NULL:(t->right)) /* MR19 */
+
+
+/* define global variables needed by #i stack */
+#define zzASTgvars \
+ AST *zzastStack[ZZAST_STACKSIZE]; \
+ int zzast_sp = ZZAST_STACKSIZE;
+
+#define zzASTVars AST *_ast = NULL, *_sibling = NULL, *_tail = NULL
+#define zzSTR ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )
+#define zzastCur (zzastStack[zzast_sp])
+#define zzastArg(i) (zzastStack[zztsp-i])
+#define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;
+#define zzastDPush --zzast_sp
+#define zzastMARK zztsp=zzast_sp; /* Save state of stack */
+#define zzastREL zzast_sp=zztsp; /* Return state of stack */
+#define zzrm_ast {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}
+
+extern int zzast_sp;
+extern AST *zzastStack[];
+
+#ifdef __USE_PROTOS
+void zzlink(AST **, AST **, AST **);
+void zzsubchild(AST **, AST **, AST **);
+void zzsubroot(AST **, AST **, AST **);
+void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));
+void zzfree_ast(AST *);
+AST *zztmake(AST *, ...);
+AST *zzdup_ast(AST *);
+void zztfree(AST *);
+void zzdouble_link(AST *, AST *, AST *);
+AST *zzastnew(void);
+
+#else
+
+void zzlink();
+AST *zzastnew();
+void zzsubchild();
+void zzsubroot();
+void zzpre_ast();
+void zzfree_ast();
+AST *zztmake();
+AST *zzdup_ast();
+void zztfree();
+void zzdouble_link();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h
new file mode 100644
index 0000000000..874e37a297
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h
@@ -0,0 +1,46 @@
+/* ANTLR attribute definition -- constant width text
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ZZCHARBUF_H
+#define ZZCHARBUF_H
+
+#include "pcctscfg.h"
+
+#include "pccts_string.h"
+
+#ifndef D_TextSize
+#define D_TextSize 30
+#endif
+
+typedef struct { char text[D_TextSize]; } Attrib;
+
+#define zzcr_attr(a,tok,t) strncpy((a)->text, t, D_TextSize-1); \
+ (a)->text[D_TextSize-1] = '\0';
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c
new file mode 100644
index 0000000000..930c5df667
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c
@@ -0,0 +1,58 @@
+/*
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#include "pcctscfg.h"
+
+#ifdef __STDC__
+#include "pccts_stdlib.h"
+#else
+#include <malloc.h>
+#endif
+#include "pccts_string.h"
+
+/* 133MR1 include stdio.h for fprintf in charptr.c */
+
+#include "pccts_stdio.h"
+
+/* 133MR1 include charptr.h for Attrib in charptr.c */
+
+#include "charptr.h"
+
+#ifdef __USE_PROTOS
+zzcr_attr(Attrib *a,int token,char *text)
+#else
+zzcr_attr(a,token,text)
+Attrib *a;
+int token;
+char *text;
+#endif
+{
+ *a = (char *) malloc(strlen(text)+1); /* MR6 */
+ if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}
+ strcpy(*a, text);
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h
new file mode 100644
index 0000000000..3e92b05c0e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+/*
+ * WARNING!!!!: charptr.h does NOT make copies and the
+ * memory is freed after the attribute scope exits.
+ */
+
+#ifndef ZZCHARPTR_H
+#define ZZCHARPTR_H
+
+typedef char *Attrib;
+#define zzdef0(a) {*(a)=NULL;}
+/* MR8 Jens Tingleff (jensting@imaginet.fr) */
+/* Set memory pointer to null after free() */
+#define zzd_attr(a) {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; }
+
+#ifdef __STDC__
+extern zzcr_attr(Attrib *,int,char *);
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h
new file mode 100644
index 0000000000..8aa50ad618
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h
@@ -0,0 +1 @@
+#include "pcctscfg.h"
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h
new file mode 100644
index 0000000000..41881e929d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h
@@ -0,0 +1,499 @@
+/* dlgauto.h automaton
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Will Cohen and Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ZZDEFAUTO_H
+#define ZZDEFAUTO_H
+
+/* 10-Apr-97 133MR1 Uses __USE_PROTOS show should #include pcctscfg.h */
+
+#include "pcctscfg.h"
+
+zzchar_t *zzlextext; /* text of most recently matched token */
+zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */
+zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */
+int zzbufsize = 0; /* number of characters in zzlextext */ /* MR7 */
+int zzbegcol = 0; /* column that first character of token is in*/
+int zzendcol = 0; /* column that last character of token is in */
+int zzline = 1; /* line current token is on */
+int zzreal_line=1; /* line of 1st portion of token that is not skipped */
+int zzchar; /* character to determine next state */
+int zzbufovf; /* indicates that buffer too small for text */
+int zzcharfull = 0;
+static zzchar_t *zznextpos;/* points to next available position in zzlextext*/
+static int zzclass;
+
+#ifdef __USE_PROTOS
+void zzerrstd(const char *);
+void (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */
+extern int zzerr_in(void);
+static int (*zzfunc_in)(void) = zzerr_in; /* MR20 */
+#else
+void zzerrstd();
+void (*zzerr)()=zzerrstd; /* pointer to error reporting function */
+extern int zzerr_in();
+static int (*zzfunc_in)() = zzerr_in; /* MR20 */
+#endif
+
+static FILE *zzstream_in=0;
+static zzchar_t *zzstr_in=0;
+
+#ifdef USER_ZZMODE_STACK
+int zzauto = 0;
+#else
+static int zzauto = 0;
+#endif
+static int zzadd_erase;
+static char zzebuf[70];
+
+#ifdef ZZCOL
+#define ZZINC (++zzendcol)
+#else
+#define ZZINC
+#endif
+
+
+#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}
+#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}
+#define ZZGETC_STR { \
+ if (*zzstr_in){ \
+ zzchar = *zzstr_in; \
+ ++zzstr_in; \
+ }else{ \
+ zzchar = EOF; \
+ } \
+ zzclass = ZZSHIFT(zzchar); \
+}
+
+#define ZZNEWSTATE (newstate = dfa[state][zzclass])
+
+#ifndef ZZCOPY
+#define ZZCOPY \
+ /* Truncate matching buffer to size (not an error) */ \
+ if (zznextpos < lastpos){ \
+ *(zznextpos++) = zzchar; \
+ }else{ \
+ zzbufovf = 1; \
+ }
+#endif
+
+void
+#ifdef __USE_PROTOS
+zzrdstream( FILE *f )
+#else
+zzrdstream( f )
+FILE *f;
+#endif
+{
+ /* make sure that it is really set to something, otherwise just
+ leave it be.
+ */
+ if (f){
+ /* make sure that there is always someplace to get input
+ before closing zzstream_in
+ */
+#if 0
+ if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
+#endif
+ zzline = 1;
+ zzstream_in = f;
+ zzfunc_in = NULL;
+ zzstr_in = 0;
+ zzcharfull = 0;
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+zzrdfunc( int (*f)(void) )
+#else
+zzrdfunc( f )
+int (*f)();
+#endif
+{
+ /* make sure that it is really set to something, otherwise just
+ leave it be.
+ */
+ if (f){
+ /* make sure that there is always someplace to get input
+ before closing zzstream_in
+ */
+#if 0
+ if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
+#endif
+ zzline = 1;
+ zzstream_in = NULL;
+ zzfunc_in = f;
+ zzstr_in = 0;
+ zzcharfull = 0;
+ }
+}
+
+
+void
+#ifdef __USE_PROTOS
+zzrdstr( zzchar_t *s )
+#else
+zzrdstr( s )
+zzchar_t *s;
+#endif
+{
+ /* make sure that it is really set to something, otherwise just
+ leave it be.
+ */
+ if (s){
+ /* make sure that there is always someplace to get input
+ before closing zzstream_in
+ */
+#if 0
+ if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );
+#endif
+ zzline = 1;
+ zzstream_in = NULL;
+ zzfunc_in = 0;
+ zzstr_in = s;
+ zzcharfull = 0;
+ }
+}
+
+
+#ifdef __USE_PROTOS
+void zzclose_stream(void)
+#else
+void zzclose_stream()
+#endif
+{
+#if 0
+ fclose( zzstream_in );
+ zzstream_in = NULL;
+ zzfunc_in = NULL;
+#endif
+}
+
+/* saves dlg state, but not what feeds dlg (such as file position) */
+void
+#ifdef __USE_PROTOS
+zzsave_dlg_state(struct zzdlg_state *state)
+#else
+zzsave_dlg_state(state)
+struct zzdlg_state *state;
+#endif
+{
+ state->stream = zzstream_in;
+ state->func_ptr = zzfunc_in;
+ state->str = zzstr_in;
+ state->auto_num = zzauto;
+ state->add_erase = zzadd_erase;
+ state->lookc = zzchar;
+ state->char_full = zzcharfull;
+ state->begcol = zzbegcol;
+ state->endcol = zzendcol;
+ state->line = zzline;
+ state->lextext = zzlextext;
+ state->begexpr = zzbegexpr;
+ state->endexpr = zzendexpr;
+ state->bufsize = zzbufsize;
+ state->bufovf = zzbufovf;
+ state->nextpos = zznextpos;
+ state->class_num = zzclass;
+}
+
+void
+#ifdef __USE_PROTOS
+zzrestore_dlg_state(struct zzdlg_state *state)
+#else
+zzrestore_dlg_state(state)
+struct zzdlg_state *state;
+#endif
+{
+ zzstream_in = state->stream;
+ zzfunc_in = state->func_ptr;
+ zzstr_in = state->str;
+ zzauto = state->auto_num;
+ zzadd_erase = state->add_erase;
+ zzchar = state->lookc;
+ zzcharfull = state->char_full;
+ zzbegcol = state->begcol;
+ zzendcol = state->endcol;
+ zzline = state->line;
+ zzlextext = state->lextext;
+ zzbegexpr = state->begexpr;
+ zzendexpr = state->endexpr;
+ zzbufsize = state->bufsize;
+ zzbufovf = state->bufovf;
+ zznextpos = state->nextpos;
+ zzclass = state->class_num;
+}
+
+void
+#ifdef __USE_PROTOS
+zzmode( int m )
+#else
+zzmode( m )
+int m;
+#endif
+{
+ /* points to base of dfa table */
+ if (m<MAX_MODE){
+ zzauto = m;
+ /* have to redo class since using different compression */
+ zzclass = ZZSHIFT(zzchar);
+ }else{
+ sprintf(zzebuf,"Invalid automaton mode = %d ",m);
+ zzerr(zzebuf);
+ }
+}
+
+/* erase what is currently in the buffer, and get a new reg. expr */
+
+#ifdef __USE_PROTOS
+void zzskip(void)
+#else
+void zzskip()
+#endif
+{
+ zzadd_erase = 1;
+}
+
+/* don't erase what is in the zzlextext buffer, add on to it */
+#ifdef __USE_PROTOS
+void zzmore()
+#else
+void zzmore()
+#endif
+{
+ zzadd_erase = 2;
+}
+
+/* substitute c for the reg. expr last matched and is in the buffer */
+#ifdef __USE_PROTOS
+void
+zzreplchar(zzchar_t c)
+#else
+void
+zzreplchar(c)
+zzchar_t c;
+#endif
+{
+ /* can't allow overwriting null at end of string */
+ if (zzbegexpr < &zzlextext[zzbufsize-1]){
+ *zzbegexpr = c;
+ *(zzbegexpr+1) = '\0';
+ }
+ zzendexpr = zzbegexpr;
+ zznextpos = zzbegexpr + 1;
+}
+
+/* replace the string s for the reg. expr last matched and in the buffer */
+void
+#ifdef __USE_PROTOS
+zzreplstr(register zzchar_t *s)
+#else
+zzreplstr(s)
+register zzchar_t *s;
+#endif
+{
+ register zzchar_t *l= &zzlextext[zzbufsize -1];
+
+ zznextpos = zzbegexpr;
+ if (s){
+ while ((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){
+ /* empty */
+ }
+ /* correct for NULL at end of string */
+ zznextpos--;
+ }
+ if ((zznextpos <= l) && (*(--s) == 0)){
+ zzbufovf = 0;
+ }else{
+ zzbufovf = 1;
+ }
+ *(zznextpos) = '\0';
+ zzendexpr = zznextpos - 1;
+}
+
+#ifdef __USE_PROTOS
+void zzgettok(void)
+#else
+void zzgettok()
+#endif
+{
+ register int state, newstate;
+ /* last space reserved for the null char */
+ register zzchar_t *lastpos;
+
+skip:
+ zzreal_line = zzline;
+ zzbufovf = 0;
+ lastpos = &zzlextext[zzbufsize-1];
+ zznextpos = zzlextext;
+ zzbegcol = zzendcol+1;
+more:
+ zzbegexpr = zznextpos;
+#ifdef ZZINTERACTIVE
+ /* interactive version of automaton */
+ /* if there is something in zzchar, process it */
+ state = newstate = dfa_base[zzauto];
+ if (zzcharfull){
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ if (zzstr_in)
+ while (zzalternatives[newstate]){
+ state = newstate;
+ ZZGETC_STR;
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ else if (zzstream_in)
+ while (zzalternatives[newstate]){
+ state = newstate;
+ ZZGETC_STREAM;
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ else if (zzfunc_in)
+ while (zzalternatives[newstate]){
+ state = newstate;
+ ZZGETC_FUNC;
+ ZZINC;
+ ZZCOPY;
+ ZZNEWSTATE;
+ }
+ /* figure out if last character really part of token */
+ if ((state != dfa_base[zzauto]) && (newstate == DfaStates)){
+ zzcharfull = 1;
+ --zznextpos;
+ }else{
+ zzcharfull = 0;
+ state = newstate;
+ }
+ *(zznextpos) = '\0';
+ /* Able to transition out of start state to some non err state?*/
+ if ( state == dfa_base[zzauto] ){
+ /* make sure doesn't get stuck */
+ zzadvance();
+ }
+#else
+ /* non-interactive version of automaton */
+ if (!zzcharfull)
+ zzadvance();
+ else
+ ZZINC;
+ state = dfa_base[zzauto];
+ if (zzstr_in)
+ while (ZZNEWSTATE != DfaStates){
+ state = newstate;
+ ZZCOPY;
+ ZZGETC_STR;
+ ZZINC;
+ }
+ else if (zzstream_in)
+ while (ZZNEWSTATE != DfaStates){
+ state = newstate;
+ ZZCOPY;
+ ZZGETC_STREAM;
+ ZZINC;
+ }
+ else if (zzfunc_in)
+ while (ZZNEWSTATE != DfaStates){
+ state = newstate;
+ ZZCOPY;
+ ZZGETC_FUNC;
+ ZZINC;
+ }
+ zzcharfull = 1;
+ if ( state == dfa_base[zzauto] ){
+ if (zznextpos < lastpos){
+ *(zznextpos++) = zzchar;
+ }else{
+ zzbufovf = 1;
+ }
+ *zznextpos = '\0';
+ /* make sure doesn't get stuck */
+ zzadvance();
+ }else{
+ *zznextpos = '\0';
+ }
+#endif
+#ifdef ZZCOL
+ zzendcol -= zzcharfull;
+#endif
+ zzendexpr = zznextpos -1;
+ zzadd_erase = 0;
+ (*actions[accepts[state]])();
+ switch (zzadd_erase) {
+ case 1: goto skip;
+ case 2: goto more;
+ }
+}
+
+#ifdef __USE_PROTOS
+void zzadvance(void)
+#else
+void zzadvance()
+#endif
+{
+ if (zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}
+ if (zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}
+ if (zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}
+ if (!(zzstream_in || zzfunc_in || zzstr_in)){
+ zzerr_in();
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+zzerrstd(const char *s)
+#else
+zzerrstd(s)
+char *s;
+#endif
+{
+ zzLexErrCount++; /* MR11 */
+ fprintf(stderr,
+ "%s near line %d (text was '%s')\n",
+ ((s == NULL) ? "Lexical error" : s),
+ zzline,zzlextext);
+}
+
+#ifdef __USE_PROTOS
+int zzerr_in(void)
+#else
+int zzerr_in()
+#endif
+{
+ fprintf(stderr,"No input stream, function, or string\n");
+ /* return eof to get out gracefully */
+ return EOF;
+}
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h
new file mode 100644
index 0000000000..d45c6277e2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h
@@ -0,0 +1,128 @@
+/* dlgdef.h
+ * Things in scanner produced by dlg that should be visible to the outside
+ * world
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ZZDLGDEF_H
+#define ZZDLGDEF_H
+
+#include "pcctscfg.h"
+
+#ifndef zzchar_t
+#ifdef ZZWCHAR_T
+#define zzchar_t wchar_t
+#else
+#define zzchar_t char
+#endif
+#endif
+
+struct zzdlg_state {
+ FILE *stream;
+#ifdef __USE_PROTOS
+ int (*func_ptr)(void);
+#else
+ int (*func_ptr)();
+#endif
+ zzchar_t *str;
+ int auto_num;
+ int add_erase;
+ int lookc;
+ int char_full;
+ int begcol, endcol;
+ int line;
+ zzchar_t *lextext, *begexpr, *endexpr;
+ int bufsize;
+ int bufovf;
+ zzchar_t *nextpos;
+ int class_num;
+};
+
+extern zzchar_t *zzlextext; /* text of most recently matched token */
+extern zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */
+extern zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */
+extern int zzbufsize; /* how long zzlextext is */
+extern int zzbegcol; /* column that first character of token is in*/
+extern int zzendcol; /* column that last character of token is in */
+extern int zzline; /* line current token is on */
+extern int zzreal_line; /* line of 1st portion of token that is not skipped */
+extern int zzchar; /* character to determine next state */
+extern int zzbufovf; /* indicates that buffer too small for text */
+#ifdef __USE_PROTOS
+extern void (*zzerr)(const char *);/* pointer to error reporting function */
+#else
+extern void (*zzerr)();
+#endif
+
+#ifdef USER_ZZMODE_STACK
+extern int zzauto;
+#endif
+
+#ifdef __USE_PROTOS
+extern void zzadvance(void);
+extern void zzskip(void); /* erase zzlextext, look for antoher token */
+extern void zzmore(void); /* keep zzlextext, look for another token */
+extern void zzmode(int k); /* switch to automaton 'k' */
+extern void zzrdstream(FILE *);/* what stream to read from */
+extern void zzclose_stream(void);/* close the current input stream */
+extern void zzrdfunc(int (*)(void));/* what function to get char from */
+extern void zzrdstr( zzchar_t * );
+extern void zzgettok(void); /* get next token */
+extern void zzreplchar(zzchar_t c);/* replace last recognized reg. expr. with
+ a character */
+extern void zzreplstr(zzchar_t *s);/* replace last recognized reg. expr. with
+ a string */
+extern void zzsave_dlg_state(struct zzdlg_state *);
+extern void zzrestore_dlg_state(struct zzdlg_state *);
+extern int zzerr_in(void);
+extern void zzerrstd(const char *);
+extern void zzerraction(void);
+
+#else
+
+extern void zzadvance();
+extern void zzskip(); /* erase zzlextext, look for antoher token */
+extern void zzmore(); /* keep zzlextext, look for another token */
+extern void zzmode(/*k*/); /* switch to automaton 'k' */
+extern void zzrdstream(); /* what stream to read from */
+extern void zzclose_stream();/* close the current input stream */
+extern void zzrdfunc(); /* what function to get char from */
+extern void zzrdstr();
+extern void zzgettok(); /* get next token */
+extern void zzreplchar(); /* replace last recognized reg. expr. with
+ a character */
+extern void zzreplstr(); /* replace last recognized reg. expr. with
+ a string */
+extern void zzsave_dlg_state();
+extern void zzrestore_dlg_state();
+extern int zzerr_in();
+extern void zzerrstd();
+extern void zzerraction();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h
new file mode 100644
index 0000000000..c08dbb4b05
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h
@@ -0,0 +1,1168 @@
+/*
+ * err.h
+ *
+ * Standard error handling mechanism
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ERR_H
+#define ERR_H
+
+#include "pcctscfg.h"
+#include <stdlib.h>
+#include <assert.h>
+
+/* */
+/* 7-Apr-97 133MR1 */
+/* Proper choice of STDC and cplusplus pre-processor symbols (?) */
+/* */
+#include "pccts_string.h"
+
+#ifdef PCCTS_USE_STDARG
+#include "pccts_stdarg.h"
+#else
+#include <varargs.h>
+#endif
+
+#ifdef DUM
+/* Define usable bits per unsigned int word (used for set stuff) */
+#ifdef PC
+#define BSETWORDSIZE 16
+#define BSETLOGWORDSIZE 4
+#else
+#define BSETWORDSIZE 32
+#define BSETLOGWORDSIZE 5
+#endif
+#endif
+
+#define BSETWORDSIZE 8
+#define BSETLOGWORDSIZE 3 /* SetWordType is 8bits */
+
+#define BSETMODWORD(x) ((x) & (BSETWORDSIZE-1)) /* x % BSETWORDSIZE */
+#define BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE) /* x / BSETWORDSIZE */
+
+/* This is not put into the global pccts_parser structure because it is
+ * hidden and does not need to be saved during a "save state" operation
+ */
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte */
+static SetWordType bitmask[] = {
+ 0x00000001, 0x00000002, 0x00000004, 0x00000008,
+ 0x00000010, 0x00000020, 0x00000040, 0x00000080
+};
+
+#ifdef zzTRACE_RULES
+int zzTraceOptionValueDefault=1;
+int zzTraceOptionValue=1;
+int zzTraceGuessOptionValue=1;
+char *zzTraceCurrentRuleName=NULL;
+int zzTraceDepth=0;
+#endif
+
+int zzGuessSeq=0; /* MR10 */
+int zzSyntaxErrCount=0; /* MR11 */
+int zzLexErrCount=0; /* MR11 */
+
+void
+#ifdef __USE_PROTOS
+zzresynch(SetWordType *wd,SetWordType mask)
+#else
+zzresynch(wd,mask)
+SetWordType *wd, mask;
+#endif
+{
+ static int consumed = 1;
+
+ /* if you enter here without having consumed a token from last resynch
+ * force a token consumption.
+ */
+ if ( !consumed ) {zzCONSUME; consumed=1; return;} /* MR10 */
+
+ /* if current token is in resynch set, we've got what we wanted */
+ if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}
+
+ /* scan until we find something in the resynch set */
+ while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}
+ consumed=1;
+}
+
+/* */
+/* 7-Apr-97 133MR1 for C++ and MR7 for C */
+/* Change suggested by Eli Sternheim (eli@interhdl.com) */
+/* */
+
+void
+#ifdef __USE_PROTOS
+zzconsumeUntil(SetWordType *st)
+#else
+zzconsumeUntil(st)
+SetWordType *st;
+#endif
+{
+ int tmp; /* MR7 */
+ while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) { /* MR7 */
+ zzCONSUME; } /* MR7 */
+}
+
+/* */
+/* 7-Apr-97 133MR1 for C++ and MR7 for C */
+/* Change suggested by Eli Sternheim (eli@interhdl.com) */
+/* */
+
+void
+#ifdef __USE_PROTOS
+zzconsumeUntilToken(int t)
+#else
+zzconsumeUntilToken(t)
+int t;
+#endif
+{
+ int tmp; /* MR7 */
+ while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; } /* MR7 */
+}
+
+/* input looks like:
+ * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)
+ * where the zzMiss stuff is set here to the token that did not match
+ * (and which set wasn't it a member of).
+ */
+
+#ifdef PCCTS_USE_STDARG
+void zzFAIL(int k, ...)
+#else
+void zzFAIL(va_alist)
+va_dcl
+#endif
+{
+#ifdef LL_K
+ static char text[LL_K*ZZLEXBUFSIZE+1];
+ SetWordType *f[LL_K];
+#else
+ static char text[ZZLEXBUFSIZE+1];
+ SetWordType *f[1];
+#endif
+ SetWordType **miss_set;
+ char **miss_text;
+ int *bad_tok;
+ char **bad_text;
+ int *err_k;
+ int i;
+ va_list ap;
+#ifndef PCCTS_USE_STDARG /* MR20 */
+ int k;
+#endif
+#ifdef PCCTS_USE_STDARG /* MR20 */
+ va_start(ap, k);
+#else
+ va_start(ap);
+ k = va_arg(ap, int); /* how many lookahead sets? */
+#endif
+ assert(k <= sizeof(f)/sizeof(f[0])); /* MR20 G. Hobbelt */
+ text[0] = '\0';
+ for (i=1; i<=k; i++) /* collect all lookahead sets */
+ {
+ f[i-1] = va_arg(ap, SetWordType *);
+ }
+ for (i=1; i<=k; i++) /* look for offending token */
+ {
+ if ( i>1 ) strcat(text, " ");
+ strcat(text, LATEXT(i));
+ if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;
+ }
+ miss_set = va_arg(ap, SetWordType **);
+ miss_text = va_arg(ap, char **);
+ bad_tok = va_arg(ap, int *);
+ bad_text = va_arg(ap, char **);
+ err_k = va_arg(ap, int *);
+ if ( i>k )
+ {
+ /* bad; lookahead is permutation that cannot be matched,
+ * but, the ith token of lookahead is valid at the ith position
+ * (The old LL sub 1 (k) versus LL(k) parsing technique)
+ */
+ *miss_set = NULL;
+ *miss_text = zzlextext;
+ *bad_tok = LA(1);
+ *bad_text = LATEXT(1);
+ *err_k = k;
+ return;
+ }
+/* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
+ *miss_set = f[i-1];
+ *miss_text = text;
+ *bad_tok = LA(i);
+ *bad_text = LATEXT(i);
+ if ( i==1 ) *err_k = 1;
+ else *err_k = k;
+}
+
+#ifdef __USE_PROTOS
+void zzTraceGuessDone(zzantlr_state *state)
+#else
+void zzTraceGuessDone(state)
+ zzantlr_state *state;
+#endif
+{
+#ifdef zzTRACE_RULES
+#ifdef ZZCAN_GUESS
+
+ int doIt=0;
+
+ if (zzTraceCurrentRuleName == NULL) return;
+
+ if (zzTraceOptionValue <= 0) {
+ doIt=0;
+ } else if (zzTraceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",
+ state->traceCurrentRuleName,
+ LATEXT(1),
+ state->traceDepth);
+ if (state->guessing != 0) {
+ fprintf(stderr," (guess mode continues - an enclosing guess is still active)");
+ } else {
+ fprintf(stderr," (guess mode ends)");
+ };
+ fprintf(stderr,"\n");
+ };
+#endif
+#endif
+}
+
+void
+#ifdef __USE_PROTOS
+zzsave_antlr_state(zzantlr_state *buf)
+#else
+zzsave_antlr_state(buf)
+zzantlr_state *buf;
+#endif
+{
+#ifdef LL_K
+ int i;
+#endif
+
+#ifdef ZZCAN_GUESS
+ buf->guess_start = zzguess_start;
+ buf->guessing = zzguessing;
+#endif
+ buf->asp = zzasp;
+#ifdef GENAST
+ buf->ast_sp = zzast_sp;
+#endif
+#ifdef ZZINF_LOOK
+ buf->inf_labase = zzinf_labase;
+ buf->inf_last = zzinf_last;
+
+/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
+/* MR6 Additional state needs to be saved/restored */
+
+ buf->inf_tokens = zzinf_tokens; /* MR6 */
+ buf->inf_text = zzinf_text; /* MR6 */
+ buf->inf_text_buffer = zzinf_text_buffer; /* MR6 */
+ buf->inf_line = zzinf_line; /* MR6 */
+
+#endif
+#ifdef DEMAND_LOOK
+ buf->dirty = zzdirty;
+#endif
+#ifdef LL_K
+ for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];
+ for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);
+ buf->lap = zzlap;
+ buf->labase = zzlabase;
+#else
+ buf->token = zztoken;
+ strcpy(buf->text, zzlextext);
+#endif
+#ifdef zzTRACE_RULES
+
+ /* MR10 */
+
+ buf->traceOptionValue=zzTraceOptionValue;
+ buf->traceGuessOptionValue=zzTraceGuessOptionValue;
+ buf->traceCurrentRuleName=zzTraceCurrentRuleName;
+ buf->traceDepth=zzTraceDepth;
+#endif
+}
+
+void
+#ifdef __USE_PROTOS
+zzrestore_antlr_state(zzantlr_state *buf)
+#else
+zzrestore_antlr_state(buf)
+zzantlr_state *buf;
+#endif
+{
+
+#ifdef zzTRACE_RULES
+ int prevTraceOptionValue;
+#endif
+
+#ifdef LL_K
+ int i;
+#endif
+
+#ifdef ZZCAN_GUESS
+ zzguess_start = buf->guess_start;
+ zzguessing = buf->guessing;
+#endif
+ zzasp = buf->asp;
+#ifdef GENAST
+ zzast_sp = buf->ast_sp;
+#endif
+#ifdef ZZINF_LOOK
+ zzinf_labase = buf->inf_labase;
+ zzinf_last = buf->inf_last;
+
+/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
+/* MR6 Additional state needs to be saved/restored */
+
+ zzinf_tokens = buf->inf_tokens; /* MR6 */
+ zzinf_text = buf->inf_text; /* MR6 */
+ zzinf_text_buffer = buf->inf_text_buffer; /* MR6 */
+ zzinf_line = buf->inf_line; /* MR6 */
+#endif
+#ifdef DEMAND_LOOK
+ zzdirty = buf->dirty;
+#endif
+#ifdef LL_K
+ for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];
+ for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);
+ zzlap = buf->lap;
+ zzlabase = buf->labase;
+#else
+ zztoken = buf->token;
+ strcpy(zzlextext, buf->text);
+#endif
+#ifdef zzTRACE_RULES
+
+ prevTraceOptionValue=zzTraceOptionValue;
+ zzTraceOptionValue=buf->traceOptionValue;
+ if ( (prevTraceOptionValue > 0) !=
+ (zzTraceOptionValue > 0)) {
+ if (zzTraceOptionValue > 0) {
+ fprintf(stderr,"trace enable restored in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ if (zzTraceOptionValue <= 0) {
+ fprintf(stderr,"trace disable restored in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ };
+
+ zzTraceOptionValue=buf->traceOptionValue; /* MR10 */
+ zzTraceGuessOptionValue=buf->traceGuessOptionValue; /* MR10 */
+ zzTraceCurrentRuleName=buf->traceCurrentRuleName; /* MR10 */
+ zzTraceDepth=buf->traceDepth; /* MR10 */
+ zzTraceGuessDone(buf); /* MR10 */
+#endif
+}
+
+void
+#ifdef __USE_PROTOS
+zzedecode(SetWordType *a)
+#else
+zzedecode(a)
+SetWordType *a;
+#endif
+{
+ register SetWordType *p = a;
+ register SetWordType *endp = &(p[zzSET_SIZE]);
+ register unsigned e = 0;
+
+ if ( zzset_deg(a)>1 ) fprintf(stderr, " {");
+ do {
+ register SetWordType t = *p;
+ register SetWordType *b = &(bitmask[0]);
+ do {
+ if ( t & *b ) fprintf(stderr, " %s", zztokens[e]);
+ e++;
+ } while (++b < &(bitmask[sizeof(SetWordType)*8]));
+ } while (++p < endp);
+ if ( zzset_deg(a)>1 ) fprintf(stderr, " }");
+}
+
+#ifndef USER_ZZSYN
+/* standard error reporting function */
+void
+#ifdef __USE_PROTOS
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
+#else
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)
+char *text, *egroup, *bad_text;
+int tok;
+int etok;
+int k;
+SetWordType *eset;
+#endif
+{
+
+ zzSyntaxErrCount++; /* MR11 */
+ fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);
+ if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
+ if ( k==1 ) fprintf(stderr, " missing");
+ else
+ {
+ fprintf(stderr, "; \"%s\" not", bad_text);
+ if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
+ }
+ if ( zzset_deg(eset)>0 ) zzedecode(eset);
+ else fprintf(stderr, " %s", zztokens[etok]);
+ if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
+ fprintf(stderr, "\n");
+}
+#endif
+
+/* is b an element of set p? */
+int
+#ifdef __USE_PROTOS
+zzset_el(unsigned b, SetWordType *p)
+#else
+zzset_el(b,p)
+unsigned b;
+SetWordType *p;
+#endif
+{
+ return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );
+}
+
+int
+#ifdef __USE_PROTOS
+zzset_deg(SetWordType *a)
+#else
+zzset_deg(a)
+SetWordType *a;
+#endif
+{
+ /* Fast compute degree of a set... the number
+ of elements present in the set. Assumes
+ that all word bits are used in the set
+ */
+ register SetWordType *p = a;
+ register SetWordType *endp = &(a[zzSET_SIZE]);
+ register int degree = 0;
+
+ if ( a == NULL ) return 0;
+ while ( p < endp )
+ {
+ register SetWordType t = *p;
+ register SetWordType *b = &(bitmask[0]);
+ do {
+ if (t & *b) ++degree;
+ } while (++b < &(bitmask[sizeof(SetWordType)*8]));
+ p++;
+ }
+
+ return(degree);
+}
+
+#ifdef DEMAND_LOOK
+
+#ifdef LL_K
+int
+#ifdef __USE_PROTOS
+_zzmatch(int _t, char **zzBadText, char **zzMissText,
+ int *zzMissTok, int *zzBadTok,
+ SetWordType **zzMissSet)
+#else
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
+int _t;
+char **zzBadText;
+char **zzMissText;
+int *zzMissTok, *zzBadTok;
+SetWordType **zzMissSet;
+#endif
+{
+ if ( zzdirty==LL_K ) {
+ zzCONSUME;
+ }
+ if ( LA(1)!=_t ) {
+ *zzBadText = *zzMissText=LATEXT(1);
+ *zzMissTok= _t; *zzBadTok=LA(1);
+ *zzMissSet=NULL;
+ return 0;
+ }
+ zzMakeAttr
+ zzdirty++;
+ zzlabase++;
+ return 1;
+}
+
+int
+#ifdef __USE_PROTOS
+_zzmatch_wsig(int _t)
+#else
+_zzmatch_wsig(_t)
+int _t;
+#endif
+{
+ if ( zzdirty==LL_K ) {
+ zzCONSUME;
+ }
+ if ( LA(1)!=_t ) {
+ return 0;
+ }
+ zzMakeAttr
+ zzdirty++;
+ zzlabase++;
+ return 1;
+}
+
+#else
+
+int
+#ifdef __USE_PROTOS
+_zzmatch(int _t, char **zzBadText, char **zzMissText,
+ int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)
+#else
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
+int _t;
+char **zzBadText;
+char **zzMissText;
+int *zzMissTok, *zzBadTok;
+SetWordType **zzMissSet;
+#endif
+{
+ if ( zzdirty ) {zzCONSUME;}
+ if ( LA(1)!=_t ) {
+ *zzBadText = *zzMissText=LATEXT(1);
+ *zzMissTok= _t; *zzBadTok=LA(1);
+ *zzMissSet=NULL;
+ return 0;
+ }
+ zzdirty = 1;
+ zzMakeAttr
+ return 1;
+}
+
+int
+#ifdef __USE_PROTOS
+_zzmatch_wsig(int _t)
+#else
+_zzmatch_wsig(_t)
+int _t;
+#endif
+{
+ if ( zzdirty ) {zzCONSUME;}
+ if ( LA(1)!=_t ) {
+ return 0;
+ }
+ zzdirty = 1;
+ zzMakeAttr
+ return 1;
+}
+
+#endif /*LL_K*/
+
+#else
+
+int
+#ifdef __USE_PROTOS
+_zzmatch(int _t, char **zzBadText, char **zzMissText,
+ int *zzMissTok, int *zzBadTok,
+ SetWordType **zzMissSet)
+#else
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
+int _t;
+char **zzBadText;
+char **zzMissText;
+int *zzMissTok, *zzBadTok;
+SetWordType **zzMissSet;
+#endif
+{
+ if ( LA(1)!=_t ) {
+ *zzBadText = *zzMissText=LATEXT(1);
+ *zzMissTok= _t; *zzBadTok=LA(1);
+ *zzMissSet=NULL;
+ return 0;
+ }
+ zzMakeAttr
+ return 1;
+}
+
+int
+#ifdef __USE_PROTOS
+_zzmatch_wsig(int _t)
+#else
+_zzmatch_wsig(_t)
+int _t;
+#endif
+{
+ if ( LA(1)!=_t ) return 0;
+ zzMakeAttr
+ return 1;
+}
+
+#endif /*DEMAND_LOOK*/
+
+#ifdef ZZINF_LOOK
+void
+#ifdef __USE_PROTOS
+_inf_zzgettok(void)
+#else
+_inf_zzgettok()
+#endif
+{
+ if ( zzinf_labase >= zzinf_last )
+ {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}
+ else {
+ NLA = zzinf_tokens[zzinf_labase];
+ zzline = zzinf_line[zzinf_labase]; /* wrong in 1.21 */
+ strcpy(NLATEXT, zzinf_text[zzinf_labase]);
+ zzinf_labase++;
+ }
+}
+#endif
+
+#ifdef ZZINF_LOOK
+/* allocate default size text,token and line arrays;
+ * then, read all of the input reallocing the arrays as needed.
+ * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)
+ * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.
+ */
+void
+#ifdef __USE_PROTOS
+zzfill_inf_look(void)
+#else
+zzfill_inf_look()
+#endif
+{
+ int tok, line;
+ int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;
+ int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;
+ int zzinf_text_buffer_index = 0;
+ int zzinf_lap = 0;
+
+ /* allocate text/token buffers */
+ zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);
+ if ( zzinf_text_buffer == NULL )
+ {
+ fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",
+ zzinf_text_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+ zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int));
+ if ( zzinf_tokens == NULL )
+ {
+ fprintf(stderr, "cannot allocate token buffer (%d tokens)\n",
+ zzinf_token_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+ zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));
+ if ( zzinf_line == NULL )
+ {
+ fprintf(stderr, "cannot allocate line buffer (%d ints)\n",
+ zzinf_token_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+
+ /* get tokens, copying text to text buffer */
+ zzinf_text_buffer_index = 0;
+ do {
+ zzgettok();
+ line = zzreal_line;
+ while ( zzinf_lap>=zzinf_token_buffer_size )
+ {
+ zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE;
+ zzinf_tokens = (int *) realloc(zzinf_tokens,
+ zzinf_token_buffer_size*sizeof(int));
+ if ( zzinf_tokens == NULL )
+ {
+ fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n",
+ zzinf_token_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+ zzinf_line = (int *) realloc(zzinf_line,
+ zzinf_token_buffer_size*sizeof(int));
+ if ( zzinf_line == NULL )
+ {
+ fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",
+ zzinf_token_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+
+ }
+ while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )
+ {
+ zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE;
+ zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,
+ zzinf_text_buffer_size);
+ if ( zzinf_text_buffer == NULL )
+ {
+ fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",
+ zzinf_text_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+ }
+ /* record token and text and line of input symbol */
+ tok = zzinf_tokens[zzinf_lap] = NLA;
+ strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);
+ zzinf_text_buffer_index += strlen(NLATEXT)+1;
+ zzinf_line[zzinf_lap] = line;
+ zzinf_lap++;
+ } while (tok!=zzEOF_TOKEN);
+ zzinf_labase = 0;
+ zzinf_last = zzinf_lap-1;
+
+ /* allocate ptrs to text of ith token */
+ zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));
+ if ( zzinf_text == NULL )
+ {
+ fprintf(stderr, "cannot allocate lookahead text buffer (%d)\n",
+ zzinf_text_buffer_size);
+ exit(PCCTS_EXIT_FAILURE);
+ }
+ zzinf_text_buffer_index = 0;
+ zzinf_lap = 0;
+ /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */
+ while (zzinf_lap<=zzinf_last)
+ {
+ zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index];
+ zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1;
+ }
+}
+#endif
+
+int
+#ifdef __USE_PROTOS
+_zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,
+ int *zzMissTok, int *zzBadTok,
+ SetWordType **zzMissSet)
+#else
+_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
+SetWordType *e;
+char **zzBadText;
+char **zzMissText;
+int *zzMissTok, *zzBadTok;
+SetWordType **zzMissSet;
+#endif
+{
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ if ( zzdirty==LL_K ) {zzCONSUME;}
+#else
+ if ( zzdirty ) {zzCONSUME;}
+#endif
+#endif
+ if ( !zzset_el((unsigned)LA(1), e) ) {
+ *zzBadText = LATEXT(1); *zzMissText=NULL;
+ *zzMissTok= 0; *zzBadTok=LA(1);
+ *zzMissSet=e;
+ return 0;
+ }
+ zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ zzdirty++;
+ zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
+#else
+ zzdirty = 1;
+#endif
+#endif
+ return 1;
+}
+
+int
+#ifdef __USE_PROTOS
+_zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)
+#else
+_zzmatch_wdfltsig(tokenWanted, whatFollows)
+int tokenWanted;
+SetWordType *whatFollows;
+#endif
+{
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ if ( zzdirty==LL_K ) {
+ zzCONSUME;
+ }
+#else
+ if ( zzdirty ) {zzCONSUME;}
+#endif
+#endif
+
+ if ( LA(1)!=tokenWanted )
+ {
+ zzSyntaxErrCount++; /* MR11 */
+ fprintf(stderr,
+ "line %d: syntax error at \"%s\" missing %s\n",
+ zzline,
+ (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),
+ zztokens[tokenWanted]);
+ zzconsumeUntil( whatFollows );
+ return 0;
+ }
+ else {
+ zzMakeAttr
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ zzdirty++;
+ zzlabase++;
+#else
+ zzdirty = 1;
+#endif
+#else
+/* zzCONSUME; consume if not demand lookahead */
+#endif
+ return 1;
+ }
+}
+
+int
+#ifdef __USE_PROTOS
+_zzsetmatch_wdfltsig(SetWordType *tokensWanted,
+ int tokenTypeOfSet,
+ SetWordType *whatFollows)
+#else
+_zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)
+SetWordType *tokensWanted;
+int tokenTypeOfSet;
+SetWordType *whatFollows;
+#endif
+{
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ if ( zzdirty==LL_K ) {zzCONSUME;}
+#else
+ if ( zzdirty ) {zzCONSUME;}
+#endif
+#endif
+ if ( !zzset_el((unsigned)LA(1), tokensWanted) )
+ {
+ zzSyntaxErrCount++; /* MR11 */
+ fprintf(stderr,
+ "line %d: syntax error at \"%s\" missing %s\n",
+ zzline,
+ (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),
+ zztokens[tokenTypeOfSet]);
+ zzconsumeUntil( whatFollows );
+ return 0;
+ }
+ else {
+ zzMakeAttr
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ zzdirty++;
+ zzlabase++;
+#else
+ zzdirty = 1;
+#endif
+#else
+/* zzCONSUME; consume if not demand lookahead */
+#endif
+ return 1;
+ }
+}
+
+int
+#ifdef __USE_PROTOS
+_zzsetmatch_wsig(SetWordType *e)
+#else
+_zzsetmatch_wsig(e)
+SetWordType *e;
+#endif
+{
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ if ( zzdirty==LL_K ) {zzCONSUME;}
+#else
+ if ( zzdirty ) {zzCONSUME;}
+#endif
+#endif
+ if ( !zzset_el((unsigned)LA(1), e) ) return 0;
+ zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
+#ifdef DEMAND_LOOK
+#ifdef LL_K
+ zzdirty++;
+ zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
+#else
+ zzdirty = 1;
+#endif
+#endif
+ return 1;
+}
+
+#ifdef USER_ZZMODE_STACK
+static int zzmstk[ZZMAXSTK] = { -1 };
+static int zzmdep = 0;
+static char zzmbuf[70];
+
+void
+#ifdef __USE_PROTOS
+zzmpush( int m )
+#else
+zzmpush( m )
+int m;
+#endif
+{
+ if(zzmdep == ZZMAXSTK - 1) {
+ sprintf(zzmbuf, "Mode stack overflow ");
+ zzerr(zzmbuf);
+ } else {
+ zzmstk[zzmdep++] = zzauto;
+ zzmode(m);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+zzmpop( void )
+#else
+zzmpop( )
+#endif
+{
+ if(zzmdep == 0)
+ { sprintf(zzmbuf, "Mode stack underflow ");
+ zzerr(zzmbuf);
+ }
+ else
+ { zzmdep--;
+ zzmode(zzmstk[zzmdep]);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+zzsave_mode_stack( int modeStack[], int *modeLevel )
+#else
+zzsave_mode_stack( modeStack, modeLevel )
+int modeStack[];
+int *modeLevel;
+#endif
+{
+ int i;
+ memcpy(modeStack, zzmstk, sizeof(zzmstk));
+ *modeLevel = zzmdep;
+ zzmdep = 0;
+
+ return;
+}
+
+void
+#ifdef __USE_PROTOS
+zzrestore_mode_stack( int modeStack[], int *modeLevel )
+#else
+zzrestore_mode_stack( modeStack, modeLevel )
+int modeStack[];
+int *modeLevel;
+#endif
+{
+ int i;
+
+ memcpy(zzmstk, modeStack, sizeof(zzmstk));
+ zzmdep = *modeLevel;
+
+ return;
+}
+#endif /* USER_ZZMODE_STACK */
+
+#ifdef __USE_PROTOS
+void zzTraceReset(void)
+#else
+void zzTraceReset()
+#endif
+{
+#ifdef zzTRACE_RULES
+ zzTraceOptionValue=zzTraceOptionValueDefault;
+ zzTraceGuessOptionValue=1;
+ zzTraceCurrentRuleName=NULL;
+ zzTraceDepth=0;
+#endif
+}
+
+#ifdef __USE_PROTOS
+void zzTraceGuessFail(void)
+#else
+void zzTraceGuessFail()
+#endif
+{
+
+#ifdef zzTRACE_RULES
+#ifdef ZZCAN_GUESS
+
+ int doIt=0;
+
+ if (zzTraceOptionValue <= 0) {
+ doIt=0;
+ } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
+ doIt=0;
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"guess failed\n");
+ };
+#endif
+#endif
+}
+
+/* zzTraceOption:
+ zero value turns off trace
+*/
+
+#ifdef __USE_PROTOS
+void zzTraceIn(char * rule)
+#else
+void zzTraceIn(rule)
+ char *rule;
+#endif
+{
+#ifdef zzTRACE_RULES
+
+ int doIt=0;
+
+ zzTraceDepth++;
+ zzTraceCurrentRuleName=rule;
+
+ if (zzTraceOptionValue <= 0) {
+ doIt=0;
+#ifdef ZZCAN_GUESS
+ } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
+ doIt=0;
+#endif
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"enter rule %s {\"%s\"} depth %d",
+ rule,
+ LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
+ zzTraceDepth);
+#ifdef ZZCAN_GUESS
+ if (zzguessing) fprintf(stderr," guessing");
+#endif
+ fprintf(stderr,"\n");
+ };
+#endif
+ return;
+}
+
+#ifdef __USE_PROTOS
+void zzTraceOut(char * rule)
+#else
+void zzTraceOut(rule)
+ char *rule;
+#endif
+{
+#ifdef zzTRACE_RULES
+ int doIt=0;
+
+ zzTraceDepth--;
+
+ if (zzTraceOptionValue <= 0) {
+ doIt=0;
+#ifdef ZZCAN_GUESS
+ } else if (zzguessing && zzTraceGuessOptionValue <= 0) {
+ doIt=0;
+#endif
+ } else {
+ doIt=1;
+ };
+
+ if (doIt) {
+ fprintf(stderr,"exit rule %s {\"%s\"} depth %d",
+ rule,
+ LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
+ zzTraceDepth+1);
+#ifdef ZZCAN_GUESS
+ if (zzguessing) fprintf(stderr," guessing");
+#endif
+ fprintf(stderr,"\n");
+ };
+#endif
+}
+
+#ifdef __USE_PROTOS
+int zzTraceOption(int delta)
+#else
+int zzTraceOption(delta)
+ int delta;
+#endif
+{
+#ifdef zzTRACE_RULES
+ int prevValue=zzTraceOptionValue;
+
+ zzTraceOptionValue=zzTraceOptionValue+delta;
+
+ if (zzTraceCurrentRuleName != NULL) {
+ if (prevValue <= 0 && zzTraceOptionValue > 0) {
+ fprintf(stderr,"trace enabled in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ if (prevValue > 0 && zzTraceOptionValue <= 0) {
+ fprintf(stderr,"trace disabled in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ };
+ return prevValue;
+#else
+ return 0;
+#endif
+}
+
+#ifdef __USE_PROTOS
+int zzTraceGuessOption(int delta)
+#else
+int zzTraceGuessOption(delta)
+ int delta;
+#endif
+{
+#ifdef zzTRACE_RULES
+#ifdef ZZCAN_GUESS
+ int prevValue=zzTraceGuessOptionValue;
+
+ zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta;
+
+ if (zzTraceCurrentRuleName != NULL) {
+ if (prevValue <= 0 && zzTraceGuessOptionValue > 0) {
+ fprintf(stderr,"guess trace enabled in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ if (prevValue > 0 && zzTraceGuessOptionValue <= 0) {
+ fprintf(stderr,"guess trace disabled in rule %s depth %d\n",
+ zzTraceCurrentRuleName,zzTraceDepth);
+ };
+ };
+ return prevValue;
+#else
+ return 0;
+#endif
+#else
+ return 0;
+#endif
+}
+
+#endif /* ERR_H */
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h
new file mode 100644
index 0000000000..d6d51a41b6
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h
@@ -0,0 +1,37 @@
+/* ANTLR attribute definition -- long integers
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * ANTLR 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+#ifndef ZZINT_H
+#define ZZINT_H
+
+typedef long Attrib;
+
+#define zzcr_attr(a,tok,t) *(a) = atol(t);
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h
new file mode 100644
index 0000000000..ff0dfb5126
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ASSERT_H__
+#define __PCCTS_ASSERT_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <cassert>
+#else
+#include <assert.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib
new file mode 100644
index 0000000000..8d8601849d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h
new file mode 100644
index 0000000000..972b32cbd1
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_IOSTREAM_H__
+#define __PCCTS_IOSTREAM_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <iostream>
+#else
+#include <iostream.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h
new file mode 100644
index 0000000000..e25cb8c483
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ISTREAM_H__
+#define __PCCTS_ISTREAM_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <istream>
+#else
+#include <istream.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib
new file mode 100644
index 0000000000..b237a09e4d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h
new file mode 100644
index 0000000000..9ea185ca73
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_SETJMP_H__
+#define __PCCTS_SETJMP_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <csetjmp>
+#else
+#include <setjmp.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h
new file mode 100644
index 0000000000..e957430c32
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDARG_H__
+#define __PCCTS_STDARG_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <cstdarg>
+#else
+#include <stdarg.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h
new file mode 100644
index 0000000000..ac34d1086d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDIO_H__
+#define __PCCTS_STDIO_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <cstdio>
+#else
+#include <stdio.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h
new file mode 100644
index 0000000000..f0b344e8dc
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDLIB_H__
+#define __PCCTS_STDLIB_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <cstdlib>
+#else
+#include <stdlib.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h
new file mode 100644
index 0000000000..458a08a94b
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STRING_H__
+#define __PCCTS_STRING_H__
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#include <cstring>
+#else
+#include <string.h>
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h
new file mode 100644
index 0000000000..9255d1e87e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h
@@ -0,0 +1,350 @@
+#ifndef PCCTS_CONFIG_H
+#define PCCTS_CONFIG_H
+/*
+ * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER)
+ *
+ * This is a simple configuration file that doesn't have config stuff
+ * in it, but it's a start.
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
+ * Set (PCCTS) -- PCCTS is in the public domain. An individual or
+ * company may do whatever they wish with source code distributed with
+ * PCCTS or the code generated by PCCTS, including the incorporation of
+ * PCCTS, or its output, into commerical software.
+ *
+ * We encourage users to develop software with PCCTS. However, we do ask
+ * that credit is given to us for developing PCCTS. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like PCCTS and have developed a nice tool with the
+ * output, please mention that you developed it using PCCTS. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * Used by PCCTS 1.33 (SORCERER 1.00B11 and up)
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1989-1998
+ */
+
+/* This file knows about the following ``environments''
+ UNIX (default)
+ DOS (use #define PC)
+ MAC (use #define MPW; has a few things for THINK C, Metrowerks)
+ MS/C++ (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER)
+
+ */
+
+/* should test __STDC__ for 1, but some compilers don't set value, just def */
+
+#ifndef __USE_PROTOS
+#ifdef __STDC__
+#define __USE_PROTOS
+#endif
+#ifdef __cplusplus
+#define __USE_PROTOS
+#endif
+#endif
+
+#ifdef PCCTS_USE_NAMESPACE_STD
+#define PCCTS_NAMESPACE_STD namespace std {}; using namespace std;
+#else
+#define PCCTS_NAMESPACE_STD
+#endif
+
+#include "pccts_stdio.h"
+#include "pccts_stdlib.h"
+
+/* largest file name size */
+
+#ifdef _MAX_PATH
+#define MaxFileName _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */
+#else
+#define MaxFileName 300
+#endif
+
+/*
+* Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32).
+* The macros tested here are defined by Watcom, Microsoft, Borland,
+* and djgpp, respectively, when they are used as 32-bit compilers.
+* Users of these compilers *must* be sure to define PC in their
+* makefiles for this to work correctly.
+*/
+#ifdef PC
+# if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \
+ defined(__GNUC__) || defined(__GNUG__))
+# ifndef PC32
+# define PC32
+# endif
+# endif
+#endif
+
+/* MR1 10-Apr-97 Default for PC is short file names */
+/* MR1 Default for non-PC is long file names */
+/* MR1 Can override via command line option LONGFILENAMES */
+
+#ifndef LONGFILENAMES
+#ifndef PC
+#define LONGFILENAMES
+#endif
+#endif
+
+#ifndef LONGFILENAMES
+#define ATOKEN_H "AToken.h"
+#define ATOKPTR_H "ATokPtr.h"
+#define ATOKPTR_C "ATokPtr.cpp"
+#define ATOKENBUFFER_H "ATokBuf.h"
+#define ATOKENBUFFER_C "ATokBuf.cpp"
+#define ATOKENSTREAM_H "ATokStr.h"
+#define APARSER_H "AParser.h"
+#define APARSER_C "AParser.cpp"
+#define ASTBASE_H "ASTBase.h"
+#define ASTBASE_C "ASTBase.cpp"
+#define PCCTSAST_C "PCCTSAST.cpp"
+#define LIST_C "List.cpp"
+#define DLEXERBASE_H "DLexBase.h"
+#define DLEXERBASE_C "DLexBase.cpp"
+#define DLEXER_C "DLexer.cpp"
+#define STREESUPPORT_C "STreeSup.C"
+#else
+#define ATOKEN_H "AToken.h"
+#define ATOKPTR_H "ATokPtr.h"
+#define ATOKPTR_C "ATokPtr.cpp"
+#define ATOKENBUFFER_H "ATokenBuffer.h"
+#define ATOKENBUFFER_C "ATokenBuffer.cpp"
+#define ATOKENSTREAM_H "ATokenStream.h"
+#define APARSER_H "AParser.h"
+#define APARSER_C "AParser.cpp"
+#define ASTBASE_H "ASTBase.h"
+#define ASTBASE_C "ASTBase.cpp"
+#define PCCTSAST_C "PCCTSAST.cpp"
+#define LIST_C "List.cpp"
+#define DLEXERBASE_H "DLexerBase.h"
+#define DLEXERBASE_C "DLexerBase.cpp"
+#define DLEXER_C "DLexer.cpp"
+#define STREESUPPORT_C "STreeSupport.cpp"
+#endif
+
+/* SORCERER Stuff */
+
+/* MR8 6-Aug-97 Change from ifdef PC to ifndef LONGFILENAMES */
+
+#ifndef LONGFILENAMES
+#define STPARSER_H "STreePar.h"
+#define STPARSER_C "STreePar.C"
+#else
+#define STPARSER_H "STreeParser.h"
+#define STPARSER_C "STreeParser.cpp"
+#endif
+
+#ifdef MPW
+#define CPP_FILE_SUFFIX ".cp"
+#define CPP_FILE_SUFFIX_NO_DOT "cp"
+#define OBJ_FILE_SUFFIX ".o"
+#else
+#ifdef PC
+#define CPP_FILE_SUFFIX ".cpp"
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"
+#define OBJ_FILE_SUFFIX ".obj"
+#else
+#ifdef __VMS
+#define CPP_FILE_SUFFIX ".cpp"
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"
+#define OBJ_FILE_SUFFIX ".obj"
+#else
+#define CPP_FILE_SUFFIX ".cpp"
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"
+#define OBJ_FILE_SUFFIX ".o"
+#endif
+#endif
+#endif
+
+/* User may redefine how line information looks */ /* make it #line MR7 */
+/* MR21 Use #ifndef */
+
+#ifndef LineInfoFormatStr
+#define LineInfoFormatStr "#line %d \"%s\"\n"
+#endif
+
+#ifdef MPW /* Macintosh Programmer's Workshop */
+#define ErrHdr "File \"%s\"; Line %d #"
+#else
+#ifdef _MSC_VER /* MR14 Microsoft Visual C++ environment */
+#define ErrHdr "%s(%d) :"
+#else
+#define ErrHdr "%s, line %d:" /* default */
+#endif
+#endif
+
+/* must assume old K&R cpp here, can't use #if defined(..)... */
+
+#ifdef MPW
+#define TopDirectory ":"
+#define DirectorySymbol ":"
+#define OutputDirectoryOption "Directory where all output files should go (default=\":\")"
+#else
+#ifdef PC
+#define TopDirectory "."
+#define DirectorySymbol "\\"
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"
+#else
+#ifdef __VMS
+#define TopDirectory "[000000]"
+#define DirectorySymbol "]"
+#define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")"
+#else
+#define TopDirectory "."
+#define DirectorySymbol "/"
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"
+#endif
+#endif
+#endif
+
+#ifdef MPW
+
+/* Make sure we have prototypes for all functions under MPW */
+
+#include "pccts_string.h"
+#include "pccts_stdlib.h"
+
+/* MR6 2-Jun-97 Fixes false dependency caused by VC++ #include scanner */
+/* MR6 Reported by Brad Schick (schick@interaccess.com) */
+#define MPW_CursorCtl_Header <CursorCtl.h>
+#include MPW_CursorCtl_Header
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype);
+#ifdef __cplusplus
+}
+#endif
+
+/* File creators for various popular development environments */
+
+#define MAC_FILE_CREATOR 'MPS ' /* MPW Text files */
+#if 0
+#define MAC_FILE_CREATOR 'KAHL' /* THINK C/Symantec C++ Text files */
+#endif
+#if 0
+#define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */
+#endif
+
+#endif
+
+#ifdef MPW
+#define DAWDLE SpinCursor(1)
+#else
+#define DAWDLE
+#endif
+
+#ifdef MPW
+#define SPECIAL_INITS
+#define SPECIAL_FOPEN
+#endif
+
+#ifdef MPW
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+void special_inits()
+{
+ InitCursorCtl((acurHandle) 0);
+}
+#endif
+
+#ifdef MPW
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+void special_fopen_actions(char * s)
+{
+ fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');
+}
+#endif
+
+/* Define usable bits for set.c stuff */
+#define BytesPerWord sizeof(unsigned)
+#define WORDSIZE (sizeof(unsigned)*8)
+#define LogWordSize (WORDSIZE==16?4:5)
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#if defined(VAXC) || defined(__VMS)
+#include <ssdef.h>
+#define PCCTS_EXIT_SUCCESS 1
+#define PCCTS_EXIT_FAILURE SS$_ABORT
+#define zzDIE return SS$_ABORT;
+#define zzDONE return 1;
+
+#else /* !VAXC and !__VMS */
+
+#define PCCTS_EXIT_SUCCESS 0
+#define PCCTS_EXIT_FAILURE 1
+#define zzDIE return 1;
+#define zzDONE return 0;
+
+#endif
+
+#ifdef USER_ZZMODE_STACK
+# ifndef ZZSTACK_MAX_MODE
+# define ZZSTACK_MAX_MODE 32
+# endif
+# define ZZMAXSTK (ZZSTACK_MAX_MODE * 2)
+#endif
+
+#ifndef DllExportPCCTS
+#define DllExportPCCTS
+#endif
+
+#ifdef PC
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME
+#endif
+#endif
+
+#ifdef PC32
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME
+#endif
+#endif
+
+#ifdef __VMS
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME
+#endif
+#endif
+
+#ifdef __USE_PROTOS
+#ifndef PCCTS_USE_STDARG
+#define PCCTS_USE_STDARG
+#endif
+#endif
+
+#ifdef __STDC__
+#ifndef PCCTS_USE_STDARG
+#define PCCTS_USE_STDARG
+#endif
+#endif
+
+#ifdef __cplusplus
+#ifndef PCCTS_USE_STDARG
+#define PCCTS_USE_STDARG
+#endif
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp
new file mode 100644
index 0000000000..26b88c3cf8
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp
@@ -0,0 +1,118 @@
+# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=pcctslib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "pcctslib50.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "pcctslib50.mak" CFG="pcctslib - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+
+!IF "$(CFG)" == "pcctslib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# SUBTRACT CPP /YX
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"pccts_release.lib"
+# Begin Special Build Tool
+SOURCE=$(InputPath)
+PostBuild_Desc=Copy to ..\lib
+PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "pcctslib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# SUBTRACT CPP /YX
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"pccts_debug.lib"
+# Begin Special Build Tool
+SOURCE=$(InputPath)
+PostBuild_Desc=Copy to ..\lib
+PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "pcctslib - Win32 Release"
+# Name "pcctslib - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\AParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ASTBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ATokenBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BufFileInput.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\DLexerBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PCCTSAST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SList.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw
new file mode 100644
index 0000000000..995e5bff2e
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "pcctslib"=.\pcctslib50.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp
new file mode 100644
index 0000000000..d3e3b0c97c
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp
@@ -0,0 +1,124 @@
+# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=pcctslib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "pcctslib60.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "pcctslib60.mak" CFG="pcctslib - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "pcctslib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"pccts_release.lib"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy to ..\lib
+PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "pcctslib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"pccts_debug.lib"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy to ..\lib
+PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "pcctslib - Win32 Release"
+# Name "pcctslib - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\AParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ASTBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ATokenBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BufFileInput.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\DLexerBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PCCTSAST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SList.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw
new file mode 100644
index 0000000000..3400c443cd
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "pcctslib"=.\pcctslib60.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat
new file mode 100644
index 0000000000..8784aee9ab
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat
@@ -0,0 +1,11 @@
+ren aparser.c aparser.cpp
+ren astbase.c astbase.cpp
+ren atokenbu.c atokbuf.cpp
+ren atokenbu.h atokbuf.h
+ren atokenst.h atokstr.h
+ren dlexerba.c dlexbase.cpp
+ren dlexerba.h dlexbase.h
+ren dlexer.c dlexer.cpp
+ren list.c list.cpp
+ren pblackbo.h pblckbox.h
+ren pcctsast.c pcctsast.cpp
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp
new file mode 100644
index 0000000000..d6b8bf6c2d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp
@@ -0,0 +1,105 @@
+/*
+ * SList.C
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * PCCTS 1.33
+ * Terence Parr
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1992-1998
+ */
+
+#define ANTLR_SUPPORT_CODE
+
+#include "SList.h"
+
+/* Iterate over a list of elements; returns ptr to a new element
+ * in list upon every call and NULL when no more are left.
+ * Very useful like this:
+ *
+ * cursor = mylist;
+ * while ( (p=mylist->iterate(&cursor)) ) {
+ * // place with element p
+ * }
+ *
+ * The cursor must be initialized to point to the list to iterate over.
+ */
+void *SList::
+iterate(SListNode **cursor)
+{
+ void *e;
+
+ if ( cursor == NULL || *cursor==NULL ) return NULL;
+ if ( head == *cursor ) { *cursor = (*cursor)->next(); }
+ e = (*cursor)->elem();
+ (*cursor) = (*cursor)->next();
+ return e;
+}
+
+/* add an element to end of list. */
+void SList::
+add(void *e)
+{
+ SListNode *p, *tail=NULL;
+ require(e!=NULL, "slist_add: attempting to add NULL list element");
+
+ p = new SListNode;
+ require(p!=NULL, "add: cannot alloc new list node");
+ p->setElem(e);
+ if ( head == NULL )
+ {
+ head = tail = p;
+ }
+ else /* find end of list */
+ {
+ tail->setNext(p);
+ tail = p;
+ }
+}
+
+void SList::
+lfree()
+{
+ SListNode *p,*q;
+
+ if ( head==NULL ) return; /* empty list */
+ for (p = head; p!=NULL; p=q)
+ {
+ q = p->next();
+ free(p);
+ }
+}
+
+PCCTS_AST *SList::
+to_ast(SList list)
+{
+ PCCTS_AST *t=NULL, *last=NULL;
+ SListNode *p;
+
+ for (p = head; p!=NULL; p=p->next())
+ {
+ PCCTS_AST *u = (PCCTS_AST *)p->elem();
+ if ( last==NULL ) last = t = u;
+ else { last->setRight(u); last = u; }
+ }
+ return t;
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib
new file mode 100644
index 0000000000..8d8601849d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib
new file mode 100644
index 0000000000..b237a09e4d
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib
Binary files differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h
new file mode 100644
index 0000000000..1004147101
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h
@@ -0,0 +1,8 @@
+#ifndef SASTBase_h
+#define SASTBase_h
+
+#include "PCCTSAST.h"
+
+typedef PCCTS_AST SORASTBase;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h
new file mode 100644
index 0000000000..79f90180cc
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h
@@ -0,0 +1,26 @@
+#ifndef SCommonAST_h
+#define SCommonAST_h
+
+#include <stdio.h>
+#include "PCCTSAST.h"
+#include "SASTBase.h"
+
+/* If you use SORCERER alone, you can subclass this to get a nice tree def */
+
+class SORCommonAST : public SORASTBase {
+protected:
+ SORCommonAST *_right, *_down;
+ int _type;
+
+public:
+ SORCommonAST() { _right = _down = NULL; }
+ PCCTS_AST *right() { return _right; } // define the SORCERER interface
+ PCCTS_AST *down() { return _down; }
+ int type() { return _type; }
+ void setRight(PCCTS_AST *t) { _right = (SORCommonAST *)t; }
+ void setDown(PCCTS_AST *t) { _down = (SORCommonAST *)t; }
+ void setType(int t) { _type = t; }
+ virtual PCCTS_AST *shallowCopy() {return NULL;}
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h
new file mode 100644
index 0000000000..558f6a572b
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h
@@ -0,0 +1,110 @@
+#ifndef STreeParser_h
+#define STreeParser_h
+
+/*
+ * STreeParser.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+/* The programmer should derive a class from SORASTBase; SORASTBase defines
+ * the minimum public interface that a tree node must follow for SORCERER to
+ * be able to walk the trees.
+ */
+
+/* The @-vars are added by the subclass created by SORCERER; the constructor
+ * is used to init the @-vars.
+ */
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include "SASTBase.h"
+
+#define _DOWN _t=(SORASTBase *)_t->down()
+#define _RIGHT _t=(SORASTBase *)_t->right()
+
+#define _SAVE SORASTBase *_save=_t
+#define _RESTORE _t = _save
+#define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL;
+#define _GUESS {save_state(&_st); \
+ _savet = _t; \
+ guessing = 1; \
+ _gv = setjmp(startofguess.state);}
+#define _GUESS_FAIL longjmp(startofguess.state, 1)
+#define _GUESS_DONE {restore_state(&_st); _t = _savet;}
+#define _MATCH(tok) MATCH(_t,tok)
+#define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2)
+#define _WILDCARD WILDCARD(_t)
+
+#define ast_return(t) *_result = (SORASTBase *)t;
+
+#define STreeTry(r,p,t) \
+ (p)->try_result = NULL; \
+ (p)->sjrv = setjmp((p)->startofguess); \
+ if ( !(p)->sjrv ) { \
+ rule(p,t,&try_result); \
+ (p)->try_ok = 1; \
+ } \
+ else { \
+ (p)->try_ok = 0; \
+ } \
+ if ( (p)->try_ok )
+
+
+/* Used only during TRANSFORM mode */
+#define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL
+
+typedef struct _Sjmp_buf {
+ jmp_buf state;
+ } Sjmp_buf;
+
+class STreeParser {
+protected:
+ int try_ok, sjrv; /* used by STreeTry macro */
+ SORASTBase *try_result; /* tree coming back from try */
+ int guessing;
+ Sjmp_buf startofguess;
+// SORASTBase *t;
+
+ void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
+ void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
+ virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);
+ virtual void missing_wildcard();
+ virtual void mismatched_token(int looking_for, SORASTBase *found);
+ virtual void no_viable_alt(char *rulename, SORASTBase *root);
+ virtual void MATCH(SORASTBase *_t, int tok);
+ virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);
+ virtual void WILDCARD(SORASTBase *_t);
+
+public:
+ STreeParser() { guessing = 0; }
+ virtual void panic(char *err);
+ void save_state(STreeParser *);
+ void restore_state(STreeParser *);
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h
new file mode 100644
index 0000000000..9c7fd693f2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h
@@ -0,0 +1,72 @@
+#ifndef astlib_h
+#define astlib_h
+
+/*
+ * astlib.h -- C ast_* library header
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <setjmp.h>
+#include "sorcerer.h"
+#include "sorlist.h"
+
+#define MaxTreeStackDepth 400
+
+#ifdef __USE_PROTOS
+extern SORAST *ast_make(SORAST *rt, ...);
+extern SORAST *ast_find_all(SORAST *t, SORAST *u, SORAST **cursor);
+extern int ast_match(SORAST *t, SORAST *u);
+extern void ast_insert_after(SORAST *a, SORAST *b);
+extern void ast_append(SORAST *a, SORAST *b);
+extern SORAST *ast_tail(SORAST *a);
+extern SORAST *ast_bottom(SORAST *a);
+extern SORAST *ast_cut_between(SORAST *a, SORAST *b);
+extern SList *ast_to_slist(SORAST *t);
+extern SORAST *slist_to_ast(SList *list);
+extern void ast_free(SORAST *t);
+extern int ast_scan(char *template, SORAST *tree, ...);
+extern int ast_nsiblings(SORAST *t);
+extern SORAST *ast_sibling_index(SORAST *t, int i);
+extern int ast_match_partial(SORAST *t, SORAST *u);
+#else
+extern SORAST *ast_make();
+extern SORAST *ast_find_all();
+extern int ast_match();
+extern void ast_insert_after();
+extern void ast_append();
+extern SORAST *ast_tail();
+extern SORAST *ast_bottom();
+extern SORAST *ast_cut_between();
+extern SList *ast_to_slist();
+extern SORAST *slist_to_ast();
+extern void ast_free();
+extern int ast_scan();
+extern int ast_nsiblings();
+extern SORAST *ast_sibling_index();
+extern int ast_match_partial();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h
new file mode 100644
index 0000000000..a8e14bb7af
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h
@@ -0,0 +1,61 @@
+#ifndef SINTSTACK_H
+#define SINTSTACK_H
+
+/*
+ * SIntStack.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "sorcerer.h"
+
+typedef struct _istack {
+ int *data;
+ int sp;
+ int size;
+ } SIntStack;
+
+#ifdef __USE_PROTOS
+extern SIntStack *sint_newstack(int size);
+extern void sint_freestack(SIntStack *st);
+extern void sint_push(SIntStack *st, int i);
+extern int sint_pop(SIntStack *st);
+extern int sint_stacksize(SIntStack *st);
+extern void sint_stackreset(SIntStack *st);
+extern int sint_stackempty(SIntStack *st);
+extern int sint_top(SIntStack *st);
+#else
+extern SIntStack *sint_newstack();
+extern void sint_freestack();
+extern void sint_push();
+extern int sint_pop();
+extern int sint_stacksize();
+extern void sint_stackreset();
+extern int sint_stackempty();
+extern int sint_top();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h
new file mode 100644
index 0000000000..29f77029ed
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h
@@ -0,0 +1,172 @@
+#ifndef sorcerer_h
+#define sorcerer_h
+
+/*
+ * sorcerer.h -- header for all sorcerer files
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "pcctscfg.h"
+
+#ifdef __USE_PROTOS
+#include <stdlib.h>
+#else
+#include <malloc.h>
+#endif
+
+#include <setjmp.h>
+
+/* SUPERCLASS SORAST (your tree must look at minimum like this)
+typedef struct _node {
+ struct _node *right, *down;
+ int token;
+ -- user-defined stuff goes here
+ } SORAST;
+*/
+
+/* Can be used sort of like inheritance to get the desired struct def */
+#define AST_REQD_FIELDS \
+ struct _node *right, *down; \
+ int token;
+
+/* C MATCH */ /* MR21 Short circuit on null pointer */
+#define _MATCH(tok) if (! _t || _t->token!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
+#define _MATCHRANGE(tok,tok2) \
+ if (! _t || _t->token<tok || _t->token>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
+
+/* C++ MATCH */
+#define _CPPMATCH(tok) if ( _t->token()!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
+#define _CPPMATCHRANGE(tok,tok2) \
+ if ( _t->token()<tok || _t->token()>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
+
+/* Normal DOWN and RIGHT */
+#define _DOWN _t=_t->down
+#define _RIGHT _t=_t->right
+
+/* C++ DOWN and RIGHT */
+#define _CPPDOWN _t=(SORAST *) _t->down()
+#define _CPPRIGHT _t=(SORAST *) _t->right()
+
+#define _SAVE SORAST *_save=_t
+#define _RESTORE _t = _save
+#define _SETLABEL(u) u=_t
+#define _WILDCARD if ( _t==NULL ) if ( _parser->guessing ) _GUESS_FAIL; else missing_wildcard(_parser)
+#define _GUESS_BLOCK STreeParser _st; int _gv; SORAST *_savet=NULL;
+#define _GUESS {_st = *_parser; \
+ _savet = _t; \
+ _parser->guessing = 1; \
+ _gv = setjmp(_parser->startofguess.state);}
+#define _GUESS_FAIL longjmp(_parser->startofguess.state, 1)
+#define _GUESS_DONE {*_parser = _st; _t = _savet;}
+
+/* These are used mainly by the C output */
+#ifndef ast_down
+#define ast_down down
+#endif
+#ifndef ast_right
+#define ast_right right
+#endif
+
+#define STreeTry(r,p,t) \
+ (p)->try_result = NULL; \
+ (p)->sjrv = setjmp((p)->startofguess); \
+ if ( !(p)->sjrv ) { \
+ rule(p,t,&try_result); \
+ (p)->try_ok = 1; \
+ } \
+ else { \
+ (p)->try_ok = 0; \
+ } \
+ if ( (p)->try_ok )
+
+
+/* Used only during TRANSFORM mode */
+#define TREE_CONSTR_PTRS SORAST *_r=NULL,*_s=NULL,*_e=NULL
+
+typedef struct _Sjmp_buf {
+ jmp_buf state;
+ } Sjmp_buf;
+
+#ifndef _PARSER_VARS
+#define _PARSER_VARS
+#endif
+
+#ifndef _REFVARS
+#define _REFVARS
+#endif
+
+typedef struct _STreeParser {
+ int try_ok, sjrv; /* used by STreeTry macro */
+ SORAST *try_result; /* tree coming back from try */
+ int guessing;
+ Sjmp_buf startofguess;
+ SORAST *t;
+ _REFVARS
+ _PARSER_VARS
+ } STreeParser;
+
+#define STreeParserInit(_p) { (_p)->guessing = 0; _refvar_inits(_p); }
+
+
+ /* S a n i t y C h e c k i n g */
+
+#ifndef require
+#define require(expr, err) {if ( !(expr) ) sorcerer_panic(err);}
+#endif
+
+
+ /* T r a n s f o r m M a c r o s */
+#define ast_return(_t) *_result = _t
+
+
+#ifdef __USE_PROTOS
+extern void mismatched_range(STreeParser *_parser, int looking_for, int upper_token, SORAST *found);
+extern void missing_wildcard(STreeParser *_parser);
+extern void mismatched_token(STreeParser *_parser, int looking_for, SORAST *found);
+extern void no_viable_alt(STreeParser *_parser, char *rulename, SORAST *root);
+extern void sorcerer_panic(char *err);
+extern void _refvar_inits(STreeParser *); /* MR15 Kevin J. Cummings */
+extern void _mkroot(SORAST **, SORAST **, SORAST **, SORAST *);
+extern void _mkchild(SORAST **, SORAST **, SORAST **, SORAST *);
+extern SORAST *ast_alloc(void);
+extern SORAST *ast_dup(SORAST *t);
+extern SORAST *ast_dup_node(SORAST *t);
+#else
+extern void mismatched_range();
+extern void missing_wildcard();
+extern void mismatched_token();
+extern void no_viable_alt();
+extern void sorcerer_panic();
+extern void _refvar_inits(); /* MR15 Kevin J. Cummings */
+extern void _mkroot();
+extern void _mkchild();
+extern SORAST *ast_alloc();
+extern SORAST *ast_dup();
+extern SORAST *ast_dup_node();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h
new file mode 100644
index 0000000000..08c1ad0e1f
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h
@@ -0,0 +1,52 @@
+#ifndef SLIST_H
+#define SLIST_H
+
+/*
+ * SList.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "sorcerer.h"
+
+typedef struct _SList {
+ void *elem; /* pointer to any kind of element */
+ struct _SList *next;
+ } SList;
+
+#define newSList (SList *) calloc(1, sizeof(SList));
+
+#ifdef __USE_PROTOS
+extern void *slist_iterate(SList *list, SList **);
+extern void slist_add( SList **list, void *e );
+extern void slist_free(SList *list);
+#else
+extern void *slist_iterate();
+extern void slist_add();
+extern void slist_free();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h
new file mode 100644
index 0000000000..fe80598977
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h
@@ -0,0 +1,46 @@
+#ifndef SSTACK_H
+#define SSTACK_H
+
+/*
+ * SStack.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include "sorlist.h"
+
+typedef SList SStack;
+
+#define newSStack (SStack *) calloc(1, sizeof(SStack));
+
+#ifdef __USE_PROTOS
+extern void sstack_push( SStack **st, void *e );
+extern void *sstack_pop( SStack **st );
+#else
+extern void sstack_push();
+extern void *sstack_pop();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h
new file mode 100644
index 0000000000..35be33e6c7
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h
@@ -0,0 +1,45 @@
+#ifndef CASTBase_h
+#define CASTBase_h
+
+/*
+ * CASTBase.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+/* ONLY USED TO C COMPILE LIBRARY FUNCTIONS; YOU CAN FORCE THEM TO COMPILE WITH
+ * YOUR SORAST DEF IF YOU WANT (THAT WAY, ORDER OF FIELD DEFINITION IS IRRELEVANT)
+ */
+
+/* Typically, this file is not used / seen by the programmer */
+
+/* Used as "super-class" for compiling C library routines */
+typedef struct _nodebase {
+ struct _nodebase *right, *down;
+ int token;
+ } SORAST;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp
new file mode 100644
index 0000000000..0d50a337f0
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp
@@ -0,0 +1,151 @@
+#include <stdio.h>
+#include "STreeParser.h"
+
+void STreeParser::
+MATCH(SORASTBase *_t,int tok)
+{
+ if ( _t->type()!=tok )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else mismatched_token(tok, _t);
+ }
+}
+
+void STreeParser::
+MATCHRANGE(SORASTBase *_t,int tok,int tok2)
+{
+ if ( _t->type()<tok || _t->type()>tok2 )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else mismatched_range(tok, tok2, _t);
+ }
+}
+
+void STreeParser::
+WILDCARD(SORASTBase *_t)
+{
+ if ( _t==NULL )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else missing_wildcard();
+ }
+}
+
+void STreeParser::
+mismatched_range(int looking_for, int upper_token, SORASTBase *found)
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found token %d\n",
+ looking_for, upper_token,
+ found->type());
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found NULL tree\n",
+ looking_for, upper_token);
+ }
+}
+
+void STreeParser::
+missing_wildcard()
+{
+ fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
+}
+
+void STreeParser::
+mismatched_token(int looking_for, SORASTBase *found)
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token %d found token %d\n",
+ looking_for,
+ found->type());
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token %d found NULL tree\n",
+ looking_for);
+ }
+}
+
+void STreeParser::
+no_viable_alt(char *rulename, SORASTBase *root)
+{
+ if ( root==NULL )
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for NULL tree\n",
+ rulename);
+ else
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for tree\n",
+ rulename);
+}
+
+void STreeParser::
+panic(char *err)
+{
+ fprintf(stderr, "panic: %s\n", err);
+ exit(-1);
+}
+
+void STreeParser::
+save_state(STreeParser *buf)
+{
+ buf->try_ok = this->try_ok;
+ buf->sjrv = this->sjrv;
+ buf->guessing = this->guessing;
+ buf->startofguess = this->startofguess;
+}
+
+void STreeParser::
+restore_state(STreeParser *buf)
+{
+ this->try_ok = buf->try_ok;
+ this->sjrv = buf->sjrv;
+ this->guessing = buf->guessing;
+ this->startofguess = buf->startofguess;
+}
+
+void STreeParser::
+_mkroot(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)
+{
+ *r = t;
+}
+
+void STreeParser::
+_mkchild(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)
+{
+#ifdef BEFORE_GARYS_FIX
+ /* if no sibling list, must attach to any existing root */
+ if ( *s==NULL )
+ {
+ *s = *e = t;
+ /* If r is NULL, then there was no root defined--must be sibling list */
+ if ( *r==NULL ) *r = *s;
+ else (*r)->setDown(t);
+ }
+ else { (*e)->setRight(t); *e = t; }
+#endif
+/*
+ should do nothing if asked to add a NULL argument. NULL's come up
+ when a rule wants to return "nothing".
+*/
+ /* if no sibling list, must attach to any existing root */
+ if (*s == NULL)
+ {
+ *s = *e = t;
+ // If r is NULL then there was no root defined--must be sibling list
+ if (*r == NULL) *r = *s;
+ else (*r)->setDown(t);
+ }
+ else if (*e != NULL)
+ {
+ (*e)->setRight(t);
+ *e = t;
+ }
+ if (*e != NULL) {
+ while ((*e)->right() != NULL) *e = (SORASTBase *)(*e)->right();
+ }
+}
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c
new file mode 100644
index 0000000000..8ba1a49b50
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c
@@ -0,0 +1,834 @@
+/*
+ * astlib.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include <stdio.h>
+#include "pcctscfg.h"
+#include <ctype.h>
+
+#define SORCERER_TRANSFORM
+
+#include "CASTBase.h"
+#include "astlib.h"
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+ /* String Scanning/Parsing Stuff */
+
+#define StringScanMaxText 50
+
+typedef struct stringlexer {
+#ifdef __USE_PROTOS
+ signed int c;
+#else
+ int c;
+#endif
+ char *input;
+ char *p;
+ char text[StringScanMaxText];
+ } StringLexer;
+
+#define LPAREN 1
+#define RPAREN 2
+#define PERCENT 3
+#define INT 4
+#define COLON 5
+#define POUND 6
+#define PERIOD 7
+#define StringScanEOF -1
+#define VALID_SCAN_TOKEN(t) (t>=LPAREN && t<=PERIOD)
+
+static char *scan_token_tbl[] = {
+ "invalid", /* 0 */
+ "LPAREN", /* 1 */
+ "RPAREN", /* 2 */
+ "PERCENT", /* 3 */
+ "INT", /* 4 */
+ "COLON", /* 5 */
+ "POUND", /* 6 */
+ "PERIOD", /* 7 */
+};
+
+char *
+#ifdef __USE_PROTOS
+scan_token_str(int t)
+#else
+scan_token_str(t)
+int t;
+#endif
+{
+ if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];
+ else if ( t==StringScanEOF ) return "<end-of-string>";
+ else return "<invalid-token>";
+}
+
+typedef struct stringparser {
+ int token;
+ StringLexer *lexer;
+ int num_labels;
+ } StringParser;
+
+ /* This type ONLY USED by ast_scan() */
+
+typedef struct _scanast {
+ struct _scanast *right, *down;
+ int token;
+ int label_num;
+ } ScanAST;
+
+#ifdef __USE_PROTOS
+static void stringlexer_init(StringLexer *scanner, char *input);
+static void stringparser_init(StringParser *, StringLexer *);
+static ScanAST *stringparser_parse_scanast(char *templ, int *n);
+static ScanAST *stringparser_parse_tree(StringParser *parser);
+static ScanAST *stringparser_parse_element(StringParser *parser);
+static void stringscan_advance(StringLexer *scanner);
+static int stringscan_gettok(StringLexer *scanner);
+#else
+static void stringlexer_init();
+static void stringparser_init();
+static ScanAST *stringparser_parse_scanast();
+static ScanAST *stringparser_parse_tree();
+static ScanAST *stringparser_parse_element();
+static void stringscan_advance();
+static int stringscan_gettok();
+#endif
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually sibling lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ *
+ * The ast_down and ast_right down/right pointers are used to make the tree.
+ */
+SORAST *
+#ifdef PCCTS_USE_STDARG
+ast_make(SORAST *rt, ...)
+#else
+ast_make(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ register SORAST *child, *sibling=NULL, *tail = NULL, *w;
+ SORAST *root;
+
+#ifdef PCCTS_USE_STDARG
+ va_start(ap, rt);
+ root = rt;
+#else
+ va_start(ap);
+ root = va_arg(ap, SORAST *);
+#endif
+
+ if ( root != NULL )
+ if ( root->ast_down != NULL ) return NULL;
+ child = va_arg(ap, SORAST *);
+ while ( child != NULL )
+ {
+ /* find end of child */
+ for (w=child; w->ast_right!=NULL; w=w->ast_right) {;}
+ if ( sibling == NULL ) {sibling = child; tail = w;}
+ else {tail->ast_right = child; tail = w;}
+ child = va_arg(ap, SORAST *);
+ }
+ if ( root==NULL ) root = sibling;
+ else root->ast_down = sibling;
+ va_end(ap);
+ return root;
+}
+
+/* The following push and pop routines are only used by ast_find_all() */
+
+static void
+#ifdef __USE_PROTOS
+_push(SORAST **st, int *sp, SORAST *e)
+#else
+_push(st, sp, e)
+SORAST **st;
+int *sp;
+SORAST *e;
+#endif
+{
+ (*sp)--;
+ require((*sp)>=0, "stack overflow");
+ st[(*sp)] = e;
+}
+
+static SORAST *
+#ifdef __USE_PROTOS
+_pop(SORAST **st, int *sp)
+#else
+_pop(st, sp)
+SORAST **st;
+int *sp;
+#endif
+{
+ SORAST *e = st[*sp];
+ (*sp)++;
+ require((*sp)<=MaxTreeStackDepth, "stack underflow");
+ return e;
+}
+
+/* Is 'u' a subtree of 't' beginning at the root? */
+int
+#ifdef __USE_PROTOS
+ast_match_partial(SORAST *t, SORAST *u)
+#else
+ast_match_partial(t, u)
+SORAST *t, *u;
+#endif
+{
+ SORAST *sib;
+
+ if ( u==NULL ) return 1;
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
+ {
+ if ( sib->token != u->token ) return 0;
+ if ( sib->ast_down!=NULL )
+ if ( !ast_match_partial(sib->ast_down, u->ast_down) ) return 0;
+ }
+ return 1;
+}
+
+/* Find all occurrences of u in t.
+ * 'cursor' must be initialized to 't'. It eventually
+ * returns NULL when no more occurrences of 'u' are found.
+ */
+SORAST *
+#ifdef __USE_PROTOS
+ast_find_all(SORAST *t, SORAST *u, SORAST **cursor)
+#else
+ast_find_all(t, u, cursor)
+SORAST *t, *u, **cursor;
+#endif
+{
+ SORAST *sib;
+ static SORAST *template_stack[MaxTreeStackDepth];
+ static int tsp = MaxTreeStackDepth;
+
+ if ( *cursor == NULL ) return NULL;
+ if ( *cursor!=t ) sib = *cursor;
+ else {
+ /* else, first time--start at top of template 't' */
+ tsp = MaxTreeStackDepth;
+ sib = t;
+ /* bottom of stack is always a NULL--"cookie" indicates "done" */
+ _push(template_stack, &tsp, NULL);
+ }
+
+keep_looking:
+ if ( sib==NULL ) /* hit end of sibling list */
+ {
+ sib = _pop(template_stack, &tsp);
+ if ( sib == NULL ) { *cursor = NULL; return NULL; }
+ }
+
+ if ( sib->token != u->token )
+ {
+ /* look for another match */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ sib=sib->ast_down;
+ goto keep_looking;
+ }
+ /* nothing below to try, try next sibling */
+ sib=sib->ast_right;
+ goto keep_looking;
+ }
+
+ /* found a matching root node, try to match what's below */
+ if ( ast_match_partial(sib, u) )
+ {
+ /* record sibling cursor so we can pick up next from there */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ *cursor = sib->ast_down;
+ }
+ else if ( sib->ast_right!=NULL ) *cursor = sib->ast_right;
+ else *cursor = _pop(template_stack, &tsp);
+ return sib;
+ }
+
+ /* no match, keep searching */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ sib=sib->ast_down;
+ }
+ else sib = sib->ast_right; /* else, try to right if zip below */
+ goto keep_looking;
+}
+
+/* are two trees exactly alike? */
+int
+#ifdef __USE_PROTOS
+ast_match(SORAST *t, SORAST *u)
+#else
+ast_match(t, u)
+SORAST *t, *u;
+#endif
+{
+ SORAST *sib;
+
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
+ {
+ if ( sib->token != u->token ) return 0;
+ if ( sib->ast_down!=NULL )
+ if ( !ast_match(sib->ast_down, u->ast_down) ) return 0;
+ }
+ return 1;
+}
+
+static int
+#ifdef __USE_PROTOS
+ast_scanmatch(ScanAST *t, SORAST *u, SORAST **labels[], int *n)
+#else
+ast_scanmatch(t, u, labels, n)
+ScanAST *t;
+SORAST *u;
+SORAST **labels[];
+int *n;
+#endif
+{
+ ScanAST *sib;
+
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right, u=u->ast_right)
+ {
+ /* make sure tokens match; token of '0' means wildcard match */
+ if ( sib->token != u->token && sib->token!=0 ) return 0;
+ /* we have a matched token here; set label pointers if exists */
+ if ( sib->label_num>0 )
+ {
+ require(labels!=NULL, "label found in template, but no array of labels");
+ (*n)++;
+ *(labels[sib->label_num-1]) = u;
+ }
+ /* match what's below if something there and current node is not wildcard */
+ if ( sib->down!=NULL && sib->token!=0 )
+ if ( !ast_scanmatch(sib->down, u->ast_down, labels, n) ) return 0;
+ }
+ return 1;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_insert_after(SORAST *a, SORAST *b)
+#else
+ast_insert_after(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_insert_after: NULL input tree");
+ if ( b==NULL ) return;
+ /* find end of b's child list */
+ for (end=b; end->ast_right!=NULL; end=end->ast_right) {;}
+ end->ast_right = a->ast_right;
+ a->ast_right = b;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_append(SORAST *a, SORAST *b)
+#else
+ast_append(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL&&b!=NULL, "ast_append: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
+ end->ast_right = b;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_tail(SORAST *a)
+#else
+ast_tail(a)
+SORAST *a;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_tail: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
+ return end;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_bottom(SORAST *a)
+#else
+ast_bottom(a)
+SORAST *a;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_bottom: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_down!=NULL; end=end->ast_down) {;}
+ return end;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_cut_between(SORAST *a, SORAST *b)
+#else
+ast_cut_between(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end, *ret;
+ require(a!=NULL&&b!=NULL, "ast_cut_between: NULL input tree");
+ /* find node pointing to b */
+ for (end=a; end->ast_right!=NULL&&end->ast_right!=b; end=end->ast_right)
+ {;}
+ require(end->ast_right!=NULL, "ast_cut_between: a,b not connected");
+ end->ast_right = NULL; /* don't want it point to 'b' anymore */
+ ret = a->ast_right;
+ a->ast_right = b;
+ return ret;
+}
+
+SList *
+#ifdef __USE_PROTOS
+ast_to_slist(SORAST *t)
+#else
+ast_to_slist(t)
+SORAST *t;
+#endif
+{
+ SList *list=NULL;
+ SORAST *p;
+
+ for (p=t; p!=NULL; p=p->ast_right)
+ {
+ slist_add(&list, p);
+ }
+ return list;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+slist_to_ast(SList *list)
+#else
+slist_to_ast(list)
+SList *list;
+#endif
+{
+ SORAST *t=NULL, *last=NULL;
+ SList *p;
+
+ for (p = list->next; p!=NULL; p=p->next)
+ {
+ SORAST *u = (SORAST *)p->elem;
+ if ( last==NULL ) last = t = u;
+ else { last->ast_right = u; last = u; }
+ }
+ return t;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_free(SORAST *t)
+#else
+ast_free(t)
+SORAST *t;
+#endif
+{
+ if ( t == NULL ) return;
+ ast_free( t->ast_down );
+ ast_free( t->ast_right );
+ free( t );
+}
+
+int
+#ifdef __USE_PROTOS
+ast_nsiblings(SORAST *t)
+#else
+ast_nsiblings(t)
+SORAST *t;
+#endif
+{
+ int n=0;
+
+ while ( t!=NULL )
+ {
+ n++;
+ t = t->ast_right;
+ }
+ return n;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_sibling_index(SORAST *t, int i)
+#else
+ast_sibling_index(t,i)
+SORAST *t;
+int i;
+#endif
+{
+ int j=1;
+ require(i>0, "ast_sibling_index: i<=0");
+
+ while ( t!=NULL )
+ {
+ if ( j==i ) return t;
+ j++;
+ t = t->ast_right;
+ }
+ return NULL;
+}
+
+static void
+#ifdef __USE_PROTOS
+scanast_free(ScanAST *t)
+#else
+scanast_free(t)
+ScanAST *t;
+#endif
+{
+ if ( t == NULL ) return;
+ scanast_free( t->down );
+ scanast_free( t->right );
+ free( t );
+}
+
+/*
+ * ast_scan
+ *
+ * This function is like scanf(): it attempts to match a template
+ * against an input tree. A variable number of tree pointers
+ * may be set according to the '%i' labels in the template string.
+ * For example:
+ *
+ * ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
+ * t, &w, &x, &y, &z);
+ *
+ * Naturally, you'd want this converted from
+ *
+ * ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",
+ * t, &w, &x, &y, &z);
+ *
+ * by SORCERER.
+ *
+ * This function call must be done withing a SORCERER file because SORCERER
+ * must convert the token references to the associated token number.
+ *
+ * This functions parses the template and creates trees which are then
+ * matched against the input tree. The labels are set as they are
+ * encountered; hence, partial matches may leave some pointers set
+ * and some NULL. This routines initializes all argument pointers to NULL
+ * at the beginning.
+ *
+ * This function returns the number of labels matched.
+ */
+int
+#ifdef PCCTS_USE_STDARG
+ast_scan(char *templ, SORAST *tree, ...)
+#else
+ast_scan(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ ScanAST *t;
+ int n, i, found=0;
+ SORAST ***label_ptrs=NULL;
+
+#ifdef PCCTS_USE_STDARG
+ va_start(ap, tree);
+#else
+ char *templ;
+ SORAST *tree;
+
+ va_start(ap);
+ templ = va_arg(ap, char *);
+ tree = va_arg(ap, SORAST *);
+#endif
+
+ /* make a ScanAST tree out of the template */
+ t = stringparser_parse_scanast(templ, &n);
+
+ /* make an array out of the labels */
+ if ( n>0 )
+ {
+ label_ptrs = (SORAST ***) calloc(n, sizeof(SORAST **));
+ require(label_ptrs!=NULL, "ast_scan: out of memory");
+ for (i=1; i<=n; i++)
+ {
+ label_ptrs[i-1] = va_arg(ap, SORAST **);
+ *(label_ptrs[i-1]) = NULL;
+ }
+ }
+
+ /* match the input tree against the template */
+ ast_scanmatch(t, tree, label_ptrs, &found);
+
+ scanast_free(t);
+ free(label_ptrs);
+
+ return found;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+new_scanast(int tok)
+#else
+new_scanast(tok)
+int tok;
+#endif
+{
+ ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));
+ if ( p == NULL ) {fprintf(stderr, "out of mem\n"); exit(-1);}
+ p->token = tok;
+ return p;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_scanast(char *templ, int *num_labels)
+#else
+stringparser_parse_scanast(templ, num_labels)
+char *templ;
+int *num_labels;
+#endif
+{
+ StringLexer lex;
+ StringParser parser;
+ ScanAST *t;
+
+ stringlexer_init(&lex, templ);
+ stringparser_init(&parser, &lex);
+ t = stringparser_parse_tree(&parser);
+ *num_labels = parser.num_labels;
+ return t;
+}
+
+static void
+#ifdef __USE_PROTOS
+stringparser_match(StringParser *parser, int token)
+#else
+stringparser_match(parser, token)
+StringParser *parser;
+int token;
+#endif
+{
+ if ( parser->token != token ) sorcerer_panic("bad tree in ast_scan()");
+}
+
+/*
+ * Match a tree of the form:
+ * (root child1 child2 ... childn)
+ * or,
+ * node
+ *
+ * where the elements are integers or labeled integers.
+ */
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_tree(StringParser *parser)
+#else
+stringparser_parse_tree(parser)
+StringParser *parser;
+#endif
+{
+ ScanAST *t=NULL, *root, *child, *last = NULL;
+
+ if ( parser->token != POUND )
+ {
+ return stringparser_parse_element(parser);
+ }
+ stringparser_match(parser,POUND);
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,LPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root = stringparser_parse_element(parser);
+ while ( parser->token != RPAREN )
+ {
+ child = stringparser_parse_element(parser);
+ if ( t==NULL ) { t = child; last = t; }
+ else { last->right = child; last = child; }
+ }
+ stringparser_match(parser,RPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root->down = t;
+ return root;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_element(StringParser *parser)
+#else
+stringparser_parse_element(parser)
+StringParser *parser;
+#endif
+{
+ static char ebuf[100];
+ int label = 0;
+
+ if ( parser->token == POUND )
+ {
+ return stringparser_parse_tree(parser);
+ }
+ if ( parser->token == PERCENT )
+ {
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,INT);
+ label = atoi(parser->lexer->text);
+ parser->num_labels++;
+ if ( label==0 ) sorcerer_panic("%%0 is an invalid label");
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,COLON);
+ parser->token = stringscan_gettok(parser->lexer);
+ /* can label tokens and wildcards */
+ if ( parser->token != INT && parser->token != PERIOD )
+ sorcerer_panic("can only label tokens");
+ }
+ if ( parser->token == INT )
+ {
+ ScanAST *p = new_scanast(atoi(parser->lexer->text));
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ if ( parser->token == PERIOD )
+ {
+ ScanAST *p = new_scanast(0); /* token of 0 is wildcard */
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ sprintf(ebuf, "mismatch token in ast_scan(): %s", scan_token_str(parser->token));
+ sorcerer_panic(ebuf);
+ return NULL; /* MR20 make -Wall happy */
+}
+
+static void
+#ifdef __USE_PROTOS
+stringparser_init(StringParser *parser, StringLexer *input)
+#else
+stringparser_init(parser, input)
+StringParser *parser;
+StringLexer *input;
+#endif
+{
+ parser->lexer = input;
+ parser->token = stringscan_gettok(parser->lexer);
+ parser->num_labels = 0;
+}
+
+static void
+#ifdef __USE_PROTOS
+stringlexer_init(StringLexer *scanner, char *input)
+#else
+stringlexer_init(scanner, input)
+StringLexer *scanner;
+char *input;
+#endif
+{
+ scanner->text[0]='\0';
+ scanner->input = input;
+ scanner->p = input;
+ stringscan_advance(scanner);
+}
+
+static void
+#ifdef __USE_PROTOS
+stringscan_advance(StringLexer *scanner)
+#else
+stringscan_advance(scanner)
+StringLexer *scanner;
+#endif
+{
+ if ( *(scanner->p) == '\0' ) scanner->c = StringScanEOF;
+ scanner->c = *(scanner->p)++;
+}
+
+static int
+#ifdef __USE_PROTOS
+stringscan_gettok(StringLexer *scanner)
+#else
+stringscan_gettok(scanner)
+StringLexer *scanner;
+#endif
+{
+ char *index = &scanner->text[0];
+ static char ebuf[100];
+
+ while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
+ if ( isdigit(scanner->c) )
+ {
+ int tok = INT;
+ while ( isdigit(scanner->c) ) {
+ *index++ = scanner->c;
+ stringscan_advance(scanner);
+ }
+ *index = '\0';
+ return tok;
+ }
+ switch ( scanner->c )
+ {
+ case '#' : stringscan_advance(scanner); return POUND;
+ case '(' : stringscan_advance(scanner); return LPAREN;
+ case ')' : stringscan_advance(scanner); return RPAREN;
+ case '%' : stringscan_advance(scanner); return PERCENT;
+ case ':' : stringscan_advance(scanner); return COLON;
+ case '.' : stringscan_advance(scanner); return PERIOD;
+ case '\0' : return StringScanEOF;
+ case StringScanEOF : return StringScanEOF;
+ default :
+ sprintf(ebuf, "invalid char in ast_scan: '%c'", scanner->c);
+ sorcerer_panic(ebuf);
+ return 0; /* MR20 Make -Wall happy */
+ }
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c
new file mode 100644
index 0000000000..4048ba50b2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c
@@ -0,0 +1,100 @@
+/*
+ * errsupport.c -- error support code for SORCERER output
+ *
+ * Define your own or compile and link this in.
+ *
+ * Terence Parr
+ * U of MN, AHPCRC
+ * February 1994
+ */
+#include "sorcerer.h"
+
+void
+#ifdef __USE_PROTOS
+mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found )
+#else
+mismatched_range( _parser, looking_for, upper_token, found )
+int looking_for;
+int upper_token;
+SORAST *found;
+STreeParser *_parser;
+#endif
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found token %d\n",
+ looking_for, upper_token,
+ found->token);
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found NULL tree\n",
+ looking_for, upper_token);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+missing_wildcard(STreeParser *_parser)
+#else
+missing_wildcard(_parser)
+STreeParser *_parser;
+#endif
+{
+ fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
+}
+
+void
+#ifdef __USE_PROTOS
+mismatched_token( STreeParser *_parser, int looking_for, SORAST *found )
+#else
+mismatched_token( _parser, looking_for, found )
+int looking_for;
+SORAST *found;
+STreeParser *_parser;
+#endif
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token %d found token %d\n",
+ looking_for,
+ found->token);
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token %d found NULL tree\n",
+ looking_for);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root )
+#else
+no_viable_alt( _parser, rulename, root )
+char *rulename;
+SORAST *root;
+STreeParser *_parser;
+#endif
+{
+ if ( root==NULL )
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for NULL tree\n",
+ rulename);
+ else
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for tree\n",
+ rulename);
+}
+
+void
+#ifdef __USE_PROTOS
+sorcerer_panic(char *err)
+#else
+sorcerer_panic(err)
+char *err;
+#endif
+{
+ fprintf(stderr, "panic: %s\n", err);
+ exit(-1);
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile
new file mode 100644
index 0000000000..c4e9bca9e8
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile
@@ -0,0 +1,21 @@
+#
+# Makefile for SORCERER libraries
+#
+SRC = astlib.c sstack.c sorlist.c sintstack.c
+OBJ = astlib.o sstack.o sorlist.o sintstack.o
+CFLAGS=-g -I../../h -I../h
+CC=cc
+
+libs : $(OBJ) $(SRC)
+
+clean:
+ rm -f *.o core
+
+scrub:
+ rm -f *.o core
+
+ci:
+ ci -u $(SRC) *.h makefile
+
+co:
+ co -l $(SRC) *.h makefile
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp
new file mode 100644
index 0000000000..390d34fc06
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp
@@ -0,0 +1,130 @@
+# Microsoft Developer Studio Project File - Name="lib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=lib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "lib.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "lib.mak" CFG="lib - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "lib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "lib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""$/pccts/Sorcerer/lib", EPABAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+
+!IF "$(CFG)" == "lib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "h" /I "..\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "lib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "h" /I "..\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "lib - Win32 Release"
+# Name "lib - Win32 Debug"
+# Begin Group "Header files"
+
+# PROP Default_Filter "h"
+# Begin Source File
+
+SOURCE=.\CASTBase.h
+# End Source File
+# End Group
+# Begin Group "Source files"
+
+# PROP Default_Filter "c,cpp"
+# Begin Source File
+
+SOURCE=.\astlib.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\errsupport.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\PCCTSAST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sintstack.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\SList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sorcerer.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\sorlist.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\sstack.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\STreeParser.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c
new file mode 100644
index 0000000000..a3708c94fb
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c
@@ -0,0 +1,140 @@
+/*
+ * sint.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sintstack.h"
+
+SIntStack *
+#ifdef __USE_PROTOS
+sint_newstack(int size)
+#else
+sint_newstack(size)
+int size;
+#endif
+{
+ SIntStack *p = (SIntStack *) calloc(1, sizeof(SIntStack));
+ require(p!=NULL, "sint_newstack: out of memory");
+ p->data = (int *) calloc(size, sizeof(int));
+ require(p!=NULL, "sint_newstack: out of memory");
+ p->size = size;
+ p->sp = size;
+ return p;
+}
+
+void
+#ifdef __USE_PROTOS
+sint_freestack(SIntStack *st)
+#else
+sint_freestack(st)
+SIntStack *st;
+#endif
+{
+ if ( st==NULL ) return;
+ if ( st->data==NULL ) return;
+ free(st->data);
+ free(st);
+}
+
+void
+#ifdef __USE_PROTOS
+sint_push(SIntStack *st,int i)
+#else
+sint_push(st,i)
+SIntStack *st;
+int i;
+#endif
+{
+ require(st->sp>0, "sint_push: stack overflow");
+ st->data[--(st->sp)] = i;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_pop(SIntStack *st)
+#else
+sint_pop(st)
+SIntStack *st;
+#endif
+{
+ require(st->sp<st->size, "sint_pop: stack underflow");
+ return st->data[st->sp++];
+}
+
+int
+#ifdef __USE_PROTOS
+sint_stacksize(SIntStack *st)
+#else
+sint_stacksize(st)
+SIntStack *st;
+#endif
+{
+ return st->size - st->sp;
+}
+
+void
+#ifdef __USE_PROTOS
+sint_stackreset(SIntStack *st)
+#else
+sint_stackreset(st)
+SIntStack *st;
+#endif
+{
+ st->sp = st->size;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_stackempty(SIntStack *st)
+#else
+sint_stackempty(st)
+SIntStack *st;
+#endif
+{
+ return st->sp==st->size;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_top(SIntStack *st)
+#else
+sint_top(st)
+SIntStack *st;
+#endif
+{
+ require(st->sp<st->size, "sint_top: stack underflow");
+ return st->data[st->sp];
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c
new file mode 100644
index 0000000000..ad4c3a7eee
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c
@@ -0,0 +1,169 @@
+/*
+ * sorcerer.c -- support code for SORCERER output
+ *
+ * Define your own or compile and link this in.
+ *
+ * Terence Parr
+ * U of MN, AHPCRC
+ * February 1994
+ */
+
+/***********************************************************************
+ 2-Oct-97 The routine ast_dup() appeared to have a bug in it. Instead
+ of providing a deep copy of its argument it made a bushy copy
+ of its argument - by duplicating the nodes pointed to by
+ its right link. This is certainly not deliberate and does
+ not match code in PCCTSAST.cpp (which had its own bug). This
+ has been changed to do a deep copy in the traditional sense.
+***********************************************************************/
+
+#ifdef OLD
+/* Given a result pointer, return the same one if *t is NULL,
+ * else find the end of the sibling list and return the address
+ * the 'next[write]' field in that last node.
+ */
+AST **
+#ifdef __USE_PROTOS
+_nextresult(STreeParser *_parser, AST **t)
+#else
+_nextresult(_parser, t)
+AST **t;
+STreeParser *_parser;
+#endif
+{
+ AST *p = *t;
+
+ if ( p==NULL ) return t;
+ while ( p->ast_right(_parser->write) != NULL )
+ {
+ p = p->ast_right(_parser->write);
+ }
+ return &(p->ast_right(_parser->write));
+}
+
+/*
+ * Copy the read pointers to the write pointers for a node or entire subtree
+ */
+void
+#ifdef __USE_PROTOS
+_copy_wildcard(STreeParser *_parser, AST *t, int root)
+#else
+_copy_wildcard(_parser, t, root)
+STreeParser *_parser;
+AST *t;
+int root;
+#endif
+{
+ while ( t!=NULL )
+ {
+ if ( !root ) t->ast_right(_parser->write) = t->ast_right(_parser->read);
+ t->ast_down(_parser->write) = t->ast_down(_parser->read);
+ if ( t->ast_down(_parser->read)!=NULL )
+ _copy_wildcard(_parser, t->ast_down(_parser->read), 0);
+ if ( root ) return;
+ else root=0;
+ t = t->ast_right(_parser->read);
+ }
+}
+#endif
+
+void
+#ifdef __USE_PROTOS
+_mkroot(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
+#else
+_mkroot(r,s,e,t)
+SORAST **r, **s, **e, *t;
+#endif
+{
+ *r = t;
+}
+
+void
+#ifdef __USE_PROTOS
+_mkchild(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
+#else
+_mkchild(r,s,e,t)
+SORAST **r, **s, **e, *t;
+#endif
+{
+ /* if no sibling list, must attach to any existing root */
+ if ( *s==NULL )
+ {
+ *s = *e = t;
+ /* If r is NULL, then there was no root defined--must be sibling list */
+ if ( *r==NULL ) *r = *s;
+ else (*r)->ast_down = t;
+ }
+ else { (*e)->ast_right = t; *e = t; }
+}
+
+/* THESE FUNCS HAVE TO GO HERE BECAUSE THEY ARE SENSITIVE TO USER'S SORAST DEF */
+SORAST *
+#ifdef __USE_PROTOS
+ast_alloc(void)
+#else
+ast_alloc()
+#endif
+{
+ SORAST *t = (SORAST *)calloc(1, sizeof(SORAST));
+ if ( t==NULL ) sorcerer_panic("out of memory");
+ return t;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup_bushy(SORAST *t)
+#else
+ast_dup_bushy(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
+ u->ast_right = ast_dup_bushy(t->ast_right);
+ return u;
+}
+
+
+/* Assume t is a root node of a tree--duplicate that node and what's below */
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup(SORAST *t)
+#else
+ast_dup(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
+ u->ast_right = NULL;
+ return u;
+}
+
+/* Assume t is a root node of a tree--duplicate that node and what's below */
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup_node(SORAST *t)
+#else
+ast_dup_node(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->down = NULL;
+ u->right = NULL;
+ return u;
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c
new file mode 100644
index 0000000000..6872974c26
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c
@@ -0,0 +1,123 @@
+/*
+ * slist.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sorlist.h"
+
+/* Iterate over a list of elements; returns ptr to a new element
+ * in list upon every call and NULL when no more are left.
+ * Very useful like this:
+ *
+ * cursor = mylist;
+ * while ( (p=slist_iterate(mylist,&cursor)) ) {
+ * / * place with element p * /
+ * }
+ *
+ * The cursor must be initialized to point to the list to iterate over.
+ */
+void *
+#ifdef __USE_PROTOS
+slist_iterate(SList *list, SList **cursor)
+#else
+slist_iterate(list, cursor)
+SList *list, **cursor;
+#endif
+{
+ void *e;
+
+ if ( list==NULL || cursor == NULL || *cursor==NULL ) return NULL;
+ if ( list== *cursor ) { *cursor = (*cursor)->next; }
+ e = (*cursor)->elem;
+ (*cursor) = (*cursor)->next;
+ return e;
+}
+
+/*
+ * add an element to a list.
+ *
+ * Any non-empty list has a sentinel node whose 'elem' pointer is really
+ * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1).
+ * Elements are appended to the list.
+ */
+void
+#ifdef __USE_PROTOS
+slist_add( SList **list, void *e )
+#else
+slist_add( list, e )
+SList **list;
+void *e;
+#endif
+{
+ SList *p, *tail;
+ require(e!=NULL, "slist_add: attempting to add NULL list element");
+
+ p = newSList;
+ require(p!=NULL, "slist_add: cannot alloc new list node");
+ p->elem = e;
+ if ( *list == NULL )
+ {
+ SList *sentinel = newSList;
+ require(sentinel!=NULL, "slist_add: cannot alloc sentinel node");
+ *list=sentinel;
+ sentinel->next = p;
+ sentinel->elem = (char *)p; /* set tail pointer */
+ }
+ else /* find end of list */
+ {
+ tail = (SList *) (*list)->elem; /* get tail pointer */
+ tail->next = p;
+ (*list)->elem = (char *) p; /* reset tail */
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+slist_free(SList *list)
+#else
+slist_free(list)
+SList *list;
+#endif
+{
+ SList *p,*q;
+
+ if ( list==NULL ) return; /* empty list */
+ for (p = list->next; p!=NULL; p=q)
+ {
+ q = p->next;
+ free(p);
+ }
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c
new file mode 100644
index 0000000000..c8a97b06fa
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c
@@ -0,0 +1,78 @@
+/*
+ * sstack.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "pcctscfg.h"
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sstack.h"
+
+void
+#ifdef __USE_PROTOS
+sstack_push( SStack **st, void *e )
+#else
+sstack_push( st, e )
+SStack **st;
+void *e;
+#endif
+{
+ SStack *p;
+ require(e!=NULL, "sstack_push: attempting to add NULL list element");
+
+ p = newSStack;
+ require(p!=NULL, "sstack_push: cannot alloc new list node");
+ p->elem = e;
+ p->next = *st;
+ *st = p;
+}
+
+void *
+#ifdef __USE_PROTOS
+sstack_pop( SStack **st )
+#else
+sstack_pop( st )
+SStack **st;
+#endif
+{
+ SStack *p = *st;
+ void *r;
+
+ *st = (*st)->next;
+ r = p->elem;
+ free(p);
+ return r;
+}
+