mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 16:26:11 +02:00
Scanner2 - Allow escaped newlines within identifiers.
This commit is contained in:
parent
96ddf17ee8
commit
6f274623f2
1 changed files with 13 additions and 3 deletions
|
@ -634,6 +634,13 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
++len;
|
++len;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if( c == '\\' && bufferPos[bufferStackPos] + 1 < buffer.length && buffer[ bufferPos[bufferStackPos] + 1 ] == '\n')
|
||||||
|
{
|
||||||
|
// escaped newline
|
||||||
|
++bufferPos[bufferStackPos];
|
||||||
|
len += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,8 +678,9 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tokenType = keywords.get(buffer, start, len);
|
int tokenType = keywords.get(buffer, start, len);
|
||||||
|
char [] result = removedEscapedNewline( CharArrayUtils.extract( buffer, start, len ) );
|
||||||
if (tokenType == keywords.undefined)
|
if (tokenType == keywords.undefined)
|
||||||
return new ImagedToken(IToken.tIDENTIFIER, new String(buffer, start, len));
|
return new ImagedToken(IToken.tIDENTIFIER, new String( result));
|
||||||
return new SimpleToken(tokenType);
|
return new SimpleToken(tokenType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,7 +1196,6 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
|
|
||||||
if( encounteredMultilineComment )
|
if( encounteredMultilineComment )
|
||||||
text = removeMultilineCommentFromBuffer( text );
|
text = removeMultilineCommentFromBuffer( text );
|
||||||
if( CharArrayUtils.indexOf( '\n', text ) != -1 )
|
|
||||||
text = removedEscapedNewline( text );
|
text = removedEscapedNewline( text );
|
||||||
|
|
||||||
// Throw it in
|
// Throw it in
|
||||||
|
@ -1198,11 +1205,14 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
: new FunctionStyleMacro(name, text, arglist));
|
: new FunctionStyleMacro(name, text, arglist));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param text
|
* @param text
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private char[] removedEscapedNewline(char[] text) {
|
private char[] removedEscapedNewline(char[] text) {
|
||||||
|
if( CharArrayUtils.indexOf( '\n', text ) == -1 )
|
||||||
|
return text;
|
||||||
char [] result = new char[ text.length ];
|
char [] result = new char[ text.length ];
|
||||||
Arrays.fill( result, ' ');
|
Arrays.fill( result, ' ');
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue