mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Follow up 253690: Creating problem node.
This commit is contained in:
parent
3fa42529d9
commit
f116df561b
3 changed files with 19 additions and 35 deletions
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||||
|
@ -1733,7 +1734,19 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return funcDefinition;
|
return funcDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IASTDeclarator addInitializer(FoundAggregateInitializer lie, DeclarationOptions option) throws EndOfFileException;
|
protected abstract IASTInitializer optionalInitializer(DeclarationOptions options)
|
||||||
|
throws EndOfFileException, BacktrackException;
|
||||||
|
|
||||||
|
protected IASTDeclarator addInitializer(FoundAggregateInitializer e, DeclarationOptions options)
|
||||||
|
throws EndOfFileException, BacktrackException {
|
||||||
|
final IASTDeclarator d = e.fDeclarator;
|
||||||
|
IASTInitializer i = optionalInitializer(options);
|
||||||
|
if (i != null) {
|
||||||
|
d.setInitializer(i);
|
||||||
|
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
|
protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
|
||||||
IToken t= consume(IToken.tLPAREN);
|
IToken t= consume(IToken.tLPAREN);
|
||||||
|
|
|
@ -134,7 +134,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
this.nodeFactory = CNodeFactory.getDefault();
|
this.nodeFactory = CNodeFactory.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTInitializer optionalCInitializer() throws EndOfFileException, BacktrackException {
|
@Override
|
||||||
|
protected IASTInitializer optionalInitializer(DeclarationOptions options) throws EndOfFileException, BacktrackException {
|
||||||
if (LTcatchEOF(1) == IToken.tASSIGN) {
|
if (LTcatchEOF(1) == IToken.tASSIGN) {
|
||||||
final int offset= consume().getOffset();
|
final int offset= consume().getOffset();
|
||||||
IASTInitializerClause initClause = initClause(false);
|
IASTInitializerClause initClause = initClause(false);
|
||||||
|
@ -1314,7 +1315,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (lt1 == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
|
if (lt1 == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
|
||||||
throw new FoundAggregateInitializer(declspec, d);
|
throw new FoundAggregateInitializer(declspec, d);
|
||||||
|
|
||||||
IASTInitializer i = optionalCInitializer();
|
IASTInitializer i = optionalInitializer(option);
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
d.setInitializer(i);
|
d.setInitializer(i);
|
||||||
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
||||||
|
@ -1322,21 +1323,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IASTDeclarator addInitializer(FoundAggregateInitializer e, DeclarationOptions options) throws EndOfFileException {
|
|
||||||
final IASTDeclarator d = e.fDeclarator;
|
|
||||||
try {
|
|
||||||
IASTInitializer i = optionalCInitializer();
|
|
||||||
if (i != null) {
|
|
||||||
d.setInitializer(i);
|
|
||||||
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
|
||||||
}
|
|
||||||
} catch (BacktrackException e1) {
|
|
||||||
// mstodo add problem node
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTDeclarator declarator(IASTDeclSpecifier declSpec, DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclarator declarator(IASTDeclSpecifier declSpec, DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
final int startingOffset = LA(1).getOffset();
|
final int startingOffset = LA(1).getOffset();
|
||||||
int endOffset = startingOffset;
|
int endOffset = startingOffset;
|
||||||
|
|
|
@ -2779,22 +2779,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return dtor;
|
return dtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IASTDeclarator addInitializer(FoundAggregateInitializer e, DeclarationOptions option) throws EndOfFileException {
|
|
||||||
final IASTDeclarator d = e.fDeclarator;
|
|
||||||
try {
|
|
||||||
IASTInitializer i = optionalInitializer(option);
|
|
||||||
if (i != null) {
|
|
||||||
d.setInitializer(i);
|
|
||||||
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
|
||||||
}
|
|
||||||
} catch (BacktrackException e1) {
|
|
||||||
// mstodo add problem node
|
|
||||||
failParse();
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initializer:
|
* initializer:
|
||||||
* brace-or-equal-initializer
|
* brace-or-equal-initializer
|
||||||
|
@ -2804,7 +2788,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* = initializer-clause
|
* = initializer-clause
|
||||||
* braced-init-list
|
* braced-init-list
|
||||||
*/
|
*/
|
||||||
private IASTInitializer optionalInitializer(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
@Override
|
||||||
|
protected IASTInitializer optionalInitializer(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
final int lt1= LTcatchEOF(1);
|
final int lt1= LTcatchEOF(1);
|
||||||
|
|
||||||
// = initializer-clause
|
// = initializer-clause
|
||||||
|
|
Loading…
Add table
Reference in a new issue