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.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;
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class ProblemCollector implements IProblemRequestor {
|
|||
*
|
||||
* @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);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,30 +27,39 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
|||
public class ASTProblem extends ASTNode implements IASTProblem {
|
||||
|
||||
private IASTNode parent;
|
||||
|
||||
private ASTNodeProperty property;
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent()
|
||||
*/
|
||||
public IASTNode getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void setParent(IASTNode node) {
|
||||
this.parent = node;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent()
|
||||
*/
|
||||
public ASTNodeProperty getPropertyInParent() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty)
|
||||
*/
|
||||
public void setPropertyInParent(ASTNodeProperty property) {
|
||||
|
@ -58,37 +67,43 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
|||
}
|
||||
|
||||
private final char[] arg;
|
||||
|
||||
private final int id;
|
||||
|
||||
private final boolean isError;
|
||||
private final boolean isWarning;
|
||||
|
||||
|
||||
private final boolean isWarning;
|
||||
|
||||
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.arg = arg;
|
||||
this.isWarning = warn;
|
||||
this.isError = error;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IProblem#getID()
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IProblem#isError()
|
||||
*/
|
||||
public boolean isError() {
|
||||
return isError;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IProblem#isWarning()
|
||||
*/
|
||||
public boolean isWarning() {
|
||||
|
@ -98,183 +113,286 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
|||
protected static final Map errorMessages;
|
||||
static {
|
||||
errorMessages = new HashMap();
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_CONVERSION_TYPE ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_MALFORMED_EXPRESSION ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_AMBIGUOUS_LOOKUP ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_TYPE ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_CIRCULAR_INHERITANCE ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_OVERLOAD ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_USING ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_BAD_VISIBILITY ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer( IProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION ),
|
||||
ParserMessages.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_UNBALANCE_CONDITION),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
|
||||
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
|
||||
errorMessages.put(
|
||||
new Integer(IProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
|
||||
ParserMessages.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$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_CONVERSION_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_MALFORMED_EXPRESSION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_AMBIGUOUS_LOOKUP),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_CIRCULAR_INHERITANCE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_OVERLOAD),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_TEMPLATE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_USING),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_BAD_VISIBILITY),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_UNBALANCE_CONDITION),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
|
||||
ParserMessages
|
||||
.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$
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
if( message != null )
|
||||
public String getMessage() {
|
||||
if (message != null)
|
||||
return message;
|
||||
|
||||
String msg = (String) errorMessages.get( new Integer(id) );
|
||||
if( msg == null )
|
||||
msg = ""; //$NON-NLS-1$
|
||||
|
||||
if( arg != null ){
|
||||
msg = MessageFormat.format( msg, new Object [] { new String(arg) } );
|
||||
|
||||
String msg = (String) errorMessages.get(new Integer(id));
|
||||
if (msg == null)
|
||||
msg = ""; //$NON-NLS-1$
|
||||
|
||||
if (arg != null) {
|
||||
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||
}
|
||||
|
||||
Object [] args = new Object[] { msg, new String( "" ), new Integer( 0 ) }; //$NON-NLS-1$
|
||||
message = ParserMessages.getFormattedString( PROBLEM_PATTERN, args );
|
||||
return message;
|
||||
|
||||
Object[] args = new Object[] { msg, new String(""), new Integer(0) }; //$NON-NLS-1$
|
||||
message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||
return message;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
|
||||
*/
|
||||
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()
|
||||
*/
|
||||
public String getArguments() {
|
||||
return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit()
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
if (this instanceof IASTTranslationUnit)
|
||||
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.IASTNode;
|
||||
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.IASTSimpleDeclSpecifier;
|
||||
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.IGCCToken;
|
||||
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.IToken;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
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
|
||||
|
@ -100,12 +97,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
protected int backtrackCount = 0;
|
||||
|
||||
protected final void throwBacktrack(int startingOffset, int endingOffset,
|
||||
int lineNumber, char[] f) throws BacktrackException {
|
||||
protected final void throwBacktrack(int offset, int length ) throws BacktrackException {
|
||||
++backtrackCount;
|
||||
backtrack.initialize(startingOffset,
|
||||
(endingOffset == 0) ? startingOffset + 1 : endingOffset,
|
||||
lineNumber, f);
|
||||
backtrack.initialize(offset, ( length < 0 ) ? 0 : length );
|
||||
throw backtrack;
|
||||
}
|
||||
|
||||
|
@ -185,8 +179,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
if (LT(1) == type)
|
||||
return consume();
|
||||
IToken la = LA(1);
|
||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la.getLineNumber(),
|
||||
la.getFilename());
|
||||
throwBacktrack(la.getOffset(), la.getLength());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -211,8 +204,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
||||
|
||||
protected IProblemFactory problemFactory = new ParserProblemFactory();
|
||||
|
||||
protected static int parseCount = 0;
|
||||
|
||||
protected void handleOffsetLimitException(
|
||||
|
@ -298,10 +289,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
protected void failParse(BacktrackException bt) {
|
||||
if (requestor != null) {
|
||||
if (bt.getProblem() == null) {
|
||||
IProblem problem = problemFactory.createProblem(
|
||||
IProblem.SYNTAX_ERROR, bt.getStartingOffset(), bt
|
||||
.getEndOffset(), bt.getLineNumber(), bt
|
||||
.getFilename(), EMPTY_STRING, false, true);
|
||||
IASTProblem problem = createProblem( IASTProblem.SYNTAX_ERROR, bt.getOffset(), bt.getLength() );
|
||||
requestor.acceptProblem(problem);
|
||||
} else
|
||||
requestor.acceptProblem(bt.getProblem());
|
||||
|
@ -309,13 +297,20 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
failParse();
|
||||
}
|
||||
|
||||
protected void failParse(IProblem problem) {
|
||||
if (problem != null && requestor != null) {
|
||||
requestor.acceptProblem(problem);
|
||||
}
|
||||
failParse();
|
||||
/**
|
||||
* @param syntax_error
|
||||
* @param offset
|
||||
* @param length
|
||||
* @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 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 {
|
||||
++backtrackCount;
|
||||
backtrack.initialize(problem);
|
||||
|
@ -1087,8 +1082,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
enumeratorName = createName( identifier() );
|
||||
} else {
|
||||
IToken la = LA(1);
|
||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la
|
||||
.getLineNumber(), la.getFilename());
|
||||
throwBacktrack(la.getOffset(), la.getLength());
|
||||
}
|
||||
IASTExpression initialValue = null;
|
||||
if (LT(1) == IToken.tASSIGN) {
|
||||
|
@ -1115,10 +1109,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
break;
|
||||
}
|
||||
if (LT(1) != IToken.tCOMMA) {
|
||||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset() : 0;
|
||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
||||
.getLineNumber(), mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||
}
|
||||
|
||||
enumerator = createEnumerator();
|
||||
|
@ -1143,10 +1134,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
return result;
|
||||
}
|
||||
// enumSpecifierAbort
|
||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||
backup(mark);
|
||||
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(),
|
||||
mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1688,7 +1677,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
if_loop: while( true ){
|
||||
int so = consume(IToken.t_if).getOffset();
|
||||
consume(IToken.tLPAREN);
|
||||
IToken start = LA(1);
|
||||
boolean passedCondition = true;
|
||||
IASTExpression condition = null;
|
||||
try {
|
||||
|
@ -1696,14 +1684,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
consume(IToken.tRPAREN);
|
||||
} catch (BacktrackException b) {
|
||||
//if the problem has no offset info, make a new one that does
|
||||
if( b.getProblem() != null && b.getProblem().getSourceLineNumber() == -1 ){
|
||||
IProblem p = b.getProblem();
|
||||
IProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(),
|
||||
lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(),
|
||||
start.getLineNumber(), p.getOriginatingFileName(),
|
||||
p.getArguments() != null ? p.getArguments().toCharArray() : null,
|
||||
p.isWarning(), p.isError() );
|
||||
b.initialize( p2 );
|
||||
if( b.getProblem() != null ){
|
||||
IASTProblem p = b.getProblem();
|
||||
// IASTProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(),
|
||||
// lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(),
|
||||
// start.getLineNumber(), p.getOriginatingFileName(),
|
||||
// p.getArguments() != null ? p.getArguments().toCharArray() : null,
|
||||
// p.isWarning(), p.isError() );
|
||||
b.initialize( p );
|
||||
}
|
||||
failParse(b);
|
||||
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;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -21,6 +21,6 @@ import org.eclipse.cdt.core.parser.IProblem;
|
|||
*/
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.parser.BacktrackException;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -143,8 +143,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
IToken la = LA(1);
|
||||
int startingOffset = la.getOffset();
|
||||
int line = la.getLineNumber();
|
||||
char[] fn = la.getFilename();
|
||||
la = null;
|
||||
if (LT(1) == IToken.tLBRACE) {
|
||||
consume(IToken.tLBRACE);
|
||||
|
@ -195,8 +193,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
if (checkHashcode == LA(1).hashCode()) {
|
||||
IToken l2 = LA(1);
|
||||
throwBacktrack(startingOffset, l2.getEndOffset(), l2
|
||||
.getLineNumber(), l2.getFilename());
|
||||
throwBacktrack(startingOffset, l2.getEndOffset() - startingOffset);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -222,7 +219,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
// do nothing
|
||||
}
|
||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||
throwBacktrack(startingOffset, endOffset, line, fn);
|
||||
throwBacktrack(startingOffset, endOffset - startingOffset);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -399,10 +396,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
EndOfFileException {
|
||||
IToken firstToken = LA(1);
|
||||
int firstOffset = firstToken.getOffset();
|
||||
char[] fn = firstToken.getFilename();
|
||||
if (firstToken.getType() == IToken.tLBRACE)
|
||||
throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(),
|
||||
firstToken.getLineNumber(), firstToken.getFilename());
|
||||
throwBacktrack(firstToken.getOffset(), firstToken.getLength() );
|
||||
|
||||
firstToken = null; // necessary for scalability
|
||||
|
||||
|
@ -431,8 +426,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.tLBRACE:
|
||||
break;
|
||||
default:
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||
}
|
||||
|
||||
if (!consumedSemi) {
|
||||
|
@ -441,19 +435,16 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
|
||||
if (hasFunctionTryBlock && !hasFunctionBody)
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
}
|
||||
|
||||
if (hasFunctionBody) {
|
||||
if (declarators.size() != 1)
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset());
|
||||
|
||||
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
||||
if (!(declarator instanceof IASTFunctionDeclarator))
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset());
|
||||
|
||||
IASTFunctionDefinition funcDefinition = createFunctionDefinition();
|
||||
((ASTNode)funcDefinition).setOffset(firstOffset);
|
||||
|
@ -1018,7 +1009,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.tIDENTIFIER:
|
||||
|
||||
int startingOffset = LA(1).getOffset();
|
||||
int line = LA(1).getLineNumber();
|
||||
IToken t1 = identifier();
|
||||
IASTIdExpression idExpression = createIdExpression();
|
||||
IASTName name = createName(t1);
|
||||
|
@ -1029,8 +1019,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
default:
|
||||
IToken la = LA(1);
|
||||
startingOffset = la.getOffset();
|
||||
line = la.getLineNumber();
|
||||
throwBacktrack( startingOffset, startingOffset, line, la.getFilename() );
|
||||
throwBacktrack( startingOffset, la.getLength() );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1054,8 +1043,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
IToken mark = mark();
|
||||
int startingOffset = mark.getOffset();
|
||||
char [] filename = mark.getFilename();
|
||||
int lineNumber = mark.getLineNumber();
|
||||
IASTDeclSpecifier declSpecifier = null;
|
||||
IASTDeclarator declarator = null;
|
||||
|
||||
|
@ -1068,13 +1055,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
{
|
||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||
backup( mark );
|
||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
||||
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||
}
|
||||
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
||||
{
|
||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||
backup( mark );
|
||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
||||
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||
}
|
||||
|
||||
IASTTypeId result = createTypeId();
|
||||
|
@ -1458,8 +1445,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
classKind = IASTCompositeTypeSpecifier.k_union;
|
||||
break;
|
||||
default:
|
||||
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
||||
.getLineNumber(), mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), mark.getLength() );
|
||||
}
|
||||
|
||||
IToken nameToken = null;
|
||||
|
@ -1471,8 +1457,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (LT(1) != IToken.tLBRACE) {
|
||||
IToken errorPoint = LA(1);
|
||||
backup(mark);
|
||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
||||
errorPoint.getLineNumber(), errorPoint.getFilename());
|
||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getLength());
|
||||
}
|
||||
|
||||
consume(IToken.tLBRACE);
|
||||
|
@ -1553,8 +1538,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
default:
|
||||
backup(t);
|
||||
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(),
|
||||
t.getFilename());
|
||||
throwBacktrack(t.getOffset(), t.getLength() );
|
||||
}
|
||||
|
||||
IToken identifier = identifier();
|
||||
|
@ -1598,8 +1582,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTName declaratorName = null;
|
||||
IToken la = LA(1);
|
||||
int startingOffset = la.getOffset();
|
||||
int line = la.getLineNumber();
|
||||
char[] fn = la.getFilename();
|
||||
la = null;
|
||||
List pointerOps = new ArrayList(DEFAULT_POINTEROPS_LIST_SIZE);
|
||||
List parameters = Collections.EMPTY_LIST;
|
||||
|
@ -1648,8 +1630,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset() : 0;
|
||||
if (seenParameter)
|
||||
throwBacktrack(startingOffset, endOffset,
|
||||
line, fn);
|
||||
throwBacktrack(startingOffset, endOffset - startingOffset);
|
||||
IASTParameterDeclaration pd = parameterDeclaration();
|
||||
if (parameters == Collections.EMPTY_LIST)
|
||||
parameters = new ArrayList(
|
||||
|
@ -1869,8 +1850,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
if (current == LA(1)) {
|
||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||
throwBacktrack(current.getOffset(), endOffset, current
|
||||
.getLineNumber(), current.getFilename());
|
||||
throwBacktrack(current.getOffset(), endOffset - current.getOffset() );
|
||||
}
|
||||
|
||||
IASTParameterDeclaration result = createParameterDeclaration();
|
||||
|
@ -2151,4 +2131,5 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
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.IASTPointer;
|
||||
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.IASTSimpleDeclSpecifier;
|
||||
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.IGCCToken;
|
||||
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.IToken;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.parser.BacktrackException;
|
||||
import org.eclipse.cdt.internal.core.parser.SimpleDeclarationStrategy;
|
||||
import org.eclipse.cdt.internal.core.parser.TemplateParameterManager;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||
|
@ -221,8 +221,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} while (scopes.size() > 0
|
||||
&& (top == IToken.tGT || top == IToken.tLT));
|
||||
if (top != IToken.tLBRACKET)
|
||||
throwBacktrack(startingOffset, last.getEndOffset(),
|
||||
last.getLineNumber(), last.getFilename());
|
||||
throwBacktrack(startingOffset, last.getEndOffset() - startingOffset );
|
||||
|
||||
break;
|
||||
case IToken.tRPAREN:
|
||||
|
@ -231,8 +230,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} while (scopes.size() > 0
|
||||
&& (top == IToken.tGT || top == IToken.tLT));
|
||||
if (top != IToken.tLPAREN)
|
||||
throwBacktrack(startingOffset, last.getEndOffset(),
|
||||
last.getLineNumber(), last.getFilename());
|
||||
throwBacktrack(startingOffset, last.getEndOffset() - startingOffset );
|
||||
|
||||
break;
|
||||
case IToken.tLT:
|
||||
|
@ -250,8 +248,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
IToken start = LA(1);
|
||||
int startingOffset = start.getOffset();
|
||||
int startingLineNumber = start.getOffset();
|
||||
char[] fn = start.getFilename();
|
||||
int endOffset = 0;
|
||||
start = null;
|
||||
List list = new ArrayList();
|
||||
|
||||
|
@ -289,6 +286,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
consume();
|
||||
} else if (LT(1) != IToken.tGT) {
|
||||
failed = true;
|
||||
endOffset = LA(1).getEndOffset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +294,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
templateIdScopes.pop();
|
||||
|
||||
if (failed)
|
||||
throwBacktrack(startingOffset, 0, startingLineNumber, fn);
|
||||
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||
|
||||
|
||||
return list;
|
||||
|
@ -344,8 +342,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
default:
|
||||
IToken l = LA(1);
|
||||
backup(mark);
|
||||
throwBacktrack(first.getOffset(), l.getEndOffset(), first
|
||||
.getLineNumber(), l.getFilename());
|
||||
throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset() );
|
||||
}
|
||||
|
||||
while (LT(1) == IToken.tCOLONCOLON) {
|
||||
|
@ -361,8 +358,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.t_operator:
|
||||
IToken l = LA(1);
|
||||
backup(mark);
|
||||
throwBacktrack(first.getOffset(), l.getEndOffset(), first
|
||||
.getLineNumber(), l.getFilename());
|
||||
throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset() );
|
||||
case IToken.tIDENTIFIER:
|
||||
last = consume();
|
||||
last = consumeTemplateArguments(last, argumentList);
|
||||
|
@ -409,45 +405,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
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,
|
||||
EndOfFileException {
|
||||
// we know this is an operator
|
||||
|
@ -472,9 +429,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
toSend = consume();
|
||||
else
|
||||
throwBacktrack(operatorToken.getOffset(),
|
||||
toSend != null ? toSend.getEndOffset() : 0,
|
||||
operatorToken.getLineNumber(), operatorToken
|
||||
.getFilename());
|
||||
toSend != null ? toSend.getEndOffset() - operatorToken.getOffset(): 0 );
|
||||
} else {
|
||||
// must be a conversion function
|
||||
typeId(true);
|
||||
|
@ -563,8 +518,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
}
|
||||
IToken la = LA(1);
|
||||
throwBacktrack(startingOffset, la.getEndOffset(), la
|
||||
.getLineNumber(), la.getFilename());
|
||||
throwBacktrack(startingOffset, la.getEndOffset() - startingOffset );
|
||||
|
||||
}
|
||||
if( t == LA(1) )
|
||||
|
@ -913,8 +867,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
IToken mark = mark();
|
||||
int startingOffset = mark.getOffset();
|
||||
char [] filename = mark.getFilename();
|
||||
int lineNumber = mark.getLineNumber();
|
||||
IASTDeclSpecifier declSpecifier = null;
|
||||
IASTDeclarator declarator = null;
|
||||
|
||||
|
@ -927,13 +879,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
{
|
||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||
backup( mark );
|
||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
||||
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||
}
|
||||
if( declarator == null || declarator.getName().toString() != null ) //$NON-NLS-1$
|
||||
{
|
||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||
backup( mark );
|
||||
throwBacktrack( startingOffset, endingOffset, lineNumber, filename );
|
||||
throwBacktrack( startingOffset, endingOffset - startingOffset );
|
||||
}
|
||||
|
||||
IASTTypeId result = createTypeId();
|
||||
|
@ -1051,7 +1003,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
templateIdScopes.pop();
|
||||
} //pop 1st Parent
|
||||
placementParseFailure = true;
|
||||
throwBacktrack( backtrackMarker.getOffset(), backtrackMarker.getEndOffset(), backtrackMarker.getLineNumber(), backtrackMarker.getFilename() );
|
||||
throwBacktrack( backtrackMarker.getOffset(), backtrackMarker.getLength() );
|
||||
}
|
||||
else
|
||||
placementParseFailure = false;
|
||||
|
@ -1669,9 +1621,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
default:
|
||||
IToken la = LA(1);
|
||||
int startingOffset = la.getOffset();
|
||||
int line = la.getLineNumber();
|
||||
char[] fn = la.getFilename();
|
||||
throwBacktrack(startingOffset, startingOffset, line, fn);
|
||||
throwBacktrack(startingOffset, la.getLength());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1714,8 +1664,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
duple = operatorId(start, null);
|
||||
else {
|
||||
backup(mark);
|
||||
throwBacktrack(start.getOffset(), end.getEndOffset(), end
|
||||
.getLineNumber(), start.getFilename());
|
||||
throwBacktrack(start.getOffset(), end.getEndOffset() - start.getOffset() );
|
||||
}
|
||||
} else if (LT(1) == IToken.t_operator)
|
||||
duple = operatorId(null, null);
|
||||
|
@ -1810,8 +1759,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON)
|
||||
name = createName( name() );
|
||||
else
|
||||
throwBacktrack(firstToken.getOffset(), endOffset, firstToken
|
||||
.getLineNumber(), firstToken.getFilename());
|
||||
throwBacktrack(firstToken.getOffset(), endOffset - firstToken.getOffset() );
|
||||
|
||||
consume(IToken.tSEMI);
|
||||
ICPPASTUsingDirective astUD = createUsingDirective();
|
||||
|
@ -2237,8 +2185,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
protected IASTDeclaration simpleDeclarationStrategyUnion() throws EndOfFileException, BacktrackException {
|
||||
simpleDeclarationMark = mark();
|
||||
IProblem firstFailure = null;
|
||||
IProblem secondFailure = null;
|
||||
IASTProblem firstFailure = null;
|
||||
IASTProblem secondFailure = null;
|
||||
try {
|
||||
return simpleDeclaration(SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
||||
false);
|
||||
|
@ -2345,8 +2293,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IToken assign = consume(IToken.tASSIGN);
|
||||
|
||||
if (name.toString() == null) {
|
||||
throwBacktrack(first.getOffset(), assign.getEndOffset(), first
|
||||
.getLineNumber(), first.getFilename());
|
||||
throwBacktrack(first.getOffset(), assign.getEndOffset() - first.getOffset() );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2365,8 +2312,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return alias;
|
||||
} else {
|
||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||
throwBacktrack(first.getOffset(), endOffset, first.getLineNumber(),
|
||||
first.getFilename());
|
||||
throwBacktrack(first.getOffset(), endOffset - first.getOffset() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2486,11 +2432,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws BacktrackException, EndOfFileException {
|
||||
IToken firstToken = LA(1);
|
||||
int firstOffset = firstToken.getOffset();
|
||||
int firstLine = firstToken.getLineNumber();
|
||||
char[] fn = firstToken.getFilename();
|
||||
if (firstToken.getType() == IToken.tLBRACE)
|
||||
throwBacktrack(firstOffset, firstToken.getEndOffset(),
|
||||
firstLine, fn);
|
||||
throwBacktrack(firstOffset, firstToken.getLength() );
|
||||
firstToken = null; // necessary for scalability
|
||||
|
||||
ICPPASTDeclSpecifier declSpec = declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR);
|
||||
|
@ -2531,12 +2474,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
case IToken.tRPAREN:
|
||||
if (!fromCatchHandler)
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
break;
|
||||
default:
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
}
|
||||
|
||||
if (!consumedSemi) {
|
||||
|
@ -2545,19 +2486,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
|
||||
if (hasFunctionTryBlock && !hasFunctionBody)
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
}
|
||||
|
||||
if (hasFunctionBody) {
|
||||
if (declarators.size() != 1)
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
|
||||
IASTDeclarator declarator = (IASTDeclarator) declarators.get(0);
|
||||
if (!(declarator instanceof IASTFunctionDeclarator))
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1)
|
||||
.getLineNumber(), fn);
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset );
|
||||
|
||||
if( ! constructorChain.isEmpty() && declarator instanceof ICPPASTFunctionDeclarator )
|
||||
{
|
||||
|
@ -2707,8 +2645,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
if (current == LA(1)) {
|
||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
||||
throwBacktrack(current.getOffset(), endOffset, current
|
||||
.getLineNumber(), current.getFilename());
|
||||
throwBacktrack(current.getOffset(), endOffset - current.getOffset() );
|
||||
}
|
||||
ICPPASTParameterDeclaration parm = createParameterDeclaration();
|
||||
((ASTNode)parm).setOffset( current.getOffset() );
|
||||
|
@ -2901,7 +2838,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if( !supportRestrict )
|
||||
{
|
||||
IToken la = LA(1);
|
||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
||||
throwBacktrack( la.getOffset(), la.getEndOffset() - la.getOffset() );
|
||||
}
|
||||
isRestrict = true;
|
||||
consume();
|
||||
|
@ -2936,7 +2873,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if( ! supportComplex )
|
||||
{
|
||||
IToken la = LA(1);
|
||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
||||
throwBacktrack( la.getOffset(), la.getEndOffset() - la.getOffset() );
|
||||
}
|
||||
consume(IToken.t__Complex);
|
||||
simpleType = IGPPASTSimpleDeclSpecifier.t_Complex;
|
||||
|
@ -2945,7 +2882,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if( ! supportComplex )
|
||||
{
|
||||
IToken la = LA(1);
|
||||
throwBacktrack( la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename() );
|
||||
throwBacktrack( la.getOffset(), la.getLength() );
|
||||
}
|
||||
consume(IToken.t__Imaginary);
|
||||
simpleType = IGPPASTSimpleDeclSpecifier.t_Imaginary;
|
||||
|
@ -3188,8 +3125,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
default:
|
||||
backup(t);
|
||||
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(),
|
||||
t.getFilename());
|
||||
throwBacktrack(t.getOffset(), t.getLength() );
|
||||
}
|
||||
|
||||
IASTName name = createName( name() );
|
||||
|
@ -3363,8 +3299,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
IToken la = LA(1);
|
||||
int startingOffset = la.getOffset();
|
||||
int line = la.getLineNumber();
|
||||
char[] fn = la.getFilename();
|
||||
la = null;
|
||||
IASTDeclarator innerDecl = null;
|
||||
IASTName declaratorName = null;
|
||||
|
@ -3437,8 +3371,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
: 0;
|
||||
logException(
|
||||
"declarator:queryIsTypeName", e); //$NON-NLS-1$
|
||||
throwBacktrack(startingOffset, endOffset,
|
||||
line, newMark.getFilename());
|
||||
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||
}
|
||||
} catch (BacktrackException b) {
|
||||
failed = true;
|
||||
|
@ -3472,8 +3405,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset() : 0;
|
||||
if (seenParameter)
|
||||
throwBacktrack(startingOffset, endOffset,
|
||||
line, fn);
|
||||
throwBacktrack(startingOffset, endOffset - startingOffset );
|
||||
IASTParameterDeclaration p = parameterDeclaration();
|
||||
if( parameters == Collections.EMPTY_LIST )
|
||||
parameters = new ArrayList( DEFAULT_PARM_LIST_SIZE );
|
||||
|
@ -3728,16 +3660,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset() : 0;
|
||||
backup(mark);
|
||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
||||
.getLineNumber(), mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), endOffset - mark.getOffset() );
|
||||
}
|
||||
return TokenFactory.createTokenDuple( start, end, argumentList.getTemplateArgumentsList() );
|
||||
}
|
||||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset() : 0;
|
||||
backup(mark);
|
||||
throwBacktrack(mark.getOffset(), endOffset, mark
|
||||
.getLineNumber(), mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), endOffset - mark.getOffset() );
|
||||
|
||||
return null;
|
||||
} finally {
|
||||
|
@ -3779,8 +3709,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
classKind = IASTCompositeTypeSpecifier.k_union;
|
||||
break;
|
||||
default:
|
||||
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
||||
.getLineNumber(), mark.getFilename());
|
||||
throwBacktrack(mark.getOffset(), mark.getLength());
|
||||
}
|
||||
|
||||
IASTName name = null;
|
||||
|
@ -3794,8 +3723,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
|
||||
IToken errorPoint = LA(1);
|
||||
backup(mark);
|
||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
||||
errorPoint.getLineNumber(), errorPoint.getFilename());
|
||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getLength() );
|
||||
}
|
||||
|
||||
ICPPASTCompositeTypeSpecifier astClassSpecifier = createClassSpecifier();
|
||||
|
@ -3998,8 +3926,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throws EndOfFileException, BacktrackException {
|
||||
if (LT(1) != IToken.t_catch) {
|
||||
IToken la = LA(1);
|
||||
throwBacktrack(la.getOffset(), la.getEndOffset(), la
|
||||
.getLineNumber(), la.getFilename()); // error, need at least one of these
|
||||
throwBacktrack(la.getOffset(), la.getLength()); // error, need at least one of these
|
||||
}
|
||||
while (LT(1) == IToken.t_catch) {
|
||||
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 {
|
||||
|
||||
private List problems = Collections.EMPTY_LIST;
|
||||
private static final IASTProblem[] EMPTY_PROBLEMS_ARRAY = new IASTProblem[0];
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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()
|
||||
*/
|
||||
public IASTProblem[] getScannerProblems() {
|
||||
if( problems == Collections.EMPTY_LIST ) return EMPTY_PROBLEMS_ARRAY;
|
||||
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.ICodeReaderFactory;
|
||||
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.filetype.ICFileType;
|
||||
import org.eclipse.cdt.core.filetype.ICFileTypeConstants;
|
||||
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.IScannerInfo;
|
||||
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 IProblemRequestor PROBLEM_REQUESTOR = new IProblemRequestor() {
|
||||
|
||||
public boolean acceptProblem(IProblem problem) {
|
||||
public boolean acceptProblem(IASTProblem problem) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue