11 package net.sf.gridarta.textedit.textarea.tokenmarker;
13 import javax.swing.text.Segment;
27 private final boolean js;
40 final char[] array = line.array;
41 final int offset = line.offset;
44 final int length = line.count + offset;
45 boolean backslash =
false;
47 byte currentToken = token;
49 for (
int i = offset; i <
length; i++) {
52 final char c = array[i];
54 backslash = !backslash;
58 switch (currentToken) {
63 addToken(i - lastOffset, currentToken);
81 addToken(i - lastOffset, currentToken);
92 addToken(i1 - lastOffset, currentToken);
102 addToken(i1 - lastOffset, currentToken);
113 addToken(i + 3 - lastOffset, currentToken);
162 if (length - i > 1) {
166 if (array[i1] ==
'/') {
171 }
else if (array[i1] ==
'*') {
179 if (!Character.isLetterOrDigit(c) && c !=
'_') {
189 }
else if (c ==
'"') {
200 }
else if (c ==
'\'') {
210 if (c ==
'*' && length - i > 1 && array[i1] ==
'/') {
220 throw new InternalError(
"Invalid state: " + currentToken);
224 switch (currentToken) {
242 addToken(length - lastOffset, currentToken);
249 private void doKeyword(
final Segment line,
final int i) {
250 final int i1 = i + 1;
253 final byte
id = keywords.
lookup(line, lastKeyword, len);
255 if (lastKeyword != lastOffset) {
int length
The number of lines in the model being tokenized.
static final byte COMMENT2
Comment 2 token id.
static final byte JAVASCRIPT
static final byte INTERNAL_FIRST
The first id that can be used for internal state in a token marker.
void doKeyword(final Segment line, final int i)
byte lookup(final Segment text, final int offset, final int length)
Looks up a key.
static final byte COMMENT1
Comment 1 token id.
void addToken(final int length, final byte id)
Adds a token to the token list.
static final byte LITERAL1
Literal 1 token id.
static KeywordMap getJavaScriptKeywords()
Base package of all Gridarta classes.
Class with several utility functions used by jEdit's syntax colorizing subsystem. ...
final KeywordMap keywords
This package contains the other part of the script editor.
static final byte LITERAL2
Literal 2 token id.
static boolean regionMatches(final boolean ignoreCase, final Segment text, final int offset, final CharSequence match)
Checks if a sub-region of a.
Maps (parts of) Segments to.
static final byte NULL
Normal text token id.
static final byte KEYWORD2
Keyword 2 token id.
A token marker that splits lines of text into tokens.
static final byte KEYWORD1
Keyword 1 token id.
HTMLTokenMarker(final boolean js)
byte markTokensImpl(final byte token, final Segment line)
static final byte INVALID
Invalid token id.