summaryrefslogtreecommitdiff
path: root/Tools/CCode/Source/Pccts/h
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/CCode/Source/Pccts/h')
-rw-r--r--Tools/CCode/Source/Pccts/h/AParser.cpp871
-rw-r--r--Tools/CCode/Source/Pccts/h/AParser.h376
-rw-r--r--Tools/CCode/Source/Pccts/h/ASTBase.cpp256
-rw-r--r--Tools/CCode/Source/Pccts/h/ASTBase.h122
-rw-r--r--Tools/CCode/Source/Pccts/h/ATokPtr.h88
-rw-r--r--Tools/CCode/Source/Pccts/h/ATokPtrImpl.h88
-rw-r--r--Tools/CCode/Source/Pccts/h/AToken.h325
-rw-r--r--Tools/CCode/Source/Pccts/h/ATokenBuffer.cpp374
-rw-r--r--Tools/CCode/Source/Pccts/h/ATokenBuffer.h109
-rw-r--r--Tools/CCode/Source/Pccts/h/ATokenStream.h51
-rw-r--r--Tools/CCode/Source/Pccts/h/BufFileInput.cpp100
-rw-r--r--Tools/CCode/Source/Pccts/h/BufFileInput.h53
-rw-r--r--Tools/CCode/Source/Pccts/h/DLG_stream_input.h98
-rw-r--r--Tools/CCode/Source/Pccts/h/DLexer.h191
-rw-r--r--Tools/CCode/Source/Pccts/h/DLexerBase.cpp302
-rw-r--r--Tools/CCode/Source/Pccts/h/DLexerBase.h198
-rw-r--r--Tools/CCode/Source/Pccts/h/PBlackBox.h134
-rw-r--r--Tools/CCode/Source/Pccts/h/PCCTSAST.cpp684
-rw-r--r--Tools/CCode/Source/Pccts/h/PCCTSAST.h143
-rw-r--r--Tools/CCode/Source/Pccts/h/SList.h72
-rw-r--r--Tools/CCode/Source/Pccts/h/antlr.h807
-rw-r--r--Tools/CCode/Source/Pccts/h/ast.c345
-rw-r--r--Tools/CCode/Source/Pccts/h/ast.h121
-rw-r--r--Tools/CCode/Source/Pccts/h/charbuf.h46
-rw-r--r--Tools/CCode/Source/Pccts/h/charptr.c58
-rw-r--r--Tools/CCode/Source/Pccts/h/charptr.h48
-rw-r--r--Tools/CCode/Source/Pccts/h/config.h1
-rw-r--r--Tools/CCode/Source/Pccts/h/dlgauto.h504
-rw-r--r--Tools/CCode/Source/Pccts/h/dlgdef.h128
-rw-r--r--Tools/CCode/Source/Pccts/h/err.h1170
-rw-r--r--Tools/CCode/Source/Pccts/h/int.h37
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_assert.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_iostream.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_istream.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_setjmp.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_stdarg.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_stdio.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_stdlib.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pccts_string.h10
-rw-r--r--Tools/CCode/Source/Pccts/h/pcctscfg.h359
-rw-r--r--Tools/CCode/Source/Pccts/h/pcnames.bat11
-rw-r--r--Tools/CCode/Source/Pccts/h/slist.cpp116
42 files changed, 0 insertions, 8466 deletions
diff --git a/Tools/CCode/Source/Pccts/h/AParser.cpp b/Tools/CCode/Source/Pccts/h/AParser.cpp
deleted file mode 100644
index 720fe75af1..0000000000
--- a/Tools/CCode/Source/Pccts/h/AParser.cpp
+++ /dev/null
@@ -1,871 +0,0 @@
-/* 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-2000
- */
-
-#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;
-}
-
-
-#ifdef _MSC_VER // MR23
-//Turn off warning:
-//interaction between '_setjmp' and C++ object destruction is non-portable
-#pragma warning(disable : 4611)
-#endif
-int ANTLRParser::
-guess(ANTLRParserState *st)
-{
- saveState(st);
- guessing = 1;
- return setjmp(guess_start.state);
-}
-#ifdef _MSC_VER // MR23
-#pragma warning(default: 4611)
-#endif
-
-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) {
- /* MR23 */ printMessage(stderr,
- "trace enable restored in rule %s depth %d\n",
- traceCurrentRuleName,
- traceDepth);
- };
- if (traceOptionValue <= 0) {
- /* MR23 */ printMessage(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, SetWordType *tokclassErrset)
-{
- if ( dirty==LLk ) {
- consume();
- }
- if ( !set_el(LA(1), tset) ) {
- *MissText=NULL; /* MR23 */
- *MissTok=(ANTLRTokenType) 0; /* MR23 */
- *BadTok=LT(1); /* MR23 */
- *MissSet=tokclassErrset; /* MR23 */
- 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.
- */
-
-/* MR23 THM There appears to be a parameter "badText" passed to syn()
- which is not present in the parameter list. This may be
- because in C mode there is no attribute function which
- returns the text, so the text representation of the token
- must be passed explicitly. I think.
-*/
-
-void ANTLRParser::
-syn(_ANTLRTokenPtr /*tok MR23*/, ANTLRChar *egroup, SetWordType *eset,
- ANTLRTokenType etok, int k)
-{
- int line;
-
- line = LT(1)->getLine();
-
- syntaxErrCount++; /* MR11 */
-
- /* MR23 If the token is not an EOF token, then use the ->getText() value.
-
- If the token is the EOF token the text returned by ->getText()
- may be garbage. If the text from the token table is "@" use
- "<eof>" instead, because end-users don't know what "@" means.
- If the text is not "@" then use that text, which must have been
- supplied by the grammar writer.
- */
- const char * errorAt = LT(1)->getText();
- if (LA(1) == eofToken) {
- errorAt = parserTokenName(LA(1));
- if (errorAt[0] == '@') errorAt = "<eof>";
- }
- /* MR23 */ printMessage(stderr, "line %d: syntax error at \"%s\"",
- line, errorAt);
- if ( !etok && !eset ) {/* MR23 */ printMessage(stderr, "\n"); return;}
- if ( k==1 ) /* MR23 */ printMessage(stderr, " missing");
- else
- {
- /* MR23 */ printMessage(stderr, "; \"%s\" not", LT(k)->getText()); // MR23 use LT(k) since k>1
- if ( set_deg(eset)>1 ) /* MR23 */ printMessage(stderr, " in");
- }
- if ( set_deg(eset)>0 ) edecode(eset);
- else /* MR23 */ printMessage(stderr, " %s", token_tbl[etok]);
- if ( strlen(egroup) > 0 ) /* MR23 */ printMessage(stderr, " in %s", egroup);
- /* MR23 */ printMessage(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 ) /* MR23 */ printMessage(stderr, " {");
- do {
- register SetWordType t = *p;
- register SetWordType *b = &(bitmask[0]);
- do {
- if ( t & *b ) /* MR23 */ printMessage(stderr, " %s", token_tbl[e]);
- e++;
- } while (++b < &(bitmask[sizeof(SetWordType)*8]));
- } while (++p < endp);
- if ( set_deg(a)>1 ) /* MR23 */ printMessage(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
- }
-/* MR23 printMessage(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 */
- /* MR23 */ printMessage(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 */
- /* MR23 */ printMessage(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
-{
- /* MR23 */ printMessage(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) {
- /* MR23 */ printMessage(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) {
- /* MR23 */ printMessage(stderr," (guess mode continues - an enclosing guess is still active)");
- } else {
- /* MR23 */ printMessage(stderr," (guess mode ends)");
- };
- /* MR23 */ printMessage(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) {
- /* MR23 */ printMessage(stderr,"guess failed in %s\n",traceCurrentRuleName);
- };
-}
-
-/* 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) {
- /* MR23 */ printMessage(stderr,"enter rule %s {\"%s\"} depth %d",
- rule,
- LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
- traceDepth);
- if (guessing) /* MR23 */ printMessage(stderr," guessing");
- /* MR23 */ printMessage(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) {
- /* MR23 */ printMessage(stderr,"exit rule %s {\"%s\"} depth %d",
- rule,
- LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),
- traceDepth+1);
- if (guessing) /* MR23 */ printMessage(stderr," guessing");
- /* MR23 */ printMessage(stderr,"\n");
- };
-}
-
-int ANTLRParser::traceOption(int delta) {
-
- int prevValue=traceOptionValue;
-
- traceOptionValue=traceOptionValue+delta;
-
- if (traceCurrentRuleName != NULL) {
- if (prevValue <= 0 && traceOptionValue > 0) {
- /* MR23 */ printMessage(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
- };
- if (prevValue > 0 && traceOptionValue <= 0) {
- /* MR23 */ printMessage(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) {
- /* MR23 */ printMessage(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);
- };
- if (prevValue > 0 && traceGuessOptionValue <= 0) {
- /* MR23 */ printMessage(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
-}
-
-//MR23
-int ANTLRParser::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
- int iRet = printMessageV(pFile, pFormat, marker);
- va_end( marker );
- return iRet;
-}
-
-int ANTLRParser::printMessageV(FILE* pFile, const char* pFormat, va_list arglist) // MR23
-{
- return vfprintf(pFile, pFormat, arglist);
-}
-
-// MR23 Move semantic predicate error handling from macro to virtual function
-//
-// Called by the zzfailed_pred
-
-void ANTLRParser::failedSemanticPredicate(const char* predicate)
-{
- printMessage(stdout,"line %d: semantic error; failed predicate: '%s'\n",
- LT(1)->getLine(), predicate);
-}
diff --git a/Tools/CCode/Source/Pccts/h/AParser.h b/Tools/CCode/Source/Pccts/h/AParser.h
deleted file mode 100644
index fe405f4167..0000000000
--- a/Tools/CCode/Source/Pccts/h/AParser.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/* 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-2000
- */
-
-#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 **,
- SetWordType * tokclassErrset /* MR23 */);
- 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 *);
-
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
- virtual int printMessageV(FILE* pFile, const char* pFormat, va_list arglist); // MR23
-
- 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
- virtual void failedSemanticPredicate(const char* predicate); /* MR23 */
-};
-
-#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,_tokclassErrset) \
- if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \
- (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet, _tokclassErrset) ) 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 in guess mode.
-// MR1 Identification and correction due to J. Lilley
-//
-// MR23 Call virtual method to report error.
-// MR23 Provide more control over failed predicate action
-// without any need for user to worry about guessing internals.
-
-#ifndef zzfailed_pred
-#define zzfailed_pred(_p,_hasuseraction,_useraction) \
- if (guessing) { \
- zzGUESS_FAIL; \
- } else { \
- zzfailed_pred_action(_p,_hasuseraction,_useraction) \
- }
-#endif
-
-// MR23 Provide more control over failed predicate action
-// without any need for user to worry about guessing internals.
-// _hasuseraction == 0 => no user specified error action
-// _hasuseraction == 1 => user specified error action
-
-#ifndef zzfailed_pred_action
-#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \
- if (_hasuseraction) { _useraction } else { failedSemanticPredicate(_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/Tools/CCode/Source/Pccts/h/ASTBase.cpp b/Tools/CCode/Source/Pccts/h/ASTBase.cpp
deleted file mode 100644
index a94f080c86..0000000000
--- a/Tools/CCode/Source/Pccts/h/ASTBase.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/* 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-2000
- */
-
-#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(void* pData /*= NULL*/ /* MR23 */)
-{
- ASTBase *tree = this;
-
- while ( tree!= NULL )
- {
- if ( tree->_down != NULL ) {
- tree->preorder_before_action(pData); // MR1
- };
- tree->preorder_action(pData);
- if ( tree->_down!=NULL )
- {
- tree->_down->preorder(pData);
- tree->preorder_after_action(pData); // 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=NULL /*MR23*/, *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)
-{
- /* MR23 */ printMessage(stderr,"ASTBase panic: %s\n", msg);
- exit(PCCTS_EXIT_FAILURE);
-}
-
-#ifdef PCCTS_NOT_USING_SOR
-//MR23
-int ASTBase::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
- int iRet = vfprintf(pFile, pFormat, marker);
- va_end( marker );
- return iRet;
-}
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/ASTBase.h b/Tools/CCode/Source/Pccts/h/ASTBase.h
deleted file mode 100644
index 912f4b8482..0000000000
--- a/Tools/CCode/Source/Pccts/h/ASTBase.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* 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-2000
- */
-
-#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(void* pData = NULL /* MR23 */);
- static ASTBase *tmake(ASTBase *, ...);
- static void link(ASTBase **, ASTBase **, ASTBase **);
- void subchild(ASTBase **, ASTBase **, ASTBase **);
- void subroot(ASTBase **, ASTBase **, ASTBase **);
- virtual void preorder_action(void* /*pData*/ = NULL /* MR23 */) { ; }
- virtual void preorder_before_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " ("); }
- virtual void preorder_after_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " )"); }
- virtual void panic(const char *msg); /* MR21 */
- virtual void reportOverwriteOfDownPointer(); /* MR21 */
-#ifdef PCCTS_NOT_USING_SOR
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
-#endif
-};
-
-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/Tools/CCode/Source/Pccts/h/ATokPtr.h b/Tools/CCode/Source/Pccts/h/ATokPtr.h
deleted file mode 100644
index 75b4c86cbf..0000000000
--- a/Tools/CCode/Source/Pccts/h/ATokPtr.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/ATokPtrImpl.h b/Tools/CCode/Source/Pccts/h/ATokPtrImpl.h
deleted file mode 100644
index 9c07cf52a9..0000000000
--- a/Tools/CCode/Source/Pccts/h/ATokPtrImpl.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * ATokPtrImpl.h (formerly ATokPtr.cpp)
- *
- * This is #included in ATokBuffer.cpp for historical reasons.
- * It has been renamed because of problems with the .cpp extension
- * when used with IDE.
- *
- *
- * 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/AToken.h b/Tools/CCode/Source/Pccts/h/AToken.h
deleted file mode 100644
index 6167c21ef5..0000000000
--- a/Tools/CCode/Source/Pccts/h/AToken.h
+++ /dev/null
@@ -1,325 +0,0 @@
-/* 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-2000
- */
-
-#ifndef ATOKEN_H_GATE
-#define ATOKEN_H_GATE
-
-#include "pcctscfg.h"
-
-#include "pccts_string.h"
-#include "pccts_stdio.h"
-#include "pccts_stdlib.h"
-#include "pccts_stdarg.h" // MR23
-
-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
- {
- /* MR23 */ printMessage(stderr, "ANTLRAbstractToken panic: %s\n", msg);
- exit(PCCTS_EXIT_FAILURE);
- }
-
- virtual int printMessage(FILE* pFile, const char* pFormat, ...) // MR23
- {
- va_list marker;
- va_start( marker, pFormat );
- int iRet = vfprintf(pFile, pFormat, marker);
- va_end( marker );
- return iRet;
- }
-};
-
-/* 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:
-
- // MR23 - No matter what you do, you're hammered.
- // Don't give names to formals something breaks.
- // Give names to formals and don't use them it breaks.
-
-#ifndef DBG_REFCOUNTTOKEN
- ANTLRRefCountToken(ANTLRTokenType /* t MR23 */, const ANTLRChar * /* s MR23 */)
-#else
- ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar * s)
-#endif
-
-#ifndef DBG_REFCOUNTTOKEN
- {
- refcnt_ = 0;
- }
-#else
- {
- ctor++;
- refcnt_ = 0;
- if ( t==1 ) sprintf(object,"tok_EOF");
- else sprintf(object,"tok_%s",s);
- /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);
- }
-#endif
- ANTLRRefCountToken()
-#ifndef DBG_REFCOUNTTOKEN
- { refcnt_ = 0; }
-#else
- {
- ctor++;
- refcnt_ = 0;
- sprintf(object,"tok_blank");
- /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);
- }
- virtual ~ANTLRRefCountToken()
- {
- dtor++;
- if ( dtor>ctor ) /* MR23 */ printMessage(stderr, "WARNING: dtor>ctor\n");
- /* MR23 */ printMessage(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 MR23*/,
- ANTLRChar * /*txt MR23*/,
- int /*line MR23*/)
- {
- 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/Tools/CCode/Source/Pccts/h/ATokenBuffer.cpp b/Tools/CCode/Source/Pccts/h/ATokenBuffer.cpp
deleted file mode 100644
index 9a2f2fc88b..0000000000
--- a/Tools/CCode/Source/Pccts/h/ATokenBuffer.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/* ANTLRTokenBuffer.cpp
- *
- * 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-2000
- */
-
-typedef int ANTLRTokenType; // fool AToken.h into compiling
-
-class ANTLRParser; /* MR1 */
-
-#define ANTLR_SUPPORT_CODE
-
-#include "pcctscfg.h"
-
-#include ATOKENBUFFER_H
-#include APARSER_H // MR23
-
-typedef ANTLRAbstractToken *_ANTLRTokenPtr;
-
-#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)
-static unsigned char test[1000];
-#endif
-
-#ifdef DBG_REFCOUNTTOKEN
-int ANTLRRefCountToken::ctor = 0; /* MR23 */
-int ANTLRRefCountToken::dtor = 0; /* MR23 */
-#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];
- threshold = &buffer[(int)(buffer_size/2)]; // MR23 - Used to be 1.0/2.0 !
- _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
- /* MR23 */ printMessage(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
-/* MR23 */ printMessage(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);
-#endif
- makeRoom();
- }
- }
- else {
- if ( next > end_of_buffer )
- {
-#ifdef DBG_TBUF
-/* MR23 */ printMessage(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)
- /* MR23 */ printMessage(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]++;
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(stderr, "in makeRoom.................\n");
- /* MR23 */ printMessage(stderr, "num_markers==%d\n", num_markers);
-#endif
-/*
- if ( num_markers == 0 )
- {
-*/
-#ifdef DBG_TBUF
- /* MR23 */ printMessage(stderr, "moving lookahead and resetting next\n");
-
- _ANTLRTokenPtr *r;
- /* MR23 */ printMessage(stderr, "tbuf = [");
- for (r=buffer; r<=last; r++)
- {
- if ( *r==NULL ) /* MR23 */ printMessage(stderr, " xxx");
- else /* MR23 */ printMessage(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());
- }
- /* MR23 */ printMessage(stderr, " ]\n");
-
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(stderr, "lookahead buffer = [");
-#endif
- for (int i=1; i<=(k-1); i++)
- {
- *p++ = *q++;
-#ifdef DBG_TBUF
- /* MR23 */ printMessage(stderr,
- " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());
-#endif
- }
-#ifdef DBG_TBUF
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(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
- /* MR23 */ printMessage(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];
- threshold = &buffer[(int)(buffer_size*(1.0/2.0))];
-
-/*
- // 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
-
-void ANTLRTokenBuffer::panic(const char *msg) // MR23
-{
- if (parser) //MR23
- parser->panic(msg); //MR23
- else //MR23
- exit(PCCTS_EXIT_FAILURE);
-}
-
-//MR23
-int ANTLRTokenBuffer::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
-
- int iRet = 0;
- if (parser)
- parser->printMessageV(pFile, pFormat, marker);
- else
- iRet = vfprintf(pFile, pFormat, marker);
-
- va_end( marker );
- return iRet;
-}
-
-/* to avoid having to link in another file just for the smart token ptr
- * stuff, we include it here. Ugh.
- *
- * MR23 This causes nothing but problems for IDEs.
- * Change from .cpp to .h
- *
- */
-
-#include ATOKPTR_IMPL_H
diff --git a/Tools/CCode/Source/Pccts/h/ATokenBuffer.h b/Tools/CCode/Source/Pccts/h/ATokenBuffer.h
deleted file mode 100644
index 1c008fd59e..0000000000
--- a/Tools/CCode/Source/Pccts/h/ATokenBuffer.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* 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-2000
- */
-
-#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); /* MR20 const */
-
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
-
-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/Tools/CCode/Source/Pccts/h/ATokenStream.h b/Tools/CCode/Source/Pccts/h/ATokenStream.h
deleted file mode 100644
index 3dfea6ebff..0000000000
--- a/Tools/CCode/Source/Pccts/h/ATokenStream.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 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-2000
- */
-
-#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 MR23*/) {return 0; }; // MR12
- virtual ANTLRParser * getParser() { return 0; }; // MR12
-};
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/BufFileInput.cpp b/Tools/CCode/Source/Pccts/h/BufFileInput.cpp
deleted file mode 100644
index 99d08a42a4..0000000000
--- a/Tools/CCode/Source/Pccts/h/BufFileInput.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-// 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/Tools/CCode/Source/Pccts/h/BufFileInput.h b/Tools/CCode/Source/Pccts/h/BufFileInput.h
deleted file mode 100644
index ea54c0ee26..0000000000
--- a/Tools/CCode/Source/Pccts/h/BufFileInput.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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/Tools/CCode/Source/Pccts/h/DLG_stream_input.h b/Tools/CCode/Source/Pccts/h/DLG_stream_input.h
deleted file mode 100644
index d2147f5217..0000000000
--- a/Tools/CCode/Source/Pccts/h/DLG_stream_input.h
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/************************************************************/
-/* */
-/* 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/Tools/CCode/Source/Pccts/h/DLexer.h b/Tools/CCode/Source/Pccts/h/DLexer.h
deleted file mode 100644
index 37cac24f14..0000000000
--- a/Tools/CCode/Source/Pccts/h/DLexer.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* DLexer.h (formerly DLexer.cpp)
- *
- * This was renamed because the use of the .cpp extension caused problems
- * with IDEs.
- *
- * 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-2000
- */
-
-#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 */ /* MR23 */ printMessage(stdout, "\ntoken name=%s",parser->parserTokenName(tk));
-/* MR1 */ } else {
-/* MR1 */ /* MR23 */ printMessage(stdout, "\ntoken nnumber=%d",tk);
-/* MR1 */ };
-/* MR1 */ /* MR23 */ printMessage(stdout, " lextext=(%s) mode=%d",
-/* MR1 */ (_lextext[0]=='\n' && _lextext[1]==0) ?
-/* MR1 */ "newline" : _lextext,
-/* MR1 */ automaton);
-/* MR1 */ if (interactive && !charfull) {
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=empty");
-/* MR1 */ } else {
-/* MR1 */ if (ch=='\n') {
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=newline");
-/* MR1 */ } else {
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=(%c)",ch);
-/* MR1 */ };
-/* MR1 */ };
-/* MR1 */ /* MR23 */ printMessage(stdout, " %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/Tools/CCode/Source/Pccts/h/DLexerBase.cpp b/Tools/CCode/Source/Pccts/h/DLexerBase.cpp
deleted file mode 100644
index b218afc038..0000000000
--- a/Tools/CCode/Source/Pccts/h/DLexerBase.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/* 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-2000
- */
-
-#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
-#include APARSER_H // MR23
-
-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;
- if (c != '\0') {
- nextpos = _begexpr + 1;
- }
- else {
- nextpos = _begexpr; /* MR30 Zero terminates string. */
- }
-}
-
-/* replace the string s for the reg. expr last matched and in the buffer */
-
-#ifdef _MSC_VER // MR23
-//Turn off "assignment within conditional expression" warning
-#pragma warning(disable : 4706)
-#endif
-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;
-}
-#ifdef _MSC_VER // MR23
-#pragma warning(default: 4706)
-#endif
-
-void DLGLexerBase::
-errstd(const char *s) /* MR20 const */
-{
- lexErrCount++; /* MR11 */
- /* MR23 */ printMessage(stderr,
- "%s near line %d (text was '%s')\n",
- ((s == NULL) ? "Lexical error" : s),
- _line,_lextext);
-}
-
-int DLGLexerBase::
-err_in()
-{
- /* MR23 */ printMessage(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 */
-{
- if (parser) //MR23
- parser->panic(msg); //MR23
- else //MR23
- {
- /* MR23 */ printMessage(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
-
-//MR23
-int DLGLexerBase::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
-
- int iRet = 0;
- if (parser)
- parser->printMessageV(pFile, pFormat, marker);
- else
- iRet = vfprintf(pFile, pFormat, marker);
-
- va_end( marker );
- return iRet;
-}
diff --git a/Tools/CCode/Source/Pccts/h/DLexerBase.h b/Tools/CCode/Source/Pccts/h/DLexerBase.h
deleted file mode 100644
index db6cc1890c..0000000000
--- a/Tools/CCode/Source/Pccts/h/DLexerBase.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/* 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-2000
- */
-
-#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
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
-};
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/PBlackBox.h b/Tools/CCode/Source/Pccts/h/PBlackBox.h
deleted file mode 100644
index d25b8d6939..0000000000
--- a/Tools/CCode/Source/Pccts/h/PBlackBox.h
+++ /dev/null
@@ -1,134 +0,0 @@
-#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-2000
- */
-
-/* Completely rewritten by Chris Uzdavinis (chris@atdesk.com) for MR23 */
-
-#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 {
-private:
- // no copy construction allowed
- ParserBlackBox(ParserBlackBox const &);
-
- // no copy assignment allowed
- ParserBlackBox & operator=(ParserBlackBox const &);
-
-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)
- : in(0)
- , scan(0)
- , tok(0)
- , pipe(0)
- , _parser(0)
- , file(0)
- , openByBlackBox(0)
- {
- if (f == NULL)
- {
- cerr << "invalid file pointer\n";
- }
- else
- {
- 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)
- : in(0)
- , scan(0)
- , tok(0)
- , pipe(0)
- , _parser(0)
- , file(0)
- , openByBlackBox(0)
- {
- 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/Tools/CCode/Source/Pccts/h/PCCTSAST.cpp b/Tools/CCode/Source/Pccts/h/PCCTSAST.cpp
deleted file mode 100644
index a8249cdac0..0000000000
--- a/Tools/CCode/Source/Pccts/h/PCCTSAST.cpp
+++ /dev/null
@@ -1,684 +0,0 @@
-/*
- * 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-2000
- */
-
-#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 ) /* MR23 */ printMessage(f," (");
- lisp_action(f);
- if ( down()!=NULL ) down()->lisp(f);
- if ( down() != NULL ) /* MR23 */ printMessage(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=NULL /*MR23*/, *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]; /* MR23 Remove "static" */
- /*** static ***/ int tsp = MaxTreeStackDepth; /* MR23 Remove "static" */
-
-////static int nesting = 0; /* MR23 Not referenced */
-
- 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 ) return 0; /* MR23 removed unreachable code */
-
- 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;
-}
-
-#ifdef _MSC_VER // MR23
-//Turn off "unreachable code" warning
-#pragma warning(disable : 4702)
-#endif
-/* 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;
-}
-#ifdef _MSC_VER // MR23
-#pragma warning(default : 4702)
-#endif
-
-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 )
- panic("out of memory\n"); // MR23
- 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=NULL /*MR23*/;
-
- 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)
-{
- 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];
- char ebuf[100]; /* MR23 Remove static */
-
- while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
- if ( isdigit(scanner->c) )
- {
- int tok = __INT;
- while ( isdigit(scanner->c) ) {
- *index++ = (char) /* static_cast<char> */ (scanner->c); // MR23
- 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>";
-}
-
-//MR23
-int PCCTS_AST::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
- int iRet = vfprintf(pFile, pFormat, marker);
- va_end( marker );
- return iRet;
-}
diff --git a/Tools/CCode/Source/Pccts/h/PCCTSAST.h b/Tools/CCode/Source/Pccts/h/PCCTSAST.h
deleted file mode 100644
index 3485da7d1b..0000000000
--- a/Tools/CCode/Source/Pccts/h/PCCTSAST.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* 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-2000
- */
-
-#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 MR23 */) {;}
- 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 MR23 */) {;}
- 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
- { /* MR23 */ printMessage(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
-};
-
-#endif /* PCCTSAST_H */
diff --git a/Tools/CCode/Source/Pccts/h/SList.h b/Tools/CCode/Source/Pccts/h/SList.h
deleted file mode 100644
index 5b8bf97427..0000000000
--- a/Tools/CCode/Source/Pccts/h/SList.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#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-2000
- */
-
-#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){ /* MR23 */ printMessage(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
- virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23
-};
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/antlr.h b/Tools/CCode/Source/Pccts/h/antlr.h
deleted file mode 100644
index 80664535d3..0000000000
--- a/Tools/CCode/Source/Pccts/h/antlr.h
+++ /dev/null
@@ -1,807 +0,0 @@
-/* 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-2000
- */
-
-#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,_hasuseraction,_useraction) \
- if (zzguessing) { \
- zzGUESS_FAIL; \
- } else { \
- zzfailed_pred_action(_p,_hasuseraction,_useraction); \
- }
-#else
-#define zzfailed_pred(_p,_hasuseraction,_useraction) \
- zzfailed_pred_action(_p,_hasuseraction,_useraction);
-#endif
-#endif
-
-/* MR23 Provide more control over failed predicate action
- without any need for user to worry about guessing internals.
- _hasuseraction == 0 => no user specified error action
- _hasuseraction == 1 => user specified error action
-*/
-
-#ifndef zzfailed_pred_action
-#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \
- if (_hasuseraction) { _useraction } \
- else { fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); }
-#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,_tokclassErrset) \
- if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail; /* MR23 */
-
-#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 **, SetWordType * /* MR23 */);
-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
-
-
-/* MR26 */
-
-#ifdef PCCTS_USE_STDARG
-extern void zzFAIL(int k, ...);
-#else
-extern void zzFAIL();
-#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 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 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/Tools/CCode/Source/Pccts/h/ast.c b/Tools/CCode/Source/Pccts/h/ast.c
deleted file mode 100644
index 9326ae16ae..0000000000
--- a/Tools/CCode/Source/Pccts/h/ast.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/* 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/ast.h b/Tools/CCode/Source/Pccts/h/ast.h
deleted file mode 100644
index 5ff84bd76c..0000000000
--- a/Tools/CCode/Source/Pccts/h/ast.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* 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-2000
- */
-
-#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[];
-
-/* MR26 */
-
-#ifdef PCCTS_USE_STDARG
-AST *zztmake(AST *, ...);
-#else
-AST *zztmake();
-#endif
-
-#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 *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 *zzdup_ast();
-void zztfree();
-void zzdouble_link();
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/charbuf.h b/Tools/CCode/Source/Pccts/h/charbuf.h
deleted file mode 100644
index 5f01c8ba35..0000000000
--- a/Tools/CCode/Source/Pccts/h/charbuf.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/charptr.c b/Tools/CCode/Source/Pccts/h/charptr.c
deleted file mode 100644
index d3f80e60ba..0000000000
--- a/Tools/CCode/Source/Pccts/h/charptr.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/charptr.h b/Tools/CCode/Source/Pccts/h/charptr.h
deleted file mode 100644
index e73da681a4..0000000000
--- a/Tools/CCode/Source/Pccts/h/charptr.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *
- * 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-2000
- */
-
-/*
- * 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/Tools/CCode/Source/Pccts/h/config.h b/Tools/CCode/Source/Pccts/h/config.h
deleted file mode 100644
index 8aa50ad618..0000000000
--- a/Tools/CCode/Source/Pccts/h/config.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "pcctscfg.h"
diff --git a/Tools/CCode/Source/Pccts/h/dlgauto.h b/Tools/CCode/Source/Pccts/h/dlgauto.h
deleted file mode 100644
index db94cefaca..0000000000
--- a/Tools/CCode/Source/Pccts/h/dlgauto.h
+++ /dev/null
@@ -1,504 +0,0 @@
-/* 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-2000
- */
-
-#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;
- if (c != '\0') {
- zznextpos = zzbegexpr + 1;
- }
- else {
- zznextpos = zzbegexpr; /* MR30 Zero terminates string. */
- }
-}
-
-/* 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 */
- zzchar_t *lastpos; /* MR27 Remove register since address operator used. */
-
-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/Tools/CCode/Source/Pccts/h/dlgdef.h b/Tools/CCode/Source/Pccts/h/dlgdef.h
deleted file mode 100644
index 733d2568e3..0000000000
--- a/Tools/CCode/Source/Pccts/h/dlgdef.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* 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-2000
- */
-
-#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/Tools/CCode/Source/Pccts/h/err.h b/Tools/CCode/Source/Pccts/h/err.h
deleted file mode 100644
index b2b196bd75..0000000000
--- a/Tools/CCode/Source/Pccts/h/err.h
+++ /dev/null
@@ -1,1170 +0,0 @@
-/*
- * 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-2000
- */
-
-#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,
- SetWordType *zzTokclassErrset /* MR23 */)
-#else
-_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet, zzTokclassErrset /* MR23 */)
-SetWordType *e;
-char **zzBadText;
-char **zzMissText;
-int *zzMissTok, *zzBadTok;
-SetWordType **zzMissSet;
-SetWordType *zzTokclassErrset;
-#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=zzTokclassErrset; /* MR23 */
- 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/Tools/CCode/Source/Pccts/h/int.h b/Tools/CCode/Source/Pccts/h/int.h
deleted file mode 100644
index cdcaa92426..0000000000
--- a/Tools/CCode/Source/Pccts/h/int.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* 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-2000
- */
-
-#ifndef ZZINT_H
-#define ZZINT_H
-
-typedef long Attrib;
-
-#define zzcr_attr(a,tok,t) *(a) = atol(t);
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_assert.h b/Tools/CCode/Source/Pccts/h/pccts_assert.h
deleted file mode 100644
index ff0dfb5126..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_assert.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_ASSERT_H__
-#define __PCCTS_ASSERT_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <cassert>
-#else
-#include <assert.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_iostream.h b/Tools/CCode/Source/Pccts/h/pccts_iostream.h
deleted file mode 100644
index 972b32cbd1..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_iostream.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_IOSTREAM_H__
-#define __PCCTS_IOSTREAM_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <iostream>
-#else
-#include <iostream.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_istream.h b/Tools/CCode/Source/Pccts/h/pccts_istream.h
deleted file mode 100644
index e25cb8c483..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_istream.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_ISTREAM_H__
-#define __PCCTS_ISTREAM_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <istream>
-#else
-#include <istream.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_setjmp.h b/Tools/CCode/Source/Pccts/h/pccts_setjmp.h
deleted file mode 100644
index 9ea185ca73..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_setjmp.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_SETJMP_H__
-#define __PCCTS_SETJMP_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <csetjmp>
-#else
-#include <setjmp.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_stdarg.h b/Tools/CCode/Source/Pccts/h/pccts_stdarg.h
deleted file mode 100644
index e957430c32..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_stdarg.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDARG_H__
-#define __PCCTS_STDARG_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <cstdarg>
-#else
-#include <stdarg.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_stdio.h b/Tools/CCode/Source/Pccts/h/pccts_stdio.h
deleted file mode 100644
index ac34d1086d..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_stdio.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDIO_H__
-#define __PCCTS_STDIO_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <cstdio>
-#else
-#include <stdio.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_stdlib.h b/Tools/CCode/Source/Pccts/h/pccts_stdlib.h
deleted file mode 100644
index f0b344e8dc..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_stdlib.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDLIB_H__
-#define __PCCTS_STDLIB_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <cstdlib>
-#else
-#include <stdlib.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pccts_string.h b/Tools/CCode/Source/Pccts/h/pccts_string.h
deleted file mode 100644
index 458a08a94b..0000000000
--- a/Tools/CCode/Source/Pccts/h/pccts_string.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STRING_H__
-#define __PCCTS_STRING_H__
-
-#ifdef PCCTS_USE_NAMESPACE_STD
-#include <cstring>
-#else
-#include <string.h>
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pcctscfg.h b/Tools/CCode/Source/Pccts/h/pcctscfg.h
deleted file mode 100644
index 0c3c5ba6fd..0000000000
--- a/Tools/CCode/Source/Pccts/h/pcctscfg.h
+++ /dev/null
@@ -1,359 +0,0 @@
-#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-2000
- */
-
-/* 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_IMPL_H "ATokPtrIm.h"
-#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_H "DLexer.h"
-#define STREESUPPORT_C "STreeSup.C"
-#else
-#define ATOKEN_H "AToken.h"
-#define ATOKPTR_H "ATokPtr.h"
-#define ATOKPTR_IMPL_H "ATokPtrImpl.h"
-#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_H "DLexer.h"
-#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
-
-#ifdef _MSC_VER
-/*Turn off the warnings for:
- unreferenced inline/local function has been removed
-*/
-#pragma warning(disable : 4514)
-/* function not expanded */
-#pragma warning(disable : 4710)
-#endif
-
-#endif
diff --git a/Tools/CCode/Source/Pccts/h/pcnames.bat b/Tools/CCode/Source/Pccts/h/pcnames.bat
deleted file mode 100644
index 8784aee9ab..0000000000
--- a/Tools/CCode/Source/Pccts/h/pcnames.bat
+++ /dev/null
@@ -1,11 +0,0 @@
-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/Tools/CCode/Source/Pccts/h/slist.cpp b/Tools/CCode/Source/Pccts/h/slist.cpp
deleted file mode 100644
index faf2fe4967..0000000000
--- a/Tools/CCode/Source/Pccts/h/slist.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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-2000
- */
-
-#define ANTLR_SUPPORT_CODE
-
-#include "SList.h"
-#include "pccts_stdarg.h" // MR23
-
-/* 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;
-}
-
-// MR23
-int SList::printMessage(FILE* pFile, const char* pFormat, ...)
-{
- va_list marker;
- va_start( marker, pFormat );
- int iRet = vfprintf(pFile, pFormat, marker);
- va_end( marker );
- return iRet;
-}