summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
commit3eb9473ea9a949badfe06ae61d2d3fcfa53651c7 (patch)
treee9d8c368dbb1e58794b2c00acefe4bbad270f8c4 /EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer
parent30d4a0c7ec19938196b1308006b990e0945150da (diff)
downloadedk2-platforms-3eb9473ea9a949badfe06ae61d2d3fcfa53651c7.tar.xz
Add in the 1st version of ECP.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer')
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h8
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h26
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h110
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h72
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h61
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h172
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h52
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h46
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h45
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp151
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c834
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c100
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile21
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp130
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c140
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c169
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c123
-rw-r--r--EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c78
18 files changed, 2338 insertions, 0 deletions
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h
new file mode 100644
index 0000000000..1004147101
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h
@@ -0,0 +1,8 @@
+#ifndef SASTBase_h
+#define SASTBase_h
+
+#include "PCCTSAST.h"
+
+typedef PCCTS_AST SORASTBase;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h
new file mode 100644
index 0000000000..79f90180cc
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h
@@ -0,0 +1,26 @@
+#ifndef SCommonAST_h
+#define SCommonAST_h
+
+#include <stdio.h>
+#include "PCCTSAST.h"
+#include "SASTBase.h"
+
+/* If you use SORCERER alone, you can subclass this to get a nice tree def */
+
+class SORCommonAST : public SORASTBase {
+protected:
+ SORCommonAST *_right, *_down;
+ int _type;
+
+public:
+ SORCommonAST() { _right = _down = NULL; }
+ PCCTS_AST *right() { return _right; } // define the SORCERER interface
+ PCCTS_AST *down() { return _down; }
+ int type() { return _type; }
+ void setRight(PCCTS_AST *t) { _right = (SORCommonAST *)t; }
+ void setDown(PCCTS_AST *t) { _down = (SORCommonAST *)t; }
+ void setType(int t) { _type = t; }
+ virtual PCCTS_AST *shallowCopy() {return NULL;}
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h
new file mode 100644
index 0000000000..558f6a572b
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h
@@ -0,0 +1,110 @@
+#ifndef STreeParser_h
+#define STreeParser_h
+
+/*
+ * STreeParser.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Parr Research Corporation
+ * with Purdue University and AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+/* The programmer should derive a class from SORASTBase; SORASTBase defines
+ * the minimum public interface that a tree node must follow for SORCERER to
+ * be able to walk the trees.
+ */
+
+/* The @-vars are added by the subclass created by SORCERER; the constructor
+ * is used to init the @-vars.
+ */
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include "SASTBase.h"
+
+#define _DOWN _t=(SORASTBase *)_t->down()
+#define _RIGHT _t=(SORASTBase *)_t->right()
+
+#define _SAVE SORASTBase *_save=_t
+#define _RESTORE _t = _save
+#define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL;
+#define _GUESS {save_state(&_st); \
+ _savet = _t; \
+ guessing = 1; \
+ _gv = setjmp(startofguess.state);}
+#define _GUESS_FAIL longjmp(startofguess.state, 1)
+#define _GUESS_DONE {restore_state(&_st); _t = _savet;}
+#define _MATCH(tok) MATCH(_t,tok)
+#define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2)
+#define _WILDCARD WILDCARD(_t)
+
+#define ast_return(t) *_result = (SORASTBase *)t;
+
+#define STreeTry(r,p,t) \
+ (p)->try_result = NULL; \
+ (p)->sjrv = setjmp((p)->startofguess); \
+ if ( !(p)->sjrv ) { \
+ rule(p,t,&try_result); \
+ (p)->try_ok = 1; \
+ } \
+ else { \
+ (p)->try_ok = 0; \
+ } \
+ if ( (p)->try_ok )
+
+
+/* Used only during TRANSFORM mode */
+#define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL
+
+typedef struct _Sjmp_buf {
+ jmp_buf state;
+ } Sjmp_buf;
+
+class STreeParser {
+protected:
+ int try_ok, sjrv; /* used by STreeTry macro */
+ SORASTBase *try_result; /* tree coming back from try */
+ int guessing;
+ Sjmp_buf startofguess;
+// SORASTBase *t;
+
+ void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
+ void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);
+ virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);
+ virtual void missing_wildcard();
+ virtual void mismatched_token(int looking_for, SORASTBase *found);
+ virtual void no_viable_alt(char *rulename, SORASTBase *root);
+ virtual void MATCH(SORASTBase *_t, int tok);
+ virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);
+ virtual void WILDCARD(SORASTBase *_t);
+
+public:
+ STreeParser() { guessing = 0; }
+ virtual void panic(char *err);
+ void save_state(STreeParser *);
+ void restore_state(STreeParser *);
+};
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h
new file mode 100644
index 0000000000..9c7fd693f2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h
@@ -0,0 +1,72 @@
+#ifndef astlib_h
+#define astlib_h
+
+/*
+ * astlib.h -- C ast_* library header
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <setjmp.h>
+#include "sorcerer.h"
+#include "sorlist.h"
+
+#define MaxTreeStackDepth 400
+
+#ifdef __USE_PROTOS
+extern SORAST *ast_make(SORAST *rt, ...);
+extern SORAST *ast_find_all(SORAST *t, SORAST *u, SORAST **cursor);
+extern int ast_match(SORAST *t, SORAST *u);
+extern void ast_insert_after(SORAST *a, SORAST *b);
+extern void ast_append(SORAST *a, SORAST *b);
+extern SORAST *ast_tail(SORAST *a);
+extern SORAST *ast_bottom(SORAST *a);
+extern SORAST *ast_cut_between(SORAST *a, SORAST *b);
+extern SList *ast_to_slist(SORAST *t);
+extern SORAST *slist_to_ast(SList *list);
+extern void ast_free(SORAST *t);
+extern int ast_scan(char *template, SORAST *tree, ...);
+extern int ast_nsiblings(SORAST *t);
+extern SORAST *ast_sibling_index(SORAST *t, int i);
+extern int ast_match_partial(SORAST *t, SORAST *u);
+#else
+extern SORAST *ast_make();
+extern SORAST *ast_find_all();
+extern int ast_match();
+extern void ast_insert_after();
+extern void ast_append();
+extern SORAST *ast_tail();
+extern SORAST *ast_bottom();
+extern SORAST *ast_cut_between();
+extern SList *ast_to_slist();
+extern SORAST *slist_to_ast();
+extern void ast_free();
+extern int ast_scan();
+extern int ast_nsiblings();
+extern SORAST *ast_sibling_index();
+extern int ast_match_partial();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h
new file mode 100644
index 0000000000..a8e14bb7af
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h
@@ -0,0 +1,61 @@
+#ifndef SINTSTACK_H
+#define SINTSTACK_H
+
+/*
+ * SIntStack.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "sorcerer.h"
+
+typedef struct _istack {
+ int *data;
+ int sp;
+ int size;
+ } SIntStack;
+
+#ifdef __USE_PROTOS
+extern SIntStack *sint_newstack(int size);
+extern void sint_freestack(SIntStack *st);
+extern void sint_push(SIntStack *st, int i);
+extern int sint_pop(SIntStack *st);
+extern int sint_stacksize(SIntStack *st);
+extern void sint_stackreset(SIntStack *st);
+extern int sint_stackempty(SIntStack *st);
+extern int sint_top(SIntStack *st);
+#else
+extern SIntStack *sint_newstack();
+extern void sint_freestack();
+extern void sint_push();
+extern int sint_pop();
+extern int sint_stacksize();
+extern void sint_stackreset();
+extern int sint_stackempty();
+extern int sint_top();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h
new file mode 100644
index 0000000000..29f77029ed
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h
@@ -0,0 +1,172 @@
+#ifndef sorcerer_h
+#define sorcerer_h
+
+/*
+ * sorcerer.h -- header for all sorcerer files
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "pcctscfg.h"
+
+#ifdef __USE_PROTOS
+#include <stdlib.h>
+#else
+#include <malloc.h>
+#endif
+
+#include <setjmp.h>
+
+/* SUPERCLASS SORAST (your tree must look at minimum like this)
+typedef struct _node {
+ struct _node *right, *down;
+ int token;
+ -- user-defined stuff goes here
+ } SORAST;
+*/
+
+/* Can be used sort of like inheritance to get the desired struct def */
+#define AST_REQD_FIELDS \
+ struct _node *right, *down; \
+ int token;
+
+/* C MATCH */ /* MR21 Short circuit on null pointer */
+#define _MATCH(tok) if (! _t || _t->token!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
+#define _MATCHRANGE(tok,tok2) \
+ if (! _t || _t->token<tok || _t->token>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
+
+/* C++ MATCH */
+#define _CPPMATCH(tok) if ( _t->token()!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)
+#define _CPPMATCHRANGE(tok,tok2) \
+ if ( _t->token()<tok || _t->token()>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)
+
+/* Normal DOWN and RIGHT */
+#define _DOWN _t=_t->down
+#define _RIGHT _t=_t->right
+
+/* C++ DOWN and RIGHT */
+#define _CPPDOWN _t=(SORAST *) _t->down()
+#define _CPPRIGHT _t=(SORAST *) _t->right()
+
+#define _SAVE SORAST *_save=_t
+#define _RESTORE _t = _save
+#define _SETLABEL(u) u=_t
+#define _WILDCARD if ( _t==NULL ) if ( _parser->guessing ) _GUESS_FAIL; else missing_wildcard(_parser)
+#define _GUESS_BLOCK STreeParser _st; int _gv; SORAST *_savet=NULL;
+#define _GUESS {_st = *_parser; \
+ _savet = _t; \
+ _parser->guessing = 1; \
+ _gv = setjmp(_parser->startofguess.state);}
+#define _GUESS_FAIL longjmp(_parser->startofguess.state, 1)
+#define _GUESS_DONE {*_parser = _st; _t = _savet;}
+
+/* These are used mainly by the C output */
+#ifndef ast_down
+#define ast_down down
+#endif
+#ifndef ast_right
+#define ast_right right
+#endif
+
+#define STreeTry(r,p,t) \
+ (p)->try_result = NULL; \
+ (p)->sjrv = setjmp((p)->startofguess); \
+ if ( !(p)->sjrv ) { \
+ rule(p,t,&try_result); \
+ (p)->try_ok = 1; \
+ } \
+ else { \
+ (p)->try_ok = 0; \
+ } \
+ if ( (p)->try_ok )
+
+
+/* Used only during TRANSFORM mode */
+#define TREE_CONSTR_PTRS SORAST *_r=NULL,*_s=NULL,*_e=NULL
+
+typedef struct _Sjmp_buf {
+ jmp_buf state;
+ } Sjmp_buf;
+
+#ifndef _PARSER_VARS
+#define _PARSER_VARS
+#endif
+
+#ifndef _REFVARS
+#define _REFVARS
+#endif
+
+typedef struct _STreeParser {
+ int try_ok, sjrv; /* used by STreeTry macro */
+ SORAST *try_result; /* tree coming back from try */
+ int guessing;
+ Sjmp_buf startofguess;
+ SORAST *t;
+ _REFVARS
+ _PARSER_VARS
+ } STreeParser;
+
+#define STreeParserInit(_p) { (_p)->guessing = 0; _refvar_inits(_p); }
+
+
+ /* S a n i t y C h e c k i n g */
+
+#ifndef require
+#define require(expr, err) {if ( !(expr) ) sorcerer_panic(err);}
+#endif
+
+
+ /* T r a n s f o r m M a c r o s */
+#define ast_return(_t) *_result = _t
+
+
+#ifdef __USE_PROTOS
+extern void mismatched_range(STreeParser *_parser, int looking_for, int upper_token, SORAST *found);
+extern void missing_wildcard(STreeParser *_parser);
+extern void mismatched_token(STreeParser *_parser, int looking_for, SORAST *found);
+extern void no_viable_alt(STreeParser *_parser, char *rulename, SORAST *root);
+extern void sorcerer_panic(char *err);
+extern void _refvar_inits(STreeParser *); /* MR15 Kevin J. Cummings */
+extern void _mkroot(SORAST **, SORAST **, SORAST **, SORAST *);
+extern void _mkchild(SORAST **, SORAST **, SORAST **, SORAST *);
+extern SORAST *ast_alloc(void);
+extern SORAST *ast_dup(SORAST *t);
+extern SORAST *ast_dup_node(SORAST *t);
+#else
+extern void mismatched_range();
+extern void missing_wildcard();
+extern void mismatched_token();
+extern void no_viable_alt();
+extern void sorcerer_panic();
+extern void _refvar_inits(); /* MR15 Kevin J. Cummings */
+extern void _mkroot();
+extern void _mkchild();
+extern SORAST *ast_alloc();
+extern SORAST *ast_dup();
+extern SORAST *ast_dup_node();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h
new file mode 100644
index 0000000000..08c1ad0e1f
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h
@@ -0,0 +1,52 @@
+#ifndef SLIST_H
+#define SLIST_H
+
+/*
+ * SList.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "sorcerer.h"
+
+typedef struct _SList {
+ void *elem; /* pointer to any kind of element */
+ struct _SList *next;
+ } SList;
+
+#define newSList (SList *) calloc(1, sizeof(SList));
+
+#ifdef __USE_PROTOS
+extern void *slist_iterate(SList *list, SList **);
+extern void slist_add( SList **list, void *e );
+extern void slist_free(SList *list);
+#else
+extern void *slist_iterate();
+extern void slist_add();
+extern void slist_free();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h
new file mode 100644
index 0000000000..fe80598977
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h
@@ -0,0 +1,46 @@
+#ifndef SSTACK_H
+#define SSTACK_H
+
+/*
+ * SStack.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include "sorlist.h"
+
+typedef SList SStack;
+
+#define newSStack (SStack *) calloc(1, sizeof(SStack));
+
+#ifdef __USE_PROTOS
+extern void sstack_push( SStack **st, void *e );
+extern void *sstack_pop( SStack **st );
+#else
+extern void sstack_push();
+extern void *sstack_pop();
+#endif
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h
new file mode 100644
index 0000000000..35be33e6c7
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h
@@ -0,0 +1,45 @@
+#ifndef CASTBase_h
+#define CASTBase_h
+
+/*
+ * CASTBase.h
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+/* ONLY USED TO C COMPILE LIBRARY FUNCTIONS; YOU CAN FORCE THEM TO COMPILE WITH
+ * YOUR SORAST DEF IF YOU WANT (THAT WAY, ORDER OF FIELD DEFINITION IS IRRELEVANT)
+ */
+
+/* Typically, this file is not used / seen by the programmer */
+
+/* Used as "super-class" for compiling C library routines */
+typedef struct _nodebase {
+ struct _nodebase *right, *down;
+ int token;
+ } SORAST;
+
+#endif
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp
new file mode 100644
index 0000000000..0d50a337f0
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp
@@ -0,0 +1,151 @@
+#include <stdio.h>
+#include "STreeParser.h"
+
+void STreeParser::
+MATCH(SORASTBase *_t,int tok)
+{
+ if ( _t->type()!=tok )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else mismatched_token(tok, _t);
+ }
+}
+
+void STreeParser::
+MATCHRANGE(SORASTBase *_t,int tok,int tok2)
+{
+ if ( _t->type()<tok || _t->type()>tok2 )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else mismatched_range(tok, tok2, _t);
+ }
+}
+
+void STreeParser::
+WILDCARD(SORASTBase *_t)
+{
+ if ( _t==NULL )
+ {
+ if ( guessing ) _GUESS_FAIL;
+ else missing_wildcard();
+ }
+}
+
+void STreeParser::
+mismatched_range(int looking_for, int upper_token, SORASTBase *found)
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found token %d\n",
+ looking_for, upper_token,
+ found->type());
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found NULL tree\n",
+ looking_for, upper_token);
+ }
+}
+
+void STreeParser::
+missing_wildcard()
+{
+ fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
+}
+
+void STreeParser::
+mismatched_token(int looking_for, SORASTBase *found)
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token %d found token %d\n",
+ looking_for,
+ found->type());
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token %d found NULL tree\n",
+ looking_for);
+ }
+}
+
+void STreeParser::
+no_viable_alt(char *rulename, SORASTBase *root)
+{
+ if ( root==NULL )
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for NULL tree\n",
+ rulename);
+ else
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for tree\n",
+ rulename);
+}
+
+void STreeParser::
+panic(char *err)
+{
+ fprintf(stderr, "panic: %s\n", err);
+ exit(-1);
+}
+
+void STreeParser::
+save_state(STreeParser *buf)
+{
+ buf->try_ok = this->try_ok;
+ buf->sjrv = this->sjrv;
+ buf->guessing = this->guessing;
+ buf->startofguess = this->startofguess;
+}
+
+void STreeParser::
+restore_state(STreeParser *buf)
+{
+ this->try_ok = buf->try_ok;
+ this->sjrv = buf->sjrv;
+ this->guessing = buf->guessing;
+ this->startofguess = buf->startofguess;
+}
+
+void STreeParser::
+_mkroot(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)
+{
+ *r = t;
+}
+
+void STreeParser::
+_mkchild(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)
+{
+#ifdef BEFORE_GARYS_FIX
+ /* if no sibling list, must attach to any existing root */
+ if ( *s==NULL )
+ {
+ *s = *e = t;
+ /* If r is NULL, then there was no root defined--must be sibling list */
+ if ( *r==NULL ) *r = *s;
+ else (*r)->setDown(t);
+ }
+ else { (*e)->setRight(t); *e = t; }
+#endif
+/*
+ should do nothing if asked to add a NULL argument. NULL's come up
+ when a rule wants to return "nothing".
+*/
+ /* if no sibling list, must attach to any existing root */
+ if (*s == NULL)
+ {
+ *s = *e = t;
+ // If r is NULL then there was no root defined--must be sibling list
+ if (*r == NULL) *r = *s;
+ else (*r)->setDown(t);
+ }
+ else if (*e != NULL)
+ {
+ (*e)->setRight(t);
+ *e = t;
+ }
+ if (*e != NULL) {
+ while ((*e)->right() != NULL) *e = (SORASTBase *)(*e)->right();
+ }
+}
+
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c
new file mode 100644
index 0000000000..8ba1a49b50
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c
@@ -0,0 +1,834 @@
+/*
+ * astlib.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include <stdio.h>
+#include "pcctscfg.h"
+#include <ctype.h>
+
+#define SORCERER_TRANSFORM
+
+#include "CASTBase.h"
+#include "astlib.h"
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+ /* String Scanning/Parsing Stuff */
+
+#define StringScanMaxText 50
+
+typedef struct stringlexer {
+#ifdef __USE_PROTOS
+ signed int c;
+#else
+ int c;
+#endif
+ char *input;
+ char *p;
+ char text[StringScanMaxText];
+ } StringLexer;
+
+#define LPAREN 1
+#define RPAREN 2
+#define PERCENT 3
+#define INT 4
+#define COLON 5
+#define POUND 6
+#define PERIOD 7
+#define StringScanEOF -1
+#define VALID_SCAN_TOKEN(t) (t>=LPAREN && t<=PERIOD)
+
+static char *scan_token_tbl[] = {
+ "invalid", /* 0 */
+ "LPAREN", /* 1 */
+ "RPAREN", /* 2 */
+ "PERCENT", /* 3 */
+ "INT", /* 4 */
+ "COLON", /* 5 */
+ "POUND", /* 6 */
+ "PERIOD", /* 7 */
+};
+
+char *
+#ifdef __USE_PROTOS
+scan_token_str(int t)
+#else
+scan_token_str(t)
+int t;
+#endif
+{
+ if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];
+ else if ( t==StringScanEOF ) return "<end-of-string>";
+ else return "<invalid-token>";
+}
+
+typedef struct stringparser {
+ int token;
+ StringLexer *lexer;
+ int num_labels;
+ } StringParser;
+
+ /* This type ONLY USED by ast_scan() */
+
+typedef struct _scanast {
+ struct _scanast *right, *down;
+ int token;
+ int label_num;
+ } ScanAST;
+
+#ifdef __USE_PROTOS
+static void stringlexer_init(StringLexer *scanner, char *input);
+static void stringparser_init(StringParser *, StringLexer *);
+static ScanAST *stringparser_parse_scanast(char *templ, int *n);
+static ScanAST *stringparser_parse_tree(StringParser *parser);
+static ScanAST *stringparser_parse_element(StringParser *parser);
+static void stringscan_advance(StringLexer *scanner);
+static int stringscan_gettok(StringLexer *scanner);
+#else
+static void stringlexer_init();
+static void stringparser_init();
+static ScanAST *stringparser_parse_scanast();
+static ScanAST *stringparser_parse_tree();
+static ScanAST *stringparser_parse_element();
+static void stringscan_advance();
+static int stringscan_gettok();
+#endif
+
+/* build a tree (root child1 child2 ... NULL)
+ * If root is NULL, simply make the children siblings and return ptr
+ * to 1st sibling (child1). If root is not single node, return NULL.
+ *
+ * Siblings that are actually sibling lists themselves are handled
+ * correctly. For example #( NULL, #( NULL, A, B, C), D) results
+ * in the tree ( NULL A B C D ).
+ *
+ * Requires at least two parameters with the last one being NULL. If
+ * both are NULL, return NULL.
+ *
+ * The ast_down and ast_right down/right pointers are used to make the tree.
+ */
+SORAST *
+#ifdef PCCTS_USE_STDARG
+ast_make(SORAST *rt, ...)
+#else
+ast_make(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ register SORAST *child, *sibling=NULL, *tail = NULL, *w;
+ SORAST *root;
+
+#ifdef PCCTS_USE_STDARG
+ va_start(ap, rt);
+ root = rt;
+#else
+ va_start(ap);
+ root = va_arg(ap, SORAST *);
+#endif
+
+ if ( root != NULL )
+ if ( root->ast_down != NULL ) return NULL;
+ child = va_arg(ap, SORAST *);
+ while ( child != NULL )
+ {
+ /* find end of child */
+ for (w=child; w->ast_right!=NULL; w=w->ast_right) {;}
+ if ( sibling == NULL ) {sibling = child; tail = w;}
+ else {tail->ast_right = child; tail = w;}
+ child = va_arg(ap, SORAST *);
+ }
+ if ( root==NULL ) root = sibling;
+ else root->ast_down = sibling;
+ va_end(ap);
+ return root;
+}
+
+/* The following push and pop routines are only used by ast_find_all() */
+
+static void
+#ifdef __USE_PROTOS
+_push(SORAST **st, int *sp, SORAST *e)
+#else
+_push(st, sp, e)
+SORAST **st;
+int *sp;
+SORAST *e;
+#endif
+{
+ (*sp)--;
+ require((*sp)>=0, "stack overflow");
+ st[(*sp)] = e;
+}
+
+static SORAST *
+#ifdef __USE_PROTOS
+_pop(SORAST **st, int *sp)
+#else
+_pop(st, sp)
+SORAST **st;
+int *sp;
+#endif
+{
+ SORAST *e = st[*sp];
+ (*sp)++;
+ require((*sp)<=MaxTreeStackDepth, "stack underflow");
+ return e;
+}
+
+/* Is 'u' a subtree of 't' beginning at the root? */
+int
+#ifdef __USE_PROTOS
+ast_match_partial(SORAST *t, SORAST *u)
+#else
+ast_match_partial(t, u)
+SORAST *t, *u;
+#endif
+{
+ SORAST *sib;
+
+ if ( u==NULL ) return 1;
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
+ {
+ if ( sib->token != u->token ) return 0;
+ if ( sib->ast_down!=NULL )
+ if ( !ast_match_partial(sib->ast_down, u->ast_down) ) return 0;
+ }
+ return 1;
+}
+
+/* Find all occurrences of u in t.
+ * 'cursor' must be initialized to 't'. It eventually
+ * returns NULL when no more occurrences of 'u' are found.
+ */
+SORAST *
+#ifdef __USE_PROTOS
+ast_find_all(SORAST *t, SORAST *u, SORAST **cursor)
+#else
+ast_find_all(t, u, cursor)
+SORAST *t, *u, **cursor;
+#endif
+{
+ SORAST *sib;
+ static SORAST *template_stack[MaxTreeStackDepth];
+ static int tsp = MaxTreeStackDepth;
+
+ if ( *cursor == NULL ) return NULL;
+ if ( *cursor!=t ) sib = *cursor;
+ else {
+ /* else, first time--start at top of template 't' */
+ tsp = MaxTreeStackDepth;
+ sib = t;
+ /* bottom of stack is always a NULL--"cookie" indicates "done" */
+ _push(template_stack, &tsp, NULL);
+ }
+
+keep_looking:
+ if ( sib==NULL ) /* hit end of sibling list */
+ {
+ sib = _pop(template_stack, &tsp);
+ if ( sib == NULL ) { *cursor = NULL; return NULL; }
+ }
+
+ if ( sib->token != u->token )
+ {
+ /* look for another match */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ sib=sib->ast_down;
+ goto keep_looking;
+ }
+ /* nothing below to try, try next sibling */
+ sib=sib->ast_right;
+ goto keep_looking;
+ }
+
+ /* found a matching root node, try to match what's below */
+ if ( ast_match_partial(sib, u) )
+ {
+ /* record sibling cursor so we can pick up next from there */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ *cursor = sib->ast_down;
+ }
+ else if ( sib->ast_right!=NULL ) *cursor = sib->ast_right;
+ else *cursor = _pop(template_stack, &tsp);
+ return sib;
+ }
+
+ /* no match, keep searching */
+ if ( sib->ast_down!=NULL )
+ {
+ if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);
+ sib=sib->ast_down;
+ }
+ else sib = sib->ast_right; /* else, try to right if zip below */
+ goto keep_looking;
+}
+
+/* are two trees exactly alike? */
+int
+#ifdef __USE_PROTOS
+ast_match(SORAST *t, SORAST *u)
+#else
+ast_match(t, u)
+SORAST *t, *u;
+#endif
+{
+ SORAST *sib;
+
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)
+ {
+ if ( sib->token != u->token ) return 0;
+ if ( sib->ast_down!=NULL )
+ if ( !ast_match(sib->ast_down, u->ast_down) ) return 0;
+ }
+ return 1;
+}
+
+static int
+#ifdef __USE_PROTOS
+ast_scanmatch(ScanAST *t, SORAST *u, SORAST **labels[], int *n)
+#else
+ast_scanmatch(t, u, labels, n)
+ScanAST *t;
+SORAST *u;
+SORAST **labels[];
+int *n;
+#endif
+{
+ ScanAST *sib;
+
+ if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;
+ if ( u==NULL ) return 0;
+
+ for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right, u=u->ast_right)
+ {
+ /* make sure tokens match; token of '0' means wildcard match */
+ if ( sib->token != u->token && sib->token!=0 ) return 0;
+ /* we have a matched token here; set label pointers if exists */
+ if ( sib->label_num>0 )
+ {
+ require(labels!=NULL, "label found in template, but no array of labels");
+ (*n)++;
+ *(labels[sib->label_num-1]) = u;
+ }
+ /* match what's below if something there and current node is not wildcard */
+ if ( sib->down!=NULL && sib->token!=0 )
+ if ( !ast_scanmatch(sib->down, u->ast_down, labels, n) ) return 0;
+ }
+ return 1;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_insert_after(SORAST *a, SORAST *b)
+#else
+ast_insert_after(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_insert_after: NULL input tree");
+ if ( b==NULL ) return;
+ /* find end of b's child list */
+ for (end=b; end->ast_right!=NULL; end=end->ast_right) {;}
+ end->ast_right = a->ast_right;
+ a->ast_right = b;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_append(SORAST *a, SORAST *b)
+#else
+ast_append(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL&&b!=NULL, "ast_append: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
+ end->ast_right = b;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_tail(SORAST *a)
+#else
+ast_tail(a)
+SORAST *a;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_tail: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}
+ return end;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_bottom(SORAST *a)
+#else
+ast_bottom(a)
+SORAST *a;
+#endif
+{
+ SORAST *end;
+ require(a!=NULL, "ast_bottom: NULL input tree");
+ /* find end of child list */
+ for (end=a; end->ast_down!=NULL; end=end->ast_down) {;}
+ return end;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_cut_between(SORAST *a, SORAST *b)
+#else
+ast_cut_between(a, b)
+SORAST *a,*b;
+#endif
+{
+ SORAST *end, *ret;
+ require(a!=NULL&&b!=NULL, "ast_cut_between: NULL input tree");
+ /* find node pointing to b */
+ for (end=a; end->ast_right!=NULL&&end->ast_right!=b; end=end->ast_right)
+ {;}
+ require(end->ast_right!=NULL, "ast_cut_between: a,b not connected");
+ end->ast_right = NULL; /* don't want it point to 'b' anymore */
+ ret = a->ast_right;
+ a->ast_right = b;
+ return ret;
+}
+
+SList *
+#ifdef __USE_PROTOS
+ast_to_slist(SORAST *t)
+#else
+ast_to_slist(t)
+SORAST *t;
+#endif
+{
+ SList *list=NULL;
+ SORAST *p;
+
+ for (p=t; p!=NULL; p=p->ast_right)
+ {
+ slist_add(&list, p);
+ }
+ return list;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+slist_to_ast(SList *list)
+#else
+slist_to_ast(list)
+SList *list;
+#endif
+{
+ SORAST *t=NULL, *last=NULL;
+ SList *p;
+
+ for (p = list->next; p!=NULL; p=p->next)
+ {
+ SORAST *u = (SORAST *)p->elem;
+ if ( last==NULL ) last = t = u;
+ else { last->ast_right = u; last = u; }
+ }
+ return t;
+}
+
+void
+#ifdef __USE_PROTOS
+ast_free(SORAST *t)
+#else
+ast_free(t)
+SORAST *t;
+#endif
+{
+ if ( t == NULL ) return;
+ ast_free( t->ast_down );
+ ast_free( t->ast_right );
+ free( t );
+}
+
+int
+#ifdef __USE_PROTOS
+ast_nsiblings(SORAST *t)
+#else
+ast_nsiblings(t)
+SORAST *t;
+#endif
+{
+ int n=0;
+
+ while ( t!=NULL )
+ {
+ n++;
+ t = t->ast_right;
+ }
+ return n;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_sibling_index(SORAST *t, int i)
+#else
+ast_sibling_index(t,i)
+SORAST *t;
+int i;
+#endif
+{
+ int j=1;
+ require(i>0, "ast_sibling_index: i<=0");
+
+ while ( t!=NULL )
+ {
+ if ( j==i ) return t;
+ j++;
+ t = t->ast_right;
+ }
+ return NULL;
+}
+
+static void
+#ifdef __USE_PROTOS
+scanast_free(ScanAST *t)
+#else
+scanast_free(t)
+ScanAST *t;
+#endif
+{
+ if ( t == NULL ) return;
+ scanast_free( t->down );
+ scanast_free( t->right );
+ free( t );
+}
+
+/*
+ * ast_scan
+ *
+ * This function is like scanf(): it attempts to match a template
+ * against an input tree. A variable number of tree pointers
+ * may be set according to the '%i' labels in the template string.
+ * For example:
+ *
+ * ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",
+ * t, &w, &x, &y, &z);
+ *
+ * Naturally, you'd want this converted from
+ *
+ * ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",
+ * t, &w, &x, &y, &z);
+ *
+ * by SORCERER.
+ *
+ * This function call must be done withing a SORCERER file because SORCERER
+ * must convert the token references to the associated token number.
+ *
+ * This functions parses the template and creates trees which are then
+ * matched against the input tree. The labels are set as they are
+ * encountered; hence, partial matches may leave some pointers set
+ * and some NULL. This routines initializes all argument pointers to NULL
+ * at the beginning.
+ *
+ * This function returns the number of labels matched.
+ */
+int
+#ifdef PCCTS_USE_STDARG
+ast_scan(char *templ, SORAST *tree, ...)
+#else
+ast_scan(va_alist)
+va_dcl
+#endif
+{
+ va_list ap;
+ ScanAST *t;
+ int n, i, found=0;
+ SORAST ***label_ptrs=NULL;
+
+#ifdef PCCTS_USE_STDARG
+ va_start(ap, tree);
+#else
+ char *templ;
+ SORAST *tree;
+
+ va_start(ap);
+ templ = va_arg(ap, char *);
+ tree = va_arg(ap, SORAST *);
+#endif
+
+ /* make a ScanAST tree out of the template */
+ t = stringparser_parse_scanast(templ, &n);
+
+ /* make an array out of the labels */
+ if ( n>0 )
+ {
+ label_ptrs = (SORAST ***) calloc(n, sizeof(SORAST **));
+ require(label_ptrs!=NULL, "ast_scan: out of memory");
+ for (i=1; i<=n; i++)
+ {
+ label_ptrs[i-1] = va_arg(ap, SORAST **);
+ *(label_ptrs[i-1]) = NULL;
+ }
+ }
+
+ /* match the input tree against the template */
+ ast_scanmatch(t, tree, label_ptrs, &found);
+
+ scanast_free(t);
+ free(label_ptrs);
+
+ return found;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+new_scanast(int tok)
+#else
+new_scanast(tok)
+int tok;
+#endif
+{
+ ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));
+ if ( p == NULL ) {fprintf(stderr, "out of mem\n"); exit(-1);}
+ p->token = tok;
+ return p;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_scanast(char *templ, int *num_labels)
+#else
+stringparser_parse_scanast(templ, num_labels)
+char *templ;
+int *num_labels;
+#endif
+{
+ StringLexer lex;
+ StringParser parser;
+ ScanAST *t;
+
+ stringlexer_init(&lex, templ);
+ stringparser_init(&parser, &lex);
+ t = stringparser_parse_tree(&parser);
+ *num_labels = parser.num_labels;
+ return t;
+}
+
+static void
+#ifdef __USE_PROTOS
+stringparser_match(StringParser *parser, int token)
+#else
+stringparser_match(parser, token)
+StringParser *parser;
+int token;
+#endif
+{
+ if ( parser->token != token ) sorcerer_panic("bad tree in ast_scan()");
+}
+
+/*
+ * Match a tree of the form:
+ * (root child1 child2 ... childn)
+ * or,
+ * node
+ *
+ * where the elements are integers or labeled integers.
+ */
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_tree(StringParser *parser)
+#else
+stringparser_parse_tree(parser)
+StringParser *parser;
+#endif
+{
+ ScanAST *t=NULL, *root, *child, *last = NULL;
+
+ if ( parser->token != POUND )
+ {
+ return stringparser_parse_element(parser);
+ }
+ stringparser_match(parser,POUND);
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,LPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root = stringparser_parse_element(parser);
+ while ( parser->token != RPAREN )
+ {
+ child = stringparser_parse_element(parser);
+ if ( t==NULL ) { t = child; last = t; }
+ else { last->right = child; last = child; }
+ }
+ stringparser_match(parser,RPAREN);
+ parser->token = stringscan_gettok(parser->lexer);
+ root->down = t;
+ return root;
+}
+
+static ScanAST *
+#ifdef __USE_PROTOS
+stringparser_parse_element(StringParser *parser)
+#else
+stringparser_parse_element(parser)
+StringParser *parser;
+#endif
+{
+ static char ebuf[100];
+ int label = 0;
+
+ if ( parser->token == POUND )
+ {
+ return stringparser_parse_tree(parser);
+ }
+ if ( parser->token == PERCENT )
+ {
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,INT);
+ label = atoi(parser->lexer->text);
+ parser->num_labels++;
+ if ( label==0 ) sorcerer_panic("%%0 is an invalid label");
+ parser->token = stringscan_gettok(parser->lexer);
+ stringparser_match(parser,COLON);
+ parser->token = stringscan_gettok(parser->lexer);
+ /* can label tokens and wildcards */
+ if ( parser->token != INT && parser->token != PERIOD )
+ sorcerer_panic("can only label tokens");
+ }
+ if ( parser->token == INT )
+ {
+ ScanAST *p = new_scanast(atoi(parser->lexer->text));
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ if ( parser->token == PERIOD )
+ {
+ ScanAST *p = new_scanast(0); /* token of 0 is wildcard */
+ parser->token = stringscan_gettok(parser->lexer);
+ p->label_num = label;
+ return p;
+ }
+ sprintf(ebuf, "mismatch token in ast_scan(): %s", scan_token_str(parser->token));
+ sorcerer_panic(ebuf);
+ return NULL; /* MR20 make -Wall happy */
+}
+
+static void
+#ifdef __USE_PROTOS
+stringparser_init(StringParser *parser, StringLexer *input)
+#else
+stringparser_init(parser, input)
+StringParser *parser;
+StringLexer *input;
+#endif
+{
+ parser->lexer = input;
+ parser->token = stringscan_gettok(parser->lexer);
+ parser->num_labels = 0;
+}
+
+static void
+#ifdef __USE_PROTOS
+stringlexer_init(StringLexer *scanner, char *input)
+#else
+stringlexer_init(scanner, input)
+StringLexer *scanner;
+char *input;
+#endif
+{
+ scanner->text[0]='\0';
+ scanner->input = input;
+ scanner->p = input;
+ stringscan_advance(scanner);
+}
+
+static void
+#ifdef __USE_PROTOS
+stringscan_advance(StringLexer *scanner)
+#else
+stringscan_advance(scanner)
+StringLexer *scanner;
+#endif
+{
+ if ( *(scanner->p) == '\0' ) scanner->c = StringScanEOF;
+ scanner->c = *(scanner->p)++;
+}
+
+static int
+#ifdef __USE_PROTOS
+stringscan_gettok(StringLexer *scanner)
+#else
+stringscan_gettok(scanner)
+StringLexer *scanner;
+#endif
+{
+ char *index = &scanner->text[0];
+ static char ebuf[100];
+
+ while ( isspace(scanner->c) ) { stringscan_advance(scanner); }
+ if ( isdigit(scanner->c) )
+ {
+ int tok = INT;
+ while ( isdigit(scanner->c) ) {
+ *index++ = scanner->c;
+ stringscan_advance(scanner);
+ }
+ *index = '\0';
+ return tok;
+ }
+ switch ( scanner->c )
+ {
+ case '#' : stringscan_advance(scanner); return POUND;
+ case '(' : stringscan_advance(scanner); return LPAREN;
+ case ')' : stringscan_advance(scanner); return RPAREN;
+ case '%' : stringscan_advance(scanner); return PERCENT;
+ case ':' : stringscan_advance(scanner); return COLON;
+ case '.' : stringscan_advance(scanner); return PERIOD;
+ case '\0' : return StringScanEOF;
+ case StringScanEOF : return StringScanEOF;
+ default :
+ sprintf(ebuf, "invalid char in ast_scan: '%c'", scanner->c);
+ sorcerer_panic(ebuf);
+ return 0; /* MR20 Make -Wall happy */
+ }
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c
new file mode 100644
index 0000000000..4048ba50b2
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c
@@ -0,0 +1,100 @@
+/*
+ * errsupport.c -- error support code for SORCERER output
+ *
+ * Define your own or compile and link this in.
+ *
+ * Terence Parr
+ * U of MN, AHPCRC
+ * February 1994
+ */
+#include "sorcerer.h"
+
+void
+#ifdef __USE_PROTOS
+mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found )
+#else
+mismatched_range( _parser, looking_for, upper_token, found )
+int looking_for;
+int upper_token;
+SORAST *found;
+STreeParser *_parser;
+#endif
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found token %d\n",
+ looking_for, upper_token,
+ found->token);
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token range %d..%d found NULL tree\n",
+ looking_for, upper_token);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+missing_wildcard(STreeParser *_parser)
+#else
+missing_wildcard(_parser)
+STreeParser *_parser;
+#endif
+{
+ fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
+}
+
+void
+#ifdef __USE_PROTOS
+mismatched_token( STreeParser *_parser, int looking_for, SORAST *found )
+#else
+mismatched_token( _parser, looking_for, found )
+int looking_for;
+SORAST *found;
+STreeParser *_parser;
+#endif
+{
+ if ( found!=NULL ) {
+ fprintf(stderr,
+ "parse error: expected token %d found token %d\n",
+ looking_for,
+ found->token);
+ }
+ else {
+ fprintf(stderr,
+ "parse error: expected token %d found NULL tree\n",
+ looking_for);
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root )
+#else
+no_viable_alt( _parser, rulename, root )
+char *rulename;
+SORAST *root;
+STreeParser *_parser;
+#endif
+{
+ if ( root==NULL )
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for NULL tree\n",
+ rulename);
+ else
+ fprintf(stderr,
+ "parse error: in rule %s, no viable alternative for tree\n",
+ rulename);
+}
+
+void
+#ifdef __USE_PROTOS
+sorcerer_panic(char *err)
+#else
+sorcerer_panic(err)
+char *err;
+#endif
+{
+ fprintf(stderr, "panic: %s\n", err);
+ exit(-1);
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile
new file mode 100644
index 0000000000..c4e9bca9e8
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile
@@ -0,0 +1,21 @@
+#
+# Makefile for SORCERER libraries
+#
+SRC = astlib.c sstack.c sorlist.c sintstack.c
+OBJ = astlib.o sstack.o sorlist.o sintstack.o
+CFLAGS=-g -I../../h -I../h
+CC=cc
+
+libs : $(OBJ) $(SRC)
+
+clean:
+ rm -f *.o core
+
+scrub:
+ rm -f *.o core
+
+ci:
+ ci -u $(SRC) *.h makefile
+
+co:
+ co -l $(SRC) *.h makefile
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp
new file mode 100644
index 0000000000..390d34fc06
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp
@@ -0,0 +1,130 @@
+# Microsoft Developer Studio Project File - Name="lib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=lib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "lib.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "lib.mak" CFG="lib - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "lib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "lib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""$/pccts/Sorcerer/lib", EPABAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+
+!IF "$(CFG)" == "lib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "h" /I "..\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "lib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "h" /I "..\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "lib - Win32 Release"
+# Name "lib - Win32 Debug"
+# Begin Group "Header files"
+
+# PROP Default_Filter "h"
+# Begin Source File
+
+SOURCE=.\CASTBase.h
+# End Source File
+# End Group
+# Begin Group "Source files"
+
+# PROP Default_Filter "c,cpp"
+# Begin Source File
+
+SOURCE=.\astlib.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\errsupport.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\PCCTSAST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sintstack.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\SList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sorcerer.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\sorlist.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\sstack.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\STreeParser.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c
new file mode 100644
index 0000000000..a3708c94fb
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c
@@ -0,0 +1,140 @@
+/*
+ * sint.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sintstack.h"
+
+SIntStack *
+#ifdef __USE_PROTOS
+sint_newstack(int size)
+#else
+sint_newstack(size)
+int size;
+#endif
+{
+ SIntStack *p = (SIntStack *) calloc(1, sizeof(SIntStack));
+ require(p!=NULL, "sint_newstack: out of memory");
+ p->data = (int *) calloc(size, sizeof(int));
+ require(p!=NULL, "sint_newstack: out of memory");
+ p->size = size;
+ p->sp = size;
+ return p;
+}
+
+void
+#ifdef __USE_PROTOS
+sint_freestack(SIntStack *st)
+#else
+sint_freestack(st)
+SIntStack *st;
+#endif
+{
+ if ( st==NULL ) return;
+ if ( st->data==NULL ) return;
+ free(st->data);
+ free(st);
+}
+
+void
+#ifdef __USE_PROTOS
+sint_push(SIntStack *st,int i)
+#else
+sint_push(st,i)
+SIntStack *st;
+int i;
+#endif
+{
+ require(st->sp>0, "sint_push: stack overflow");
+ st->data[--(st->sp)] = i;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_pop(SIntStack *st)
+#else
+sint_pop(st)
+SIntStack *st;
+#endif
+{
+ require(st->sp<st->size, "sint_pop: stack underflow");
+ return st->data[st->sp++];
+}
+
+int
+#ifdef __USE_PROTOS
+sint_stacksize(SIntStack *st)
+#else
+sint_stacksize(st)
+SIntStack *st;
+#endif
+{
+ return st->size - st->sp;
+}
+
+void
+#ifdef __USE_PROTOS
+sint_stackreset(SIntStack *st)
+#else
+sint_stackreset(st)
+SIntStack *st;
+#endif
+{
+ st->sp = st->size;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_stackempty(SIntStack *st)
+#else
+sint_stackempty(st)
+SIntStack *st;
+#endif
+{
+ return st->sp==st->size;
+}
+
+int
+#ifdef __USE_PROTOS
+sint_top(SIntStack *st)
+#else
+sint_top(st)
+SIntStack *st;
+#endif
+{
+ require(st->sp<st->size, "sint_top: stack underflow");
+ return st->data[st->sp];
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c
new file mode 100644
index 0000000000..ad4c3a7eee
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c
@@ -0,0 +1,169 @@
+/*
+ * sorcerer.c -- support code for SORCERER output
+ *
+ * Define your own or compile and link this in.
+ *
+ * Terence Parr
+ * U of MN, AHPCRC
+ * February 1994
+ */
+
+/***********************************************************************
+ 2-Oct-97 The routine ast_dup() appeared to have a bug in it. Instead
+ of providing a deep copy of its argument it made a bushy copy
+ of its argument - by duplicating the nodes pointed to by
+ its right link. This is certainly not deliberate and does
+ not match code in PCCTSAST.cpp (which had its own bug). This
+ has been changed to do a deep copy in the traditional sense.
+***********************************************************************/
+
+#ifdef OLD
+/* Given a result pointer, return the same one if *t is NULL,
+ * else find the end of the sibling list and return the address
+ * the 'next[write]' field in that last node.
+ */
+AST **
+#ifdef __USE_PROTOS
+_nextresult(STreeParser *_parser, AST **t)
+#else
+_nextresult(_parser, t)
+AST **t;
+STreeParser *_parser;
+#endif
+{
+ AST *p = *t;
+
+ if ( p==NULL ) return t;
+ while ( p->ast_right(_parser->write) != NULL )
+ {
+ p = p->ast_right(_parser->write);
+ }
+ return &(p->ast_right(_parser->write));
+}
+
+/*
+ * Copy the read pointers to the write pointers for a node or entire subtree
+ */
+void
+#ifdef __USE_PROTOS
+_copy_wildcard(STreeParser *_parser, AST *t, int root)
+#else
+_copy_wildcard(_parser, t, root)
+STreeParser *_parser;
+AST *t;
+int root;
+#endif
+{
+ while ( t!=NULL )
+ {
+ if ( !root ) t->ast_right(_parser->write) = t->ast_right(_parser->read);
+ t->ast_down(_parser->write) = t->ast_down(_parser->read);
+ if ( t->ast_down(_parser->read)!=NULL )
+ _copy_wildcard(_parser, t->ast_down(_parser->read), 0);
+ if ( root ) return;
+ else root=0;
+ t = t->ast_right(_parser->read);
+ }
+}
+#endif
+
+void
+#ifdef __USE_PROTOS
+_mkroot(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
+#else
+_mkroot(r,s,e,t)
+SORAST **r, **s, **e, *t;
+#endif
+{
+ *r = t;
+}
+
+void
+#ifdef __USE_PROTOS
+_mkchild(SORAST **r, SORAST **s, SORAST **e, SORAST *t)
+#else
+_mkchild(r,s,e,t)
+SORAST **r, **s, **e, *t;
+#endif
+{
+ /* if no sibling list, must attach to any existing root */
+ if ( *s==NULL )
+ {
+ *s = *e = t;
+ /* If r is NULL, then there was no root defined--must be sibling list */
+ if ( *r==NULL ) *r = *s;
+ else (*r)->ast_down = t;
+ }
+ else { (*e)->ast_right = t; *e = t; }
+}
+
+/* THESE FUNCS HAVE TO GO HERE BECAUSE THEY ARE SENSITIVE TO USER'S SORAST DEF */
+SORAST *
+#ifdef __USE_PROTOS
+ast_alloc(void)
+#else
+ast_alloc()
+#endif
+{
+ SORAST *t = (SORAST *)calloc(1, sizeof(SORAST));
+ if ( t==NULL ) sorcerer_panic("out of memory");
+ return t;
+}
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup_bushy(SORAST *t)
+#else
+ast_dup_bushy(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
+ u->ast_right = ast_dup_bushy(t->ast_right);
+ return u;
+}
+
+
+/* Assume t is a root node of a tree--duplicate that node and what's below */
+
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup(SORAST *t)
+#else
+ast_dup(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */
+ u->ast_right = NULL;
+ return u;
+}
+
+/* Assume t is a root node of a tree--duplicate that node and what's below */
+SORAST *
+#ifdef __USE_PROTOS
+ast_dup_node(SORAST *t)
+#else
+ast_dup_node(t)
+SORAST *t;
+#endif
+{
+ SORAST *u;
+
+ if ( t == NULL ) return NULL;
+ u = ast_alloc();
+ *u = *t; /* copy contents */
+ u->down = NULL;
+ u->right = NULL;
+ return u;
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c
new file mode 100644
index 0000000000..6872974c26
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c
@@ -0,0 +1,123 @@
+/*
+ * slist.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sorlist.h"
+
+/* Iterate over a list of elements; returns ptr to a new element
+ * in list upon every call and NULL when no more are left.
+ * Very useful like this:
+ *
+ * cursor = mylist;
+ * while ( (p=slist_iterate(mylist,&cursor)) ) {
+ * / * place with element p * /
+ * }
+ *
+ * The cursor must be initialized to point to the list to iterate over.
+ */
+void *
+#ifdef __USE_PROTOS
+slist_iterate(SList *list, SList **cursor)
+#else
+slist_iterate(list, cursor)
+SList *list, **cursor;
+#endif
+{
+ void *e;
+
+ if ( list==NULL || cursor == NULL || *cursor==NULL ) return NULL;
+ if ( list== *cursor ) { *cursor = (*cursor)->next; }
+ e = (*cursor)->elem;
+ (*cursor) = (*cursor)->next;
+ return e;
+}
+
+/*
+ * add an element to a list.
+ *
+ * Any non-empty list has a sentinel node whose 'elem' pointer is really
+ * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1).
+ * Elements are appended to the list.
+ */
+void
+#ifdef __USE_PROTOS
+slist_add( SList **list, void *e )
+#else
+slist_add( list, e )
+SList **list;
+void *e;
+#endif
+{
+ SList *p, *tail;
+ require(e!=NULL, "slist_add: attempting to add NULL list element");
+
+ p = newSList;
+ require(p!=NULL, "slist_add: cannot alloc new list node");
+ p->elem = e;
+ if ( *list == NULL )
+ {
+ SList *sentinel = newSList;
+ require(sentinel!=NULL, "slist_add: cannot alloc sentinel node");
+ *list=sentinel;
+ sentinel->next = p;
+ sentinel->elem = (char *)p; /* set tail pointer */
+ }
+ else /* find end of list */
+ {
+ tail = (SList *) (*list)->elem; /* get tail pointer */
+ tail->next = p;
+ (*list)->elem = (char *) p; /* reset tail */
+ }
+}
+
+void
+#ifdef __USE_PROTOS
+slist_free(SList *list)
+#else
+slist_free(list)
+SList *list;
+#endif
+{
+ SList *p,*q;
+
+ if ( list==NULL ) return; /* empty list */
+ for (p = list->next; p!=NULL; p=q)
+ {
+ q = p->next;
+ free(p);
+ }
+}
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c
new file mode 100644
index 0000000000..c8a97b06fa
--- /dev/null
+++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c
@@ -0,0 +1,78 @@
+/*
+ * sstack.c
+ *
+ * SOFTWARE RIGHTS
+ *
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
+ * domain. An individual or company may do whatever they wish with
+ * source code distributed with SORCERER or the code generated by
+ * SORCERER, including the incorporation of SORCERER, or its output, into
+ * commerical software.
+ *
+ * We encourage users to develop software with SORCERER. However, we do
+ * ask that credit is given to us for developing SORCERER. By "credit",
+ * we mean that if you incorporate our source code into one of your
+ * programs (commercial product, research project, or otherwise) that you
+ * acknowledge this fact somewhere in the documentation, research report,
+ * etc... If you like SORCERER and have developed a nice tool with the
+ * output, please mention that you developed it using SORCERER. In
+ * addition, we ask that this header remain intact in our source code.
+ * As long as these guidelines are kept, we expect to continue enhancing
+ * this system and expect to make other tools available as they are
+ * completed.
+ *
+ * SORCERER 1.00B
+ * Terence Parr
+ * AHPCRC, University of Minnesota
+ * 1992-1994
+ */
+
+#include "pcctscfg.h"
+#include <stdio.h>
+#include <setjmp.h>
+
+#ifdef PCCTS_USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include "CASTBase.h"
+#include "sstack.h"
+
+void
+#ifdef __USE_PROTOS
+sstack_push( SStack **st, void *e )
+#else
+sstack_push( st, e )
+SStack **st;
+void *e;
+#endif
+{
+ SStack *p;
+ require(e!=NULL, "sstack_push: attempting to add NULL list element");
+
+ p = newSStack;
+ require(p!=NULL, "sstack_push: cannot alloc new list node");
+ p->elem = e;
+ p->next = *st;
+ *st = p;
+}
+
+void *
+#ifdef __USE_PROTOS
+sstack_pop( SStack **st )
+#else
+sstack_pop( st )
+SStack **st;
+#endif
+{
+ SStack *p = *st;
+ void *r;
+
+ *st = (*st)->next;
+ r = p->elem;
+ free(p);
+ return r;
+}
+