01: package net.xoetrope.builder.editor.syntaxhighlight;
02:
03: /*
04: * PropsTokenMarker.java - Java props/DOS INI token marker
05: * Copyright (C) 1998, 1999 Slava Pestov
06: *
07: * You may use and modify this package for any purpose. Redistribution is
08: * permitted, in both source and binary form, provided that this notice
09: * remains intact in all source distributions of this package.
10: */
11:
12: import javax.swing.text.Segment;
13:
14: /**
15: * Java properties/DOS INI token marker.
16: *
17: * @author Slava Pestov
18: * @version $Id: PropsTokenMarker.java,v 1.22 2005/01/05 17:20:49 luano Exp $
19: */
20: public class PropsTokenMarker extends TokenMarker {
21: public static final byte VALUE = Token.INTERNAL_FIRST;
22:
23: public byte markTokensImpl(byte token, Segment line, int lineIndex) {
24: char[] array = line.array;
25: int offset = line.offset;
26: int lastOffset = offset;
27: int length = line.count + offset;
28: loop: for (int i = offset; i < length; i++) {
29: int i1 = (i + 1);
30:
31: switch (token) {
32: case Token.NULL:
33: switch (array[i]) {
34: case '#':
35: case ';':
36: if (i == offset) {
37: addToken(line.count, Token.COMMENT1);
38: lastOffset = length;
39: break loop;
40: }
41: break;
42: case '[':
43: if (i == offset) {
44: addToken(i - lastOffset, token);
45: token = Token.KEYWORD2;
46: lastOffset = i;
47: }
48: break;
49: case '=':
50: addToken(i - lastOffset, Token.KEYWORD1);
51: token = VALUE;
52: lastOffset = i;
53: break;
54: }
55: break;
56: case Token.KEYWORD2:
57: if (array[i] == ']') {
58: addToken(i1 - lastOffset, token);
59: token = Token.NULL;
60: lastOffset = i1;
61: }
62: break;
63: case VALUE:
64: break;
65: default:
66: throw new InternalError("Invalid state: " + token);
67: }
68: }
69: if (lastOffset != length)
70: addToken(length - lastOffset, Token.NULL);
71: return Token.NULL;
72: }
73:
74: public boolean supportsMultilineTokens() {
75: return false;
76: }
77: }
|