int yylengthLength, int yylength, Object lexerState) {
assert (phpTokens.size() == 0 || getLastToken().getEnd() == start)
&& tokensIterator == null;
if (phpTokens.size() > 0) {
ContextRegion lastContextRegion = (ContextRegion) phpTokens
.get(phpTokens.size() - 1);
if (deprecatedKeywordAfter(lastContextRegion.getType())) {
if (isKeyword(yylex)) {
yylex = PHPRegionTypes.PHP_STRING;
}
}
}
// if state was change - we add a new token and add state
if (lexerStateChanges.size() == 0
|| !getLastChange().state.equals(lexerState)) {
int textLength = (AbstractPhpLexer.WHITESPACE.equals(yylex)) ? 0
: yylengthLength;
final ContextRegion contextRegion = new ContextRegion(yylex, start,
textLength, yylength);
phpTokens.addLast(contextRegion);
lexerStateChanges.addLast(new LexerStateChange(
(LexerState) lexerState, contextRegion));
return;
}
assert phpTokens.size() > 0;
// if we can only adjust the previous token size
if (yylex == AbstractPhpLexer.WHITESPACE) {
final ITextRegion last = phpTokens.getLast();
last.adjustLength(yylength);
} else { // else - add as a new token
final ContextRegion contextRegion = new ContextRegion(yylex, start,
yylengthLength, yylength);
phpTokens.addLast(contextRegion);
}
}