]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / h / PCCTSAST.h
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h
new file mode 100644 (file)
index 0000000..c9fb597
--- /dev/null
@@ -0,0 +1,142 @@
+/* Abstract syntax tree\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef PCCTSAST_H\r
+#define PCCTSAST_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+//class SList;\r
+\r
+#define StringScanMaxText  50\r
+#define MaxTreeStackDepth  400\r
+\r
+//\r
+//  7-Apr-97 133MR1  signed int not accepted by AT&T cfront\r
+//\r
+typedef struct stringlexer {\r
+      int c;            // MR1\r
+      char *input;\r
+      char *p;\r
+      char text[StringScanMaxText];\r
+    } StringLexer;\r
+\r
+/* Define the structures needed for ast_scan() */\r
+typedef struct stringparser {\r
+      int token;\r
+      StringLexer *lexer;\r
+      int num_labels;\r
+    } StringParser;\r
+\r
+typedef struct _scanast {\r
+            struct _scanast *_right, *_down;\r
+            int _token;\r
+      int label_num;\r
+      int type() { return _token; }\r
+      struct _scanast *right() { return _right; }\r
+      struct _scanast *down() { return _down; }\r
+        } ScanAST;\r
+\r
+#define VALID_SCAN_TOKEN(t)    (t>=__LPAREN && t<=__PERIOD)\r
+\r
+class DllExportPCCTS PCCTS_AST {\r
+protected:\r
+  static const char *scan_token_tbl[];    /* MR20 const */\r
+  enum {\r
+  __LPAREN=1,\r
+  __RPAREN=2,\r
+  __PERCENT=3,\r
+  __INT=4,\r
+  __COLON=5,\r
+  __POUND=6,\r
+  __PERIOD=7,\r
+  __StringScanEOF=-1};\r
+\r
+protected:\r
+  const char *scan_token_str(int t);  /* MR20 const */\r
+  void stringlexer_init(StringLexer *scanner, char *input);\r
+  void stringparser_init(StringParser *, StringLexer *);\r
+  ScanAST *stringparser_parse_scanast(char *templ, int *n);\r
+  ScanAST *stringparser_parse_tree(StringParser *parser);\r
+  ScanAST *stringparser_parse_element(StringParser *parser);\r
+  void stringscan_advance(StringLexer *scanner);\r
+  int stringscan_gettok(StringLexer *scanner);\r
+  void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);\r
+  PCCTS_AST *_pop(PCCTS_AST **st, int *sp);\r
+  int match_partial(PCCTS_AST *t, PCCTS_AST *u);\r
+  int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);\r
+  void scanast_free(ScanAST *t);\r
+  ScanAST *new_scanast(int tok);\r
+  void stringparser_match(StringParser *parser, int type);\r
+  virtual PCCTS_AST *deepCopyBushy();\r
+\r
+public:\r
+  PCCTS_AST()  {;}\r
+  virtual ~PCCTS_AST() {;}\r
+\r
+  /* This group must be defined for SORCERER to work correctly */\r
+  virtual PCCTS_AST *right() = 0;\r
+  virtual PCCTS_AST *down() = 0;\r
+  virtual void setRight(PCCTS_AST *t) = 0;\r
+  virtual void setDown(PCCTS_AST *t) = 0;\r
+// we define these so ANTLR doesn't have to\r
+  virtual int type() { return 0; }\r
+  virtual void setType(int t) {;}\r
+  virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}\r
+\r
+  /* These are not needed by ANTLR, but are support functions */\r
+  virtual PCCTS_AST *deepCopy();  // used by SORCERER in transform mode\r
+  virtual void addChild(PCCTS_AST *t);\r
+  virtual void lisp_action(FILE *f) {;}\r
+  virtual void lisp(FILE *f);\r
+  static PCCTS_AST *make(PCCTS_AST *rt, ...);\r
+  virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);\r
+  virtual int match(PCCTS_AST *u);\r
+  virtual void insert_after(PCCTS_AST *b);\r
+  virtual void append(PCCTS_AST *b);\r
+  virtual PCCTS_AST *tail();\r
+  virtual PCCTS_AST *bottom();\r
+  static  PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);\r
+//  virtual SList *to_slist();\r
+  virtual void tfree();\r
+  int ast_scan(char *templ, ...);\r
+  virtual int nsiblings();\r
+  virtual PCCTS_AST *sibling_index(int i);\r
+\r
+  void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */\r
+  virtual void panic(const char *err)     // MR20 const\r
+    { fprintf(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
+};\r
+\r
+#endif /* PCCTSAST_H */\r