mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Updated ScannerException to be more precise and include more information. Updated Parser to be more careful of how it handles particular Scanner errors in COMPLETE_PARSE mode. TESTS Updated ScannerTestCase to keep up to date wrt ScannerException updates.
This commit is contained in:
parent
8f627892aa
commit
93b627eabc
9 changed files with 267 additions and 82 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2003-09-09 John Camelon
|
||||||
|
Updated ScannerTestCase to keep up to date wrt ScannerException updates.
|
||||||
|
|
||||||
2003-09-09 Andrew Niefer
|
2003-09-09 Andrew Niefer
|
||||||
Modified resources/search/classDecl.cpp
|
Modified resources/search/classDecl.cpp
|
||||||
- to include more function declarations to test parameter matching
|
- to include more function declarations to test parameter matching
|
||||||
|
|
|
@ -1270,33 +1270,33 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
try{
|
try{
|
||||||
validateEOF();
|
validateEOF();
|
||||||
} catch ( ScannerException e ){
|
} catch ( ScannerException e ){
|
||||||
assertTrue( e.getMessage().equals( "Unbounded string" ));
|
assertTrue( e.getErrorCode() == ScannerException.ErrorCode.UNBOUNDED_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeScanner( "#include <foo.h" );
|
initializeScanner( "#include <foo.h" );
|
||||||
try{
|
try{
|
||||||
validateEOF();
|
validateEOF();
|
||||||
} catch ( ScannerException e ){
|
} catch ( ScannerException e ){
|
||||||
assertTrue( e.getMessage().equals( "Ill-formed #include: reached end of line before >" ));
|
assertTrue( e.getErrorCode() == ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE);
|
||||||
}
|
}
|
||||||
initializeScanner( "#define FOO(A" );
|
initializeScanner( "#define FOO(A" );
|
||||||
try{
|
try{
|
||||||
validateEOF();
|
validateEOF();
|
||||||
} catch( ScannerException e ){
|
} catch( ScannerException e ){
|
||||||
assertTrue( e.getMessage().equals( "Unexpected newline in macro formal parameter list."));
|
assertTrue( e.getErrorCode() == ScannerException.ErrorCode.MALFORMED_MACRO_DEFN );
|
||||||
}
|
}
|
||||||
initializeScanner( "#define FOO(A \\ B" );
|
initializeScanner( "#define FOO(A \\ B" );
|
||||||
try{
|
try{
|
||||||
validateEOF();
|
validateEOF();
|
||||||
} catch( ScannerException e ){
|
} catch( ScannerException e ){
|
||||||
assertTrue( e.getMessage().equals( "Unexpected '\\' in macro formal parameter list."));
|
assertTrue( e.getErrorCode() == ScannerException.ErrorCode.MALFORMED_MACRO_DEFN );
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeScanner( "#define FOO(A,\\\nB) 1\n FOO(foo" );
|
initializeScanner( "#define FOO(A,\\\nB) 1\n FOO(foo" );
|
||||||
try{
|
try{
|
||||||
validateInteger("1");
|
validateInteger("1");
|
||||||
} catch( ScannerException e ){
|
} catch( ScannerException e ){
|
||||||
assertTrue( e.getMessage().equals( "Improper use of macro FOO" ) );
|
assertTrue( e.getErrorCode() == ScannerException.ErrorCode.MACRO_USAGE_ERROR );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-09-09 John Camelon
|
||||||
|
Updated ScannerException to be more precise and include more information.
|
||||||
|
Updated Parser to be more careful of how it handles particular Scanner errors in COMPLETE_PARSE mode.
|
||||||
|
|
||||||
2003-09-08 Bogdan Gheorghe
|
2003-09-08 Bogdan Gheorghe
|
||||||
Added ScannerExceptions in Preprocessor.java to PDE Error
|
Added ScannerExceptions in Preprocessor.java to PDE Error
|
||||||
Log
|
Log
|
||||||
|
|
|
@ -21,5 +21,13 @@ public class Enum
|
||||||
this.enumValue = enumValue;
|
this.enumValue = enumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int enumValue;
|
private final int enumValue;
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getEnumValue()
|
||||||
|
{
|
||||||
|
return enumValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,163 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ScannerException extends Exception {
|
public class ScannerException extends Exception {
|
||||||
|
|
||||||
/**
|
private final String info;
|
||||||
* Constructor for ScannerException.
|
private final String fileName;
|
||||||
*/
|
private final int offset;
|
||||||
public ScannerException() {
|
private final static int OFFSET_NOT_PROVIDED = -1;
|
||||||
super();
|
private final ErrorCode code;
|
||||||
|
|
||||||
|
public static class ErrorCode extends Enum
|
||||||
|
{
|
||||||
|
public static final ErrorCode POUND_ERROR = new ErrorCode( 0 );
|
||||||
|
public static final ErrorCode INCLUSION_NOT_FOUND = new ErrorCode( 1 );
|
||||||
|
public static final ErrorCode DEFINITION_NOT_FOUND = new ErrorCode( 2 );
|
||||||
|
public static final ErrorCode UNBALANCED_CONDITIONALS = new ErrorCode( 3 );
|
||||||
|
public static final ErrorCode MALFORMED_MACRO_DEFN = new ErrorCode( 4 );
|
||||||
|
public static final ErrorCode UNBOUNDED_STRING = new ErrorCode( 5 );
|
||||||
|
public static final ErrorCode BAD_FLOATING_POINT = new ErrorCode( 6 );
|
||||||
|
public static final ErrorCode BAD_HEXIDECIMAL_FORMAT = new ErrorCode( 7 );
|
||||||
|
public static final ErrorCode INVALID_PREPROCESSOR_DIRECTIVE = new ErrorCode( 8 );
|
||||||
|
public static final ErrorCode ATTEMPTED_REDEFINITION = new ErrorCode( 9 );
|
||||||
|
public static final ErrorCode UNDEF_DEFINITION_NOT_FOUND = new ErrorCode( 10 );
|
||||||
|
public static final ErrorCode INVALID_ESCAPE_CHARACTER_SEQUENCE = new ErrorCode( 11 );
|
||||||
|
public static final ErrorCode EXPRESSION_EVALUATION_ERROR = new ErrorCode( 12 );
|
||||||
|
public static final ErrorCode UNEXPECTED_EOF = new ErrorCode(13);
|
||||||
|
public static final ErrorCode MACRO_USAGE_ERROR = new ErrorCode( 14 );
|
||||||
|
public static final ErrorCode MACRO_PASTING_ERROR = new ErrorCode( 15 );
|
||||||
|
public static final ErrorCode CIRCULAR_INCLUSION = new ErrorCode( 16 );
|
||||||
|
/**
|
||||||
|
* @param enumValue
|
||||||
|
*/
|
||||||
|
protected ErrorCode(int enumValue)
|
||||||
|
{
|
||||||
|
super(enumValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasInfo()
|
||||||
|
{
|
||||||
|
if( this == ErrorCode.UNBALANCED_CONDITIONALS ||
|
||||||
|
this == ErrorCode.UNBOUNDED_STRING ||
|
||||||
|
this == ErrorCode.BAD_FLOATING_POINT ||
|
||||||
|
this == ErrorCode.BAD_HEXIDECIMAL_FORMAT ||
|
||||||
|
this == ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE ||
|
||||||
|
this == ErrorCode.UNEXPECTED_EOF ||
|
||||||
|
this == ErrorCode.MACRO_PASTING_ERROR )
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasOffsetInfo()
|
||||||
|
{
|
||||||
|
if( this == INCLUSION_NOT_FOUND || this == POUND_ERROR )
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isSeriousError(ParserMode mode)
|
||||||
|
{
|
||||||
|
if( mode == ParserMode.COMPLETE_PARSE )
|
||||||
|
if( this == ErrorCode.POUND_ERROR ||
|
||||||
|
this == ErrorCode.DEFINITION_NOT_FOUND ||
|
||||||
|
this == ErrorCode.UNBALANCED_CONDITIONALS ||
|
||||||
|
this == ErrorCode.MALFORMED_MACRO_DEFN ||
|
||||||
|
this == ErrorCode.UNEXPECTED_EOF ||
|
||||||
|
this == ErrorCode.MACRO_USAGE_ERROR ||
|
||||||
|
this == ErrorCode.MACRO_PASTING_ERROR ||
|
||||||
|
this == ErrorCode.UNDEF_DEFINITION_NOT_FOUND ||
|
||||||
|
this == ErrorCode.EXPRESSION_EVALUATION_ERROR ||
|
||||||
|
this == ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE ||
|
||||||
|
this == ErrorCode.ATTEMPTED_REDEFINITION )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ScannerException( ErrorCode code )
|
||||||
* Constructor for ScannerException.
|
{
|
||||||
* @param s
|
this( code, "", "UNKNOWN", OFFSET_NOT_PROVIDED );
|
||||||
*/
|
|
||||||
public ScannerException(String s) {
|
|
||||||
super(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScannerException( ErrorCode code, String info )
|
||||||
|
{
|
||||||
|
this( code, info, "UNKNOWN", OFFSET_NOT_PROVIDED );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScannerException( ErrorCode code, String fileName, int offset )
|
||||||
|
{
|
||||||
|
this( code, "", fileName, offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map errorMessages = new HashMap();
|
||||||
|
|
||||||
|
static {
|
||||||
|
errorMessages.put( ErrorCode.POUND_ERROR, "#error " );
|
||||||
|
errorMessages.put( ErrorCode.INCLUSION_NOT_FOUND, "Inclusion not found: " );
|
||||||
|
errorMessages.put( ErrorCode.DEFINITION_NOT_FOUND, "Definition not found: " );
|
||||||
|
errorMessages.put( ErrorCode.MALFORMED_MACRO_DEFN, "Macro definition malformed: " );
|
||||||
|
errorMessages.put( ErrorCode.ATTEMPTED_REDEFINITION, "" );
|
||||||
|
errorMessages.put( ErrorCode.UNDEF_DEFINITION_NOT_FOUND, "" );
|
||||||
|
errorMessages.put( ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, "" );
|
||||||
|
errorMessages.put( ErrorCode.EXPRESSION_EVALUATION_ERROR, "" );
|
||||||
|
errorMessages.put( ErrorCode.MACRO_USAGE_ERROR, "" );
|
||||||
|
errorMessages.put( ErrorCode.CIRCULAR_INCLUSION, "" );
|
||||||
|
|
||||||
|
errorMessages.put( ErrorCode.UNBALANCED_CONDITIONALS , "Conditionals unbalanced " );
|
||||||
|
errorMessages.put( ErrorCode.UNBOUNDED_STRING, "Unbounded string " );
|
||||||
|
errorMessages.put( ErrorCode.BAD_FLOATING_POINT, "Invalid floating point format " );
|
||||||
|
errorMessages.put( ErrorCode.BAD_HEXIDECIMAL_FORMAT, "Invalid hexidecimal format " );
|
||||||
|
errorMessages.put( ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, "Invalid preprocessor directive format " );
|
||||||
|
errorMessages.put( ErrorCode.UNEXPECTED_EOF, "Unexpected End Of File " );
|
||||||
|
errorMessages.put( ErrorCode.MACRO_PASTING_ERROR, "Invalid use of macro pasting " );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ScannerException( ErrorCode code, String info, String fileName, int offset )
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ErrorCode getErrorCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
StringBuffer buff = new StringBuffer();
|
||||||
|
String errorMessage = (String)errorMessages.get( getErrorCode() );
|
||||||
|
|
||||||
|
if( errorMessage == null ) return "";
|
||||||
|
buff.append( errorMessage );
|
||||||
|
if( getErrorCode().hasInfo() )
|
||||||
|
buff.append( info );
|
||||||
|
if( getErrorCode().hasOffsetInfo() )
|
||||||
|
{
|
||||||
|
buff.append( "from file: ");
|
||||||
|
buff.append( fileName );
|
||||||
|
buff.append( " offset @ ");
|
||||||
|
buff.append( offset );
|
||||||
|
}
|
||||||
|
return buff.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeriousError( ParserMode mode )
|
||||||
|
{
|
||||||
|
return getErrorCode().isSeriousError( mode );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class BranchTracker {
|
||||||
}
|
}
|
||||||
catch( EmptyStackException ese )
|
catch( EmptyStackException ese )
|
||||||
{
|
{
|
||||||
throw new ScannerException( "#elif without a #if ");
|
throw new ScannerException( ScannerException.ErrorCode.UNBALANCED_CONDITIONALS );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ignore == IGNORE_SENTINEL )
|
if( ignore == IGNORE_SENTINEL )
|
||||||
|
@ -135,7 +135,7 @@ public class BranchTracker {
|
||||||
}
|
}
|
||||||
catch( EmptyStackException ese )
|
catch( EmptyStackException ese )
|
||||||
{
|
{
|
||||||
throw new ScannerException( "#else without a #if ");
|
throw new ScannerException( ScannerException.ErrorCode.UNBALANCED_CONDITIONALS );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ignore == IGNORE_SENTINEL )
|
if( ignore == IGNORE_SENTINEL )
|
||||||
|
|
|
@ -67,13 +67,13 @@ public class ContextStack {
|
||||||
if( context.getKind() == IScannerContext.INCLUSION )
|
if( context.getKind() == IScannerContext.INCLUSION )
|
||||||
{
|
{
|
||||||
if( !inclusions.add( context.getFilename() ) )
|
if( !inclusions.add( context.getFilename() ) )
|
||||||
throw new ScannerException( "Inclusion " + context.getFilename() + " already encountered." );
|
throw new ScannerException( ScannerException.ErrorCode.CIRCULAR_INCLUSION, context.getFilename() );
|
||||||
context.getExtension().enterScope( requestor );
|
context.getExtension().enterScope( requestor );
|
||||||
|
|
||||||
} else if( context.getKind() == IScannerContext.MACROEXPANSION )
|
} else if( context.getKind() == IScannerContext.MACROEXPANSION )
|
||||||
{
|
{
|
||||||
if( !defines.add( context.getFilename() ) )
|
if( !defines.add( context.getFilename() ) )
|
||||||
throw new ScannerException( "Define " + context.getFilename() + " already encountered." );
|
throw new ScannerException( ScannerException.ErrorCode.MALFORMED_MACRO_DEFN, context.getFilename() );
|
||||||
}
|
}
|
||||||
if( currentContext != null )
|
if( currentContext != null )
|
||||||
contextStack.push(currentContext);
|
contextStack.push(currentContext);
|
||||||
|
|
|
@ -4562,6 +4562,11 @@ public class Parser implements IParser
|
||||||
catch (ScannerException e)
|
catch (ScannerException e)
|
||||||
{
|
{
|
||||||
Util.debugLog( "ScannerException thrown : " + e.getMessage(), IDebugLogConstants.PARSER );
|
Util.debugLog( "ScannerException thrown : " + e.getMessage(), IDebugLogConstants.PARSER );
|
||||||
|
if( e.isSeriousError(mode) )
|
||||||
|
{
|
||||||
|
failParse();
|
||||||
|
throw endOfFile;
|
||||||
|
}
|
||||||
return fetchToken();
|
return fetchToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (throwExceptionOnInclusionNotFound && inclusionReader == null )
|
if (throwExceptionOnInclusionNotFound && inclusionReader == null )
|
||||||
throw new ScannerException("Cannot find inclusion " + fileName);
|
throw new ScannerException( ScannerException.ErrorCode.INCLUSION_NOT_FOUND, fileName );
|
||||||
}
|
}
|
||||||
else // local inclusion
|
else // local inclusion
|
||||||
{
|
{
|
||||||
|
@ -721,8 +721,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (throwExceptionOnUnboundedString)
|
if (throwExceptionOnUnboundedString)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.UNBOUNDED_STRING, getCurrentFile(), getCurrentOffset() );
|
||||||
"Unbounded string" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -830,7 +829,7 @@ public class Scanner implements IScanner {
|
||||||
if( getChar() == '.' )
|
if( getChar() == '.' )
|
||||||
return newToken( IToken.tELIPSE, "..." );
|
return newToken( IToken.tELIPSE, "..." );
|
||||||
else
|
else
|
||||||
throw new ScannerException( "Invalid floating point @ offset " + contextStack.getCurrentContext().getOffset() );
|
throw new ScannerException( ScannerException.ErrorCode.BAD_FLOATING_POINT, getCurrentFile(), getCurrentOffset() );
|
||||||
} else {
|
} else {
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
return newToken( IToken.tDOT, ".", contextStack.getCurrentContext() );
|
return newToken( IToken.tDOT, ".", contextStack.getCurrentContext() );
|
||||||
|
@ -838,7 +837,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
} else if (c == 'x') {
|
} else if (c == 'x') {
|
||||||
if( ! firstCharZero )
|
if( ! firstCharZero )
|
||||||
throw new ScannerException( "Invalid Hexidecimal @ offset " + contextStack.getCurrentContext().getOffset() );
|
throw new ScannerException( ScannerException.ErrorCode.BAD_HEXIDECIMAL_FORMAT, getCurrentFile(), getCurrentOffset() );
|
||||||
|
|
||||||
hex = true;
|
hex = true;
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -967,7 +966,7 @@ public class Scanner implements IScanner {
|
||||||
if( c == '#' )
|
if( c == '#' )
|
||||||
{
|
{
|
||||||
if( skipped )
|
if( skipped )
|
||||||
throw new ScannerException(BAD_PP + contextStack.getCurrentContext().getOffset());
|
throw new ScannerException(ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
else
|
else
|
||||||
return newToken( tPOUNDPOUND, "##" );
|
return newToken( tPOUNDPOUND, "##" );
|
||||||
} else if( tokenizingMacroReplacementList ) {
|
} else if( tokenizingMacroReplacementList ) {
|
||||||
|
@ -987,8 +986,7 @@ public class Scanner implements IScanner {
|
||||||
Object directive = ppDirectives.get(token);
|
Object directive = ppDirectives.get(token);
|
||||||
if (directive == null) {
|
if (directive == null) {
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
BAD_PP + contextStack.getCurrentContext().getOffset());
|
|
||||||
} else {
|
} else {
|
||||||
int type = ((Integer) directive).intValue();
|
int type = ((Integer) directive).intValue();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -1026,7 +1024,7 @@ public class Scanner implements IScanner {
|
||||||
String toBeUndefined = getNextIdentifier();
|
String toBeUndefined = getNextIdentifier();
|
||||||
|
|
||||||
if( ( definitions.remove(toBeUndefined) == null ) && mode == ParserMode.COMPLETE_PARSE )
|
if( ( definitions.remove(toBeUndefined) == null ) && mode == ParserMode.COMPLETE_PARSE )
|
||||||
throw new ScannerException( "Attempt to #undef symbol " + toBeUndefined + " when it was never defined");
|
throw new ScannerException( ScannerException.ErrorCode.UNDEF_DEFINITION_NOT_FOUND, toBeUndefined, getCurrentFile(), getCurrentOffset() );
|
||||||
|
|
||||||
skipOverTextUntilNewline();
|
skipOverTextUntilNewline();
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1064,7 +1062,7 @@ public class Scanner implements IScanner {
|
||||||
case PreprocessorDirectives.ENDIF :
|
case PreprocessorDirectives.ENDIF :
|
||||||
String restOfLine = getRestOfPreprocessorLine().trim();
|
String restOfLine = getRestOfPreprocessorLine().trim();
|
||||||
if( ! restOfLine.equals( "" ) && throwExceptionOnBadPreprocessorSyntax )
|
if( ! restOfLine.equals( "" ) && throwExceptionOnBadPreprocessorSyntax )
|
||||||
throw new ScannerException( BAD_PP + contextStack.getCurrentContext().getOffset() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
passOnToClient = branches.poundendif();
|
passOnToClient = branches.poundendif();
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
|
@ -1086,7 +1084,14 @@ public class Scanner implements IScanner {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case PreprocessorDirectives.ELSE :
|
case PreprocessorDirectives.ELSE :
|
||||||
passOnToClient = branches.poundelse();
|
try
|
||||||
|
{
|
||||||
|
passOnToClient = branches.poundelse();
|
||||||
|
}
|
||||||
|
catch( ScannerException se )
|
||||||
|
{
|
||||||
|
repackageScannerExceptionAndThrow(se);
|
||||||
|
}
|
||||||
|
|
||||||
skipOverTextUntilNewline();
|
skipOverTextUntilNewline();
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1098,14 +1103,23 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if (elsifExpression.equals(""))
|
if (elsifExpression.equals(""))
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException("Malformed #elsif clause");
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
|
|
||||||
boolean elsifResult = false;
|
boolean elsifResult = false;
|
||||||
try{
|
try{
|
||||||
elsifResult = evaluateExpression(elsifExpression );
|
elsifResult = evaluateExpression(elsifExpression );
|
||||||
} catch( ScannerException e ){}
|
} catch( ScannerException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
passOnToClient = branches.poundelif( elsifResult );
|
try
|
||||||
|
{
|
||||||
|
passOnToClient = branches.poundelif( elsifResult );
|
||||||
|
}
|
||||||
|
catch( ScannerException se )
|
||||||
|
{
|
||||||
|
repackageScannerExceptionAndThrow( se );
|
||||||
|
}
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1124,8 +1138,9 @@ public class Scanner implements IScanner {
|
||||||
String error = getRestOfPreprocessorLine();
|
String error = getRestOfPreprocessorLine();
|
||||||
|
|
||||||
if (mode == ParserMode.COMPLETE_PARSE) {
|
if (mode == ParserMode.COMPLETE_PARSE) {
|
||||||
throw new ScannerException("#error " + error);
|
throw new ScannerException(ScannerException.ErrorCode.POUND_ERROR, error, getCurrentFile(), getCurrentOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
case PreprocessorDirectives.PRAGMA :
|
case PreprocessorDirectives.PRAGMA :
|
||||||
|
@ -1138,17 +1153,14 @@ public class Scanner implements IScanner {
|
||||||
getRestOfPreprocessorLine().trim();
|
getRestOfPreprocessorLine().trim();
|
||||||
if (!remainderOfLine.equals("")) {
|
if (!remainderOfLine.equals("")) {
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
BAD_PP + contextStack.getCurrentContext().getOffset());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
default :
|
default :
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
BAD_PP + contextStack.getCurrentContext().getOffset());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1163,12 +1175,12 @@ public class Scanner implements IScanner {
|
||||||
if( next == '\'' )
|
if( next == '\'' )
|
||||||
return newToken( type, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
return newToken( type, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
||||||
else if( throwExceptionOnBadCharacterRead )
|
else if( throwExceptionOnBadCharacterRead )
|
||||||
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, getCurrentFile(), getCurrentOffset() );
|
||||||
} else if( next == '\'' )
|
} else if( next == '\'' )
|
||||||
return newToken( type, new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
return newToken( type, new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
||||||
else
|
else
|
||||||
if( throwExceptionOnBadCharacterRead )
|
if( throwExceptionOnBadCharacterRead )
|
||||||
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, getCurrentFile(), getCurrentOffset() );
|
||||||
case ':' :
|
case ':' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -1482,7 +1494,7 @@ public class Scanner implements IScanner {
|
||||||
default :
|
default :
|
||||||
// Bad character
|
// Bad character
|
||||||
if( throwExceptionOnBadCharacterRead )
|
if( throwExceptionOnBadCharacterRead )
|
||||||
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, getCurrentFile(), getCurrentOffset() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c = ' ';
|
c = ' ';
|
||||||
|
@ -1497,7 +1509,7 @@ public class Scanner implements IScanner {
|
||||||
if (throwExceptionOnEOFWithoutBalancedEndifs && ( getDepth() != 0) && !atEOF )
|
if (throwExceptionOnEOFWithoutBalancedEndifs && ( getDepth() != 0) && !atEOF )
|
||||||
{
|
{
|
||||||
atEOF = true;
|
atEOF = true;
|
||||||
throw new ScannerException("End of file encountered without terminating #endif");
|
throw new ScannerException(ScannerException.ErrorCode.UNBALANCED_CONDITIONALS, getCurrentFile(), getCurrentOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done
|
// we're done
|
||||||
|
@ -1505,6 +1517,30 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void repackageScannerExceptionAndThrow(ScannerException se)
|
||||||
|
throws ScannerException
|
||||||
|
{
|
||||||
|
throw new ScannerException( se.getErrorCode(), getCurrentFile(), getCurrentOffset() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected String getCurrentFile()
|
||||||
|
{
|
||||||
|
if( contextStack.getCurrentContext() != null )
|
||||||
|
return contextStack.getCurrentContext().getFilename();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected int getCurrentOffset()
|
||||||
|
{
|
||||||
|
if( contextStack.getCurrentContext() != null )
|
||||||
|
return contextStack.getCurrentContext().getOffset();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class endOfMacroTokenException extends Exception {};
|
protected static class endOfMacroTokenException extends Exception {};
|
||||||
// the static instance we always use
|
// the static instance we always use
|
||||||
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
||||||
|
@ -1549,8 +1585,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (throwExceptionOnUnboundedString)
|
if (throwExceptionOnUnboundedString)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.UNBOUNDED_STRING, getCurrentFile(), getCurrentOffset() );
|
||||||
"Unbounded string" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1565,12 +1600,12 @@ public class Scanner implements IScanner {
|
||||||
if( next == '\'' )
|
if( next == '\'' )
|
||||||
return newToken( IToken.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
return newToken( IToken.tCHAR, '\\' + new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
||||||
else if( throwExceptionOnBadCharacterRead )
|
else if( throwExceptionOnBadCharacterRead )
|
||||||
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, getCurrentFile(), getCurrentOffset());
|
||||||
} else if( next == '\'' )
|
} else if( next == '\'' )
|
||||||
return newToken( IToken.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
return newToken( IToken.tCHAR, new Character( (char)c ).toString(), contextStack.getCurrentContext() );
|
||||||
else
|
else
|
||||||
if( throwExceptionOnBadCharacterRead )
|
if( throwExceptionOnBadCharacterRead )
|
||||||
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + contextStack.getCurrentContext().getOffset() + " of file " + contextStack.getCurrentContext().getFilename() );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, getCurrentFile(), getCurrentOffset());
|
||||||
case ',' :
|
case ',' :
|
||||||
if (tokenImage.length() > 0) throw endOfMacroToken;
|
if (tokenImage.length() > 0) throw endOfMacroToken;
|
||||||
return newToken(IToken.tCOMMA, ",", contextStack.getCurrentContext());
|
return newToken(IToken.tCOMMA, ",", contextStack.getCurrentContext());
|
||||||
|
@ -1806,15 +1841,11 @@ public class Scanner implements IScanner {
|
||||||
throwExpressionEvaluationError(expression);
|
throwExpressionEvaluationError(expression);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void throwExpressionEvaluationError(String expression) throws ScannerException {
|
protected void throwExpressionEvaluationError(String expression) throws ScannerException {
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.EXPRESSION_EVALUATION_ERROR, expression, getCurrentFile(), getCurrentOffset());
|
||||||
"Expression "
|
|
||||||
+ expression
|
|
||||||
+ " evaluates to an undefined value");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void skipOverSinglelineComment() throws ScannerException {
|
protected void skipOverSinglelineComment() throws ScannerException {
|
||||||
|
@ -1875,7 +1906,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if (c == NOCHAR) {
|
if (c == NOCHAR) {
|
||||||
if (throwExceptionOnEOFWithinMultilineComment)
|
if (throwExceptionOnEOFWithinMultilineComment)
|
||||||
throw new ScannerException("Encountered EOF while in multiline comment");
|
throw new ScannerException( ScannerException.ErrorCode.UNEXPECTED_EOF, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
|
@ -1911,7 +1942,7 @@ public class Scanner implements IScanner {
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
} catch (EndOfFile eof) {
|
} catch (EndOfFile eof) {
|
||||||
if (throwExceptionOnBadPreprocessorSyntax) {
|
if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Encountered ill-formed #include" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1928,7 +1959,7 @@ public class Scanner implements IScanner {
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
|
|
||||||
if (throwExceptionOnBadPreprocessorSyntax) {
|
if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Encountered ill-formed #include" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1950,7 +1981,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
} catch (EndOfFile eof) {
|
} catch (EndOfFile eof) {
|
||||||
if (throwExceptionOnBadPreprocessorSyntax) {
|
if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Ill-formed #include: reached end of line before >" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1960,13 +1991,13 @@ public class Scanner implements IScanner {
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
|
|
||||||
if (throwExceptionOnBadPreprocessorSyntax) {
|
if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Encountered ill-formed #include" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (throwExceptionOnBadPreprocessorSyntax) {
|
} else if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Encountered ill-formed #include" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( EndOfFile eof )
|
catch( EndOfFile eof )
|
||||||
|
@ -1975,7 +2006,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (throwExceptionOnBadPreprocessorSyntax) {
|
} else if (throwExceptionOnBadPreprocessorSyntax) {
|
||||||
throw new ScannerException( "Encountered ill-formed #include" );
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
String f = fileName.toString();
|
String f = fileName.toString();
|
||||||
|
@ -2003,12 +2034,7 @@ public class Scanner implements IScanner {
|
||||||
if (mode == ParserMode.COMPLETE_PARSE) {
|
if (mode == ParserMode.COMPLETE_PARSE) {
|
||||||
String checkForRedefinition = (String) definitions.get(key);
|
String checkForRedefinition = (String) definitions.get(key);
|
||||||
if (checkForRedefinition != null) {
|
if (checkForRedefinition != null) {
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.ATTEMPTED_REDEFINITION, key, getCurrentFile(), getCurrentOffset());
|
||||||
"Preprocessor symbol "
|
|
||||||
+ key
|
|
||||||
+ " has already been defined to "
|
|
||||||
+ checkForRedefinition
|
|
||||||
+ " cannot redefined.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2032,16 +2058,16 @@ public class Scanner implements IScanner {
|
||||||
} else {
|
} else {
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
if( throwExceptionOnBadPreprocessorSyntax )
|
if( throwExceptionOnBadPreprocessorSyntax )
|
||||||
throw new ScannerException( "Unexpected '\\' in macro formal parameter list." );
|
throw new ScannerException( ScannerException.ErrorCode.MALFORMED_MACRO_DEFN, getCurrentFile(), getCurrentOffset());
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
} else if( c == '\r' || c == '\n' ){
|
} else if( c == '\r' || c == '\n' ){
|
||||||
if( throwExceptionOnBadPreprocessorSyntax )
|
if( throwExceptionOnBadPreprocessorSyntax )
|
||||||
throw new ScannerException( "Unexpected newline in macro formal parameter list." );
|
throw new ScannerException( ScannerException.ErrorCode.MALFORMED_MACRO_DEFN, getCurrentFile(), getCurrentOffset());
|
||||||
else return;
|
else return;
|
||||||
} else if( c == NOCHAR ){
|
} else if( c == NOCHAR ){
|
||||||
if( throwExceptionOnBadPreprocessorSyntax )
|
if( throwExceptionOnBadPreprocessorSyntax )
|
||||||
throw new ScannerException( "Unexpected EOF in macro formal parameter list." );
|
throw new ScannerException( ScannerException.ErrorCode.UNEXPECTED_EOF, getCurrentFile(), getCurrentOffset());
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2081,8 +2107,8 @@ public class Scanner implements IScanner {
|
||||||
if (index == -1 ) {
|
if (index == -1 ) {
|
||||||
//not found
|
//not found
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
BAD_PP + contextStack.getCurrentContext().getOffset());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2139,13 +2165,12 @@ public class Scanner implements IScanner {
|
||||||
// this is not a comment
|
// this is not a comment
|
||||||
// it is a bad statement
|
// it is a bad statement
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
BAD_PP + contextStack.getCurrentContext().getOffset());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Util.debugLog("Scanner : Encountered unexpected character " + ((char) c), IDebugLogConstants.PARSER);
|
Util.debugLog("Scanner : Encountered unexpected character " + ((char) c), IDebugLogConstants.PARSER);
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
throw new ScannerException(BAD_PP + contextStack.getCurrentContext().getOffset());
|
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
astFactory.createMacro( key, beginning, contextStack.getCurrentContext().getOffset(), offset ).acceptElement( requestor );
|
astFactory.createMacro( key, beginning, contextStack.getCurrentContext().getOffset(), offset ).acceptElement( requestor );
|
||||||
|
@ -2245,8 +2270,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if (parameterNames.size() != parameterValues.size()) {
|
if (parameterNames.size() != parameterValues.size()) {
|
||||||
if (throwExceptionOnBadMacroExpansion)
|
if (throwExceptionOnBadMacroExpansion)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.MACRO_USAGE_ERROR, symbol, getCurrentFile(), getCurrentOffset() );
|
||||||
"Improper use of macro " + symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int numberOfTokens = tokens.size();
|
int numberOfTokens = tokens.size();
|
||||||
|
@ -2274,7 +2298,7 @@ public class Scanner implements IScanner {
|
||||||
int index = parameterNames.indexOf(t.image);
|
int index = parameterNames.indexOf(t.image);
|
||||||
if( index == -1 ){
|
if( index == -1 ){
|
||||||
if (throwExceptionOnBadMacroExpansion)
|
if (throwExceptionOnBadMacroExpansion)
|
||||||
throw new ScannerException( "Improper use of the # preprocessing token." );
|
throw new ScannerException( ScannerException.ErrorCode.MACRO_PASTING_ERROR, getCurrentFile(), getCurrentOffset() );
|
||||||
} else {
|
} else {
|
||||||
buffer.append('\"');
|
buffer.append('\"');
|
||||||
String value = (String)parameterValuesForStringizing.elementAt(index);
|
String value = (String)parameterValuesForStringizing.elementAt(index);
|
||||||
|
@ -2331,8 +2355,7 @@ public class Scanner implements IScanner {
|
||||||
POUND_DEFINE + macro.getSignature(), ScannerContext.MACROEXPANSION, null, requestor, symbolOffset, endMacroOffset - symbolOffset + 1 );
|
POUND_DEFINE + macro.getSignature(), ScannerContext.MACROEXPANSION, null, requestor, symbolOffset, endMacroOffset - symbolOffset + 1 );
|
||||||
} else
|
} else
|
||||||
if (throwExceptionOnBadMacroExpansion)
|
if (throwExceptionOnBadMacroExpansion)
|
||||||
throw new ScannerException(
|
throw new ScannerException( ScannerException.ErrorCode.MACRO_USAGE_ERROR, symbol, getCurrentFile(), getCurrentOffset() );
|
||||||
"Improper use of macro " + symbol);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Util.debugLog(
|
Util.debugLog(
|
||||||
|
@ -2349,7 +2372,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if (c != '(') {
|
if (c != '(') {
|
||||||
if (throwExceptionOnBadMacroExpansion)
|
if (throwExceptionOnBadMacroExpansion)
|
||||||
throw new ScannerException("Improper use of macro defined()");
|
throw new ScannerException( ScannerException.ErrorCode.MACRO_USAGE_ERROR, "defined()", getCurrentFile(), getCurrentOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
@ -2360,7 +2383,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
if (c == NOCHAR) {
|
if (c == NOCHAR) {
|
||||||
if (throwExceptionOnBadMacroExpansion)
|
if (throwExceptionOnBadMacroExpansion)
|
||||||
throw new ScannerException("Improper use of macro defined()");
|
throw new ScannerException( ScannerException.ErrorCode.MACRO_USAGE_ERROR, "defined()", getCurrentFile(), getCurrentOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
String definitionIdentifier = buffer.toString().trim();
|
String definitionIdentifier = buffer.toString().trim();
|
||||||
|
|
Loading…
Add table
Reference in a new issue