View Javadoc

    1   /*
    2    * PropsTokenMarker.java - Java props/DOS INI token marker
    3    * Copyright (C) 1998, 1999 Slava Pestov
    4    *
    5    * You may use and modify this package for any purpose. Redistribution is
    6    * permitted, in both source and binary form, provided that this notice
    7    * remains intact in all source distributions of this package.
    8    */
    9
    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  {
    22  	public static final byte VALUE = Token.INTERNAL_FIRST;
    23
    24  	public byte markTokensImpl(byte token, Segment line, int lineIndex)
    25  	{
    26  		char[] array = line.array;
    27  		int offset = line.offset;
    28  		int lastOffset = offset;
    29  		int length = line.count + offset;
    30  loop:		for(int i = offset; i < length; i++)
    31  		{
    32  			int i1 = (i+1);
    33
    34  			switch(token)
    35  			{
    36  			case Token.NULL:
    37  				switch(array[i])
    38  				{
    39  				case '#': case ';':
    40  					if(i == offset)
    41  					{
    42  						addToken(line.count,Token.COMMENT1);
    43  						lastOffset = length;
    44  						break loop;
    45  					}
    46  					break;
    47  				case '[':
    48  					if(i == offset)
    49  					{
    50  						addToken(i - lastOffset,token);
    51  						token = Token.KEYWORD2;
    52  						lastOffset = i;
    53  					}
    54  					break;
    55  				case '=':
    56  					addToken(i - lastOffset,Token.KEYWORD1);
    57  					token = VALUE;
    58  					lastOffset = i;
    59  					break;
    60  				}
    61  				break;
    62  			case Token.KEYWORD2:
    63  				if(array[i] == ']')
    64  				{
    65  					addToken(i1 - lastOffset,token);
    66  					token = Token.NULL;
    67  					lastOffset = i1;
    68  				}
    69  				break;
    70  			case VALUE:
    71  				break;
    72  			default:
    73  				throw new InternalError("Invalid state: "
    74  					+ token);
    75  			}
    76  		}
    77  		if(lastOffset != length)
    78  			addToken(length - lastOffset,Token.NULL);
    79  		return Token.NULL;
    80  	}
    81
    82  	public boolean supportsMultilineTokens()
    83  	{
    84  		return false;
    85  	}
    86  }