01: /*
02: * PropsTokenMarker.java - Java props/DOS INI token marker
03: * Copyright (C) 1998, 1999 Slava Pestov
04: *
05: * You may use and modify this package for any purpose. Redistribution is
06: * permitted, in both source and binary form, provided that this notice
07: * remains intact in all source distributions of this package.
08: */
09:
10: package org.syntax.jedit.tokenmarker;
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.9 1999/12/13 03:40:30 sp 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: }
|