]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / h / ATokenBuffer.h
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h
new file mode 100644 (file)
index 0000000..719e059
--- /dev/null
@@ -0,0 +1,106 @@
+/* ANTLRTokenBuffer.h\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 ATOKENBUFFER_H_GATE\r
+#define ATOKENBUFFER_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+/*\r
+ * The parser is "attached" to an ANTLRTokenBuffer via interface\r
+ * functions: getToken() and bufferedToken().  The object that actually\r
+ * consumes characters and constructs tokens is connected to the\r
+ * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();\r
+ * where ANTLRTokenStream is really just a behavior (class with no data).\r
+ * C++ does not have this abstraction and hence we simply have come up\r
+ * with a fancy name for "void *".  See the note in ANTLRTokenStream.h on\r
+ * the "behavior" of ANTLRTokenStream.\r
+ */\r
+\r
+class ANTLRParser;          // MR1\r
+\r
+class DllExportPCCTS ANTLRTokenBuffer {\r
+protected:\r
+  ANTLRTokenStream *input;        // where do I get tokens\r
+  int buffer_size;\r
+  int chunk_size;\r
+  int num_markers;\r
+  int k;                          // Need at least this many tokens in buffer\r
+  _ANTLRTokenPtr *buffer;  // buffer used for arbitrary lookahead\r
+  _ANTLRTokenPtr *tp;        // pts into buffer; current token ptr\r
+  _ANTLRTokenPtr *last;      // pts to last valid token in buffer\r
+  _ANTLRTokenPtr *next;      // place to put token from getANTLRToken()\r
+  _ANTLRTokenPtr *end_of_buffer;\r
+  /* when you try to write a token past this and there are no markers\r
+     set, then move k-1 tokens back to the beginning of the buffer.\r
+     We want to stay away from the end of the buffer because we have\r
+     to extend it if a marker is set and we reach the end (we cannot\r
+     move tokens to the beginning of the buffer in this case).\r
+   */\r
+  _ANTLRTokenPtr *threshold;\r
+  unsigned char _deleteTokens;\r
+\r
+  // This function is filled in by the subclass; it initiates fetch of input\r
+  virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }\r
+  void makeRoom();\r
+  void extendBuffer();\r
+\r
+public:\r
+  ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);\r
+  virtual ~ANTLRTokenBuffer();\r
+  virtual _ANTLRTokenPtr getToken();\r
+  virtual void rewind(int pos);\r
+  virtual int mark();\r
+  virtual _ANTLRTokenPtr bufferedToken(int i);\r
+\r
+  void noGarbageCollectTokens()  { _deleteTokens=0; }\r
+  void garbageCollectTokens()    { _deleteTokens=1; }\r
+\r
+  virtual int bufferSize() { return buffer_size; }\r
+  virtual int minTokens() { return k; }\r
+  virtual void setMinTokens(int k_new) { k = k_new; }\r
+\r
+  virtual void panic(const char *msg) { exit(PCCTS_EXIT_FAILURE); } /* MR20 const */\r
+protected:            // MR1\r
+  ANTLRParser  *parser;      // MR1\r
+public:              // MR1\r
+  ANTLRParser  *setParser(ANTLRParser *p);  // MR1\r
+  ANTLRParser  *getParser();          // MR1\r
+    ANTLRTokenStream *getLexer() const {    // MR12\r
+      return input;}                        // MR12\r
+};\r
+\r
+#endif\r