--- /dev/null
+/* 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-1995
+ */
+
+#ifndef APARSER_H_GATE
+#define APARSER_H_GATE
+
+#include <stdio.h>
+#include <setjmp.h>
+#include "config.h"
+#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 */
+
+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;
+#define zzNON_GUESS_MODE if ( !guessing )
+#define zzGUESS_FAIL guess_fail();
+#define zzGUESS_DONE {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);}
+#define zzGUESS saveState(&zzst); \
+ guessing = 1; \
+ _marker = inputTokens->mark(); \
+ zzrv = setjmp(guess_start.state); \
+ if ( zzrv ) zzGUESS_DONE
+
+ /* 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;
+};
+
+/* 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;
+
+ ANTLRChar **token_tbl; // pointer to table of token type strings
+
+ 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;
+
+private:
+ void fill_inf_look();
+
+protected:
+ void guess_fail() { longjmp(guess_start.state, 1); }
+ void guess_done(ANTLRParserState *st){ restoreState(st); }
+ int guess(ANTLRParserState *);
+ void look(int);
+ int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,
+ _ANTLRTokenPtr *, SetWordType **);
+ int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,
+ _ANTLRTokenPtr *, SetWordType **);
+ int _match_wsig(ANTLRTokenType);
+ int _setmatch_wsig(SetWordType *);
+ virtual void consume();
+ void resynch(SetWordType *wd,SetWordType mask);
+ void prime_lookahead();
+ virtual void tracein(char *r)
+ {
+ fprintf(stderr, "enter rule \"%s\"\n", r);
+ }
+ virtual void traceout(char *r)
+ {
+ fprintf(stderr, "exit rule \"%s\"\n", r);
+ }
+ unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);} // x % EXT_WORDSIZE
+ unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;} // x / EXT_WORDSIZE
+ int set_deg(SetWordType *);
+ int set_el(ANTLRTokenType, SetWordType *);
+ void edecode(SetWordType *);
+ void FAIL(int k, ...);
+
+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)
+ {
+ return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :
+ token_type[(lap+(i)-1)&(LLk-1)];
+ }
+ _ANTLRTokenPtr LT(int i);
+
+ void setEofToken(ANTLRTokenType t) { eofToken = t; }
+
+ void noGarbageCollectTokens() { inputTokens->noGarbageCollectTokens(); }
+ void garbageCollectTokens() { inputTokens->garbageCollectTokens(); }
+
+ virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,
+ SetWordType *eset, ANTLRTokenType etok, int k);
+ void saveState(ANTLRParserState *);
+ void restoreState(ANTLRParserState *);
+
+ virtual void panic(char *msg);
+ static char *eMsgd(char *,int);
+ static char *eMsg(char *,char *);
+ static char *eMsg2(char *,char *,char *);
+
+ void consumeUntil(SetWordType *st);
+ void consumeUntilToken(int t);
+
+ virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,
+ ANTLRTokenType tokenTypeOfSet,
+ SetWordType *whatFollows);
+ virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,
+ SetWordType *whatFollows);
+};
+
+
+#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 ) goto fail; else {_signal=MismatchedToken; goto handler;}
+
+#define zzsetmatch(_ts) \
+ if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \
+ (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;
+
+#define zzsetmatch_wsig(_ts, handler) \
+ if ( !_setmatch_wsig(_ts) ) if ( guessing ) goto 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;
+
+
+#ifndef zzfailed_pred
+#define zzfailed_pred(_p) \
+ zzNON_GUESS_MODE { fprintf(stderr, "line %d: semantic error; failed predicate: '%s'\n",LT(1)->getLine(), _p); }
+#endif
+
+#define zzRULE \
+ SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0; \
+ _ANTLRTokenPtr zzBadTok; ANTLRChar *zzBadText=(ANTLRChar *)""; \
+ int zzErrk=1; \
+ 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
--- /dev/null
+/* 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-1995
+ */
+#include <stdio.h>
+#include <stdarg.h>
+
+#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 */
+void
+ASTBase::preorder()
+{
+ ASTBase *tree = this;
+
+ while ( tree!= NULL )
+ {
+ if ( tree->_down != NULL ) preorder_before_action();
+ tree->preorder_action();
+ if ( tree->_down!=NULL )
+ {
+ tree->_down->preorder();
+ preorder_after_action();
+ }
+ tree = tree->_right;
+ }
+}
+
+/* free all AST nodes in tree; apply func to each before freeing */
+void
+ASTBase::destroy()
+{
+ ASTBase* tree = this;
+ while (tree) {
+ if (tree->_down) tree->_down->destroy();
+
+ ASTBase* cur = tree;
+ tree = tree->_right;
+ delete cur;
+ }
+}
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually siblins lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ */
+ASTBase *
+ASTBase::tmake(ASTBase *root, ...)
+{
+ va_list ap;
+ register ASTBase *child, *sibling=NULL, *tail, *w;
+
+ va_start(ap, root);
+
+ if ( root != NULL )
+ if ( root->_down != NULL ) 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;
+}
+
+/* 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;
+}
+
+/* tree duplicate */
+ASTBase *
+ASTDoublyLinkedBase::dup()
+{
+ ASTDoublyLinkedBase *u, *t=this;
+
+ if ( t == NULL ) return NULL;
+/*
+ u = new ASTDoublyLinkedBase;
+ *u = *t;
+*/
+ u = (ASTDoublyLinkedBase *)this->shallowCopy();
+ u->_up = NULL; /* set by calling invocation */
+ u->_left = NULL;
+ u->_right = t->_right->dup();
+ u->_down = t->_down->dup();
+ if ( u->_right!=NULL ) ((ASTDoublyLinkedBase *)u->_right)->_left = u;
+ if ( u->_down!=NULL ) ((ASTDoublyLinkedBase *)u->_down)->_up = u;
+ return u;
+}
+
+/*
+ * 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);
+}
+
--- /dev/null
+/* 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-1995
+ */
+
+#ifndef ASTBase_H
+#define ASTBase_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "PCCTSAST.h"
+
+/*
+ * 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.
+ */
+
+class ASTBase : public PCCTS_AST {
+protected:
+ ASTBase *_right, *_down;
+
+public:
+ 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; }
+
+ ASTBase() { _right = _down = NULL; }
+ virtual ~ASTBase() { ; }
+ virtual ASTBase *dup();
+ void destroy();
+ void preorder();
+ static ASTBase *tmake(ASTBase *, ...);
+ static void link(ASTBase **, ASTBase **, ASTBase **);
+ void subchild(ASTBase **, ASTBase **, ASTBase **);
+ void subroot(ASTBase **, ASTBase **, ASTBase **);
+ virtual void preorder_action() { ; }
+ virtual void preorder_before_action() { printf(" ("); }
+ virtual void preorder_after_action() { printf(" )"); }
+};
+
+class ASTDoublyLinkedBase : public ASTBase {
+protected:
+ ASTDoublyLinkedBase *_left, *_up;
+
+public:
+ void double_link(ASTBase *left, ASTBase *up);
+ virtual ASTBase *dup();
+ PCCTS_AST *left() { return _left; }
+ PCCTS_AST *up() { return _up; }
+};
+
+class AST; // announce that this class will be coming along shortly
+#endif
--- /dev/null
+/* 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-1995
+ */
+
+#ifndef PCCTSAST_H
+#define PCCTSAST_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+//class SList;
+
+#define StringScanMaxText 50
+#define MaxTreeStackDepth 400
+
+typedef struct stringlexer {
+ signed int c;
+ 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 PCCTS_AST {
+protected:
+ static char *scan_token_tbl[];
+ enum {
+ __LPAREN=1,
+ __RPAREN=2,
+ __PERCENT=3,
+ __INT=4,
+ __COLON=5,
+ __POUND=6,
+ __PERIOD=7,
+ __StringScanEOF=-1};
+
+protected:
+ char *scan_token_str(int t);
+ void stringlexer_init(StringLexer *scanner, char *input);
+ void stringparser_init(StringParser *, StringLexer *);
+ ScanAST *stringparser_parse_scanast(char *templ, int *n);
+ ScanAST *stringparser_parse_tree(StringParser *parser);
+ ScanAST *stringparser_parse_element(StringParser *parser);
+ void stringscan_advance(StringLexer *scanner);
+ int stringscan_gettok(StringLexer *scanner);
+ void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);
+ PCCTS_AST *_pop(PCCTS_AST **st, int *sp);
+ int match_partial(PCCTS_AST *t, PCCTS_AST *u);
+ int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);
+ void scanast_free(ScanAST *t);
+ ScanAST *new_scanast(int tok);
+ void stringparser_match(StringParser *parser, int type);
+ virtual PCCTS_AST *deepCopyBushy();
+
+public:
+ PCCTS_AST() {;}
+ virtual ~PCCTS_AST() {;}
+
+ /* This group must be defined for SORCERER to work correctly */
+ virtual PCCTS_AST *right() = 0;
+ virtual PCCTS_AST *down() = 0;
+ virtual void setRight(PCCTS_AST *t) = 0;
+ virtual void setDown(PCCTS_AST *t) = 0;
+// we define these so ANTLR doesn't have to
+ virtual int type() { return 0; }
+ virtual void setType(int t) {;}
+ virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}
+
+ /* These are not needed by ANTLR, but are support functions */
+ virtual PCCTS_AST *deepCopy(); // used by SORCERER in transform mode
+ virtual void addChild(PCCTS_AST *t);
+ virtual void lisp_action(FILE *f) {;}
+ virtual void lisp(FILE *f);
+ static PCCTS_AST *make(PCCTS_AST *rt, ...);
+ virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);
+ virtual int match(PCCTS_AST *u);
+ virtual void insert_after(PCCTS_AST *b);
+ virtual void append(PCCTS_AST *b);
+ virtual PCCTS_AST *tail();
+ virtual PCCTS_AST *bottom();
+ static PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);
+// virtual SList *to_slist();
+ virtual void tfree();
+ int ast_scan(char *templ, ...);
+ virtual int nsiblings();
+ virtual PCCTS_AST *sibling_index(int i);
+
+ void require(int e,char *err){ if ( !e ) panic(err); }
+ virtual void panic(char *err)
+ { fprintf(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
+};
+
+#endif /* PCCTSAST_H */
--- /dev/null
+/*
+ * 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-1995
+ */
+
+#define ANTLR_SUPPORT_CODE
+
+#include "SList.h"
+
+/* Iterate over a list of elements; returns ptr to a new element
+ * in list upon every call and NULL when no more are left.
+ * Very useful like this:
+ *
+ * cursor = mylist;
+ * while ( (p=mylist->iterate(&cursor)) ) {
+ * // place with element p
+ * }
+ *
+ * The cursor must be initialized to point to the list to iterate over.
+ */
+void *SList::
+iterate(SListNode **cursor)
+{
+ void *e;
+
+ if ( cursor == NULL || *cursor==NULL ) return NULL;
+ if ( head == *cursor ) { *cursor = (*cursor)->next(); }
+ e = (*cursor)->elem();
+ (*cursor) = (*cursor)->next();
+ return e;
+}
+
+/* add an element to end of list. */
+void SList::
+add(void *e)
+{
+ SListNode *p, *tail;
+ 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;
+}
--- /dev/null
+#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-1995
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "PCCTSAST.h"
+
+class PCCTS_AST;
+
+class SListNode {
+protected:
+ void *_elem; /* pointer to any kind of element */
+ SListNode *_next;
+public:
+ SListNode() {_elem=_next=NULL;}
+ virtual ~SListNode() {_elem=_next=NULL;}
+ void *elem() { return _elem; }
+ void setElem(void *e) { _elem = e; }
+ void setNext(SListNode *t) { _next = t; }
+ SListNode *next() { return _next; }
+};
+
+class SList {
+ SListNode *head, *tail;
+public:
+ SList() {head=tail=NULL;}
+ virtual ~SList() {head=tail=NULL;}
+ virtual void *iterate(SListNode **);
+ virtual void add(void *e);
+ virtual void lfree();
+ virtual PCCTS_AST *to_ast(SList list);
+ virtual void require(int e,char *err){ if ( !e ) panic(err); }
+ virtual void panic(char *err){ fprintf(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }
+};
+
+#endif
--- /dev/null
+/* 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-1995
+ */
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+/* ensure that tree manipulation variables are current after a rule
+ * reference
+ */
+void
+#ifdef __STDC__
+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 __STDC__
+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 __STDC__
+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 __STDC__
+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 __STDC__
+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 */
+void
+#ifdef __STDC__
+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 );
+}
+
+/* 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 __STDC__
+AST *zztmake(AST *rt, ...)
+#else
+AST *zztmake(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ register AST *child, *sibling=NULL, *tail, *w;
+ AST *root;
+
+#ifdef __STDC__
+ 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 __STDC__
+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 __STDC__
+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 __STDC__
+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
--- /dev/null
+/* 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-1995
+ */
+
+#ifndef ZZCHARBUF_H
+#define ZZCHARBUF_H
+
+#include <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
--- /dev/null
+/*
+ * 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-1995
+ */
+#ifdef __STDC__
+#include <stdlib.h>
+#else
+#include <malloc.h>
+#endif
+#include <string.h>
+
+#ifdef __STDC__
+zzcr_attr(Attrib *a,int token,char *text)
+#else
+zzcr_attr(a,token,text)
+Attrib *a;
+int token;
+char *text;
+#endif
+{
+ *a = malloc(strlen(text)+1);
+ if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}
+ strcpy(*a, text);
+}
--- /dev/null
+#ifndef CONFIG_H
+#define CONFIG_H
+/*
+ * 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-1995
+ */
+
+/* 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)
+ */
+
+/* should test __STDC__ for 1, but some compilers don't set value, just def */
+#ifdef __STDC__
+#define __USE_PROTOS
+#endif
+#ifdef __cplusplus
+#ifndef __USE_PROTOS
+#define __USE_PROTOS
+#endif
+#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(__WATCOM__) || defined(_WIN32) || defined(__WIN32__) || \
+ defined(__GNUC__) || defined(__GNUG__))
+# ifndef PC32
+# define PC32
+# endif
+# endif
+#endif
+
+#ifdef PC
+#define ATOKEN_H "AToken.h"
+#define ATOKPTR_H "ATokPtr.h"
+#define ATOKPTR_C "ATokPtr.cpp"
+#define ATOKENBUFFER_H "ATokBuf.h"
+#define ATOKENBUFFER_C "ATokBuf.cpp"
+#define ATOKENSTREAM_H "ATokStr.h"
+#define APARSER_H "AParser.h"
+#define APARSER_C "AParser.cpp"
+#define ASTBASE_H "ASTBase.h"
+#define ASTBASE_C "ASTBase.cpp"
+#define PCCTSAST_C "PCCTSAST.cpp"
+#define LIST_C "List.cpp"
+#define DLEXERBASE_H "DLexBase.h"
+#define DLEXERBASE_C "DLexBase.cpp"
+#define DLEXER_C "DLexer.cpp"
+#define STREESUPPORT_C "STreeSup.C"
+#else
+#define ATOKEN_H "AToken.h"
+#define ATOKPTR_H "ATokPtr.h"
+#define ATOKPTR_C "ATokPtr.cpp"
+#define ATOKENBUFFER_H "ATokenBuffer.h"
+#define ATOKENBUFFER_C "ATokenBuffer.cpp"
+#define ATOKENSTREAM_H "ATokenStream.h"
+#define APARSER_H "AParser.h"
+#define APARSER_C "AParser.cpp"
+#define ASTBASE_H "ASTBase.h"
+#define ASTBASE_C "ASTBase.cpp"
+#define PCCTSAST_C "PCCTSAST.cpp"
+#define LIST_C "List.cpp"
+#define DLEXERBASE_H "DLexerBase.h"
+#define DLEXERBASE_C "DLexerBase.cpp"
+#define DLEXER_C "DLexer.cpp"
+#define STREESUPPORT_C "STreeSupport.cpp"
+#endif
+
+/* SORCERER Stuff */
+#ifdef PC
+#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
+#define CPP_FILE_SUFFIX ".cpp"
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"
+#define OBJ_FILE_SUFFIX ".o"
+#endif
+#endif
+
+/* User may redefine how line information looks */
+#define LineInfoFormatStr "# %d \"%s\"\n"
+
+#ifdef MPW /* Macintosh Programmer's Workshop */
+#define ErrHdr "File \"%s\"; Line %d #"
+#else
+#define ErrHdr "%s, line %d:"
+#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
+#define TopDirectory "."
+#define DirectorySymbol "/"
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"
+#endif
+#endif
+
+#ifdef MPW
+
+/* Make sure we have prototypes for all functions under MPW */
+
+#include <string.h>
+#include <stdlib.h>
+#include <CursorCtl.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void fsetfileinfo (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 'MMCC' /* Metrowerks C/C++ Text files */
+#endif
+
+#endif
+
+#ifdef MPW
+#define DAWDLE SpinCursor(1)
+#else
+#define DAWDLE
+#endif
+
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+#ifdef MPW
+void special_inits()
+{
+ InitCursorCtl((acurHandle) 0);
+}
+#else
+void special_inits()
+{
+}
+#endif
+
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+#ifdef MPW
+void special_fopen_actions(char * /* s */)
+{
+ fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');
+}
+#else
+void
+#ifdef __USE_PROTOS
+special_fopen_actions(char *s)
+#else
+special_fopen_actions(s)
+char *s;
+#endif
+{
+}
+#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
+
+#ifdef VAXC
+#define PCCTS_EXIT_SUCCESS 1
+#define PCCTS_EXIT_FAILURE 0
+#define zzDIE return 0;
+#define zzDONE return 1;
+
+#else /* !VAXC */
+
+#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
+
+#endif
--- /dev/null
+/* 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-1995
+ */
+
+#ifndef ZZDLGDEF_H
+#define ZZDLGDEF_H
+
+#include "config.h"
+
+#ifndef zzchar_t
+#ifdef ZZWCHAR_T
+#define zzchar_t wchar_t
+#else
+#define zzchar_t char
+#endif
+#endif
+
+struct zzdlg_state {
+ FILE *stream;
+ int (*func_ptr)();
+ 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 (*)());/* 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();
+
+#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
--- /dev/null
+/* 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-1995
+ */
+
+#ifndef ZZINT_H
+#define ZZINT_H
+
+typedef long Attrib;
+
+#define zzcr_attr(a,tok,t) *(a) = atol(t);
+
+#endif
--- /dev/null
+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