ensureCapacity(lineIndex);
	public Token markTokens(Segment line, int lineIndex)	{		ensureCapacity(lineIndex);		lastToken = null;		String token = lineIndex == 0 ? null : lineInfo[lineIndex - 1];		int offset = line.offset;		int lastOffset = offset;		int length = line.count + offset;		boolean backslash = false;loop:		for(int i = offset; i < length; i++)		{			char c = line.array[i];			// if a backslash is followed immediately			// by a non-alpha character, the command at			// the non-alpha char. If we have a backslash,			// some text, and then a non-alpha char,			// the command ends before the non-alpha char.			if(Character.isLetter(c))			{				backslash = false;			}			else			{				if(backslash)				{					// \<non alpha>					// we skip over this character,					// hence the `continue'					backslash = false;					if(token == Token.KEYWORD2 || token == EDFORMULA)						token = Token.KEYWORD2;					addToken((i+1) - lastOffset,token);					lastOffset = i+1;					if(token == Token.KEYWORD1)						token = null;					continue;				}				else				{					//\blah<non alpha>					// we leave the character in					// the stream, and it's not					// part of the command token					if(token == BDFORMULA || token == EDFORMULA)						token = Token.KEYWORD2;					addToken(i - lastOffset,token);					if(token == Token.KEYWORD1)						token = null;					lastOffset = i;				}			}			switch(c)			{			case '%':				if(backslash)				{					backslash = false;					break;				}				addToken(i - lastOffset,token);				addToken(length - i,Token.COMMENT1);				lastOffset = length;				break loop;			case '\\':				backslash = true;				if(token == null)				{					token = Token.KEYWORD1;					addToken(i - lastOffset,null);					lastOffset = i;				}				break;			case '$':				backslash = false;				if(token == null) // singe $				{					token = Token.KEYWORD2;					addToken(i - lastOffset,null);					lastOffset = i;				}				else if(token == Token.KEYWORD1) // \...$				{					token = Token.KEYWORD2;					addToken(i - lastOffset,Token.KEYWORD1);					lastOffset = i;				}				else if(token == Token.KEYWORD2) // $$aaa				{					if(i - lastOffset == 1 && line.array[i-1] == '$')					{						token = BDFORMULA;						break;					}					token = null;					addToken((i+1) - lastOffset,Token.KEYWORD2);					lastOffset = i + 1;				}				else if(token == BDFORMULA) // $$aaa$				{					token = EDFORMULA;				}				else if(token == EDFORMULA) // $$aaa$$				{					token = null;					addToken((i+1) - lastOffset,Token.KEYWORD2);					lastOffset = i + 1;				}				break;			}		}		if(lastOffset != length)			addToken(length - lastOffset,token == BDFORMULA				|| token == EDFORMULA ? Token.KEYWORD2 :				token);		lineInfo[lineIndex] = (token != Token.KEYWORD1 ? token : null);		if(lastToken != null)		{			lastToken.nextValid = false;			return firstToken;		}		else			return null;	}