1 /* Generated By:JavaCC: Do not edit this line. Token.cc Version 7.0 */ 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 */ getValue()20 void * Token::getValue() { 21 return nullptr; 22 } 23 24 /** 25 * No-argument constructor 26 */ Token()27 Token::Token() : 28 beginLine(0), beginColumn(0), endLine(0), endColumn(0) 29 { 30 this->next = nullptr; 31 this->specialToken = nullptr; 32 } 33 34 /** 35 * Constructs a new token for the specified Image. 36 */ Token(int kind)37 Token::Token(int kind) : 38 beginLine(0), beginColumn(0), endLine(0), endColumn(0) 39 { 40 this->kind = kind; 41 this->next = nullptr; 42 this->specialToken = nullptr; 43 } 44 45 /** 46 * Constructs a new token for the specified Image and Kind. 47 */ Token(int kind,const JJString & image)48 Token::Token(int kind, const JJString& image) 49 : beginLine(0), beginColumn(0), endLine(0), endColumn(0) 50 { 51 this->kind = kind; 52 this->image = image; 53 this->next = nullptr; 54 this->specialToken = nullptr; 55 } 56 57 /** 58 * Returns the image. 59 */ toString()60 const JJString& Token::toString() 61 { 62 return image; 63 } 64 65 /** 66 * Returns a new Token object, by default. However, if you want, you 67 * can create and return subclass objects based on the value of ofKind. 68 * Simply add the cases to the switch for all those special cases. 69 * For example, if you have a subclass of Token called IDToken that 70 * you want to create if ofKind is ID, simply add something like : 71 * 72 * case MyParserConstants.ID : return new IDToken(ofKind, image); 73 * 74 * to the following switch statement. Then you can cast matchedToken 75 * variable to the appropriate type and use sit in your lexical actions. 76 */ newToken(int ofKind,const JJString & image)77 Token *Token::newToken(int ofKind, const JJString& image) 78 { 79 switch(ofKind) 80 { 81 default : return new Token(ofKind, image); 82 } 83 } 84 newToken(int ofKind)85 Token *Token::newToken(int ofKind) 86 { 87 return newToken(ofKind, JJString()); 88 } 89 ~Token()90 Token::~Token() { 91 if (specialToken) delete specialToken; 92 this->kind = 0; 93 this->next = nullptr; 94 this->specialToken = nullptr; 95 } 96 97 } 98 } 99 /* JavaCC - OriginalChecksum=01131f3b3906a670aa8fee6224233701 (do not edit this line) */ 100