e52c95dd31fe40acb6c0c773d6798ef939af9206
[nemo.git] / nemo-impl / src / main / java / org / opendaylight / nemo / user / vnspacemanager / languagestyle / NEMOParse / Token.java
1 /*\r
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */\r
9 /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */\r
10 package org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse;\r
11 \r
12 /**\r
13  * Describes the input token stream.\r
14  */\r
15 \r
16 public class Token implements java.io.Serializable {\r
17 \r
18   /**\r
19    * The version identifier for this Serializable class.\r
20    * Increment only if the <i>serialized</i> form of the\r
21    * class changes.\r
22    */\r
23   private static final long serialVersionUID = 1L;\r
24 \r
25   /**\r
26    * An integer that describes the kind of this token.  This numbering\r
27    * system is determined by JavaCCParser, and a table of these numbers is\r
28    * stored in the file ...Constants.java.\r
29    */\r
30   public int kind;\r
31 \r
32   /** The line number of the first character of this Token. */\r
33   public int beginLine;\r
34   /** The column number of the first character of this Token. */\r
35   public int beginColumn;\r
36   /** The line number of the last character of this Token. */\r
37   public int endLine;\r
38   /** The column number of the last character of this Token. */\r
39   public int endColumn;\r
40 \r
41   /**\r
42    * The string image of the token.\r
43    */\r
44   public String image;\r
45 \r
46   /**\r
47    * A reference to the next regular (non-special) token from the input\r
48    * stream.  If this is the last token from the input stream, or if the\r
49    * token manager has not read tokens beyond this one, this field is\r
50    * set to null.  This is true only if this token is also a regular\r
51    * token.  Otherwise, see below for a description of the contents of\r
52    * this field.\r
53    */\r
54   public Token next;\r
55 \r
56   /**\r
57    * This field is used to access special tokens that occur prior to this\r
58    * token, but after the immediately preceding regular (non-special) token.\r
59    * If there are no such special tokens, this field is set to null.\r
60    * When there are more than one such special token, this field refers\r
61    * to the last of these special tokens, which in turn refers to the next\r
62    * previous special token through its specialToken field, and so on\r
63    * until the first special token (whose specialToken field is null).\r
64    * The next fields of special tokens refer to other special tokens that\r
65    * immediately follow it (without an intervening regular token).  If there\r
66    * is no such token, this field is null.\r
67    */\r
68   public Token specialToken;\r
69 \r
70   /**\r
71    * An optional attribute value of the Token.\r
72    * Tokens which are not used as syntactic sugar will often contain\r
73    * meaningful values that will be used later on by the compiler or\r
74    * interpreter. This attribute value is often different from the image.\r
75    * Any subclass of Token that actually wants to return a non-null value can\r
76    * override this method as appropriate.\r
77    */\r
78   public Object getValue() {\r
79     return null;\r
80   }\r
81 \r
82   /**\r
83    * No-argument constructor\r
84    */\r
85   public Token() {}\r
86 \r
87   /**\r
88    * Constructs a new token for the specified Image.\r
89    */\r
90   public Token(int kind)\r
91   {\r
92     this(kind, null);\r
93   }\r
94 \r
95   /**\r
96    * Constructs a new token for the specified Image and Kind.\r
97    */\r
98   public Token(int kind, String image)\r
99   {\r
100     this.kind = kind;\r
101     this.image = image;\r
102   }\r
103 \r
104   /**\r
105    * Returns the image.\r
106    */\r
107   public String toString()\r
108   {\r
109     return image;\r
110   }\r
111 \r
112   /**\r
113    * Returns a new Token object, by default. However, if you want, you\r
114    * can create and return subclass objects based on the value of ofKind.\r
115    * Simply add the cases to the switch for all those special cases.\r
116    * For example, if you have a subclass of Token called IDToken that\r
117    * you want to create if ofKind is ID, simply add something like :\r
118    *\r
119    *    case MyParserConstants.ID : return new IDToken(ofKind, image);\r
120    *\r
121    * to the following switch statement. Then you can cast matchedToken\r
122    * variable to the appropriate type and use sit in your lexical actions.\r
123    */\r
124   public static Token newToken(int ofKind, String image)\r
125   {\r
126     switch(ofKind)\r
127     {\r
128       default : return new Token(ofKind, image);\r
129     }\r
130   }\r
131 \r
132   public static Token newToken(int ofKind)\r
133   {\r
134     return newToken(ofKind, null);\r
135   }\r
136 \r
137 }\r
138 /* JavaCC - OriginalChecksum=dc8b83e991d3e41cf255b23a7a4d3774 (do not edit this line) */\r