mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 09:45:39 +02:00
Removed warnings.
This commit is contained in:
parent
9f21cf4d4a
commit
787b5dfcc3
8 changed files with 262 additions and 334 deletions
|
@ -385,15 +385,13 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
throw new ASTSemanticException( (IProblem)null );
|
throw new ASTSemanticException( (IProblem)null );
|
||||||
return createFieldASTNode(declarator, false );
|
return createFieldASTNode(declarator, false );
|
||||||
}
|
}
|
||||||
else
|
if (isFunction)
|
||||||
{
|
return createFunctionASTNode(declarator, false);
|
||||||
if (isFunction)
|
else
|
||||||
return createFunctionASTNode(declarator, false);
|
if( declarator.hasFunctionBody() )
|
||||||
else
|
throw new ASTSemanticException( (IProblem)null );
|
||||||
if( declarator.hasFunctionBody() )
|
return createVariableASTNode(declarator, false);
|
||||||
throw new ASTSemanticException( (IProblem)null );
|
|
||||||
return createVariableASTNode(declarator, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -418,18 +416,12 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
if( isFunction)
|
if( isFunction)
|
||||||
return createMethodASTNode(declarator, true);
|
return createMethodASTNode(declarator, true);
|
||||||
else
|
return createFieldASTNode(declarator, true );
|
||||||
return createFieldASTNode(declarator, true );
|
|
||||||
}
|
}
|
||||||
else
|
if (isFunction)
|
||||||
{
|
return createFunctionASTNode(declarator, true);
|
||||||
if (isFunction)
|
return createVariableASTNode(declarator, true);
|
||||||
return createFunctionASTNode(declarator, true);
|
}
|
||||||
else
|
|
||||||
return createVariableASTNode(declarator, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
List convertedParms = createParameterList( declarator.getParameters() );
|
List convertedParms = createParameterList( declarator.getParameters() );
|
||||||
IASTAbstractDeclaration abs = null;
|
IASTAbstractDeclaration abs = null;
|
||||||
|
@ -450,18 +442,15 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
getStartingOffset(), getStartingLine(), d
|
getStartingOffset(), getStartingLine(), d
|
||||||
.getNameStartOffset(), d.getNameEndOffset(), d
|
.getNameStartOffset(), d.getNameEndOffset(), d
|
||||||
.getNameLine());
|
.getNameLine());
|
||||||
else {
|
|
||||||
if( isWithinClass )
|
if( isWithinClass )
|
||||||
return astFactory.createField( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode() );
|
return astFactory.createField( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode() );
|
||||||
else
|
|
||||||
return astFactory.createVariable( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() );
|
return astFactory.createVariable( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() );
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
throw new BacktrackException();
|
||||||
{
|
|
||||||
throw new BacktrackException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -147,8 +147,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
public IToken consume(int type) throws EndOfFileException, BacktrackException {
|
public IToken consume(int type) throws EndOfFileException, BacktrackException {
|
||||||
if (LT(1) == type)
|
if (LT(1) == type)
|
||||||
return consume();
|
return consume();
|
||||||
else
|
throw backtrack;
|
||||||
throw backtrack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -565,16 +564,14 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
|
declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
if( extension.isValidCVModifier( language, IToken.t_restrict ))
|
||||||
{
|
{
|
||||||
if( extension.isValidCVModifier( language, IToken.t_restrict ))
|
result = consume( IToken.t_restrict );
|
||||||
{
|
declarator.addPointerOperator( extension.getPointerOperator(language, IToken.t_restrict ));
|
||||||
result = consume( IToken.t_restrict );
|
break;
|
||||||
declarator.addPointerOperator( extension.getPointerOperator(language, IToken.t_restrict ));
|
}
|
||||||
break;
|
throw backtrack;
|
||||||
}
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
|
|
||||||
default :
|
default :
|
||||||
if( extension.isValidCVModifier( language, LT(1)))
|
if( extension.isValidCVModifier( language, LT(1)))
|
||||||
|
@ -925,8 +922,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
return firstExpression;
|
||||||
return firstExpression;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1199,52 +1195,49 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return firstExpression;
|
return firstExpression;
|
||||||
}
|
}
|
||||||
else
|
IASTExpression.Kind expressionKind = null;
|
||||||
{
|
switch (t.getType())
|
||||||
IASTExpression.Kind expressionKind = null;
|
{
|
||||||
switch (t.getType())
|
case IToken.tGT :
|
||||||
{
|
expressionKind =
|
||||||
case IToken.tGT :
|
IASTExpression.Kind.RELATIONAL_GREATERTHAN;
|
||||||
expressionKind =
|
break;
|
||||||
IASTExpression.Kind.RELATIONAL_GREATERTHAN;
|
case IToken.tLT :
|
||||||
break;
|
expressionKind = IASTExpression.Kind.RELATIONAL_LESSTHAN;
|
||||||
case IToken.tLT :
|
break;
|
||||||
expressionKind = IASTExpression.Kind.RELATIONAL_LESSTHAN;
|
case IToken.tLTEQUAL :
|
||||||
break;
|
expressionKind =
|
||||||
case IToken.tLTEQUAL :
|
IASTExpression
|
||||||
expressionKind =
|
.Kind
|
||||||
IASTExpression
|
.RELATIONAL_LESSTHANEQUALTO;
|
||||||
.Kind
|
break;
|
||||||
.RELATIONAL_LESSTHANEQUALTO;
|
case IToken.tGTEQUAL :
|
||||||
break;
|
expressionKind =
|
||||||
case IToken.tGTEQUAL :
|
IASTExpression
|
||||||
expressionKind =
|
.Kind
|
||||||
IASTExpression
|
.RELATIONAL_GREATERTHANEQUALTO;
|
||||||
.Kind
|
break;
|
||||||
.RELATIONAL_GREATERTHANEQUALTO;
|
}
|
||||||
break;
|
try
|
||||||
}
|
{
|
||||||
try
|
firstExpression =
|
||||||
{
|
astFactory.createExpression(
|
||||||
firstExpression =
|
scope,
|
||||||
astFactory.createExpression(
|
expressionKind,
|
||||||
scope,
|
firstExpression,
|
||||||
expressionKind,
|
secondExpression,
|
||||||
firstExpression,
|
null,
|
||||||
secondExpression,
|
null,
|
||||||
null,
|
null, EMPTY_STRING, null);
|
||||||
null,
|
}
|
||||||
null, EMPTY_STRING, null);
|
catch (ASTSemanticException e)
|
||||||
}
|
{
|
||||||
catch (ASTSemanticException e)
|
throw backtrack;
|
||||||
{
|
} catch (Exception e)
|
||||||
throw backtrack;
|
{
|
||||||
} catch (Exception e)
|
logException( "relationalExpression::createExpression()", e ); //$NON-NLS-1$
|
||||||
{
|
throw backtrack;
|
||||||
logException( "relationalExpression::createExpression()", e ); //$NON-NLS-1$
|
}
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
if( extension.isValidRelationalExpressionStart(language, LT(1)))
|
if( extension.isValidRelationalExpressionStart(language, LT(1)))
|
||||||
|
@ -2548,15 +2541,10 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( t instanceof INumericToken )
|
if( t instanceof INumericToken )
|
||||||
{
|
|
||||||
return astFactory.createExpression(
|
return astFactory.createExpression(
|
||||||
IASTExpression.Kind.PRIMARY_INTEGER_LITERAL,
|
IASTExpression.Kind.PRIMARY_INTEGER_LITERAL,
|
||||||
((INumericToken)t).getIntegerValue(), isHex);
|
((INumericToken)t).getIntegerValue(), isHex);
|
||||||
}
|
return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, null, null, t.getImage(), null );
|
||||||
else
|
|
||||||
{
|
|
||||||
return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, null, null, t.getImage(), null );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e1)
|
catch (ASTSemanticException e1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -267,62 +267,53 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
astUD.acceptElement(requestor);
|
astUD.acceptElement(requestor);
|
||||||
return astUD;
|
return astUD;
|
||||||
}
|
}
|
||||||
else
|
throw backtrack;
|
||||||
{
|
}
|
||||||
throw backtrack;
|
boolean typeName = false;
|
||||||
}
|
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING );
|
||||||
|
|
||||||
|
if (LT(1) == IToken.t_typename)
|
||||||
|
{
|
||||||
|
typeName = true;
|
||||||
|
consume(IToken.t_typename);
|
||||||
|
}
|
||||||
|
|
||||||
|
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY );
|
||||||
|
ITokenDuple name = null;
|
||||||
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
|
{
|
||||||
|
// optional :: and nested classes handled in name
|
||||||
|
name = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boolean typeName = false;
|
throw backtrack;
|
||||||
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING );
|
|
||||||
|
|
||||||
if (LT(1) == IToken.t_typename)
|
|
||||||
{
|
|
||||||
typeName = true;
|
|
||||||
consume(IToken.t_typename);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY );
|
|
||||||
ITokenDuple name = null;
|
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
|
||||||
{
|
|
||||||
// optional :: and nested classes handled in name
|
|
||||||
name = name(scope, CompletionKind.TYPE_REFERENCE, Key.EMPTY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
if (LT(1) == IToken.tSEMI)
|
|
||||||
{
|
|
||||||
IToken last = consume(IToken.tSEMI);
|
|
||||||
IASTUsingDeclaration declaration = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
declaration =
|
|
||||||
astFactory.createUsingDeclaration(
|
|
||||||
scope,
|
|
||||||
typeName,
|
|
||||||
name,
|
|
||||||
firstToken.getOffset(),
|
|
||||||
firstToken.getLineNumber(), last.getEndOffset(), last.getLineNumber());
|
|
||||||
}
|
|
||||||
catch (Exception e1)
|
|
||||||
{
|
|
||||||
logException( "usingClause:createUsingDeclaration", e1 ); //$NON-NLS-1$
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
declaration.acceptElement( requestor );
|
|
||||||
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
|
|
||||||
return declaration;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (LT(1) == IToken.tSEMI)
|
||||||
|
{
|
||||||
|
IToken last = consume(IToken.tSEMI);
|
||||||
|
IASTUsingDeclaration declaration = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
declaration =
|
||||||
|
astFactory.createUsingDeclaration(
|
||||||
|
scope,
|
||||||
|
typeName,
|
||||||
|
name,
|
||||||
|
firstToken.getOffset(),
|
||||||
|
firstToken.getLineNumber(), last.getEndOffset(), last.getLineNumber());
|
||||||
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
logException( "usingClause:createUsingDeclaration", e1 ); //$NON-NLS-1$
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
declaration.acceptElement( requestor );
|
||||||
|
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
|
||||||
|
return declaration;
|
||||||
|
}
|
||||||
|
throw backtrack;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Implements Linkage specification in the ANSI C++ grammar.
|
* Implements Linkage specification in the ANSI C++ grammar.
|
||||||
|
@ -391,27 +382,27 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
linkage.exitScope( requestor );
|
linkage.exitScope( requestor );
|
||||||
return linkage;
|
return linkage;
|
||||||
}
|
}
|
||||||
else // single declaration
|
// single declaration
|
||||||
{
|
|
||||||
IASTLinkageSpecification linkage;
|
IASTLinkageSpecification linkage;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
linkage =
|
linkage =
|
||||||
astFactory.createLinkageSpecification(
|
astFactory.createLinkageSpecification(
|
||||||
scope,
|
scope,
|
||||||
spec.getImage(),
|
spec.getImage(),
|
||||||
firstToken.getOffset(), firstToken.getLineNumber());
|
firstToken.getOffset(), firstToken.getLineNumber());
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logException( "linkageSpecification_2:createLinkageSpecification", e ); //$NON-NLS-1$
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
linkage.enterScope( requestor );
|
|
||||||
declaration(linkage, null, null);
|
|
||||||
linkage.exitScope( requestor );
|
|
||||||
return linkage;
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logException( "linkageSpecification_2:createLinkageSpecification", e ); //$NON-NLS-1$
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
linkage.enterScope( requestor );
|
||||||
|
declaration(linkage, null, null);
|
||||||
|
linkage.exitScope( requestor );
|
||||||
|
return linkage;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -464,36 +455,34 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
return templateInstantiation;
|
return templateInstantiation;
|
||||||
}
|
}
|
||||||
else
|
consume(IToken.tLT);
|
||||||
|
if (LT(1) == IToken.tGT)
|
||||||
{
|
{
|
||||||
consume(IToken.tLT);
|
consume(IToken.tGT);
|
||||||
if (LT(1) == IToken.tGT)
|
// explicit-specialization
|
||||||
|
|
||||||
|
IASTTemplateSpecialization templateSpecialization;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
consume(IToken.tGT);
|
templateSpecialization =
|
||||||
// explicit-specialization
|
astFactory.createTemplateSpecialization(
|
||||||
|
scope,
|
||||||
IASTTemplateSpecialization templateSpecialization;
|
firstToken.getOffset(), firstToken.getLineNumber());
|
||||||
try
|
|
||||||
{
|
|
||||||
templateSpecialization =
|
|
||||||
astFactory.createTemplateSpecialization(
|
|
||||||
scope,
|
|
||||||
firstToken.getOffset(), firstToken.getLineNumber());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logException( "templateDeclaration:createTemplateSpecialization", e ); //$NON-NLS-1$
|
|
||||||
backup( mark );
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
templateSpecialization.enterScope(requestor);
|
|
||||||
declaration(templateSpecialization, templateSpecialization, null);
|
|
||||||
templateSpecialization.setEndingOffsetAndLineNumber(
|
|
||||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
|
||||||
templateSpecialization.exitScope(requestor);
|
|
||||||
return templateSpecialization;
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logException( "templateDeclaration:createTemplateSpecialization", e ); //$NON-NLS-1$
|
||||||
|
backup( mark );
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
templateSpecialization.enterScope(requestor);
|
||||||
|
declaration(templateSpecialization, templateSpecialization, null);
|
||||||
|
templateSpecialization.setEndingOffsetAndLineNumber(
|
||||||
|
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||||
|
templateSpecialization.exitScope(requestor);
|
||||||
|
return templateSpecialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1110,52 +1099,47 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
else
|
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
||||||
{
|
endDeclaration( declaration );
|
||||||
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
declaration.enterScope( requestor );
|
||||||
endDeclaration( declaration );
|
|
||||||
declaration.enterScope( requestor );
|
|
||||||
|
|
||||||
if ( !( declaration instanceof IASTScope ) )
|
if ( !( declaration instanceof IASTScope ) )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
|
||||||
handleFunctionBody((IASTScope)declaration );
|
handleFunctionBody((IASTScope)declaration );
|
||||||
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber(
|
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber(
|
||||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||||
|
|
||||||
declaration.exitScope( requestor );
|
declaration.exitScope( requestor );
|
||||||
|
|
||||||
if( hasFunctionTryBlock )
|
if( hasFunctionTryBlock )
|
||||||
catchHandlerSequence( scope );
|
catchHandlerSequence( scope );
|
||||||
|
|
||||||
return declaration;
|
return declaration;
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( sdw.getTypeSpecifier() != null )
|
if( sdw.getTypeSpecifier() != null )
|
||||||
{
|
{
|
||||||
IASTAbstractTypeSpecifierDeclaration declaration = astFactory.createTypeSpecDeclaration(
|
IASTAbstractTypeSpecifierDeclaration declaration = astFactory.createTypeSpecDeclaration(
|
||||||
sdw.getScope(),
|
sdw.getScope(),
|
||||||
sdw.getTypeSpecifier(),
|
sdw.getTypeSpecifier(),
|
||||||
ownerTemplate,
|
ownerTemplate,
|
||||||
sdw.getStartingOffset(),
|
sdw.getStartingOffset(),
|
||||||
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
||||||
sdw.isFriend());
|
sdw.isFriend());
|
||||||
declaration.acceptElement(requestor);
|
declaration.acceptElement(requestor);
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e1)
|
|
||||||
{
|
|
||||||
logException( "simpleDeclaration:createTypeSpecDeclaration", e1 ); //$NON-NLS-1$
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
logException( "simpleDeclaration:createTypeSpecDeclaration", e1 ); //$NON-NLS-1$
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3203,9 +3187,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
protected void handleClassSpecifier( IASTClassSpecifier classSpecifier ) throws EndOfFileException
|
protected void handleClassSpecifier( IASTClassSpecifier classSpecifier ) throws EndOfFileException
|
||||||
{
|
{
|
||||||
cleanupLastToken();
|
cleanupLastToken();
|
||||||
if( classSpecifier instanceof IASTOffsetableNamedElement )
|
handleOffsetableNamedElement( classSpecifier );
|
||||||
handleOffsetableNamedElement( classSpecifier );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,12 @@ public class ParserMessages {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
if( resourceBundle == null ){
|
if( resourceBundle == null )
|
||||||
return '#' + key +'#';
|
return '#' + key +'#';
|
||||||
} else {
|
try {
|
||||||
try {
|
return resourceBundle.getString(key);
|
||||||
return resourceBundle.getString(key);
|
} catch (MissingResourceException e) {
|
||||||
} catch (MissingResourceException e) {
|
return '!' + key + '!';
|
||||||
return '!' + key + '!';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,22 +154,25 @@ public class QuickParseCallback extends NullSourceElementRequestor implements IQ
|
||||||
|
|
||||||
// case 3: 1 is null
|
// case 3: 1 is null
|
||||||
if( currentMacro == null )
|
if( currentMacro == null )
|
||||||
|
{
|
||||||
if( currentDeclaration.getStartingOffset() < currentInclusion.getStartingOffset() )
|
if( currentDeclaration.getStartingOffset() < currentInclusion.getStartingOffset() )
|
||||||
return updateDeclarationIterator();
|
return updateDeclarationIterator();
|
||||||
else
|
return updateInclusionIterator();
|
||||||
return updateInclusionIterator();
|
}
|
||||||
|
|
||||||
if( currentInclusion == null )
|
if( currentInclusion == null )
|
||||||
|
{
|
||||||
if( currentDeclaration.getStartingOffset() < currentMacro.getStartingOffset() )
|
if( currentDeclaration.getStartingOffset() < currentMacro.getStartingOffset() )
|
||||||
return updateDeclarationIterator();
|
return updateDeclarationIterator();
|
||||||
else
|
return updateMacroIterator();
|
||||||
return updateMacroIterator();
|
}
|
||||||
|
|
||||||
if( currentDeclaration == null )
|
if( currentDeclaration == null )
|
||||||
|
{
|
||||||
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() )
|
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() )
|
||||||
return updateInclusionIterator();
|
return updateInclusionIterator();
|
||||||
else
|
return updateMacroIterator();
|
||||||
return updateMacroIterator();
|
}
|
||||||
|
|
||||||
// case 4: none are null
|
// case 4: none are null
|
||||||
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() &&
|
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() &&
|
||||||
|
|
|
@ -496,12 +496,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
iterator.next();
|
iterator.next();
|
||||||
return pst.getCompilationUnit();
|
return pst.getCompilationUnit();
|
||||||
}
|
}
|
||||||
else
|
return scopeToSymbol(currentScope);
|
||||||
{
|
|
||||||
return scopeToSymbol(currentScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
protected IContainerSymbol scopeToSymbol(IASTScope currentScope)
|
protected IContainerSymbol scopeToSymbol(IASTScope currentScope)
|
||||||
{
|
{
|
||||||
|
@ -935,9 +930,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
ASTNode referenced = (definition != null) ? definition : declaration;
|
ASTNode referenced = (definition != null) ? definition : declaration;
|
||||||
if( referenced instanceof IASTMethod )
|
if( referenced instanceof IASTMethod )
|
||||||
|
|
||||||
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced );
|
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced );
|
||||||
else
|
return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)referenced );
|
||||||
return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)referenced );
|
|
||||||
}
|
}
|
||||||
else if( ( symbol.getType() == TypeInfo.t_type ) ||
|
else if( ( symbol.getType() == TypeInfo.t_type ) ||
|
||||||
( symbol.getType() == TypeInfo.t_bool )||
|
( symbol.getType() == TypeInfo.t_bool )||
|
||||||
|
@ -1279,9 +1274,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
// assert lhsInfo != null : "Malformed Expression";
|
// assert lhsInfo != null : "Malformed Expression";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
return startingScope;
|
||||||
return startingScope;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -56,11 +56,8 @@ public class BranchTracker {
|
||||||
|
|
||||||
return taken;
|
return taken;
|
||||||
}
|
}
|
||||||
else
|
branches.push( FALSE );
|
||||||
{
|
return false;
|
||||||
branches.push( FALSE );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queryCurrentBranchForElif()
|
public boolean queryCurrentBranchForElif()
|
||||||
|
|
|
@ -400,8 +400,7 @@ public class Scanner implements IScanner {
|
||||||
// multiline comment
|
// multiline comment
|
||||||
if (skipOverMultilineComment())
|
if (skipOverMultilineComment())
|
||||||
break;
|
break;
|
||||||
else
|
c = getChar( true );
|
||||||
c = getChar( true );
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// we are not in a comment
|
// we are not in a comment
|
||||||
|
@ -851,13 +850,8 @@ public class Scanner implements IScanner {
|
||||||
{
|
{
|
||||||
c = getChar();
|
c = getChar();
|
||||||
if( c == '#' )
|
if( c == '#' )
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
ungetChar( c );
|
||||||
else
|
|
||||||
{
|
|
||||||
ungetChar( c );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
|
@ -922,11 +916,8 @@ public class Scanner implements IScanner {
|
||||||
// consume \ \r \n and then continue
|
// consume \ \r \n and then continue
|
||||||
return getChar(true);
|
return getChar(true);
|
||||||
}
|
}
|
||||||
else
|
// consume the \ \r and then continue
|
||||||
{
|
return c;
|
||||||
// consume the \ \r and then continue
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
@ -1024,8 +1015,7 @@ public class Scanner implements IScanner {
|
||||||
} else if( c == '.' ){
|
} else if( c == '.' ){
|
||||||
if( getChar() == '.' )
|
if( getChar() == '.' )
|
||||||
return newConstantToken( IToken.tELLIPSIS );
|
return newConstantToken( IToken.tELLIPSIS );
|
||||||
else
|
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
|
||||||
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
|
|
||||||
} else {
|
} else {
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
return newConstantToken( IToken.tDOT );
|
return newConstantToken( IToken.tDOT );
|
||||||
|
@ -1502,8 +1492,7 @@ public class Scanner implements IScanner {
|
||||||
if( buff == null ) return null;
|
if( buff == null ) return null;
|
||||||
continue; // back to top of loop
|
continue; // back to top of loop
|
||||||
}
|
}
|
||||||
else
|
ungetChar( next );
|
||||||
ungetChar( next );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1540,12 +1529,9 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if (tokenTypeObject != null)
|
if (tokenTypeObject != null)
|
||||||
return newConstantToken(((Integer) tokenTypeObject).intValue());
|
return newConstantToken(((Integer) tokenTypeObject).intValue());
|
||||||
else
|
if( scannerExtension.isExtensionKeyword( scannerData.getLanguage(), ident ) )
|
||||||
{
|
return newExtensionToken( scannerExtension.createExtensionToken(scannerData, ident ));
|
||||||
if( scannerExtension.isExtensionKeyword( scannerData.getLanguage(), ident ) )
|
return newToken(IToken.tIDENTIFIER, ident);
|
||||||
return newExtensionToken( scannerExtension.createExtensionToken(scannerData, ident ));
|
|
||||||
return newToken(IToken.tIDENTIFIER, ident);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2023,22 +2009,16 @@ public class Scanner implements IScanner {
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
token = processKeywordOrIdentifier( secondBuffer, pasting );
|
||||||
|
if (token == null)
|
||||||
{
|
{
|
||||||
token = processKeywordOrIdentifier( secondBuffer, pasting );
|
c = getChar();
|
||||||
if (token == null)
|
continue;
|
||||||
{
|
|
||||||
c = getChar();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
}
|
||||||
|
return token;
|
||||||
}
|
}
|
||||||
else
|
ungetChar( next );
|
||||||
{
|
handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
|
||||||
ungetChar( next );
|
|
||||||
handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.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 );
|
||||||
|
@ -2259,11 +2239,10 @@ public class Scanner implements IScanner {
|
||||||
{
|
{
|
||||||
return newToken( IToken.tSTRING, buff.toString());
|
return newToken( IToken.tSTRING, buff.toString());
|
||||||
|
|
||||||
} else {
|
|
||||||
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
|
|
||||||
c = getChar();
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
|
||||||
|
c = getChar();
|
||||||
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -2776,15 +2755,14 @@ public class Scanner implements IScanner {
|
||||||
if( c == '\n' ){
|
if( c == '\n' ){
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
|
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
potentialErrorMessage.append( buffer );
|
potentialErrorMessage.append( buffer );
|
||||||
potentialErrorMessage.append( '\\');
|
potentialErrorMessage.append( '\\');
|
||||||
potentialErrorMessage.append( (char)c );
|
potentialErrorMessage.append( (char)c );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true);
|
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.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 );
|
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
|
||||||
potentialErrorMessage.append( buffer );
|
potentialErrorMessage.append( buffer );
|
||||||
|
@ -3110,31 +3088,31 @@ public class Scanner implements IScanner {
|
||||||
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;
|
||||||
} else {
|
}
|
||||||
buffer.append('\"');
|
buffer.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;
|
||||||
int length = value.length();
|
int length = value.length();
|
||||||
for( int j = 0; j < length; j++ ){
|
for( int j = 0; j < length; j++ ){
|
||||||
ch = val[j];
|
ch = val[j];
|
||||||
if( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){
|
if( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){
|
||||||
//Each occurance of whitespace becomes a single space character
|
//Each occurance of whitespace becomes a single space character
|
||||||
while( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){
|
while( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ){
|
||||||
ch = val[++j];
|
ch = val[++j];
|
||||||
}
|
|
||||||
buffer.append(' ');
|
|
||||||
}
|
|
||||||
//a \ character is inserted before each " and \
|
|
||||||
if( ch == '\"' || ch == '\\' ){
|
|
||||||
buffer.append('\\');
|
|
||||||
buffer.append(ch);
|
|
||||||
} else {
|
|
||||||
buffer.append(ch);
|
|
||||||
}
|
}
|
||||||
|
buffer.append(' ');
|
||||||
|
}
|
||||||
|
//a \ character is inserted before each " and \
|
||||||
|
if( ch == '\"' || ch == '\\' ){
|
||||||
|
buffer.append('\\');
|
||||||
|
buffer.append(ch);
|
||||||
|
} else {
|
||||||
|
buffer.append(ch);
|
||||||
}
|
}
|
||||||
buffer.append('\"');
|
|
||||||
}
|
}
|
||||||
|
buffer.append('\"');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch( t.getType() )
|
switch( t.getType() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue