Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/memoire/jedit/JEditToken.java


1   
2   package com.memoire.jedit;
3   import com.memoire.jedit.*;
4   
5   /*
6    * JEditToken.java - Generic token
7    * Copyright (C) 1998, 1999 Slava Pestov
8    *
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
22   */
23  
24  
25  /**
26   * A linked list of tokens. Each token has three fields - a token
27   * identifier, which is a byte value that can be looked up in the
28   * array returned by <code>JEditSyntaxDocument.getColors()</code>
29   * to get a color value, a length value which is the length of the
30   * token in the text, and a pointer to the next token in the list.
31   *
32   * @author Slava Pestov
33   * @version $Id: JEditToken.java,v 1.3 2001/07/25 17:39:05 desnoix Exp $
34   */
35  public class JEditToken
36  {
37    /**
38     * Normal text token id. This should be used to mark
39     * normal text.
40     */
41    public static final byte NULL = 0;
42  
43    /**
44     * Comment 1 token id. This can be used to mark a comment.
45     */
46    public static final byte COMMENT1 = 1;
47  
48    /**
49     * Comment 2 token id. This can be used to mark a comment.
50     */
51    public static final byte COMMENT2 = 2;
52  
53    
54    /**
55     * Literal 1 token id. This can be used to mark a string
56     * literal (eg, C mode uses this to mark "..." literals)
57     */
58    public static final byte LITERAL1 = 3;
59  
60    /**
61     * Literal 2 token id. This can be used to mark an object
62     * literal (eg, Java mode uses this to mark true, false, etc)
63     */
64    public static final byte LITERAL2 = 4;
65  
66    /**
67     * Label token id. This can be used to mark labels
68     * (eg, C mode uses this to mark ...: sequences)
69     */
70    public static final byte LABEL = 5;
71  
72    /**
73     * Keyword 1 token id. This can be used to mark a
74     * keyword. This should be used for general language
75     * constructs.
76     */
77    public static final byte KEYWORD1 = 6;
78  
79    /**
80     * Keyword 2 token id. This can be used to mark a
81     * keyword. This should be used for preprocessor
82     * commands, or variables.
83     */
84    public static final byte KEYWORD2 = 7;
85  
86    /**
87     * Keyword 3 token id. This can be used to mark a
88     * keyword. This should be used for data types.
89     */
90    public static final byte KEYWORD3 = 8;
91  
92    /**
93     * Operator token id. This can be used to mark an
94     * operator. (eg, SQL mode marks +, -, etc with this
95     * token type)
96     */
97    public static final byte OPERATOR = 9;
98  
99    /**
100    * Invalid token id. This can be used to mark invalid
101    * or incomplete tokens, so the user can easily spot
102    * syntax errors.
103    */
104   public static final byte INVALID = 10;
105 
106   /**
107    * The total number of defined token ids.
108    */
109   public static final byte ID_COUNT = 11;
110 
111   /**
112    * The first id that can be used for internal state
113    * in a token marker.
114    */
115   public static final byte INTERNAL_FIRST = 100;
116 
117   /**
118    * The last id that can be used for internal state
119    * in a token marker.
120    */
121   public static final byte INTERNAL_LAST = 126;
122 
123   /**
124    * The token type, that along with a length of 0
125    * marks the end of the token list.
126    */
127   public static final byte END = 127;
128 
129   /**
130    * The length of this token.
131    */
132   public int length;
133 
134   /**
135    * The id of this token.
136    */
137   public byte id;
138 
139   /**
140    * The next token in the linked list.
141    */
142   public JEditToken next;
143 
144   /**
145    * Creates a new token.
146    * @param length The length of the token
147    * @param id The id of the token
148    */
149   public JEditToken(int length, byte id)
150   {
151     this.length = length;
152     this.id = id;
153   }
154 
155   /**
156    * Returns a string representation of this token.
157    */
158   public String toString()
159   {
160     return "[id=" + id + ",length=" + length + "]";
161   }
162 }
163 
164 /*
165  * ChangeLog:
166  * $Log: JEditToken.java,v $
167  * Revision 1.3  2001/07/25 17:39:05  desnoix
168  * *** empty log message ***
169  *
170  * Revision 1.2  2001/06/21 18:50:04  desnoix
171  * *** empty log message ***
172  *
173  * Revision 1.1  2001/06/13 19:48:18  desnoix
174  * *** empty log message ***
175  *
176  * Revision 1.11  1999/06/05 00:22:58  sp
177  * LGPL'd syntax package
178  *
179  * Revision 1.10  1999/04/22 06:03:26  sp
180  * Syntax colorizing change
181  *
182  * Revision 1.9  1999/04/19 05:38:20  sp
183  * Syntax API changes
184  *
185  * Revision 1.8  1999/04/01 04:13:00  sp
186  * Bug fixing for 1.5final
187  *
188  * Revision 1.7  1999/03/13 08:50:39  sp
189  * Syntax colorizing updates and cleanups, general code reorganizations
190  *
191  * Revision 1.6  1999/03/12 23:51:00  sp
192  * Console updates, uncomment removed cos it's too buggy, cvs log tags added
193  *
194  */