Token.cc
Go to the documentation of this file.
1 /* Generated By:JavaCC: Do not edit this line. Token.cc Version 6.2 */
2 /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,TOKEN_INCLUDES=,TOKEN_EXTENDS= */
3 #include "Token.h"
4 
5 namespace vhdl {
6 namespace parser {
7 
8 /**
9  * Describes the input token stream.
10  */
11 
12  /**
13  * An optional attribute value of the Token.
14  * Tokens which are not used as syntactic sugar will often contain
15  * meaningful values that will be used later on by the compiler or
16  * interpreter. This attribute value is often different from the image.
17  * Any subclass of Token that actually wants to return a non-NULL value can
18  * override this method as appropriate.
19  */
20  void * Token::getValue() {
21  return NULL;
22  }
23 
24  /**
25  * No-argument constructor
26  */
28  this->next = NULL;
29  this->specialToken = NULL;
30  }
31 
32  /**
33  * Constructs a new token for the specified Image.
34  */
36  {
37  this->kind = kind;
38  this->next = NULL;
39  this->specialToken = NULL;
40  }
41 
42  /**
43  * Constructs a new token for the specified Image and Kind.
44  */
46  {
47  this->kind = kind;
48  this->image = image;
49  this->next = NULL;
50  this->specialToken = NULL;
51  }
52 
53  /**
54  * Returns the image.
55  */
57  {
58  return image;
59  }
60 
61  /**
62  * Returns a new Token object, by default. However, if you want, you
63  * can create and return subclass objects based on the value of ofKind.
64  * Simply add the cases to the switch for all those special cases.
65  * For example, if you have a subclass of Token called IDToken that
66  * you want to create if ofKind is ID, simply add something like :
67  *
68  * case MyParserConstants.ID : return new IDToken(ofKind, image);
69  *
70  * to the following switch statement. Then you can cast matchedToken
71  * variable to the appropriate type and use sit in your lexical actions.
72  */
74  {
75  switch(ofKind)
76  {
77  default : return new Token(ofKind, image);
78  }
79  }
80 
81  Token *Token::newToken(int ofKind)
82  {
83  return newToken(ofKind, JAVACC_STRING_TYPE((JAVACC_CHAR_TYPE*)""));
84  }
85 
87  if (specialToken) delete specialToken;
88  }
89 
90 }
91 }
92 /* JavaCC - OriginalChecksum=dcb0f64486aa6455ae5af05d6bb539ec (do not edit this line) */
Token * next
Definition: Token.h:48
#define JAVACC_STRING_TYPE
Definition: JavaCC.h:16
JAVACC_STRING_TYPE image
Definition: Token.h:38
#define JAVACC_CHAR_TYPE
Definition: JavaCC.h:12
static Token * newToken(int ofKind, JAVACC_STRING_TYPE image)
Definition: Token.cc:73
virtual ~Token()
Definition: Token.cc:86
JAVACC_STRING_TYPE toString()
Definition: Token.cc:56
void * getValue()
Definition: Token.cc:20
Token * specialToken
Definition: Token.h:62