1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
John Camelon 2004-05-15 17:11:34 +00:00
parent 06d6b593af
commit c2b76e8109
4 changed files with 14 additions and 8 deletions

View file

@ -47,7 +47,7 @@ public class BaseScannerTest extends TestCase {
protected void initializeScanner( String input, ParserMode mode, ISourceElementRequestor requestor ) throws ParserFactoryError protected void initializeScanner( String input, ParserMode mode, ISourceElementRequestor requestor ) throws ParserFactoryError
{ {
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, requestor, null, null ); scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, requestor, null, null ); //$NON-NLS-1$
} }
protected void initializeScanner(String input) throws ParserFactoryError protected void initializeScanner(String input) throws ParserFactoryError
@ -65,10 +65,10 @@ public class BaseScannerTest extends TestCase {
while (t != null) while (t != null)
{ {
if (verbose) if (verbose)
System.out.println("Token t = " + t); System.out.println("Token t = " + t); //$NON-NLS-1$
if ((t.getType()> IToken.tLAST)) if ((t.getType()> IToken.tLAST))
System.out.println("Unknown type for token " + t); System.out.println("Unknown type for token " + t); //$NON-NLS-1$
t= scanner.nextToken(); t= scanner.nextToken();
} }
} }
@ -208,10 +208,10 @@ public class BaseScannerTest extends TestCase {
assertNull(scanner.getDefinition(name)); assertNull(scanner.getDefinition(name));
} }
public static final String EXCEPTION_THROWN = "Exception thrown "; public static final String EXCEPTION_THROWN = "Exception thrown "; //$NON-NLS-1$
public static final String EXPECTED_FAILURE = "This statement should not be reached " public static final String EXPECTED_FAILURE = "This statement should not be reached " //$NON-NLS-1$
+ "as we sent in bad preprocessor input to the scanner"; + "as we sent in bad preprocessor input to the scanner"; //$NON-NLS-1$
public static final boolean verbose = false; public static final boolean verbose = false;

View file

@ -1572,4 +1572,10 @@ public class ScannerTestCase extends BaseScannerTest
fullyTokenize(); fullyTokenize();
assertTrue( callback.problems.isEmpty() ); assertTrue( callback.problems.isEmpty() );
} }
public void testBug62378() throws Exception
{
initializeScanner( "\"\\?\\?<\""); //$NON-NLS-1$
validateString("\\?\\?<" ); //$NON-NLS-1$
}
} }

View file

@ -958,7 +958,6 @@ public class Scanner implements IScanner {
{ {
// TODO : we could probably return the partial string -- it might cause // TODO : we could probably return the partial string -- it might cause
// the parse to get by... // the parse to get by...
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true ); handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
return null; return null;
} }

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTInclusion;
public class ScannerContextInclusion implements IScannerContext public class ScannerContextInclusion implements IScannerContext
{ {
public static final int UNDO_BUFFER_SIZE = 4;
protected Reader reader; protected Reader reader;
private String filename; private String filename;
private IASTInclusion inc; private IASTInclusion inc;
@ -52,7 +53,7 @@ public class ScannerContextInclusion implements IScannerContext
} }
} }
protected int pos = 0; protected int pos = 0;
protected int undo[] = new int[2]; protected int undo[] = new int[UNDO_BUFFER_SIZE];
public final void ungetChar(int c) { public final void ungetChar(int c) {
undo[pos++] = c; undo[pos++] = c;
} }