5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
24 * Written by Russell Quong June 30, 1995
25 * Adapted by Terence Parr to ANTLR stuff
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
36 #include "pccts_stdio.h"
40 // pointer to a reference counted object
41 // robust in that an unused ANTLRTokenPtr can point to NULL.
43 class ANTLRAbstractToken
;
45 class DllExportPCCTS ANTLRTokenPtr
{
47 ANTLRTokenPtr(ANTLRAbstractToken
*addr
=NULL
){ptr_
= addr
; ref();}
48 ANTLRTokenPtr(const ANTLRTokenPtr
&lhs
) {ptr_
= lhs
.ptr_
; lhs
.ref();}
51 // use ANTLRTokenPtr as a pointer to ANTLRToken
53 // 8-Apr-97 MR1 Make operator -> a const member function
54 // as well as some other member functions
56 ANTLRAbstractToken
*operator-> () const { return ptr_
; } // MR1
59 // Fix suggested by Andreas Magnusson
60 // (Andreas.Magnusson@mailbox.swipnet.se)
61 void operator = (const ANTLRTokenPtr
& lhs
); // MR1
62 void operator = (ANTLRAbstractToken
*addr
);
63 int operator != (const ANTLRTokenPtr
&q
) const // MR1 // MR11 unsigned -> int
64 { return this->ptr_
!= q
.ptr_
; }
65 int operator == (const ANTLRTokenPtr
&q
) const // MR1 // MR11 unsigned -> int
66 { return this->ptr_
== q
.ptr_
; }
67 int operator == (const ANTLRAbstractToken
*addr
) const // MR11
68 { return this->ptr_
== addr
; }
69 int operator != (const ANTLRAbstractToken
*addr
) const // MR11
70 { return this->ptr_
!= addr
; }
76 ANTLRAbstractToken
*ptr_
;
79 //typedef ANTLRTokenPtr _ANTLRTokenPtr;
82 * Since you cannot redefine operator->() to return one of the user's
83 * token object types, we must down cast. This is a drag. Here's
84 * a macro that helps. template: "mytoken(a-smart-ptr)->myfield".
86 #define mytoken(tk) ((ANTLRToken *)(tk.operator->()))