]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /* ATokPtr.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 | * Written by Russell Quong June 30, 1995\r | |
25 | * Adapted by Terence Parr to ANTLR stuff\r | |
26 | * Parr Research Corporation\r | |
27 | * with Purdue University and AHPCRC, University of Minnesota\r | |
28 | * 1989-2000\r | |
29 | */\r | |
30 | \r | |
31 | #ifndef ATokPtr_h\r | |
32 | #define ATokPtr_h\r | |
33 | \r | |
34 | #include "pcctscfg.h"\r | |
35 | \r | |
36 | #include "pccts_stdio.h"\r | |
37 | \r | |
38 | PCCTS_NAMESPACE_STD\r | |
39 | \r | |
40 | // pointer to a reference counted object\r | |
41 | // robust in that an unused ANTLRTokenPtr can point to NULL.\r | |
42 | \r | |
43 | class ANTLRAbstractToken;\r | |
44 | \r | |
45 | class DllExportPCCTS ANTLRTokenPtr {\r | |
46 | public:\r | |
47 | ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}\r | |
48 | ANTLRTokenPtr(const ANTLRTokenPtr &lhs) {ptr_ = lhs.ptr_; lhs.ref();}\r | |
49 | ~ANTLRTokenPtr();\r | |
50 | \r | |
51 | // use ANTLRTokenPtr as a pointer to ANTLRToken\r | |
52 | //\r | |
53 | // 8-Apr-97 MR1 Make operator -> a const member function\r | |
54 | // as well as some other member functions\r | |
55 | //\r | |
56 | ANTLRAbstractToken *operator-> () const { return ptr_; } // MR1\r | |
57 | //\r | |
58 | // 7-Apr-97 133MR1\r | |
59 | // Fix suggested by Andreas Magnusson\r | |
60 | // (Andreas.Magnusson@mailbox.swipnet.se)\r | |
61 | void operator = (const ANTLRTokenPtr & lhs); // MR1\r | |
62 | void operator = (ANTLRAbstractToken *addr);\r | |
63 | int operator != (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int\r | |
64 | { return this->ptr_ != q.ptr_; }\r | |
65 | int operator == (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int\r | |
66 | { return this->ptr_ == q.ptr_; }\r | |
67 | int operator == (const ANTLRAbstractToken *addr) const // MR11\r | |
68 | { return this->ptr_ == addr; }\r | |
69 | int operator != (const ANTLRAbstractToken *addr) const // MR11\r | |
70 | { return this->ptr_ != addr; }\r | |
71 | \r | |
72 | void ref() const;\r | |
73 | void deref();\r | |
74 | \r | |
75 | protected:\r | |
76 | ANTLRAbstractToken *ptr_;\r | |
77 | };\r | |
78 | \r | |
79 | //typedef ANTLRTokenPtr _ANTLRTokenPtr;\r | |
80 | \r | |
81 | /*\r | |
82 | * Since you cannot redefine operator->() to return one of the user's\r | |
83 | * token object types, we must down cast. This is a drag. Here's\r | |
84 | * a macro that helps. template: "mytoken(a-smart-ptr)->myfield".\r | |
85 | */\r | |
86 | #define mytoken(tk) ((ANTLRToken *)(tk.operator->()))\r | |
87 | \r | |
88 | #endif\r |