mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
This commit is contained in:
parent
33a07a1b47
commit
d0c897c1e9
3 changed files with 65 additions and 1 deletions
|
@ -356,6 +356,7 @@ public interface IProblem
|
|||
/*
|
||||
* Parser Syntactic Problems
|
||||
*/
|
||||
public final static int SYNTAX_ERROR = SYNTAX_RELATED | 0x001;
|
||||
|
||||
/*
|
||||
* Parser Semantic Problems
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.BacktrackException;
|
|||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
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.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
@ -59,6 +60,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSetKey;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||
|
||||
|
@ -74,7 +76,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
private static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
||||
protected ISourceElementRequestor requestor = null;
|
||||
|
||||
private IProblemFactory problemFactory = new ParserProblemFactory();
|
||||
/**
|
||||
* This is the standard cosntructor that we expect the Parser to be instantiated
|
||||
* with.
|
||||
|
@ -90,6 +92,36 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
requestor = callback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#failParse()
|
||||
*/
|
||||
protected void failParse() {
|
||||
IToken referenceToken = null;
|
||||
if( lastToken != null )
|
||||
referenceToken = lastToken;
|
||||
else
|
||||
try
|
||||
{
|
||||
referenceToken = LA(1);
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
return;
|
||||
}
|
||||
IProblem problem = problemFactory.createProblem(
|
||||
IProblem.SYNTAX_ERROR,
|
||||
referenceToken.getOffset(),
|
||||
referenceToken.getOffset(),
|
||||
referenceToken.getLineNumber(),
|
||||
scanner.getCurrentFilename(),
|
||||
EMPTY_STRING,
|
||||
false,
|
||||
true );
|
||||
requestor.acceptProblem( problem );
|
||||
super.failParse();
|
||||
}
|
||||
// counter that keeps track of the number of times Parser.parse() is called
|
||||
private static int parseCount = 0;
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002-2004 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.problem.BaseProblemFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserProblemFactory extends BaseProblemFactory
|
||||
implements
|
||||
IProblemFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.problem.IProblemFactory#getRequiredAttributesForId(int)
|
||||
*/
|
||||
public String getRequiredAttributesForId(int id) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue