1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added traceLog() call into Scanner.handleProblem() and updated ParserFactory.createPreprocessor()'s error handling.

This commit is contained in:
John Camelon 2004-01-21 03:01:14 +00:00
parent ee9dc1d5a5
commit d228fe824a
3 changed files with 26 additions and 11 deletions

View file

@ -1,11 +1,14 @@
2004-01-20 John Camelon 2004-01-20 John Camelon
Tidied up Scanner implementation for unused fields, inefficient String manipulations and redundant parameters. Added traceLog() call into Scanner.handleProblem() and updated ParserFactory.createPreprocessor() for extra error handling.
2004-01-20 John Camelon
Tidied up Scanner implementation for unused fields, inefficient String manipulations and redundant parameters.
2004-01-19 John Camelon 2004-01-19 John Camelon
Added IToken.getLineNumber() to facilitate adding line numbers to AST. Added IToken.getLineNumber() to facilitate adding line numbers to AST.
Added line number support into IASTOffsetableElement. Updated all implementations to use this. Added line number support into IASTOffsetableElement. Updated all implementations to use this.
Updated Parser and IASTFactory to populate IASTOffsetableElement with the values retrieved from IToken. Updated Parser and IASTFactory to populate IASTOffsetableElement with the values retrieved from IToken.
Removed IScanner.getLineNumberForOffset(). Removed IScanner.getLineNumberForOffset().
2004-01-16 Andrew Niefer 2004-01-16 Andrew Niefer
Created IExtensibleSymbol, which is a new base class for the symbol interfaces Created IExtensibleSymbol, which is a new base class for the symbol interfaces

View file

@ -74,9 +74,14 @@ public class ParserFactory {
public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService logService ) public static IPreprocessor createPreprocessor( Reader input, String fileName, IScannerInfo info, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService logService )
{ {
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode ); if( input == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_READER );
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor ); if( fileName == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_FILENAME );
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, logService ); if( info == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_CONFIG );
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
IParserLogService log = ( logService == null ) ? createDefaultLogService() : logService;
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor );
IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, log );
return s; return s;
} }

View file

@ -80,9 +80,16 @@ public class Scanner implements IScanner {
String attributes [] = problemFactory.getRequiredAttributesForId( problemID ); String attributes [] = problemFactory.getRequiredAttributesForId( problemID );
arguments.put( attributes[ 0 ], argument ); arguments.put( attributes[ 0 ], argument );
} }
IProblem p = problemFactory.createProblem( problemID, beginningOffset, getCurrentOffset(), contextStack.getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
if( (! requestor.acceptProblem( p )) && extra ) IProblem problem = problemFactory.createProblem( problemID, beginningOffset, getCurrentOffset(), contextStack.getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
throw new ScannerException( p );
// trace log
StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: ");
logMessage.append( problem.getMessage() );
log.traceLog( logMessage.toString() );
if( (! requestor.acceptProblem( problem )) && extra )
throw new ScannerException( problem );
} }
public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log ) { public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log ) {