mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Continuation of IProblem/Backtrack migration for Parser2.
This commit is contained in:
parent
416db61299
commit
334abb5ab0
9 changed files with 450 additions and 365 deletions
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.core.parser.tests.parser2;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class ProblemCollector implements IProblemRequestor {
|
||||||
*
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.IProblemRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
* @see org.eclipse.cdt.internal.core.parser2.IProblemRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||||
*/
|
*/
|
||||||
public boolean acceptProblem(IProblem problem) {
|
public boolean acceptProblem(IASTProblem problem) {
|
||||||
problems.add(problem);
|
problems.add(problem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,30 +27,39 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||||
public class ASTProblem extends ASTNode implements IASTProblem {
|
public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
|
|
||||||
private IASTNode parent;
|
private IASTNode parent;
|
||||||
|
|
||||||
private ASTNodeProperty property;
|
private ASTNodeProperty property;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent()
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent()
|
||||||
*/
|
*/
|
||||||
public IASTNode getParent() {
|
public IASTNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode)
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||||
*/
|
*/
|
||||||
public void setParent(IASTNode node) {
|
public void setParent(IASTNode node) {
|
||||||
this.parent = node;
|
this.parent = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent()
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent()
|
||||||
*/
|
*/
|
||||||
public ASTNodeProperty getPropertyInParent() {
|
public ASTNodeProperty getPropertyInParent() {
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty)
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty)
|
||||||
*/
|
*/
|
||||||
public void setPropertyInParent(ASTNodeProperty property) {
|
public void setPropertyInParent(ASTNodeProperty property) {
|
||||||
|
@ -58,37 +67,43 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final char[] arg;
|
private final char[] arg;
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
private final boolean isError;
|
private final boolean isError;
|
||||||
private final boolean isWarning;
|
|
||||||
|
private final boolean isWarning;
|
||||||
|
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
|
||||||
public ASTProblem( int id, char[] arg, boolean warn, boolean error )
|
public ASTProblem(int id, char[] arg, boolean warn, boolean error) {
|
||||||
{
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.arg = arg;
|
this.arg = arg;
|
||||||
this.isWarning = warn;
|
this.isWarning = warn;
|
||||||
this.isError = error;
|
this.isError = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getID()
|
* @see org.eclipse.cdt.core.parser.IProblem#getID()
|
||||||
*/
|
*/
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#isError()
|
* @see org.eclipse.cdt.core.parser.IProblem#isError()
|
||||||
*/
|
*/
|
||||||
public boolean isError() {
|
public boolean isError() {
|
||||||
return isError;
|
return isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#isWarning()
|
* @see org.eclipse.cdt.core.parser.IProblem#isWarning()
|
||||||
*/
|
*/
|
||||||
public boolean isWarning() {
|
public boolean isWarning() {
|
||||||
|
@ -98,183 +113,286 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
protected static final Map errorMessages;
|
protected static final Map errorMessages;
|
||||||
static {
|
static {
|
||||||
errorMessages = new HashMap();
|
errorMessages = new HashMap();
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer( IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
.put(
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
new Integer(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer( IProblem.SEMANTIC_NAME_NOT_FOUND),
|
.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer( IProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
new Integer(IProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_CONVERSION_TYPE ),
|
errorMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||||
new Integer( IProblem.SEMANTIC_MALFORMED_EXPRESSION ),
|
ParserMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer( IProblem.SEMANTIC_AMBIGUOUS_LOOKUP ),
|
.put(
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
new Integer(IProblem.SEMANTIC_INVALID_CONVERSION_TYPE),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_TYPE ),
|
.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer( IProblem.SEMANTIC_CIRCULAR_INHERITANCE ),
|
new Integer(IProblem.SEMANTIC_MALFORMED_EXPRESSION),
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_OVERLOAD ),
|
errorMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.SEMANTIC_AMBIGUOUS_LOOKUP),
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE ),
|
ParserMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_USING ),
|
.put(
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
new Integer(IProblem.SEMANTIC_INVALID_TYPE),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer( IProblem.SEMANTIC_BAD_VISIBILITY ),
|
.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer( IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION ),
|
new Integer(IProblem.SEMANTIC_CIRCULAR_INHERITANCE),
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT ),
|
errorMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.SEMANTIC_INVALID_OVERLOAD),
|
||||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER ),
|
ParserMessages
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer( IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER ),
|
.put(
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
new Integer(IProblem.SEMANTIC_INVALID_TEMPLATE),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer( IProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION ),
|
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
new Integer(IProblem.SEMANTIC_INVALID_USING),
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||||
new Integer(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
|
errorMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.SEMANTIC_BAD_VISIBILITY),
|
||||||
new Integer(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
|
ParserMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
|
.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
|
.put(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
|
new Integer(
|
||||||
errorMessages.put(
|
IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION),
|
||||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
|
ParserMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
|
.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_UNBALANCE_CONDITION),
|
.put(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
|
new Integer(IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
|
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
|
new Integer(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
|
IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
|
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.circularInclusion")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.PREPROCESSOR_INVALID_DIRECTIVE),
|
new Integer(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidDirective")); //$NON-NLS-1$
|
IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR),
|
.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST),
|
new Integer(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
|
IProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.PREPROCESSOR_INVALID_VA_ARGS),
|
.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.SCANNER_INVALID_ESCAPECHAR),
|
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
|
||||||
new Integer(IProblem.SCANNER_UNBOUNDED_STRING),
|
errorMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.unboundedString")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
|
||||||
new Integer(IProblem.SCANNER_BAD_FLOATING_POINT),
|
ParserMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badFloatingPoint")); //$NON-NLS-1$
|
.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer(IProblem.SCANNER_BAD_HEX_FORMAT),
|
.put(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badHexFormat")); //$NON-NLS-1$
|
new Integer(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.SCANNER_BAD_OCTAL_FORMAT),
|
.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badOctalFormat")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.SCANNER_BAD_DECIMAL_FORMAT),
|
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
|
||||||
new Integer(IProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED),
|
errorMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
|
||||||
new Integer(IProblem.SCANNER_DIVIDE_BY_ZERO),
|
ParserMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
|
.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
|
||||||
errorMessages.put(
|
errorMessages
|
||||||
new Integer(IProblem.SCANNER_MISSING_R_PAREN),
|
.put(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.missingRParen")); //$NON-NLS-1$
|
new Integer(IProblem.PREPROCESSOR_UNBALANCE_CONDITION),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR),
|
.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.expressionSyntaxError")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.SCANNER_ILLEGAL_IDENTIFIER),
|
new Integer(
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
|
IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
|
||||||
errorMessages.put(
|
ParserMessages
|
||||||
new Integer(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION),
|
.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
|
errorMessages
|
||||||
errorMessages.put(
|
.put(
|
||||||
new Integer(IProblem.SCANNER_UNEXPECTED_EOF),
|
new Integer(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
|
ParserMessages
|
||||||
errorMessages.put(
|
.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
|
||||||
new Integer(IProblem.SCANNER_BAD_CHARACTER),
|
errorMessages
|
||||||
ParserMessages.getString("ScannerProblemFactory.error.scanner.badCharacter")); //$NON-NLS-1$
|
.put(
|
||||||
errorMessages.put(
|
new Integer(IProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
|
||||||
new Integer( IProblem.SYNTAX_ERROR ),
|
ParserMessages
|
||||||
ParserMessages.getString( "ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$
|
.getString("ScannerProblemFactory.error.preproc.circularInclusion")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.PREPROCESSOR_INVALID_DIRECTIVE),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.preproc.invalidDirective")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(
|
||||||
|
IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.PREPROCESSOR_INVALID_VA_ARGS),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_INVALID_ESCAPECHAR),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_UNBOUNDED_STRING),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.unboundedString")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_FLOATING_POINT),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badFloatingPoint")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_HEX_FORMAT),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badHexFormat")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_OCTAL_FORMAT),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badOctalFormat")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_DECIMAL_FORMAT),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_DIVIDE_BY_ZERO),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_MISSING_R_PAREN),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.missingRParen")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.expressionSyntaxError")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_ILLEGAL_IDENTIFIER),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_UNEXPECTED_EOF),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
|
||||||
|
errorMessages
|
||||||
|
.put(
|
||||||
|
new Integer(IProblem.SCANNER_BAD_CHARACTER),
|
||||||
|
ParserMessages
|
||||||
|
.getString("ScannerProblemFactory.error.scanner.badCharacter")); //$NON-NLS-1$
|
||||||
|
errorMessages.put(new Integer(IProblem.SYNTAX_ERROR), ParserMessages
|
||||||
|
.getString("ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
|
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
|
||||||
|
|
||||||
public String getMessage()
|
public String getMessage() {
|
||||||
{
|
if (message != null)
|
||||||
if( message != null )
|
|
||||||
return message;
|
return message;
|
||||||
|
|
||||||
String msg = (String) errorMessages.get( new Integer(id) );
|
String msg = (String) errorMessages.get(new Integer(id));
|
||||||
if( msg == null )
|
if (msg == null)
|
||||||
msg = ""; //$NON-NLS-1$
|
msg = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
if( arg != null ){
|
if (arg != null) {
|
||||||
msg = MessageFormat.format( msg, new Object [] { new String(arg) } );
|
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||||
}
|
}
|
||||||
|
|
||||||
Object [] args = new Object[] { msg, new String( "" ), new Integer( 0 ) }; //$NON-NLS-1$
|
Object[] args = new Object[] { msg, new String(""), new Integer(0) }; //$NON-NLS-1$
|
||||||
message = ParserMessages.getFormattedString( PROBLEM_PATTERN, args );
|
message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
|
* @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
|
||||||
*/
|
*/
|
||||||
public boolean checkCategory(int bitmask) {
|
public boolean checkCategory(int bitmask) {
|
||||||
return ((id & bitmask) != 0 );
|
return ((id & bitmask) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getArguments()
|
* @see org.eclipse.cdt.core.parser.IProblem#getArguments()
|
||||||
*/
|
*/
|
||||||
public String getArguments() {
|
public String getArguments() {
|
||||||
return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
|
return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit()
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit()
|
||||||
*/
|
*/
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
// TODO Auto-generated method stub
|
if (this instanceof IASTTranslationUnit)
|
||||||
return null;
|
return (IASTTranslationUnit) this;
|
||||||
|
IASTNode node = getParent();
|
||||||
|
while (!(node instanceof IASTTranslationUnit) && node != null) {
|
||||||
|
node = node.getParent();
|
||||||
|
}
|
||||||
|
return (IASTTranslationUnit) node;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
@ -52,15 +53,11 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||||
import org.eclipse.cdt.core.parser.ParseError;
|
import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.parser.BacktrackException;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserProblemFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -100,12 +97,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected int backtrackCount = 0;
|
protected int backtrackCount = 0;
|
||||||
|
|
||||||
protected final void throwBacktrack(int startingOffset, int endingOffset,
|
protected final void throwBacktrack(int offset, int length ) throws BacktrackException {
|
||||||
int lineNumber, char[] f) throws BacktrackException {
|
|
||||||
++backtrackCount;
|
++backtrackCount;
|
||||||
backtrack.initialize(startingOffset,
|
backtrack.initialize(offset, ( length < 0 ) ? 0 : length );
|
||||||
(endingOffset == 0) ? startingOffset + 1 : endingOffset,
|
|
||||||
lineNumber, f);
|
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +179,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if (LT(1) == type)
|
if (LT(1) == type)
|
||||||
return consume();
|
return consume();
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la.getLineNumber(),
|
throwBacktrack(la.getOffset(), la.getLength());
|
||||||
la.getFilename());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +204,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
||||||
|
|
||||||
protected IProblemFactory problemFactory = new ParserProblemFactory();
|
|
||||||
|
|
||||||
protected static int parseCount = 0;
|
protected static int parseCount = 0;
|
||||||
|
|
||||||
protected void handleOffsetLimitException(
|
protected void handleOffsetLimitException(
|
||||||
|
@ -298,10 +289,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected void failParse(BacktrackException bt) {
|
protected void failParse(BacktrackException bt) {
|
||||||
if (requestor != null) {
|
if (requestor != null) {
|
||||||
if (bt.getProblem() == null) {
|
if (bt.getProblem() == null) {
|
||||||
IProblem problem = problemFactory.createProblem(
|
IASTProblem problem = createProblem( IASTProblem.SYNTAX_ERROR, bt.getOffset(), bt.getLength() );
|
||||||
IProblem.SYNTAX_ERROR, bt.getStartingOffset(), bt
|
|
||||||
.getEndOffset(), bt.getLineNumber(), bt
|
|
||||||
.getFilename(), EMPTY_STRING, false, true);
|
|
||||||
requestor.acceptProblem(problem);
|
requestor.acceptProblem(problem);
|
||||||
} else
|
} else
|
||||||
requestor.acceptProblem(bt.getProblem());
|
requestor.acceptProblem(bt.getProblem());
|
||||||
|
@ -309,13 +297,20 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
failParse();
|
failParse();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void failParse(IProblem problem) {
|
/**
|
||||||
if (problem != null && requestor != null) {
|
* @param syntax_error
|
||||||
requestor.acceptProblem(problem);
|
* @param offset
|
||||||
}
|
* @param length
|
||||||
failParse();
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTProblem createProblem(int signal, int offset, int length)
|
||||||
|
{
|
||||||
|
IASTProblem result = new ASTProblem( signal, EMPTY_STRING, false, true );
|
||||||
|
((ASTNode)result).setOffset( offset );
|
||||||
|
((ASTNode)result).setLength( length );
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @param e
|
* @param e
|
||||||
|
@ -360,7 +355,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void throwBacktrack(IProblem problem)
|
protected final void throwBacktrack(IASTProblem problem)
|
||||||
throws BacktrackException {
|
throws BacktrackException {
|
||||||
++backtrackCount;
|
++backtrackCount;
|
||||||
backtrack.initialize(problem);
|
backtrack.initialize(problem);
|
||||||
|
@ -1087,8 +1082,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
enumeratorName = createName( identifier() );
|
enumeratorName = createName( identifier() );
|
||||||
} else {
|
} else {
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la
|
throwBacktrack(la.getOffset(), la.getLength());
|
||||||
.getLineNumber(), la.getFilename());
|
|
||||||
}
|
}
|
||||||
IASTExpression initialValue = null;
|
IASTExpression initialValue = null;
|
||||||
if (LT(1) == IToken.tASSIGN) {
|
if (LT(1) == IToken.tASSIGN) {
|
||||||
|
@ -1115,10 +1109,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (LT(1) != IToken.tCOMMA) {
|
if (LT(1) != IToken.tCOMMA) {
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||||
.getEndOffset() : 0;
|
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
|
||||||
.getLineNumber(), mark.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerator = createEnumerator();
|
enumerator = createEnumerator();
|
||||||
|
@ -1143,10 +1134,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// enumSpecifierAbort
|
// enumSpecifierAbort
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(),
|
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||||
mark.getFilename());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1688,7 +1677,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if_loop: while( true ){
|
if_loop: while( true ){
|
||||||
int so = consume(IToken.t_if).getOffset();
|
int so = consume(IToken.t_if).getOffset();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
IToken start = LA(1);
|
|
||||||
boolean passedCondition = true;
|
boolean passedCondition = true;
|
||||||
IASTExpression condition = null;
|
IASTExpression condition = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1696,14 +1684,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
//if the problem has no offset info, make a new one that does
|
//if the problem has no offset info, make a new one that does
|
||||||
if( b.getProblem() != null && b.getProblem().getSourceLineNumber() == -1 ){
|
if( b.getProblem() != null ){
|
||||||
IProblem p = b.getProblem();
|
IASTProblem p = b.getProblem();
|
||||||
IProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(),
|
// IASTProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(),
|
||||||
lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(),
|
// lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(),
|
||||||
start.getLineNumber(), p.getOriginatingFileName(),
|
// start.getLineNumber(), p.getOriginatingFileName(),
|
||||||
p.getArguments() != null ? p.getArguments().toCharArray() : null,
|
// p.getArguments() != null ? p.getArguments().toCharArray() : null,
|
||||||
p.isWarning(), p.isError() );
|
// p.isWarning(), p.isError() );
|
||||||
b.initialize( p2 );
|
b.initialize( p );
|
||||||
}
|
}
|
||||||
failParse(b);
|
failParse(b);
|
||||||
failParseWithErrorHandling();
|
failParseWithErrorHandling();
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class BacktrackException extends Exception {
|
||||||
|
private IASTProblem problem;
|
||||||
|
private int offset, length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p
|
||||||
|
*/
|
||||||
|
public void initialize(IASTProblem p) {
|
||||||
|
reset();
|
||||||
|
problem = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void reset() {
|
||||||
|
problem = null;
|
||||||
|
offset = 0;
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the problem.
|
||||||
|
*/
|
||||||
|
public final IASTProblem getProblem() {
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startingOffset
|
||||||
|
* @param endingOffset
|
||||||
|
* @param f TODO
|
||||||
|
*/
|
||||||
|
public void initialize(int start, int l ) {
|
||||||
|
reset();
|
||||||
|
offset = start;
|
||||||
|
length = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the length.
|
||||||
|
*/
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the offset.
|
||||||
|
*/
|
||||||
|
public int getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -21,6 +21,6 @@ import org.eclipse.cdt.core.parser.IProblem;
|
||||||
*/
|
*/
|
||||||
public interface IProblemRequestor {
|
public interface IProblemRequestor {
|
||||||
|
|
||||||
public boolean acceptProblem( IProblem problem );
|
public boolean acceptProblem( IASTProblem problem );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
||||||
import org.eclipse.cdt.internal.core.parser.BacktrackException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -143,8 +143,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
int line = la.getLineNumber();
|
|
||||||
char[] fn = la.getFilename();
|
|
||||||
la = null;
|
la = null;
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
|
@ -195,8 +193,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
if (checkHashcode == LA(1).hashCode()) {
|
if (checkHashcode == LA(1).hashCode()) {
|
||||||
IToken l2 = LA(1);
|
IToken l2 = LA(1);
|
||||||
throwBacktrack(startingOffset, l2.getEndOffset(), l2
|
throwBacktrack(startingOffset, l2.getEndOffset() - startingOffset);
|
||||||
.getLineNumber(), l2.getFilename());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +219,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||||
throwBacktrack(startingOffset, endOffset, line, fn);
|
throwBacktrack(startingOffset, endOffset - startingOffset);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,10 +396,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
EndOfFileException {
|
EndOfFileException {
|
||||||
IToken firstToken = LA(1);
|
IToken firstToken = LA(1);
|
||||||
int firstOffset = firstToken.getOffset();
|
int firstOffset = firstToken.getOffset();
|
||||||
char[] fn = firstToken.getFilename();
|
|
||||||
if (firstToken.getType() == IToken.tLBRACE)
|
if (firstToken.getType() == IToken.tLBRACE)
|
||||||
throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(),
|
throwBacktrack(firstToken.getOffset(), firstToken.getLength() );
|
||||||
firstToken.getLineNumber(), firstToken.getFilename());
|
|
||||||
|
|
||||||
firstToken = null; // necessary for scalability
|
firstToken = null; // necessary for scalability
|
||||||
|
|
||||||
|
@ -431,8 +426,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.tLBRACE:
|
case IToken.tLBRACE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||||
.getLineNumber(), fn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!consumedSemi) {
|
if (!consumedSemi) {
|
||||||
|
@ -441,19 +435,16 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFunctionTryBlock && !hasFunctionBody)
|
if (hasFunctionTryBlock && !hasFunctionBody)
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFunctionBody) {
|
if (hasFunctionBody) {
|
||||||
if (declarators.size() != 1)
|
if (declarators.size() != 1)
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset());
|
||||||
.getLineNumber(), fn);
|
|
||||||
|
|
||||||
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
||||||
if (!(declarator instanceof IASTFunctionDeclarator))
|
if (!(declarator instanceof IASTFunctionDeclarator))
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset());
|
||||||
.getLineNumber(), fn);
|
|
||||||
|
|
||||||
IASTFunctionDefinition funcDefinition = createFunctionDefinition();
|
IASTFunctionDefinition funcDefinition = createFunctionDefinition();
|
||||||
((ASTNode)funcDefinition).setOffset(firstOffset);
|
((ASTNode)funcDefinition).setOffset(firstOffset);
|
||||||
|
@ -1018,7 +1009,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.tIDENTIFIER:
|
case IToken.tIDENTIFIER:
|
||||||
|
|
||||||
int startingOffset = LA(1).getOffset();
|
int startingOffset = LA(1).getOffset();
|
||||||
int line = LA(1).getLineNumber();
|
|
||||||
IToken t1 = identifier();
|
IToken t1 = identifier();
|
||||||
IASTIdExpression idExpression = createIdExpression();
|
IASTIdExpression idExpression = createIdExpression();
|
||||||
IASTName name = createName(t1);
|
IASTName name = createName(t1);
|
||||||
|
@ -1029,8 +1019,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
default:
|
default:
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
startingOffset = la.getOffset();
|
startingOffset = la.getOffset();
|
||||||
line = la.getLineNumber();
|
throwBacktrack( startingOffset, la.getLength() );
|
||||||
throwBacktrack( startingOffset, startingOffset, line, la.getFilename() );
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,8 +1043,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
int startingOffset = mark.getOffset();
|
int startingOffset = mark.getOffset();
|
||||||
char [] filename = mark.getFilename();
|
|
||||||
int lineNumber = mark.getLineNumber();
|
|
||||||
IASTDeclSpecifier declSpecifier = null;
|
IASTDeclSpecifier declSpecifier = null;
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
|
|
||||||
|
@ -1068,13 +1055,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
{
|
{
|
||||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||||
backup( mark );
|
backup( mark );
|
||||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||||
}
|
}
|
||||||
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||||
backup( mark );
|
backup( mark );
|
||||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTTypeId result = createTypeId();
|
IASTTypeId result = createTypeId();
|
||||||
|
@ -1458,8 +1445,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
classKind = IASTCompositeTypeSpecifier.k_union;
|
classKind = IASTCompositeTypeSpecifier.k_union;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
throwBacktrack(mark.getOffset(), mark.getLength() );
|
||||||
.getLineNumber(), mark.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IToken nameToken = null;
|
IToken nameToken = null;
|
||||||
|
@ -1471,8 +1457,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) != IToken.tLBRACE) {
|
if (LT(1) != IToken.tLBRACE) {
|
||||||
IToken errorPoint = LA(1);
|
IToken errorPoint = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
throwBacktrack(errorPoint.getOffset(), errorPoint.getLength());
|
||||||
errorPoint.getLineNumber(), errorPoint.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
|
@ -1553,8 +1538,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
backup(t);
|
backup(t);
|
||||||
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(),
|
throwBacktrack(t.getOffset(), t.getLength() );
|
||||||
t.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IToken identifier = identifier();
|
IToken identifier = identifier();
|
||||||
|
@ -1598,8 +1582,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTName declaratorName = null;
|
IASTName declaratorName = null;
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
int line = la.getLineNumber();
|
|
||||||
char[] fn = la.getFilename();
|
|
||||||
la = null;
|
la = null;
|
||||||
List pointerOps = new ArrayList(DEFAULT_POINTEROPS_LIST_SIZE);
|
List pointerOps = new ArrayList(DEFAULT_POINTEROPS_LIST_SIZE);
|
||||||
List parameters = Collections.EMPTY_LIST;
|
List parameters = Collections.EMPTY_LIST;
|
||||||
|
@ -1648,8 +1630,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
if (seenParameter)
|
if (seenParameter)
|
||||||
throwBacktrack(startingOffset, endOffset,
|
throwBacktrack(startingOffset, endOffset - startingOffset);
|
||||||
line, fn);
|
|
||||||
IASTParameterDeclaration pd = parameterDeclaration();
|
IASTParameterDeclaration pd = parameterDeclaration();
|
||||||
if (parameters == Collections.EMPTY_LIST)
|
if (parameters == Collections.EMPTY_LIST)
|
||||||
parameters = new ArrayList(
|
parameters = new ArrayList(
|
||||||
|
@ -1869,8 +1850,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
if (current == LA(1)) {
|
if (current == LA(1)) {
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||||
throwBacktrack(current.getOffset(), endOffset, current
|
throwBacktrack(current.getOffset(), endOffset - current.getOffset() );
|
||||||
.getLineNumber(), current.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTParameterDeclaration result = createParameterDeclaration();
|
IASTParameterDeclaration result = createParameterDeclaration();
|
||||||
|
@ -2151,4 +2131,5 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
translationUnit = null;
|
translationUnit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -58,6 +58,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
@ -118,7 +119,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
@ -127,8 +127,8 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
||||||
import org.eclipse.cdt.internal.core.parser.BacktrackException;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.SimpleDeclarationStrategy;
|
import org.eclipse.cdt.internal.core.parser.SimpleDeclarationStrategy;
|
||||||
import org.eclipse.cdt.internal.core.parser.TemplateParameterManager;
|
import org.eclipse.cdt.internal.core.parser.TemplateParameterManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
|
@ -221,8 +221,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
} while (scopes.size() > 0
|
} while (scopes.size() > 0
|
||||||
&& (top == IToken.tGT || top == IToken.tLT));
|
&& (top == IToken.tGT || top == IToken.tLT));
|
||||||
if (top != IToken.tLBRACKET)
|
if (top != IToken.tLBRACKET)
|
||||||
throwBacktrack(startingOffset, last.getEndOffset(),
|
throwBacktrack(startingOffset, last.getEndOffset() - startingOffset );
|
||||||
last.getLineNumber(), last.getFilename());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IToken.tRPAREN:
|
case IToken.tRPAREN:
|
||||||
|
@ -231,8 +230,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
} while (scopes.size() > 0
|
} while (scopes.size() > 0
|
||||||
&& (top == IToken.tGT || top == IToken.tLT));
|
&& (top == IToken.tGT || top == IToken.tLT));
|
||||||
if (top != IToken.tLPAREN)
|
if (top != IToken.tLPAREN)
|
||||||
throwBacktrack(startingOffset, last.getEndOffset(),
|
throwBacktrack(startingOffset, last.getEndOffset() - startingOffset );
|
||||||
last.getLineNumber(), last.getFilename());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IToken.tLT:
|
case IToken.tLT:
|
||||||
|
@ -250,8 +248,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken start = LA(1);
|
IToken start = LA(1);
|
||||||
int startingOffset = start.getOffset();
|
int startingOffset = start.getOffset();
|
||||||
int startingLineNumber = start.getOffset();
|
int endOffset = 0;
|
||||||
char[] fn = start.getFilename();
|
|
||||||
start = null;
|
start = null;
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
|
|
||||||
|
@ -289,6 +286,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume();
|
consume();
|
||||||
} else if (LT(1) != IToken.tGT) {
|
} else if (LT(1) != IToken.tGT) {
|
||||||
failed = true;
|
failed = true;
|
||||||
|
endOffset = LA(1).getEndOffset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +294,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
templateIdScopes.pop();
|
templateIdScopes.pop();
|
||||||
|
|
||||||
if (failed)
|
if (failed)
|
||||||
throwBacktrack(startingOffset, 0, startingLineNumber, fn);
|
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||||
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -344,8 +342,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
default:
|
default:
|
||||||
IToken l = LA(1);
|
IToken l = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(first.getOffset(), l.getEndOffset(), first
|
throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset() );
|
||||||
.getLineNumber(), l.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (LT(1) == IToken.tCOLONCOLON) {
|
while (LT(1) == IToken.tCOLONCOLON) {
|
||||||
|
@ -361,8 +358,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.t_operator:
|
case IToken.t_operator:
|
||||||
IToken l = LA(1);
|
IToken l = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(first.getOffset(), l.getEndOffset(), first
|
throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset() );
|
||||||
.getLineNumber(), l.getFilename());
|
|
||||||
case IToken.tIDENTIFIER:
|
case IToken.tIDENTIFIER:
|
||||||
last = consume();
|
last = consume();
|
||||||
last = consumeTemplateArguments(last, argumentList);
|
last = consumeTemplateArguments(last, argumentList);
|
||||||
|
@ -409,45 +405,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a const-volatile qualifier.
|
|
||||||
*
|
|
||||||
* cvQualifier : "const" | "volatile"
|
|
||||||
*
|
|
||||||
* TODO: fix this
|
|
||||||
*
|
|
||||||
* @param ptrOp
|
|
||||||
* Pointer Operator that const-volatile applies to.
|
|
||||||
* @throws BacktrackException
|
|
||||||
*/
|
|
||||||
protected void cvQualifier(List collection)
|
|
||||||
throws EndOfFileException, BacktrackException {
|
|
||||||
|
|
||||||
int startingOffset = LA(1).getOffset();
|
|
||||||
switch (LT(1)) {
|
|
||||||
case IToken.t_const:
|
|
||||||
consume(IToken.t_const);
|
|
||||||
collection.add(null /*ASTPointerOperator.CONST_POINTER*/);
|
|
||||||
break;
|
|
||||||
case IToken.t_volatile:
|
|
||||||
consume(IToken.t_volatile);
|
|
||||||
collection.add(null/*ASTPointerOperator.VOLATILE_POINTER*/);
|
|
||||||
break;
|
|
||||||
case IToken.t_restrict:
|
|
||||||
if (allowCPPRestrict) {
|
|
||||||
consume(IToken.t_restrict);
|
|
||||||
collection
|
|
||||||
.add(null/*ASTPointerOperator.RESTRICT_POINTER*/);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
IToken la = LA(1);
|
|
||||||
throwBacktrack(startingOffset, la.getEndOffset(), la
|
|
||||||
.getLineNumber(), la.getFilename());
|
|
||||||
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ITokenDuple operatorId(IToken originalToken, TemplateParameterManager templateArgs) throws BacktrackException,
|
protected ITokenDuple operatorId(IToken originalToken, TemplateParameterManager templateArgs) throws BacktrackException,
|
||||||
EndOfFileException {
|
EndOfFileException {
|
||||||
// we know this is an operator
|
// we know this is an operator
|
||||||
|
@ -472,9 +429,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
toSend = consume();
|
toSend = consume();
|
||||||
else
|
else
|
||||||
throwBacktrack(operatorToken.getOffset(),
|
throwBacktrack(operatorToken.getOffset(),
|
||||||
toSend != null ? toSend.getEndOffset() : 0,
|
toSend != null ? toSend.getEndOffset() - operatorToken.getOffset(): 0 );
|
||||||
operatorToken.getLineNumber(), operatorToken
|
|
||||||
.getFilename());
|
|
||||||
} else {
|
} else {
|
||||||
// must be a conversion function
|
// must be a conversion function
|
||||||
typeId(true);
|
typeId(true);
|
||||||
|
@ -563,8 +518,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack(startingOffset, la.getEndOffset(), la
|
throwBacktrack(startingOffset, la.getEndOffset() - startingOffset );
|
||||||
.getLineNumber(), la.getFilename());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if( t == LA(1) )
|
if( t == LA(1) )
|
||||||
|
@ -913,8 +867,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
int startingOffset = mark.getOffset();
|
int startingOffset = mark.getOffset();
|
||||||
char [] filename = mark.getFilename();
|
|
||||||
int lineNumber = mark.getLineNumber();
|
|
||||||
IASTDeclSpecifier declSpecifier = null;
|
IASTDeclSpecifier declSpecifier = null;
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
|
|
||||||
|
@ -927,13 +879,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
{
|
{
|
||||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||||
backup( mark );
|
backup( mark );
|
||||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||||
}
|
}
|
||||||
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||||
backup( mark );
|
backup( mark );
|
||||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTTypeId result = createTypeId();
|
IASTTypeId result = createTypeId();
|
||||||
|
@ -1051,7 +1003,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
templateIdScopes.pop();
|
templateIdScopes.pop();
|
||||||
} //pop 1st Parent
|
} //pop 1st Parent
|
||||||
placementParseFailure = true;
|
placementParseFailure = true;
|
||||||
throwBacktrack( backtrackMarker.getOffset(), backtrackMarker.getEndOffset(), backtrackMarker.getLineNumber(), backtrackMarker.getFilename() );
|
throwBacktrack( backtrackMarker.getOffset(), backtrackMarker.getLength() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
placementParseFailure = false;
|
placementParseFailure = false;
|
||||||
|
@ -1669,9 +1621,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
default:
|
default:
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
int line = la.getLineNumber();
|
throwBacktrack(startingOffset, la.getLength());
|
||||||
char[] fn = la.getFilename();
|
|
||||||
throwBacktrack(startingOffset, startingOffset, line, fn);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1714,8 +1664,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
duple = operatorId(start, null);
|
duple = operatorId(start, null);
|
||||||
else {
|
else {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(start.getOffset(), end.getEndOffset(), end
|
throwBacktrack(start.getOffset(), end.getEndOffset() - start.getOffset() );
|
||||||
.getLineNumber(), start.getFilename());
|
|
||||||
}
|
}
|
||||||
} else if (LT(1) == IToken.t_operator)
|
} else if (LT(1) == IToken.t_operator)
|
||||||
duple = operatorId(null, null);
|
duple = operatorId(null, null);
|
||||||
|
@ -1810,8 +1759,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||||
name = createName( name() );
|
name = createName( name() );
|
||||||
else
|
else
|
||||||
throwBacktrack(firstToken.getOffset(), endOffset, firstToken
|
throwBacktrack(firstToken.getOffset(), endOffset - firstToken.getOffset() );
|
||||||
.getLineNumber(), firstToken.getFilename());
|
|
||||||
|
|
||||||
consume(IToken.tSEMI);
|
consume(IToken.tSEMI);
|
||||||
ICPPASTUsingDirective astUD = createUsingDirective();
|
ICPPASTUsingDirective astUD = createUsingDirective();
|
||||||
|
@ -2237,8 +2185,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
protected IASTDeclaration simpleDeclarationStrategyUnion() throws EndOfFileException, BacktrackException {
|
protected IASTDeclaration simpleDeclarationStrategyUnion() throws EndOfFileException, BacktrackException {
|
||||||
simpleDeclarationMark = mark();
|
simpleDeclarationMark = mark();
|
||||||
IProblem firstFailure = null;
|
IASTProblem firstFailure = null;
|
||||||
IProblem secondFailure = null;
|
IASTProblem secondFailure = null;
|
||||||
try {
|
try {
|
||||||
return simpleDeclaration(SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
return simpleDeclaration(SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
||||||
false);
|
false);
|
||||||
|
@ -2345,8 +2293,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IToken assign = consume(IToken.tASSIGN);
|
IToken assign = consume(IToken.tASSIGN);
|
||||||
|
|
||||||
if (name.toString() == null) {
|
if (name.toString() == null) {
|
||||||
throwBacktrack(first.getOffset(), assign.getEndOffset(), first
|
throwBacktrack(first.getOffset(), assign.getEndOffset() - first.getOffset() );
|
||||||
.getLineNumber(), first.getFilename());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2365,8 +2312,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return alias;
|
return alias;
|
||||||
} else {
|
} else {
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||||
throwBacktrack(first.getOffset(), endOffset, first.getLineNumber(),
|
throwBacktrack(first.getOffset(), endOffset - first.getOffset() );
|
||||||
first.getFilename());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2486,11 +2432,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
IToken firstToken = LA(1);
|
IToken firstToken = LA(1);
|
||||||
int firstOffset = firstToken.getOffset();
|
int firstOffset = firstToken.getOffset();
|
||||||
int firstLine = firstToken.getLineNumber();
|
|
||||||
char[] fn = firstToken.getFilename();
|
|
||||||
if (firstToken.getType() == IToken.tLBRACE)
|
if (firstToken.getType() == IToken.tLBRACE)
|
||||||
throwBacktrack(firstOffset, firstToken.getEndOffset(),
|
throwBacktrack(firstOffset, firstToken.getLength() );
|
||||||
firstLine, fn);
|
|
||||||
firstToken = null; // necessary for scalability
|
firstToken = null; // necessary for scalability
|
||||||
|
|
||||||
ICPPASTDeclSpecifier declSpec = declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR);
|
ICPPASTDeclSpecifier declSpec = declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR);
|
||||||
|
@ -2531,12 +2474,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
case IToken.tRPAREN:
|
case IToken.tRPAREN:
|
||||||
if (!fromCatchHandler)
|
if (!fromCatchHandler)
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!consumedSemi) {
|
if (!consumedSemi) {
|
||||||
|
@ -2545,19 +2486,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFunctionTryBlock && !hasFunctionBody)
|
if (hasFunctionTryBlock && !hasFunctionBody)
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFunctionBody) {
|
if (hasFunctionBody) {
|
||||||
if (declarators.size() != 1)
|
if (declarators.size() != 1)
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
|
|
||||||
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
||||||
if (!(declarator instanceof IASTFunctionDeclarator))
|
if (!(declarator instanceof IASTFunctionDeclarator))
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||||
.getLineNumber(), fn);
|
|
||||||
|
|
||||||
if( ! constructorChain.isEmpty() && declarator instanceof ICPPASTFunctionDeclarator )
|
if( ! constructorChain.isEmpty() && declarator instanceof ICPPASTFunctionDeclarator )
|
||||||
{
|
{
|
||||||
|
@ -2707,8 +2645,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
if (current == LA(1)) {
|
if (current == LA(1)) {
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||||
throwBacktrack(current.getOffset(), endOffset, current
|
throwBacktrack(current.getOffset(), endOffset - current.getOffset() );
|
||||||
.getLineNumber(), current.getFilename());
|
|
||||||
}
|
}
|
||||||
ICPPASTParameterDeclaration parm = createParameterDeclaration();
|
ICPPASTParameterDeclaration parm = createParameterDeclaration();
|
||||||
((ASTNode)parm).setOffset( current.getOffset() );
|
((ASTNode)parm).setOffset( current.getOffset() );
|
||||||
|
@ -2901,7 +2838,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if( !supportRestrict )
|
if( !supportRestrict )
|
||||||
{
|
{
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
throwBacktrack( la.getOffset(), la.getEndOffset() - la.getOffset() );
|
||||||
}
|
}
|
||||||
isRestrict = true;
|
isRestrict = true;
|
||||||
consume();
|
consume();
|
||||||
|
@ -2936,7 +2873,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if( ! supportComplex )
|
if( ! supportComplex )
|
||||||
{
|
{
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
throwBacktrack( la.getOffset(), la.getEndOffset() - la.getOffset() );
|
||||||
}
|
}
|
||||||
consume(IToken.t__Complex);
|
consume(IToken.t__Complex);
|
||||||
simpleType = IGPPASTSimpleDeclSpecifier.t_Complex;
|
simpleType = IGPPASTSimpleDeclSpecifier.t_Complex;
|
||||||
|
@ -2945,7 +2882,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if( ! supportComplex )
|
if( ! supportComplex )
|
||||||
{
|
{
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
throwBacktrack( la.getOffset(), la.getLength() );
|
||||||
}
|
}
|
||||||
consume(IToken.t__Imaginary);
|
consume(IToken.t__Imaginary);
|
||||||
simpleType = IGPPASTSimpleDeclSpecifier.t_Imaginary;
|
simpleType = IGPPASTSimpleDeclSpecifier.t_Imaginary;
|
||||||
|
@ -3188,8 +3125,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
backup(t);
|
backup(t);
|
||||||
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(),
|
throwBacktrack(t.getOffset(), t.getLength() );
|
||||||
t.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTName name = createName( name() );
|
IASTName name = createName( name() );
|
||||||
|
@ -3363,8 +3299,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
int line = la.getLineNumber();
|
|
||||||
char[] fn = la.getFilename();
|
|
||||||
la = null;
|
la = null;
|
||||||
IASTDeclarator innerDecl = null;
|
IASTDeclarator innerDecl = null;
|
||||||
IASTName declaratorName = null;
|
IASTName declaratorName = null;
|
||||||
|
@ -3437,8 +3371,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
: 0;
|
: 0;
|
||||||
logException(
|
logException(
|
||||||
"declarator:queryIsTypeName", e); //$NON-NLS-1$
|
"declarator:queryIsTypeName", e); //$NON-NLS-1$
|
||||||
throwBacktrack(startingOffset, endOffset,
|
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||||
line, newMark.getFilename());
|
|
||||||
}
|
}
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
failed = true;
|
failed = true;
|
||||||
|
@ -3472,8 +3405,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
if (seenParameter)
|
if (seenParameter)
|
||||||
throwBacktrack(startingOffset, endOffset,
|
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||||
line, fn);
|
|
||||||
IASTParameterDeclaration p = parameterDeclaration();
|
IASTParameterDeclaration p = parameterDeclaration();
|
||||||
if( parameters == Collections.EMPTY_LIST )
|
if( parameters == Collections.EMPTY_LIST )
|
||||||
parameters = new ArrayList( DEFAULT_PARM_LIST_SIZE );
|
parameters = new ArrayList( DEFAULT_PARM_LIST_SIZE );
|
||||||
|
@ -3728,16 +3660,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
throwBacktrack(mark.getOffset(), endOffset - mark.getOffset() );
|
||||||
.getLineNumber(), mark.getFilename());
|
|
||||||
}
|
}
|
||||||
return TokenFactory.createTokenDuple( start, end, argumentList.getTemplateArgumentsList() );
|
return TokenFactory.createTokenDuple( start, end, argumentList.getTemplateArgumentsList() );
|
||||||
}
|
}
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
throwBacktrack(mark.getOffset(), endOffset - mark.getOffset() );
|
||||||
.getLineNumber(), mark.getFilename());
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -3779,8 +3709,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
classKind = IASTCompositeTypeSpecifier.k_union;
|
classKind = IASTCompositeTypeSpecifier.k_union;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||||
.getLineNumber(), mark.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTName name = null;
|
IASTName name = null;
|
||||||
|
@ -3794,8 +3723,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
|
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
|
||||||
IToken errorPoint = LA(1);
|
IToken errorPoint = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
throwBacktrack(errorPoint.getOffset(), errorPoint.getLength() );
|
||||||
errorPoint.getLineNumber(), errorPoint.getFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPASTCompositeTypeSpecifier astClassSpecifier = createClassSpecifier();
|
ICPPASTCompositeTypeSpecifier astClassSpecifier = createClassSpecifier();
|
||||||
|
@ -3998,8 +3926,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
if (LT(1) != IToken.t_catch) {
|
if (LT(1) != IToken.t_catch) {
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la
|
throwBacktrack(la.getOffset(), la.getLength()); // error, need at least one of these
|
||||||
.getLineNumber(), la.getFilename()); // error, need at least one of these
|
|
||||||
}
|
}
|
||||||
while (LT(1) == IToken.t_catch) {
|
while (LT(1) == IToken.t_catch) {
|
||||||
int startOffset = consume(IToken.t_catch).getOffset();
|
int startOffset = consume(IToken.t_catch).getOffset();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
|
|
||||||
private List problems = Collections.EMPTY_LIST;
|
private List problems = Collections.EMPTY_LIST;
|
||||||
|
private static final IASTProblem[] EMPTY_PROBLEMS_ARRAY = new IASTProblem[0];
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getMacroDefinitions()
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getMacroDefinitions()
|
||||||
|
@ -243,6 +244,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getScannerProblems()
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getScannerProblems()
|
||||||
*/
|
*/
|
||||||
public IASTProblem[] getScannerProblems() {
|
public IASTProblem[] getScannerProblems() {
|
||||||
|
if( problems == Collections.EMPTY_LIST ) return EMPTY_PROBLEMS_ARRAY;
|
||||||
return (IASTProblem[]) problems.toArray( new IASTProblem[ problems.size() ]);
|
return (IASTProblem[]) problems.toArray( new IASTProblem[ problems.size() ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.IParserConfiguration;
|
import org.eclipse.cdt.core.dom.IParserConfiguration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileType;
|
import org.eclipse.cdt.core.filetype.ICFileType;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileTypeConstants;
|
import org.eclipse.cdt.core.filetype.ICFileTypeConstants;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
@ -60,7 +60,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
private static final ISourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
private static final ISourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
||||||
private static final IProblemRequestor PROBLEM_REQUESTOR = new IProblemRequestor() {
|
private static final IProblemRequestor PROBLEM_REQUESTOR = new IProblemRequestor() {
|
||||||
|
|
||||||
public boolean acceptProblem(IProblem problem) {
|
public boolean acceptProblem(IASTProblem problem) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue