svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.utils / src / main / java / org / gvsig / utils / console / jedit / Token.java @ 40561
History | View | Annotate | Download (4.29 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.utils.console.jedit; |
25 |
/*
|
26 |
* Token.java - Generic token
|
27 |
* Copyright (C) 1998, 1999 Slava Pestov
|
28 |
*
|
29 |
* You may use and modify this package for any purpose. Redistribution is
|
30 |
* permitted, in both source and binary form, provided that this notice
|
31 |
* remains intact in all source distributions of this package.
|
32 |
*/
|
33 |
|
34 |
/**
|
35 |
* A linked list of tokens. Each token has three fields - a token
|
36 |
* identifier, which is a byte value that can be looked up in the
|
37 |
* array returned by <code>SyntaxDocument.getColors()</code>
|
38 |
* to get a color value, a length value which is the length of the
|
39 |
* token in the text, and a pointer to the next token in the list.
|
40 |
*
|
41 |
* @author Slava Pestov
|
42 |
* @version $Id$
|
43 |
*/
|
44 |
public class Token |
45 |
{ |
46 |
/**
|
47 |
* Normal text token id. This should be used to mark
|
48 |
* normal text.
|
49 |
*/
|
50 |
public static final byte NULL = 0; |
51 |
|
52 |
/**
|
53 |
* Comment 1 token id. This can be used to mark a comment.
|
54 |
*/
|
55 |
public static final byte COMMENT1 = 1; |
56 |
|
57 |
/**
|
58 |
* Comment 2 token id. This can be used to mark a comment.
|
59 |
*/
|
60 |
public static final byte COMMENT2 = 2; |
61 |
|
62 |
|
63 |
/**
|
64 |
* Literal 1 token id. This can be used to mark a string
|
65 |
* literal (eg, C mode uses this to mark "..." literals)
|
66 |
*/
|
67 |
public static final byte LITERAL1 = 3; |
68 |
|
69 |
/**
|
70 |
* Literal 2 token id. This can be used to mark an object
|
71 |
* literal (eg, Java mode uses this to mark true, false, etc)
|
72 |
*/
|
73 |
public static final byte LITERAL2 = 4; |
74 |
|
75 |
/**
|
76 |
* Label token id. This can be used to mark labels
|
77 |
* (eg, C mode uses this to mark ...: sequences)
|
78 |
*/
|
79 |
public static final byte LABEL = 5; |
80 |
|
81 |
/**
|
82 |
* Keyword 1 token id. This can be used to mark a
|
83 |
* keyword. This should be used for general language
|
84 |
* constructs.
|
85 |
*/
|
86 |
public static final byte KEYWORD1 = 6; |
87 |
|
88 |
/**
|
89 |
* Keyword 2 token id. This can be used to mark a
|
90 |
* keyword. This should be used for preprocessor
|
91 |
* commands, or variables.
|
92 |
*/
|
93 |
public static final byte KEYWORD2 = 7; |
94 |
|
95 |
/**
|
96 |
* Keyword 3 token id. This can be used to mark a
|
97 |
* keyword. This should be used for data types.
|
98 |
*/
|
99 |
public static final byte KEYWORD3 = 8; |
100 |
|
101 |
/**
|
102 |
* Operator token id. This can be used to mark an
|
103 |
* operator. (eg, SQL mode marks +, -, etc with this
|
104 |
* token type)
|
105 |
*/
|
106 |
public static final byte OPERATOR = 9; |
107 |
|
108 |
/**
|
109 |
* Invalid token id. This can be used to mark invalid
|
110 |
* or incomplete tokens, so the user can easily spot
|
111 |
* syntax errors.
|
112 |
*/
|
113 |
public static final byte INVALID = 10; |
114 |
|
115 |
/**
|
116 |
* The total number of defined token ids.
|
117 |
*/
|
118 |
public static final byte ID_COUNT = 11; |
119 |
|
120 |
/**
|
121 |
* The first id that can be used for internal state
|
122 |
* in a token marker.
|
123 |
*/
|
124 |
public static final byte INTERNAL_FIRST = 100; |
125 |
|
126 |
/**
|
127 |
* The last id that can be used for internal state
|
128 |
* in a token marker.
|
129 |
*/
|
130 |
public static final byte INTERNAL_LAST = 126; |
131 |
|
132 |
/**
|
133 |
* The token type, that along with a length of 0
|
134 |
* marks the end of the token list.
|
135 |
*/
|
136 |
public static final byte END = 127; |
137 |
|
138 |
/**
|
139 |
* The length of this token.
|
140 |
*/
|
141 |
public int length; |
142 |
|
143 |
/**
|
144 |
* The id of this token.
|
145 |
*/
|
146 |
public byte id; |
147 |
|
148 |
/**
|
149 |
* The next token in the linked list.
|
150 |
*/
|
151 |
public Token next;
|
152 |
|
153 |
/**
|
154 |
* Creates a new token.
|
155 |
* @param length The length of the token
|
156 |
* @param id The id of the token
|
157 |
*/
|
158 |
public Token(int length, byte id) |
159 |
{ |
160 |
this.length = length;
|
161 |
this.id = id;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Returns a string representation of this token.
|
166 |
*/
|
167 |
public String toString() |
168 |
{ |
169 |
return "[id=" + id + ",length=" + length + "]"; |
170 |
} |
171 |
} |