/*
* PropsTokenMarker.java - Java props/DOS INI token marker
* Copyright (C) 1998, 1999 Slava Pestov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.gjt.sp.jedit.syntax;
import javax.swing.text.Segment;
/**
* Java properties/DOS INI token marker.
*
* @author Slava Pestov
* @version $Id: PropsTokenMarker.java,v 1.2 2002/03/26 18:21:01 tonyj Exp $
*/
public class PropsTokenMarker extends TokenMarker
{
public static final byte VALUE = Token.INTERNAL_FIRST;
public byte markTokensImpl(byte token, Segment line, int lineIndex)
{
int offset = line.offset;
int lastOffset = offset;
int length = line.count + offset;
loop: for(int i = offset; i < length; i++)
{
switch(line.array[i])
{
case '#': case ';':
if(i == offset && token == Token.NULL)
{
addToken(line.count,Token.COMMENT1);
lastOffset = length;
break loop;
}
break;
case '[':
if(i == offset && token == Token.NULL)
{
token = Token.KEYWORD2;
addToken(i - lastOffset,Token.NULL);
lastOffset = i;
}
break;
case ']':
if(token == Token.KEYWORD2)
{
token = Token.NULL;
addToken((i+1) - lastOffset,
Token.KEYWORD2);
lastOffset = (i+1);
}
break;
case '=':
if(token == Token.NULL)
{
token = VALUE; // Can't have [...] after =
addToken(i - lastOffset,Token.KEYWORD1);
lastOffset = i;
}
break;
}
}
if(lastOffset != length)
addToken(length - lastOffset,Token.NULL);
return Token.NULL;
}
}
/*
* ChangeLog:
* $Log: PropsTokenMarker.java,v $
* Revision 1.2 2002/03/26 18:21:01 tonyj
* Remove spurious carriage returns
*
* Revision 1.1.1.1 1999/10/21 01:48:13 tonyj
* Initial import from SourceSafe
*
* Revision 1.3 1999/04/19 05:38:20 sp
* Syntax API changes
*
* Revision 1.2 1999/03/12 23:51:00 sp
* Console updates, uncomment removed cos it's too buggy, cvs log tags added
*
*/
Ads help maintain this website.