]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.h
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / CodeTools / TianoTools / Pccts / h / ATokenBuffer.h
CommitLineData
878ddf1f 1/* ANTLRTokenBuffer.h\r
2 *\r
3 * SOFTWARE RIGHTS\r
4 *\r
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or\r
7 * company may do whatever they wish with source code distributed with\r
8 * PCCTS or the code generated by PCCTS, including the incorporation of\r
9 * PCCTS, or its output, into commerical software.\r
10 *\r
11 * We encourage users to develop software with PCCTS. However, we do ask\r
12 * that credit is given to us for developing PCCTS. By "credit",\r
13 * we mean that if you incorporate our source code into one of your\r
14 * programs (commercial product, research project, or otherwise) that you\r
15 * acknowledge this fact somewhere in the documentation, research report,\r
16 * etc... If you like PCCTS and have developed a nice tool with the\r
17 * output, please mention that you developed it using PCCTS. In\r
18 * addition, we ask that this header remain intact in our source code.\r
19 * As long as these guidelines are kept, we expect to continue enhancing\r
20 * this system and expect to make other tools available as they are\r
21 * completed.\r
22 *\r
23 * ANTLR 1.33\r
24 * Terence Parr\r
25 * Parr Research Corporation\r
26 * with Purdue University and AHPCRC, University of Minnesota\r
27 * 1989-2000\r
28 */\r
29\r
30#ifndef ATOKENBUFFER_H_GATE\r
31#define ATOKENBUFFER_H_GATE\r
32\r
33#include "pcctscfg.h"\r
34\r
35#include "pccts_stdlib.h"\r
36\r
37PCCTS_NAMESPACE_STD\r
38\r
39#include ATOKEN_H\r
40#include ATOKENSTREAM_H\r
41\r
42/*\r
43 * The parser is "attached" to an ANTLRTokenBuffer via interface\r
44 * functions: getToken() and bufferedToken(). The object that actually\r
45 * consumes characters and constructs tokens is connected to the\r
46 * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();\r
47 * where ANTLRTokenStream is really just a behavior (class with no data).\r
48 * C++ does not have this abstraction and hence we simply have come up\r
49 * with a fancy name for "void *". See the note in ANTLRTokenStream.h on\r
50 * the "behavior" of ANTLRTokenStream.\r
51 */\r
52\r
53class ANTLRParser; // MR1\r
54\r
55class DllExportPCCTS ANTLRTokenBuffer {\r
56protected:\r
57 ANTLRTokenStream *input; // where do I get tokens\r
58 int buffer_size;\r
59 int chunk_size;\r
60 int num_markers;\r
61 int k; // Need at least this many tokens in buffer\r
62 _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead\r
63 _ANTLRTokenPtr *tp; // pts into buffer; current token ptr\r
64 _ANTLRTokenPtr *last; // pts to last valid token in buffer\r
65 _ANTLRTokenPtr *next; // place to put token from getANTLRToken()\r
66 _ANTLRTokenPtr *end_of_buffer;\r
67 /* when you try to write a token past this and there are no markers\r
68 set, then move k-1 tokens back to the beginning of the buffer.\r
69 We want to stay away from the end of the buffer because we have\r
70 to extend it if a marker is set and we reach the end (we cannot\r
71 move tokens to the beginning of the buffer in this case).\r
72 */\r
73 _ANTLRTokenPtr *threshold;\r
74 unsigned char _deleteTokens;\r
75\r
76 // This function is filled in by the subclass; it initiates fetch of input\r
77 virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }\r
78 void makeRoom();\r
79 void extendBuffer();\r
80\r
81public:\r
82 ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);\r
83 virtual ~ANTLRTokenBuffer();\r
84 virtual _ANTLRTokenPtr getToken();\r
85 virtual void rewind(int pos);\r
86 virtual int mark();\r
87 virtual _ANTLRTokenPtr bufferedToken(int i);\r
88\r
89 void noGarbageCollectTokens() { _deleteTokens=0; }\r
90 void garbageCollectTokens() { _deleteTokens=1; }\r
91\r
92 virtual int bufferSize() { return buffer_size; }\r
93 virtual int minTokens() { return k; }\r
94 virtual void setMinTokens(int k_new) { k = k_new; }\r
95\r
96 virtual void panic(const char *msg); /* MR20 const */\r
97\r
98 virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
99\r
100protected: // MR1\r
101 ANTLRParser *parser; // MR1\r
102public: // MR1\r
103 ANTLRParser *setParser(ANTLRParser *p); // MR1\r
104 ANTLRParser *getParser(); // MR1\r
105 ANTLRTokenStream *getLexer() const { // MR12\r
106 return input;} // MR12\r
107};\r
108\r
109#endif\r