1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Patch for David Daoust: Removed extraneous StringBuffer objects from the Scanner.

This commit is contained in:
John Camelon 2004-05-19 15:35:06 +00:00
parent 823cb6c755
commit 9ebf2c9909
3 changed files with 291 additions and 220 deletions

View file

@ -68,6 +68,7 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
public class Scanner implements IScanner { public class Scanner implements IScanner {
static ScannerStringBuffer strbuff = new ScannerStringBuffer(100);
protected static final String HEX_PREFIX = "0x"; //$NON-NLS-1$ protected static final String HEX_PREFIX = "0x"; //$NON-NLS-1$
private static final ObjectMacroDescriptor CPLUSPLUS_MACRO = new ObjectMacroDescriptor( __CPLUSPLUS, "199711L"); //$NON-NLS-1$ private static final ObjectMacroDescriptor CPLUSPLUS_MACRO = new ObjectMacroDescriptor( __CPLUSPLUS, "199711L"); //$NON-NLS-1$
private static final ObjectMacroDescriptor STDC_VERSION_MACRO = new ObjectMacroDescriptor( __STDC_VERSION__, "199001L"); //$NON-NLS-1$ private static final ObjectMacroDescriptor STDC_VERSION_MACRO = new ObjectMacroDescriptor( __STDC_VERSION__, "199001L"); //$NON-NLS-1$
@ -314,11 +315,11 @@ public class Scanner implements IScanner {
if( !file.exists() && path.indexOf('\"') != -1 ) if( !file.exists() && path.indexOf('\"') != -1 )
{ {
StringTokenizer tokenizer = new StringTokenizer(path, "\"" ); //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(path, "\"" ); //$NON-NLS-1$
StringBuffer buffer = new StringBuffer(path.length() ); strbuff.startString();
while( tokenizer.hasMoreTokens() ){ while( tokenizer.hasMoreTokens() ){
buffer.append( tokenizer.nextToken() ); strbuff.append( tokenizer.nextToken() );
} }
file = new File( buffer.toString() ); file = new File( strbuff.toString() );
} }
if( file.exists() && file.isDirectory() ) if( file.exists() && file.isDirectory() )
@ -366,7 +367,7 @@ public class Scanner implements IScanner {
int c = getChar(); int c = getChar();
if (c == '\n') if (c == '\n')
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer(); strbuff.startString();
boolean inString = false; boolean inString = false;
boolean inChar = false; boolean inChar = false;
while (true) { while (true) {
@ -377,14 +378,14 @@ public class Scanner implements IScanner {
&& (c != '"' || ( c == '"' && inChar ) ) && (c != '"' || ( c == '"' && inChar ) )
&& (c != '\'' || ( c == '\'' && inString ) ) && (c != '\'' || ( c == '\'' && inString ) )
&& (c != NOCHAR)) { && (c != NOCHAR)) {
buffer.append((char) c); strbuff.append(c);
c = getChar( true ); c = getChar( true );
} }
if (c == '/') { if (c == '/') {
//only care about comments outside of a quote //only care about comments outside of a quote
if( inString || inChar ){ if( inString || inChar ){
buffer.append( (char) c ); strbuff.append( c );
c = getChar( true ); c = getChar( true );
continue; continue;
} }
@ -404,18 +405,18 @@ public class Scanner implements IScanner {
continue; continue;
} else { } else {
// we are not in a comment // we are not in a comment
buffer.append((char) c); strbuff.append(c);
c = next; c = next;
continue; continue;
} }
} else if( c == '"' ){ } else if( c == '"' ){
inString = !inString; inString = !inString;
buffer.append((char) c); strbuff.append(c);
c = getChar( true ); c = getChar( true );
continue; continue;
} else if( c == '\'' ){ } else if( c == '\'' ){
inChar = !inChar; inChar = !inChar;
buffer.append((char) c); strbuff.append(c);
c = getChar( true ); c = getChar( true );
continue; continue;
} else if( c == '\\' ){ } else if( c == '\\' ){
@ -428,9 +429,9 @@ public class Scanner implements IScanner {
} else if( c == '\n' ){ } else if( c == '\n' ){
c = getChar(true); c = getChar(true);
} else { } else {
buffer.append('\\'); strbuff.append('\\');
if( c == '"' || c == '\'' ){ if( c == '"' || c == '\'' ){
buffer.append((char)c); strbuff.append(c);
c = getChar( true ); c = getChar( true );
} }
} }
@ -441,7 +442,7 @@ public class Scanner implements IScanner {
} }
} }
return buffer.toString(); return strbuff.toString();
} }
protected void skipOverTextUntilNewline() throws ScannerException { protected void skipOverTextUntilNewline() throws ScannerException {
@ -481,26 +482,26 @@ public class Scanner implements IScanner {
} }
protected String getNextIdentifier() throws ScannerException { protected String getNextIdentifier() throws ScannerException {
StringBuffer buffer = new StringBuffer(); strbuff.startString();
skipOverWhitespace(); skipOverWhitespace();
int c = getChar(); int c = getChar();
if (((c >= 'a') && (c <= 'z')) if (((c >= 'a') && (c <= 'z'))
|| ((c >= 'A') && (c <= 'Z')) | (c == '_')) { || ((c >= 'A') && (c <= 'Z')) | (c == '_')) {
buffer.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
while (((c >= 'a') && (c <= 'z')) while (((c >= 'a') && (c <= 'z'))
|| ((c >= 'A') && (c <= 'Z')) || ((c >= 'A') && (c <= 'Z'))
|| ((c >= '0') && (c <= '9')) || ((c >= '0') && (c <= '9'))
|| (c == '_')) { || (c == '_')) {
buffer.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
} }
} }
ungetChar(c); ungetChar(c);
return buffer.toString(); return strbuff.toString();
} }
protected void handleInclusion(String fileName, boolean useIncludePaths, int beginOffset, int startLine, int nameOffset, int nameLine, int endOffset, int endLine ) throws ScannerException { protected void handleInclusion(String fileName, boolean useIncludePaths, int beginOffset, int startLine, int nameOffset, int nameLine, int endOffset, int endLine ) throws ScannerException {
@ -863,15 +864,15 @@ public class Scanner implements IScanner {
return nextToken( true ); return nextToken( true );
} }
public boolean pasteIntoInputStream(StringBuffer buff) throws ScannerException, EndOfFileException public boolean pasteIntoInputStream(String buff) throws ScannerException, EndOfFileException
{ {
// we have found ## in the input stream -- so save the results // we have found ## in the input stream -- so save the results
if( lookAheadForTokenPasting() ) if( lookAheadForTokenPasting() )
{ {
if( storageBuffer == null ) if( storageBuffer == null )
storageBuffer = buff; storageBuffer = new StringBuffer(buff);
else else
storageBuffer.append( buff.toString() ); storageBuffer.append( buff );
return true; return true;
} }
@ -928,7 +929,7 @@ public class Scanner implements IScanner {
public IToken processStringLiteral(boolean wideLiteral) throws ScannerException, EndOfFileException public IToken processStringLiteral(boolean wideLiteral) throws ScannerException, EndOfFileException
{ {
int beginOffset = getCurrentOffset(); int beginOffset = getCurrentOffset();
StringBuffer buff = new StringBuffer(); strbuff.startString();
int beforePrevious = NOCHAR; int beforePrevious = NOCHAR;
int previous = '"'; int previous = '"';
int c = getChar(true); int c = getChar(true);
@ -947,7 +948,7 @@ public class Scanner implements IScanner {
return null; return null;
} }
buff.append((char) c); strbuff.append(c);
beforePrevious = previous; beforePrevious = previous;
previous = c; previous = c;
c = getChar(true); c = getChar(true);
@ -958,7 +959,8 @@ public class Scanner implements IScanner {
//If the next token is going to be a string as well, we need to concatenate //If the next token is going to be a string as well, we need to concatenate
//it with this token. This will be recursive for as many strings as need to be concatenated //it with this token. This will be recursive for as many strings as need to be concatenated
IToken returnToken = newToken( type, buff.toString()); String result = strbuff.toString();
IToken returnToken = newToken( type, result );
IToken next = null; IToken next = null;
try{ try{
@ -966,7 +968,7 @@ public class Scanner implements IScanner {
if ( next != null && if ( next != null &&
(next.getType() == IToken.tSTRING || (next.getType() == IToken.tSTRING ||
next.getType() == IToken.tLSTRING )) { next.getType() == IToken.tLSTRING )) {
buff.append( next.getImage() ); returnToken.setImage(result + next.getImage());
} }
else else
cachedToken = next; cachedToken = next;
@ -974,8 +976,6 @@ public class Scanner implements IScanner {
next = null; next = null;
} }
returnToken.setImage(buff.toString());
currentToken = returnToken; currentToken = returnToken;
returnToken.setNext( null ); returnToken.setNext( null );
return returnToken; return returnToken;
@ -991,19 +991,20 @@ public class Scanner implements IScanner {
// int x = F2; // int x = F2;
int beginOffset = getCurrentOffset(); int beginOffset = getCurrentOffset();
StringBuffer buff = new StringBuffer(); strbuff.startString();
boolean hex = false; boolean hex = false;
boolean floatingPoint = ( c == '.' ) ? true : false; boolean floatingPoint = ( c == '.' ) ? true : false;
boolean firstCharZero = ( c== '0' )? true : false; boolean firstCharZero = ( c== '0' )? true : false;
buff.append((char) c); strbuff.append(c);
int firstChar = c;
c = getChar(); c = getChar();
if( ! firstCharZero && floatingPoint && !(c >= '0' && c <= '9') ){ if( ! firstCharZero && floatingPoint && !(c >= '0' && c <= '9') ){
//if pasting, there could actually be a float here instead of just a . //if pasting, there could actually be a float here instead of just a .
if( buff.toString().equals( "." ) ){ //$NON-NLS-1$ if( firstChar == '.' ) {
if( c == '*' ){ if( c == '*' ){
return newConstantToken( IToken.tDOTSTAR ); return newConstantToken( IToken.tDOTSTAR );
} else if( c == '.' ){ } else if( c == '.' ){
@ -1023,7 +1024,7 @@ public class Scanner implements IScanner {
// c = getChar(); // c = getChar();
// continue; // continue;
} }
buff.append( (char)c ); strbuff.append(c);
hex = true; hex = true;
c = getChar(); c = getChar();
} }
@ -1031,13 +1032,13 @@ public class Scanner implements IScanner {
while ((c >= '0' && c <= '9') while ((c >= '0' && c <= '9')
|| (hex || (hex
&& ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))) { && ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))) {
buff.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
} }
if( c == '.' ) if( c == '.' )
{ {
buff.append( (char)c); strbuff.append(c);
floatingPoint = true; floatingPoint = true;
c= getChar(); c= getChar();
@ -1045,7 +1046,7 @@ public class Scanner implements IScanner {
|| (hex || (hex
&& ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))) && ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))))
{ {
buff.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
} }
} }
@ -1055,27 +1056,27 @@ public class Scanner implements IScanner {
{ {
if( ! floatingPoint ) floatingPoint = true; if( ! floatingPoint ) floatingPoint = true;
// exponent type for floating point // exponent type for floating point
buff.append((char)c); strbuff.append(c);
c = getChar(); c = getChar();
// optional + or - // optional + or -
if( c == '+' || c == '-' ) if( c == '+' || c == '-' )
{ {
buff.append( (char)c ); strbuff.append(c );
c = getChar(); c = getChar();
} }
// digit sequence of exponent part // digit sequence of exponent part
while ((c >= '0' && c <= '9') ) while ((c >= '0' && c <= '9') )
{ {
buff.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
} }
// optional suffix // optional suffix
if( c == 'l' || c == 'L' || c == 'f' || c == 'F' ) if( c == 'l' || c == 'L' || c == 'f' || c == 'F' )
{ {
buff.append( (char)c ); strbuff.append(c );
c = getChar(); c = getChar();
} }
} else { } else {
@ -1103,13 +1104,12 @@ public class Scanner implements IScanner {
} }
ungetChar( c ); ungetChar( c );
String result = strbuff.toString();
if( pasting && pasteIntoInputStream(buff)) if( pasting && pasteIntoInputStream(result))
return null; return null;
String result = buff.toString();
if( floatingPoint && result.equals(".") ) //$NON-NLS-1$ if( floatingPoint && result.equals(".") ) //$NON-NLS-1$
return newConstantToken( IToken.tDOT ); return newConstantToken( IToken.tDOT );
@ -1149,17 +1149,17 @@ public class Scanner implements IScanner {
return newConstantToken( tPOUND ); //$NON-NLS-1$ return newConstantToken( tPOUND ); //$NON-NLS-1$
} }
StringBuffer buff = new StringBuffer(); strbuff.startString();
buff.append('#'); strbuff.append('#');
while (((c >= 'a') && (c <= 'z')) while (((c >= 'a') && (c <= 'z'))
|| ((c >= 'A') && (c <= 'Z')) || (c == '_') ) { || ((c >= 'A') && (c <= 'Z')) || (c == '_') ) {
buff.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
} }
ungetChar(c); ungetChar(c);
String token = buff.toString(); String token = strbuff.toString();
if( isLimitReached() ) if( isLimitReached() )
handleCompletionOnPreprocessorDirective(token); handleCompletionOnPreprocessorDirective(token);
@ -1254,9 +1254,10 @@ public class Scanner implements IScanner {
if( ! restOfLine.equals( "" ) ) //$NON-NLS-1$ if( ! restOfLine.equals( "" ) ) //$NON-NLS-1$
{ {
StringBuffer buffer = new StringBuffer("#endif "); //$NON-NLS-1$ strbuff.startString();
buffer.append( restOfLine ); strbuff.append("#endif "); //$NON-NLS-1$
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true ); strbuff.append( restOfLine );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, strbuff.toString(), beginningOffset, false, true );
} }
try{ try{
passOnToClient = scannerData.getBranchTracker().poundEndif(); passOnToClient = scannerData.getBranchTracker().poundEndif();
@ -1328,11 +1329,12 @@ public class Scanner implements IScanner {
} }
catch( EmptyStackException ese ) catch( EmptyStackException ese )
{ {
StringBuffer buffer = new StringBuffer( token ); strbuff.startString();
buffer.append( ' ' ); strbuff.append( token );
buffer.append( elifExpression ); strbuff.append( ' ' );
strbuff.append( elifExpression );
handleProblem( IProblem.PREPROCESSOR_UNBALANCE_CONDITION, handleProblem( IProblem.PREPROCESSOR_UNBALANCE_CONDITION,
buffer.toString(), strbuff.toString(),
beginningOffset, beginningOffset,
false, true ); false, true );
} }
@ -1368,30 +1370,32 @@ public class Scanner implements IScanner {
String remainderOfLine = String remainderOfLine =
getRestOfPreprocessorLine().trim(); getRestOfPreprocessorLine().trim();
if (!remainderOfLine.equals("")) { //$NON-NLS-1$ if (!remainderOfLine.equals("")) { //$NON-NLS-1$
StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$ strbuff.startString();
buffer.append( remainderOfLine ); strbuff.append( "# "); //$NON-NLS-1$
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true); strbuff.append( remainderOfLine );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, strbuff.toString(), beginningOffset, false, true);
} }
return null; return null;
default : default :
StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$ strbuff.startString();
buffer.append( token ); strbuff.append( "# "); //$NON-NLS-1$
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true ); strbuff.append( token );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, strbuff.toString(), beginningOffset, false, true );
return null; return null;
} }
} }
// buff contains \\u or \\U // buff contains \\u or \\U
protected StringBuffer processUniversalCharacterName( StringBuffer buff ) throws ScannerException protected boolean processUniversalCharacterName() throws ScannerException
{ {
// first octet is mandatory // first octet is mandatory
for( int i = 0; i < 4; ++i ) for( int i = 0; i < 4; ++i )
{ {
int c = getChar(); int c = getChar();
if( ! isHex( c )) if( ! isHex( c ))
return null; return false;
buff.append( (char) c ); strbuff.append( c );
} }
Vector v = new Vector(); Vector v = new Vector();
@ -1409,14 +1413,14 @@ public class Scanner implements IScanner {
if( v.size() == 4 ) if( v.size() == 4 )
{ {
for( int i = 0; i < 4; ++i ) for( int i = 0; i < 4; ++i )
buff.append( ((Character)v.get(i)).charValue()); strbuff.append( ((Character)v.get(i)).charValue());
} }
else else
{ {
for( int i = v.size() - 1; i >= 0; --i ) for( int i = v.size() - 1; i >= 0; --i )
ungetChar( ((Character)v.get(i)).charValue() ); ungetChar( ((Character)v.get(i)).charValue() );
} }
return buff; return true;
} }
/** /**
@ -1455,7 +1459,7 @@ public class Scanner implements IScanner {
} }
} }
protected IToken processKeywordOrIdentifier(StringBuffer buff, boolean pasting) throws ScannerException, EndOfFileException protected IToken processKeywordOrIdentifier(boolean pasting) throws ScannerException, EndOfFileException
{ {
int baseOffset = lastContext.getOffset() - 1; int baseOffset = lastContext.getOffset() - 1;
@ -1468,7 +1472,7 @@ public class Scanner implements IScanner {
while ( ( scannerExtension.offersDifferentIdentifierCharacters() && while ( ( scannerExtension.offersDifferentIdentifierCharacters() &&
scannerExtension.isValidIdentifierCharacter(c) ) || scannerExtension.isValidIdentifierCharacter(c) ) ||
isValidIdentifierCharacter(c) ) { isValidIdentifierCharacter(c) ) {
buff.append((char) c); strbuff.append(c);
c = getChar(); c = getChar();
if (c == '\\') { if (c == '\\') {
c = consumeNewlineAfterSlash(); c = consumeNewlineAfterSlash();
@ -1479,10 +1483,10 @@ public class Scanner implements IScanner {
int next = getChar(); int next = getChar();
if( next == 'u' || next == 'U') if( next == 'u' || next == 'U')
{ {
buff.append( '\\'); strbuff.append( '\\');
buff.append( (char)next ); strbuff.append( next );
buff = processUniversalCharacterName(buff); if( !processUniversalCharacterName() )
if( buff == null ) return null; return null;
continue; // back to top of loop continue; // back to top of loop
} }
ungetChar( next ); ungetChar( next );
@ -1492,7 +1496,7 @@ public class Scanner implements IScanner {
ungetChar(c); ungetChar(c);
String ident = buff. toString(); String ident = strbuff. toString();
if (ident.equals(DEFINED)) if (ident.equals(DEFINED))
return newToken(IToken.tINTEGER, handleDefinedMacro()); return newToken(IToken.tINTEGER, handleDefinedMacro());
@ -1511,7 +1515,7 @@ public class Scanner implements IScanner {
return null; return null;
} }
if( pasting && pasteIntoInputStream(buff)) if( pasting && pasteIntoInputStream(ident))
return null; return null;
Object tokenTypeObject; Object tokenTypeObject;
@ -1761,9 +1765,10 @@ public class Scanner implements IScanner {
case ':' : return newConstantToken(IToken.tLBRACKET); case ':' : return newConstantToken(IToken.tLBRACKET);
default : default :
StringBuffer buff = new StringBuffer( "<"); //$NON-NLS-1$ strbuff.startString();
buff.append( (char)c); strbuff.append('<');
String query =buff.toString(); strbuff.append(c);
String query = strbuff.toString();
if( scannerExtension.isExtensionOperator( scannerData.getLanguage(), query ) ) if( scannerExtension.isExtensionOperator( scannerData.getLanguage(), query ) )
return newExtensionToken( scannerExtension.createExtensionToken( scannerData, query )); return newExtensionToken( scannerExtension.createExtensionToken( scannerData, query ));
ungetChar(c); ungetChar(c);
@ -1784,9 +1789,10 @@ public class Scanner implements IScanner {
} }
case '=' : return newConstantToken(IToken.tGTEQUAL); case '=' : return newConstantToken(IToken.tGTEQUAL);
default : default :
StringBuffer buff = new StringBuffer( ">"); //$NON-NLS-1$ strbuff.startString();
buff.append( (char)c); strbuff.append('>');
String query =buff.toString(); strbuff.append( (char)c);
String query = strbuff.toString();
if( scannerExtension.isExtensionOperator( scannerData.getLanguage(), query ) ) if( scannerExtension.isExtensionOperator( scannerData.getLanguage(), query ) )
return newExtensionToken( scannerExtension.createExtensionToken( scannerData, query )); return newExtensionToken( scannerExtension.createExtensionToken( scannerData, query ));
ungetChar(c); ungetChar(c);
@ -1880,7 +1886,9 @@ public class Scanner implements IScanner {
{ {
// This is not a wide literal -- it must be a token or keyword // This is not a wide literal -- it must be a token or keyword
ungetChar(c); ungetChar(c);
token = processKeywordOrIdentifier(new StringBuffer( "L"), pasting);//$NON-NLS-1$ strbuff.startString();
strbuff.append('L');
token = processKeywordOrIdentifier(pasting);
} }
if (token == null) if (token == null)
{ {
@ -1941,9 +1949,9 @@ public class Scanner implements IScanner {
case 'Y': case 'Y':
case 'Z': case 'Z':
case '_': case '_':
StringBuffer sBuffer = new StringBuffer( ); strbuff.startString();
sBuffer.append( (char) c ); strbuff.append( c );
token = processKeywordOrIdentifier(sBuffer, pasting); token = processKeywordOrIdentifier(pasting);
if (token == null) if (token == null)
{ {
c = getChar(); c = getChar();
@ -1977,9 +1985,9 @@ public class Scanner implements IScanner {
scannerExtension.isValidIdentifierStartCharacter(c) ) || scannerExtension.isValidIdentifierStartCharacter(c) ) ||
isValidIdentifierStartCharacter(c) ) isValidIdentifierStartCharacter(c) )
{ {
StringBuffer startBuffer = new StringBuffer( ); strbuff.startString();
startBuffer.append( (char) c ); strbuff.append( c );
token = processKeywordOrIdentifier(startBuffer, pasting); token = processKeywordOrIdentifier(pasting);
if (token == null) if (token == null)
{ {
c = getChar(); c = getChar();
@ -1990,19 +1998,19 @@ public class Scanner implements IScanner {
else if( c == '\\' ) else if( c == '\\' )
{ {
int next = getChar(); int next = getChar();
StringBuffer ucnBuffer = new StringBuffer( "\\");//$NON-NLS-1$ strbuff.startString();
ucnBuffer.append( (char) next ); strbuff.append( '\\');
strbuff.append( next );
if( next == 'u' || next =='U' ) if( next == 'u' || next =='U' )
{ {
StringBuffer secondBuffer = processUniversalCharacterName(ucnBuffer); if( !processUniversalCharacterName() )
if( secondBuffer == null )
{ {
handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead ); handleProblem( IProblem.SCANNER_BAD_CHARACTER, strbuff.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
c = getChar(); c = getChar();
continue; continue;
} }
token = processKeywordOrIdentifier( secondBuffer, pasting ); token = processKeywordOrIdentifier( pasting );
if (token == null) if (token == null)
{ {
c = getChar(); c = getChar();
@ -2011,7 +2019,7 @@ public class Scanner implements IScanner {
return token; return token;
} }
ungetChar( next ); ungetChar( next );
handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead ); handleProblem( IProblem.SCANNER_BAD_CHARACTER, strbuff.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
} }
handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead ); handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
@ -2153,7 +2161,7 @@ public class Scanner implements IScanner {
int beginOffset = getCurrentOffset(); int beginOffset = getCurrentOffset();
int type = wideLiteral ? IToken.tLCHAR : IToken.tCHAR; int type = wideLiteral ? IToken.tLCHAR : IToken.tCHAR;
StringBuffer buffer = new StringBuffer(); strbuff.startString();
int prev = c; int prev = c;
int prevPrev = c; int prevPrev = c;
c = getChar(true); c = getChar(true);
@ -2171,13 +2179,13 @@ public class Scanner implements IScanner {
// exit condition // exit condition
if ( ( c =='\'' ) && ( prev != '\\' || prevPrev == '\\' ) ) break; if ( ( c =='\'' ) && ( prev != '\\' || prevPrev == '\\' ) ) break;
buffer.append( (char)c); strbuff.append(c);
prevPrev = prev; prevPrev = prev;
prev = c; prev = c;
c = getChar(true); c = getChar(true);
} }
return newToken( type, buffer.toString()); return newToken( type, strbuff.toString());
} }
@ -2202,57 +2210,56 @@ public class Scanner implements IScanner {
{ {
int beginOffset = getCurrentOffset(); int beginOffset = getCurrentOffset();
int c = getChar(); int c = getChar();
StringBuffer tokenImage = new StringBuffer(); strbuff.startString();
try { try {
while (c != NOCHAR) { while (c != NOCHAR) {
if ((c == ' ') || (c == '\r') || (c == '\t') || (c == '\n')) {
if (tokenImage.length() > 0) throw endOfMacroToken;
c = getChar();
continue;
} else if (c == '"') {
if (tokenImage.length() > 0) throw endOfMacroToken;
// string
StringBuffer buff = new StringBuffer();
c = getChar(true);
for( ; ; )
{
if ( c =='"' ) break;
if( c == NOCHAR) break;
buff.append((char) c);
c = getChar(true);
}
if (c != NOCHAR )
{
return newToken( IToken.tSTRING, buff.toString());
}
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
c = getChar();
continue;
} else {
switch (c) { switch (c) {
case ' ' :
case '\r' :
case '\t' :
case '\n' :
if (strbuff.length() > 0) throw endOfMacroToken;
c = getChar();
continue;
case '"' :
if (strbuff.length() > 0) throw endOfMacroToken;
// string
strbuff.startString();
c = getChar(true);
for( ; ; )
{
if ( c =='"' ) break;
if( c == NOCHAR) break;
strbuff.append(c);
c = getChar(true);
}
if (c != NOCHAR )
{
return newToken( IToken.tSTRING, strbuff.toString());
}
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
c = getChar();
continue;
case '\'' : case '\'' :
if (tokenImage.length() > 0) throw endOfMacroToken; if (strbuff.length() > 0) throw endOfMacroToken;
return processCharacterLiteral( c, false ); return processCharacterLiteral( c, false );
case ',' : case ',' :
if (tokenImage.length() > 0) throw endOfMacroToken; if (strbuff.length() > 0) throw endOfMacroToken;
return newToken(IToken.tCOMMA, ","); //$NON-NLS-1$ return newToken(IToken.tCOMMA, ","); //$NON-NLS-1$
case '(' : case '(' :
if (tokenImage.length() > 0) throw endOfMacroToken; if (strbuff.length() > 0) throw endOfMacroToken;
return newToken(IToken.tLPAREN, "("); //$NON-NLS-1$ return newToken(IToken.tLPAREN, "("); //$NON-NLS-1$
case ')' : case ')' :
if (tokenImage.length() > 0) throw endOfMacroToken; if (strbuff.length() > 0) throw endOfMacroToken;
return newToken(IToken.tRPAREN, ")"); //$NON-NLS-1$ return newToken(IToken.tRPAREN, ")"); //$NON-NLS-1$
case '/' : case '/' :
if (tokenImage.length() > 0) throw endOfMacroToken; if (strbuff.length() > 0) throw endOfMacroToken;
c = getChar(); c = getChar();
switch (c) { switch (c) {
case '/' : case '/' :
@ -2264,23 +2271,22 @@ public class Scanner implements IScanner {
c = getChar(); c = getChar();
continue; continue;
default: default:
tokenImage.append('/'); strbuff.append('/');
continue; continue;
} }
default : default :
tokenImage.append((char)c); strbuff.append(c);
c = getChar(); c = getChar();
} }
} }
}
} catch (endOfMacroTokenException e) { } catch (endOfMacroTokenException e) {
// unget the first character after the end of token // unget the first character after the end of token
ungetChar(c); ungetChar(c);
} }
// return completed token // return completed token
if (tokenImage.length() > 0) { if (strbuff.length() > 0) {
return newToken(IToken.tIDENTIFIER, tokenImage.toString()); return newToken(IToken.tIDENTIFIER, strbuff.toString());
} }
// we're done // we're done
@ -2465,11 +2471,12 @@ public class Scanner implements IScanner {
throws ScannerException { throws ScannerException {
IExpressionParser parser = null; IExpressionParser parser = null;
StringBuffer expressionBuffer = new StringBuffer( expression ); strbuff.startString();
expressionBuffer.append( ';'); strbuff.append(expression);
strbuff.append(';');
IScanner trial = new Scanner( IScanner trial = new Scanner(
new StringReader(expressionBuffer.toString()), new StringReader(strbuff.toString()),
EXPRESSION, EXPRESSION,
scannerData.getPublicDefinitions(), scannerData.getPublicDefinitions(),
scannerData.getIncludePathNames(), scannerData.getIncludePathNames(),
@ -2579,9 +2586,10 @@ public class Scanner implements IScanner {
} }
catch( ScannerUtility.InclusionParseException ipe ) catch( ScannerUtility.InclusionParseException ipe )
{ {
StringBuffer potentialErrorLine = new StringBuffer( "#include "); //$NON-NLS-1$ strbuff.startString();
potentialErrorLine.append( includeLine ); strbuff.append( "#include "); //$NON-NLS-1$
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, potentialErrorLine.toString(), beginningOffset, false, true ); strbuff.append( includeLine );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, strbuff.toString(), beginningOffset, false, true );
return; return;
} }
@ -2686,11 +2694,12 @@ public class Scanner implements IScanner {
if( beginning != NO_OFFSET_LIMIT ) if( beginning != NO_OFFSET_LIMIT )
{ {
StringBuffer buffer = new StringBuffer( POUND_DEFINE ); strbuff.startString();
buffer.append( key ); strbuff.append( POUND_DEFINE );
buffer.append( ' ' ); strbuff.append( key );
buffer.append( replacementString ); strbuff.append( ' ' );
handleProblem( IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, buffer.toString(), strbuff.append( replacementString );
handleProblem( IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, strbuff.toString(),
beginning, false, true ); beginning, false, true );
return null; return null;
} }
@ -2737,7 +2746,7 @@ public class Scanner implements IScanner {
// identifier and the opening parenthesis // identifier and the opening parenthesis
int c = getChar(); int c = getChar();
if (c == '(') { if (c == '(') {
StringBuffer buffer = new StringBuffer(); strbuff.startString();
c = getChar(true); c = getChar(true);
while (c != ')') { while (c != ')') {
if( c == '\\' ){ if( c == '\\' ){
@ -2749,27 +2758,31 @@ public class Scanner implements IScanner {
c = getChar(); c = getChar();
continue; continue;
} }
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
ungetChar( c ); ungetChar( c );
potentialErrorMessage.append( buffer ); String line = strbuff.toString();
potentialErrorMessage.append( '\\'); strbuff.startString();
potentialErrorMessage.append( (char)c ); strbuff.append( POUND_DEFINE );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true); strbuff.append( line );
strbuff.append( '\\');
strbuff.append( c );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, strbuff.toString(), beginning, false, true);
return; return;
} else if( c == '\r' || c == '\n' || c == NOCHAR ){ } else if( c == '\r' || c == '\n' || c == NOCHAR ){
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE ); String line = strbuff.toString();
potentialErrorMessage.append( buffer ); strbuff.startString();
potentialErrorMessage.append( '\\'); strbuff.append( POUND_DEFINE );
potentialErrorMessage.append( (char)c ); strbuff.append( line );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true ); strbuff.append( '\\');
strbuff.append( c );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, strbuff.toString(), beginning, false, true );
return; return;
} }
buffer.append((char) c); strbuff.append(c);
c = getChar(true); c = getChar(true);
} }
String parameters = buffer.toString(); String parameters = strbuff.toString();
// replace StringTokenizer later -- not performant // replace StringTokenizer later -- not performant
StringTokenizer tokenizer = new StringTokenizer(parameters, ","); //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(parameters, ","); //$NON-NLS-1$
@ -2897,7 +2910,7 @@ public class Scanner implements IScanner {
// split params up into single arguments // split params up into single arguments
int nParen = 0; int nParen = 0;
Vector parameters = new Vector(); Vector parameters = new Vector();
StringBuffer parBuffer = new StringBuffer(); //$NON-NLS-1$ strbuff.startString();
for (int i = 0; i < params.length(); i++) { for (int i = 0; i < params.length(); i++) {
char c = params.charAt(i); char c = params.charAt(i);
switch (c) { switch (c) {
@ -2909,17 +2922,17 @@ public class Scanner implements IScanner {
break; break;
case ',' : case ',' :
if (nParen == 0) { if (nParen == 0) {
parameters.add(parBuffer.toString()); parameters.add(strbuff.toString());
parBuffer = new StringBuffer(); //$NON-NLS-1$ strbuff.startString();
continue; continue;
} }
break; break;
default : default :
break; break;
} }
parBuffer.append( c ); strbuff.append( c );
} }
parameters.add(parBuffer.toString()); parameters.add(strbuff.toString());
Vector parameterValues = new Vector(); Vector parameterValues = new Vector();
for (int i = 0; i < parameters.size(); i++) { for (int i = 0; i < parameters.size(); i++) {
@ -2935,7 +2948,7 @@ public class Scanner implements IScanner {
scannerExtension ); scannerExtension );
tokenizer.setThrowExceptionOnBadCharacterRead(false); tokenizer.setThrowExceptionOnBadCharacterRead(false);
IToken t = null; IToken t = null;
StringBuffer buffer = new StringBuffer(); StringBuffer strbuff = new StringBuffer();
boolean space = false; boolean space = false;
try { try {
@ -2948,26 +2961,26 @@ public class Scanner implements IScanner {
t = (forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false)); t = (forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false));
if (space) if (space)
buffer.append( ' ' ); strbuff.append( ' ' );
switch (t.getType()) { switch (t.getType()) {
case IToken.tSTRING : case IToken.tSTRING :
buffer.append('\"'); strbuff.append('\"');
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\"'); strbuff.append('\"');
break; break;
case IToken.tLSTRING : case IToken.tLSTRING :
buffer.append( "L\""); //$NON-NLS-1$ strbuff.append( "L\""); //$NON-NLS-1$
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\"'); strbuff.append('\"');
break; break;
case IToken.tCHAR : case IToken.tCHAR :
buffer.append('\''); strbuff.append('\'');
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\''); strbuff.append('\'');
break; break;
default : default :
buffer.append( t.getImage()); strbuff.append( t.getImage());
break; break;
} }
space = true; space = true;
@ -2975,7 +2988,7 @@ public class Scanner implements IScanner {
} }
catch (EndOfFileException e) { catch (EndOfFileException e) {
// Good // Good
parameterValues.add(buffer.toString()); parameterValues.add(strbuff.toString());
} }
} }
@ -3017,7 +3030,7 @@ public class Scanner implements IScanner {
int c = getChar(); int c = getChar();
if (c == '(') { if (c == '(') {
StringBuffer buffer = new StringBuffer(); strbuff.startString();
int bracketCount = 1; int bracketCount = 1;
c = getChar(); c = getChar();
@ -3029,21 +3042,21 @@ public class Scanner implements IScanner {
if(bracketCount == 0 || c == NOCHAR) if(bracketCount == 0 || c == NOCHAR)
break; break;
buffer.append((char) c); strbuff.append(c);
c = getChar( true ); c = getChar( true );
} }
// Position of the closing ')' // Position of the closing ')'
int endMacroOffset = lastContext.getOffset() - 1; int endMacroOffset = lastContext.getOffset() - 1;
String betweenTheBrackets = buffer.toString().trim(); String betweenTheBrackets = strbuff.toString().trim();
Vector parameterValues = getMacroParameters(betweenTheBrackets, false); Vector parameterValues = getMacroParameters(betweenTheBrackets, false);
Vector parameterValuesForStringizing = null; Vector parameterValuesForStringizing = null;
SimpleToken t = null; SimpleToken t = null;
// create a string that represents what needs to be tokenized // create a string that represents what needs to be tokenized
buffer = new StringBuffer();
List tokens = expansion.getTokenizedExpansion(); List tokens = expansion.getTokenizedExpansion();
List parameterNames = expansion.getParameters(); List parameterNames = expansion.getParameters();
@ -3054,6 +3067,8 @@ public class Scanner implements IScanner {
return; return;
} }
strbuff.startString();
int numberOfTokens = tokens.size(); int numberOfTokens = tokens.size();
for (int i = 0; i < numberOfTokens; ++i) { for (int i = 0; i < numberOfTokens; ++i) {
@ -3066,23 +3081,28 @@ public class Scanner implements IScanner {
if (index == -1 ) { if (index == -1 ) {
// not found // not found
// just add image to buffer // just add image to buffer
buffer.append(t.getImage() ); strbuff.append(t.getImage() );
} else { } else {
buffer.append( strbuff.append(
(String) parameterValues.elementAt(index) ); (String) parameterValues.elementAt(index) );
} }
} else if (t.getType() == tPOUND) { } else if (t.getType() == tPOUND) {
//next token should be a parameter which needs to be turned into //next token should be a parameter which needs to be turned into
//a string literal //a string literal
if( parameterValuesForStringizing == null) if( parameterValuesForStringizing == null)
{
String cache = strbuff.toString();
parameterValuesForStringizing = getMacroParameters(betweenTheBrackets, true); parameterValuesForStringizing = getMacroParameters(betweenTheBrackets, true);
strbuff.startString();
strbuff.append(cache);
}
t = (SimpleToken) tokens.get( ++i ); t = (SimpleToken) tokens.get( ++i );
int index = parameterNames.indexOf(t.getImage()); int index = parameterNames.indexOf(t.getImage());
if( index == -1 ){ if( index == -1 ){
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, expansion.getName(), getCurrentOffset(), false, true ); handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, expansion.getName(), getCurrentOffset(), false, true );
return; return;
} }
buffer.append('\"'); strbuff.append('\"');
String value = (String)parameterValuesForStringizing.elementAt(index); String value = (String)parameterValuesForStringizing.elementAt(index);
char val [] = value.toCharArray(); char val [] = value.toCharArray();
char ch; char ch;
@ -3094,39 +3114,39 @@ public class Scanner implements IScanner {
while( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){ while( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){
ch = val[++j]; ch = val[++j];
} }
buffer.append(' '); strbuff.append(' ');
} }
//a \ character is inserted before each " and \ //a \ character is inserted before each " and \
if( ch == '\"' || ch == '\\' ){ if( ch == '\"' || ch == '\\' ){
buffer.append('\\'); strbuff.append('\\');
buffer.append(ch); strbuff.append(ch);
} else { } else {
buffer.append(ch); strbuff.append(ch);
} }
} }
buffer.append('\"'); strbuff.append('\"');
} else { } else {
switch( t.getType() ) switch( t.getType() )
{ {
case IToken.tSTRING: case IToken.tSTRING:
buffer.append('\"'); strbuff.append('\"');
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\"'); strbuff.append('\"');
break; break;
case IToken.tLSTRING: case IToken.tLSTRING:
buffer.append("L\""); //$NON-NLS-1$ strbuff.append("L\""); //$NON-NLS-1$
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\"'); strbuff.append('\"');
break; break;
case IToken.tCHAR: case IToken.tCHAR:
buffer.append('\''); strbuff.append('\'');
buffer.append(t.getImage()); strbuff.append(t.getImage());
buffer.append('\''); strbuff.append('\'');
break; break;
default: default:
buffer.append(t.getImage()); strbuff.append(t.getImage());
break; break;
} }
} }
@ -3144,9 +3164,9 @@ public class Scanner implements IScanner {
if( t.getType() != tPOUNDPOUND && ! pastingNext ) if( t.getType() != tPOUNDPOUND && ! pastingNext )
if (i < (numberOfTokens-1)) // Do not append to the last one if (i < (numberOfTokens-1)) // Do not append to the last one
buffer.append( " " ); //$NON-NLS-1$ strbuff.append( ' ' );
} }
String finalString = buffer.toString(); String finalString = strbuff.toString();
try try
{ {
scannerData.getContextStack().updateMacroContext( scannerData.getContextStack().updateMacroContext(

View file

@ -0,0 +1,51 @@
package org.eclipse.cdt.internal.core.parser.scanner;
import org.eclipse.cdt.core.parser.IToken;
/**
* @author ddaoust
*
*/
public class ScannerStringBuffer {
private int current_size;
private char [] s_buff;
private int s_pos;
public ScannerStringBuffer(int initialSize) {
current_size = initialSize;
s_buff = new char[current_size];
int s_pos = 0;
}
public final void startString(){
s_pos = 0;
}
public final void append(int c) {
try {
s_buff[s_pos++]= (char)c;
}
catch (ArrayIndexOutOfBoundsException a)
{
int new_size = current_size*2;
char [] new_sbuf = new char[new_size];
for (int i = 0; i < current_size; i++)
new_sbuf[i] = s_buff[i];
new_sbuf[current_size] = (char)c;
current_size = new_size;
s_buff = new_sbuf;
}
}
public final void append(String s) {
int len = s.length();
for(int i=0; i < len; i++)
append(s.charAt(i));
}
public final void append(IToken t) {
append(t.getImage());
}
public final int length() {
return s_pos;
}
public final String toString() {
return String.valueOf(s_buff, 0, s_pos);
}
}

View file

@ -30,10 +30,7 @@ import org.eclipse.cdt.core.parser.extension.IScannerExtension;
*/ */
public class ScannerUtility { public class ScannerUtility {
/** static ScannerStringBuffer strbuff = new ScannerStringBuffer(100);
* @param string
* @return
*/
static String reconcilePath(String originalPath ) { static String reconcilePath(String originalPath ) {
if( originalPath == null ) return null; if( originalPath == null ) return null;
originalPath = removeQuotes( originalPath ); originalPath = removeQuotes( originalPath );
@ -53,15 +50,15 @@ public class ScannerUtility {
else else
results.add( segment ); results.add( segment );
} }
StringBuffer buffer = new StringBuffer(); strbuff.startString();
Iterator i = results.iterator(); Iterator i = results.iterator();
while( i.hasNext() ) while( i.hasNext() )
{ {
buffer.append( (String)i.next() ); strbuff.append( (String)i.next() );
if( i.hasNext() ) if( i.hasNext() )
buffer.append( File.separatorChar ); strbuff.append( File.separatorChar );
} }
return buffer.toString(); return strbuff.toString();
} }
@ -72,11 +69,11 @@ public class ScannerUtility {
private static String removeQuotes(String originalPath) { private static String removeQuotes(String originalPath) {
String [] segments = originalPath.split( "\""); //$NON-NLS-1$ String [] segments = originalPath.split( "\""); //$NON-NLS-1$
if( segments.length == 1 ) return originalPath; if( segments.length == 1 ) return originalPath;
StringBuffer result = new StringBuffer(); strbuff.startString();
for( int i = 0; i < segments.length; ++ i ) for( int i = 0; i < segments.length; ++ i )
if( segments[i] != null ) if( segments[i] != null )
result.append( segments[i]); strbuff.append( segments[i]);
return result.toString(); return strbuff.toString();
} }
@ -152,7 +149,7 @@ public class ScannerUtility {
try try
{ {
boolean useIncludePath = true; boolean useIncludePath = true;
StringBuffer fileNameBuffer = new StringBuffer(); strbuff.startString();
int startOffset = baseOffset, endOffset = baseOffset; int startOffset = baseOffset, endOffset = baseOffset;
if (! includeLine.equals("")) { //$NON-NLS-1$ if (! includeLine.equals("")) { //$NON-NLS-1$
@ -174,7 +171,7 @@ public class ScannerUtility {
try { try {
if (t.getType() == IToken.tSTRING) { if (t.getType() == IToken.tSTRING) {
fileNameBuffer.append(t.getImage()); strbuff.append(t.getImage());
startOffset = baseOffset + t.getOffset(); startOffset = baseOffset + t.getOffset();
endOffset = baseOffset + t.getEndOffset(); endOffset = baseOffset + t.getEndOffset();
useIncludePath = false; useIncludePath = false;
@ -190,10 +187,13 @@ public class ScannerUtility {
startOffset = baseOffset + t.getOffset(); startOffset = baseOffset + t.getOffset();
while (t.getType() != IToken.tGT) { while (t.getType() != IToken.tGT) {
fileNameBuffer.append(t.getImage()); strbuff.append(t.getImage());
helperScanner.skipOverWhitespace(); helperScanner.skipOverWhitespace();
int c = helperScanner.getChar(); int c = helperScanner.getChar();
if (c == '\\') fileNameBuffer.append('\\'); else helperScanner.ungetChar(c); if (c == '\\')
strbuff.append('\\');
else
helperScanner.ungetChar(c);
t = helperScanner.nextToken(false); t = helperScanner.nextToken(false);
} }
@ -218,7 +218,7 @@ public class ScannerUtility {
} else } else
throw INCLUSION_PARSE_EXCEPTION ; throw INCLUSION_PARSE_EXCEPTION ;
return new InclusionDirective( fileNameBuffer.toString(), useIncludePath, startOffset, endOffset ); return new InclusionDirective( strbuff.toString(), useIncludePath, startOffset, endOffset );
} }
catch( ScannerException se ) catch( ScannerException se )
{ {