mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
IASTProblems are now attached to the AST rather than reported.
This commit is contained in:
parent
c9c2c1498e
commit
d91724f835
26 changed files with 1380 additions and 568 deletions
|
@ -40,7 +40,6 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.tests.parser2.ProblemCollector;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||||
|
@ -71,7 +70,6 @@ public class AST2BaseTest extends TestCase {
|
||||||
* @throws ParserException
|
* @throws ParserException
|
||||||
*/
|
*/
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
|
||||||
ProblemCollector collector = new ProblemCollector();
|
|
||||||
CodeReader codeReader = new CodeReader(code
|
CodeReader codeReader = new CodeReader(code
|
||||||
.toCharArray());
|
.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
|
@ -86,7 +84,7 @@ public class AST2BaseTest extends TestCase {
|
||||||
{
|
{
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, collector,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||||
NULL_LOG,
|
NULL_LOG,
|
||||||
config );
|
config );
|
||||||
}
|
}
|
||||||
|
@ -95,14 +93,14 @@ public class AST2BaseTest extends TestCase {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, collector,
|
parser2 = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE,
|
||||||
NULL_LOG, config );
|
NULL_LOG, config );
|
||||||
}
|
}
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser2.parse();
|
||||||
if( parser2.encounteredError() )
|
if( parser2.encounteredError() )
|
||||||
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
||||||
|
|
||||||
assertTrue( collector.hasNoProblems() );
|
//TODO add in assertion here to visit all problems
|
||||||
|
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,6 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
return parse(code, true, ParserLanguage.CPP);
|
return parse(code, true, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProblemCollector collector;
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @param b
|
* @param b
|
||||||
|
@ -126,7 +125,7 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
||||||
ParserLanguage lang, boolean gcc) throws Exception {
|
ParserLanguage lang, boolean gcc) throws Exception {
|
||||||
|
|
||||||
collector = new ProblemCollector();
|
|
||||||
CodeReader codeReader = new CodeReader(code
|
CodeReader codeReader = new CodeReader(code
|
||||||
.toCharArray());
|
.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
|
@ -144,7 +143,7 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||||
collector, NULL_LOG, config);
|
NULL_LOG, config);
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
if (gcc)
|
if (gcc)
|
||||||
|
@ -153,13 +152,15 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||||
collector, NULL_LOG, config);
|
NULL_LOG, config);
|
||||||
}
|
}
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser2.parse();
|
||||||
if (parser2.encounteredError() && expectedToPass)
|
if (parser2.encounteredError() && expectedToPass)
|
||||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
if (expectedToPass)
|
if (expectedToPass)
|
||||||
assertTrue(collector.hasNoProblems());
|
{
|
||||||
|
//TODO visit translation unit and ensure that there aren't any problems
|
||||||
|
}
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* 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.core.parser.tests.parser2;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class ProblemCollector implements IProblemRequestor {
|
|
||||||
|
|
||||||
List problems = new ArrayList();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.IProblemRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
|
||||||
*/
|
|
||||||
public boolean acceptProblem(IASTProblem problem) {
|
|
||||||
problems.add(problem);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean hasNoProblems() {
|
|
||||||
return problems.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1356,7 +1356,6 @@ public class QuickParser2Tests extends TestCase {
|
||||||
protected void parse(String code, boolean expectedToPass,
|
protected void parse(String code, boolean expectedToPass,
|
||||||
ParserLanguage lang, boolean gcc) throws Exception {
|
ParserLanguage lang, boolean gcc) throws Exception {
|
||||||
|
|
||||||
ProblemCollector collector = new ProblemCollector();
|
|
||||||
CodeReader codeReader = new CodeReader( code.toCharArray() );
|
CodeReader codeReader = new CodeReader( code.toCharArray() );
|
||||||
IScannerInfo scannerInfo = new ScannerInfo();
|
IScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScannerConfiguration configuration = null;
|
IScannerConfiguration configuration = null;
|
||||||
|
@ -1373,7 +1372,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE,
|
parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE,
|
||||||
collector, NULL_LOG, config);
|
NULL_LOG, config);
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
if (gcc)
|
if (gcc)
|
||||||
|
@ -1382,13 +1381,15 @@ public class QuickParser2Tests extends TestCase {
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE,
|
parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE,
|
||||||
collector, NULL_LOG, config);
|
NULL_LOG, config);
|
||||||
}
|
}
|
||||||
parser2.parse();
|
parser2.parse();
|
||||||
if (parser2.encounteredError() && expectedToPass)
|
if (parser2.encounteredError() && expectedToPass)
|
||||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
if (expectedToPass)
|
if (expectedToPass)
|
||||||
assertTrue(collector.hasNoProblems());
|
{
|
||||||
|
//TODO need visitor to ensure that there aren't any problems
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug60142() throws Exception {
|
public void testBug60142() throws Exception {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface IASTProblemDeclaration extends IASTDeclaration {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty PROBLEM = new ASTNodeProperty( "Problem"); //$NON-NLS-1$
|
||||||
|
public IASTProblem getProblem();
|
||||||
|
public void setProblem(IASTProblem p);
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.core.dom.ast;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface IASTProblemExpression extends IASTExpression {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty PROBLEM = new ASTNodeProperty( "Problem"); //$NON-NLS-1$
|
||||||
|
public IASTProblem getProblem();
|
||||||
|
public void setProblem(IASTProblem p);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface IASTProblemStatement extends IASTStatement {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty PROBLEM = new ASTNodeProperty( "Problem"); //$NON-NLS-1$
|
||||||
|
public IASTProblem getProblem();
|
||||||
|
public void setProblem(IASTProblem p);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface IASTProblemTypeId extends IASTTypeId {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty PROBLEM = new ASTNodeProperty( "Problem"); //$NON-NLS-1$
|
||||||
|
public IASTProblem getProblem();
|
||||||
|
public void setProblem(IASTProblem p);
|
||||||
|
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public interface IASTTypeId extends IASTNode {
|
public interface IASTTypeId extends IASTNode {
|
||||||
|
|
||||||
public static final IASTTypeId [] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
public static final IASTTypeId [] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
||||||
|
|
||||||
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty( "Decl Specifier"); //$NON-NLS-1$
|
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty( "Decl Specifier"); //$NON-NLS-1$
|
||||||
|
|
|
@ -37,6 +37,8 @@ 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.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
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;
|
||||||
|
@ -70,7 +72,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected final ParserMode mode;
|
protected final ParserMode mode;
|
||||||
|
|
||||||
protected IProblemRequestor requestor = null;
|
|
||||||
|
|
||||||
protected final boolean supportStatementsInExpressions;
|
protected final boolean supportStatementsInExpressions;
|
||||||
|
|
||||||
|
@ -80,12 +81,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
||||||
IParserLogService logService, ParserMode parserMode,
|
IParserLogService logService, ParserMode parserMode,
|
||||||
IProblemRequestor callback, boolean supportStatementsInExpressions,
|
boolean supportStatementsInExpressions, boolean supportTypeOfUnaries,
|
||||||
boolean supportTypeOfUnaries, boolean supportAlignOfUnaries) {
|
boolean supportAlignOfUnaries) {
|
||||||
this.scanner = scanner;
|
this.scanner = scanner;
|
||||||
this.log = logService;
|
this.log = logService;
|
||||||
this.mode = parserMode;
|
this.mode = parserMode;
|
||||||
this.requestor = callback;
|
|
||||||
this.supportStatementsInExpressions = supportStatementsInExpressions;
|
this.supportStatementsInExpressions = supportStatementsInExpressions;
|
||||||
this.supportTypeOfUnaries = supportTypeOfUnaries;
|
this.supportTypeOfUnaries = supportTypeOfUnaries;
|
||||||
this.supportAlignOfUnaries = supportAlignOfUnaries;
|
this.supportAlignOfUnaries = supportAlignOfUnaries;
|
||||||
|
@ -286,15 +286,16 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
throw bt;
|
throw bt;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void failParse(BacktrackException bt) {
|
protected IASTProblem failParse(BacktrackException bt) {
|
||||||
if (requestor != null) {
|
IASTProblem result = null;
|
||||||
if (bt.getProblem() == null) {
|
|
||||||
IASTProblem problem = createProblem( IASTProblem.SYNTAX_ERROR, bt.getOffset(), bt.getLength() );
|
if (bt.getProblem() == null)
|
||||||
requestor.acceptProblem(problem);
|
result = createProblem( IASTProblem.SYNTAX_ERROR, bt.getOffset(), bt.getLength() );
|
||||||
} else
|
else
|
||||||
requestor.acceptProblem(bt.getProblem());
|
result = bt.getProblem();
|
||||||
}
|
|
||||||
failParse();
|
failParse();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,14 +304,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* @param length
|
* @param length
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTProblem createProblem(int signal, int offset, int length)
|
protected abstract 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
|
||||||
|
@ -477,7 +471,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
DEFAULT_COMPOUNDSTATEMENT_LIST_SIZE);
|
DEFAULT_COMPOUNDSTATEMENT_LIST_SIZE);
|
||||||
statements.add(s);
|
statements.add(s);
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
failParse(b);
|
IASTProblem p = failParse(b);
|
||||||
|
IASTProblemStatement ps = createProblemStatement();
|
||||||
|
ps.setProblem( p );
|
||||||
|
((ASTNode)ps).setOffset( ((ASTNode)p).getOffset() );
|
||||||
|
p.setParent( ps );
|
||||||
|
p.setPropertyInParent( IASTProblemStatement.PROBLEM );
|
||||||
|
statements.add( ps );
|
||||||
if (LA(1).hashCode() == checkToken)
|
if (LA(1).hashCode() == checkToken)
|
||||||
failParseWithErrorHandling();
|
failParseWithErrorHandling();
|
||||||
}
|
}
|
||||||
|
@ -495,6 +495,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTProblemStatement createProblemStatement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -1683,17 +1688,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
condition = condition();
|
condition = condition();
|
||||||
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
|
IASTProblem p = failParse(b);
|
||||||
if( b.getProblem() != null ){
|
IASTProblemExpression ps = createProblemExpression();
|
||||||
IASTProblem p = b.getProblem();
|
ps.setProblem( p );
|
||||||
// IASTProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(),
|
((ASTNode)ps).setOffset( ((ASTNode)p).getOffset() );
|
||||||
// lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(),
|
p.setParent( ps );
|
||||||
// start.getLineNumber(), p.getOriginatingFileName(),
|
p.setPropertyInParent( IASTProblemExpression.PROBLEM );
|
||||||
// p.getArguments() != null ? p.getArguments().toCharArray() : null,
|
condition = ps;
|
||||||
// p.isWarning(), p.isError() );
|
|
||||||
b.initialize( p );
|
|
||||||
}
|
|
||||||
failParse(b);
|
|
||||||
failParseWithErrorHandling();
|
failParseWithErrorHandling();
|
||||||
passedCondition = false;
|
passedCondition = false;
|
||||||
}
|
}
|
||||||
|
@ -1742,6 +1743,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return if_statement;
|
return if_statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTProblemExpression createProblemExpression();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
* @throws EndOfFileException
|
* @throws EndOfFileException
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2002-2004 IBM Canada 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 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Created on Oct 22, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface IProblemRequestor {
|
|
||||||
|
|
||||||
public boolean acceptProblem( IASTProblem problem );
|
|
||||||
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class ASTProblem extends ASTNode implements IASTProblem {
|
public class CASTProblem extends CASTNode implements IASTProblem {
|
||||||
|
|
||||||
private IASTNode parent;
|
private IASTNode parent;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
|
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
|
||||||
public ASTProblem(int id, char[] arg, boolean warn, boolean error) {
|
public CASTProblem(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;
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CASTProblemDeclaration extends CASTProblemOwner implements
|
||||||
|
IASTProblemDeclaration {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CASTProblemExpression extends CASTProblemOwner implements
|
||||||
|
IASTProblemExpression {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
class CASTProblemOwner extends CASTNode {
|
||||||
|
|
||||||
|
private IASTProblem problem;
|
||||||
|
|
||||||
|
public IASTProblem getProblem()
|
||||||
|
{
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProblem(IASTProblem p)
|
||||||
|
{
|
||||||
|
problem = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CASTProblemStatement extends CASTProblemOwner implements
|
||||||
|
IASTProblemStatement {
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,397 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTProblem extends CPPASTNode implements IASTProblem {
|
||||||
|
private IASTNode parent;
|
||||||
|
|
||||||
|
private ASTNodeProperty property;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent()
|
||||||
|
*/
|
||||||
|
public IASTNode getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent()
|
||||||
|
*/
|
||||||
|
public ASTNodeProperty getPropertyInParent() {
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty)
|
||||||
|
*/
|
||||||
|
public void setPropertyInParent(ASTNodeProperty property) {
|
||||||
|
this.property = property;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final char[] arg;
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
private final boolean isError;
|
||||||
|
|
||||||
|
private final boolean isWarning;
|
||||||
|
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
|
public CPPASTProblem(int id, char[] arg, boolean warn, boolean error) {
|
||||||
|
this.id = id;
|
||||||
|
this.arg = arg;
|
||||||
|
this.isWarning = warn;
|
||||||
|
this.isError = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.IProblem#getID()
|
||||||
|
*/
|
||||||
|
public int getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.IProblem#isError()
|
||||||
|
*/
|
||||||
|
public boolean isError() {
|
||||||
|
return isError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.IProblem#isWarning()
|
||||||
|
*/
|
||||||
|
public boolean isWarning() {
|
||||||
|
return isWarning;
|
||||||
|
}
|
||||||
|
|
||||||
|
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$
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
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) });
|
||||||
|
}
|
||||||
|
|
||||||
|
Object[] args = new Object[] { msg, new String(""), new Integer(0) }; //$NON-NLS-1$
|
||||||
|
message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
|
||||||
|
*/
|
||||||
|
public boolean checkCategory(int bitmask) {
|
||||||
|
return ((id & bitmask) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.IProblem#getArguments()
|
||||||
|
*/
|
||||||
|
public String getArguments() {
|
||||||
|
return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit()
|
||||||
|
*/
|
||||||
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
|
if (this instanceof IASTTranslationUnit)
|
||||||
|
return (IASTTranslationUnit) this;
|
||||||
|
IASTNode node = getParent();
|
||||||
|
while (!(node instanceof IASTTranslationUnit) && node != null) {
|
||||||
|
node = node.getParent();
|
||||||
|
}
|
||||||
|
return (IASTTranslationUnit) node;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements
|
||||||
|
IASTProblemDeclaration {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTProblemExpression extends CPPASTProblemOwner implements
|
||||||
|
IASTProblemExpression {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
class CPPASTProblemOwner extends CPPASTNode {
|
||||||
|
|
||||||
|
private IASTProblem problem;
|
||||||
|
|
||||||
|
public IASTProblem getProblem()
|
||||||
|
{
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProblem(IASTProblem p)
|
||||||
|
{
|
||||||
|
problem = p;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTProblemStatement extends CPPASTProblemOwner implements
|
||||||
|
IASTProblemStatement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTProblemTypeId extends CPPASTTypeId implements
|
||||||
|
IASTProblemTypeId {
|
||||||
|
|
||||||
|
private IASTProblem problem;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTProblemTypeId#getProblem()
|
||||||
|
*/
|
||||||
|
public IASTProblem getProblem() {
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTProblemTypeId#setProblem(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
|
*/
|
||||||
|
public void setProblem(IASTProblem p) {
|
||||||
|
problem = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -59,6 +59,10 @@ 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.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
|
||||||
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;
|
||||||
|
@ -128,7 +132,6 @@ 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.BacktrackException;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
|
||||||
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;
|
||||||
|
@ -1718,10 +1721,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GNUCPPSourceParser(IScanner scanner, ParserMode mode,
|
public GNUCPPSourceParser(IScanner scanner, ParserMode mode,
|
||||||
IProblemRequestor callback, IParserLogService log,
|
IParserLogService log, ICPPParserExtensionConfiguration config) {
|
||||||
ICPPParserExtensionConfiguration config) {
|
super( scanner, log, mode, config.supportStatementsInExpressions(), config.supportTypeofUnaryExpressions(),
|
||||||
super( scanner, log, mode, callback, config.supportStatementsInExpressions(),
|
config.supportAlignOfUnaryExpression() );
|
||||||
config.supportTypeofUnaryExpressions(), config.supportAlignOfUnaryExpression() );
|
|
||||||
allowCPPRestrict = config.allowRestrictPointerOperators();
|
allowCPPRestrict = config.allowRestrictPointerOperators();
|
||||||
supportExtendedTemplateSyntax = config
|
supportExtendedTemplateSyntax = config
|
||||||
.supportExtendedTemplateSyntax();
|
.supportExtendedTemplateSyntax();
|
||||||
|
@ -1838,9 +1840,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
d.setParent( linkage );
|
d.setParent( linkage );
|
||||||
d.setPropertyInParent( ICPPASTLinkageSpecification.OWNED_DECLARATION );
|
d.setPropertyInParent( ICPPASTLinkageSpecification.OWNED_DECLARATION );
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
failParse(bt);
|
IASTProblem p = failParse(bt);
|
||||||
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
|
p.setParent( pd );
|
||||||
|
pd.setProblem( p );
|
||||||
|
((CPPASTNode)pd).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setPropertyInParent( IASTProblemDeclaration.PROBLEM );
|
||||||
|
linkage.addDeclaration( pd );
|
||||||
|
pd.setParent( linkage );
|
||||||
|
pd.setPropertyInParent( ICPPASTLinkageSpecification.OWNED_DECLARATION );
|
||||||
|
errorHandling();
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
failParseWithErrorHandling();
|
errorHandling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
|
@ -2277,9 +2288,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
d.setPropertyInParent( ICPPASTNamespaceDefinition.OWNED_DECLARATION );
|
d.setPropertyInParent( ICPPASTNamespaceDefinition.OWNED_DECLARATION );
|
||||||
namespaceDefinition.addDeclaration( d );
|
namespaceDefinition.addDeclaration( d );
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
failParse(bt);
|
IASTProblem p = failParse(bt);
|
||||||
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
|
p.setParent( pd );
|
||||||
|
pd.setProblem( p );
|
||||||
|
((CPPASTNode)pd).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setPropertyInParent( IASTProblemDeclaration.PROBLEM );
|
||||||
|
namespaceDefinition.addDeclaration( pd );
|
||||||
|
pd.setParent( namespaceDefinition );
|
||||||
|
pd.setPropertyInParent( ICPPASTNamespaceDefinition.OWNED_DECLARATION );
|
||||||
|
errorHandling();
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
failParseWithErrorHandling();
|
errorHandling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
|
@ -3460,8 +3480,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
exceptionSpecIds.add(typeId(false));
|
exceptionSpecIds.add(typeId(false));
|
||||||
} catch (BacktrackException e) {
|
} catch (BacktrackException e) {
|
||||||
failParse(e);
|
IASTProblem p = failParse(e);
|
||||||
break;
|
IASTProblemTypeId typeIdProblem = createTypeIDProblem();
|
||||||
|
typeIdProblem.setProblem( p );
|
||||||
|
((CPPASTNode)typeIdProblem).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setParent( typeIdProblem );
|
||||||
|
p.setPropertyInParent( IASTProblemTypeId.PROBLEM );
|
||||||
|
exceptionSpecIds.add( typeIdProblem );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3581,6 +3606,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTProblemTypeId createTypeIDProblem() {
|
||||||
|
return new CPPASTProblemTypeId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -3767,8 +3799,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
d.setParent( astClassSpecifier );
|
d.setParent( astClassSpecifier );
|
||||||
d.setPropertyInParent( IASTCompositeTypeSpecifier.MEMBER_DECLARATION );
|
d.setPropertyInParent( IASTCompositeTypeSpecifier.MEMBER_DECLARATION );
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
|
IASTProblem p = failParse(bt);
|
||||||
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
|
pd.setProblem( p );
|
||||||
|
((CPPASTNode)pd).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setParent( pd );
|
||||||
|
p.setPropertyInParent( IASTProblemDeclaration.PROBLEM );
|
||||||
|
astClassSpecifier.addMemberDeclaration( pd );
|
||||||
|
pd.setParent( astClassSpecifier );
|
||||||
|
pd.setPropertyInParent( IASTCompositeTypeSpecifier.MEMBER_DECLARATION );
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
failParseWithErrorHandling();
|
errorHandling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
|
@ -3931,9 +3972,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
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();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
|
boolean isEllipsis = false;
|
||||||
|
IASTDeclaration decl = null;
|
||||||
try {
|
try {
|
||||||
boolean isEllipsis = false;
|
|
||||||
IASTDeclaration decl = null;
|
|
||||||
if (LT(1) == IToken.tELLIPSIS)
|
if (LT(1) == IToken.tELLIPSIS)
|
||||||
{
|
{
|
||||||
consume(IToken.tELLIPSIS);
|
consume(IToken.tELLIPSIS);
|
||||||
|
@ -3945,29 +3986,35 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
|
||||||
IASTStatement compoundStatement = catchBlockCompoundStatement();
|
|
||||||
ICPPASTCatchHandler handler = createCatchHandler();
|
|
||||||
((ASTNode)handler).setOffset( startOffset );
|
|
||||||
handler.setIsCatchAll( isEllipsis );
|
|
||||||
if( decl != null )
|
|
||||||
{
|
|
||||||
handler.setDeclaration( decl );
|
|
||||||
decl.setParent( handler );
|
|
||||||
decl.setPropertyInParent( ICPPASTCatchHandler.DECLARATION );
|
|
||||||
}
|
|
||||||
if( compoundStatement != null )
|
|
||||||
{
|
|
||||||
handler.setCatchBody( compoundStatement );
|
|
||||||
compoundStatement.setParent( handler );
|
|
||||||
compoundStatement.setPropertyInParent( ICPPASTCatchHandler.CATCH_BODY );
|
|
||||||
}
|
|
||||||
collection.add( handler );
|
|
||||||
} catch (BacktrackException bte) {
|
|
||||||
failParse(bte);
|
|
||||||
failParseWithErrorHandling();
|
|
||||||
}
|
}
|
||||||
}
|
catch (BacktrackException bte) {
|
||||||
|
IASTProblem p = failParse(bte);
|
||||||
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
|
pd.setProblem( p );
|
||||||
|
((CPPASTNode)pd).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setParent( pd );
|
||||||
|
p.setPropertyInParent( IASTProblemDeclaration.PROBLEM );
|
||||||
|
decl = pd;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTStatement compoundStatement = catchBlockCompoundStatement();
|
||||||
|
ICPPASTCatchHandler handler = createCatchHandler();
|
||||||
|
((ASTNode)handler).setOffset( startOffset );
|
||||||
|
handler.setIsCatchAll( isEllipsis );
|
||||||
|
if( decl != null )
|
||||||
|
{
|
||||||
|
handler.setDeclaration( decl );
|
||||||
|
decl.setParent( handler );
|
||||||
|
decl.setPropertyInParent( ICPPASTCatchHandler.DECLARATION );
|
||||||
|
}
|
||||||
|
if( compoundStatement != null )
|
||||||
|
{
|
||||||
|
handler.setCatchBody( compoundStatement );
|
||||||
|
compoundStatement.setParent( handler );
|
||||||
|
compoundStatement.setPropertyInParent( ICPPASTCatchHandler.CATCH_BODY );
|
||||||
|
}
|
||||||
|
collection.add( handler );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4011,7 +4058,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
return simpleDeclarationStrategyUnion();
|
return simpleDeclarationStrategyUnion();
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
failParse(b);
|
failParse();
|
||||||
throwBacktrack(b);
|
throwBacktrack(b);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -4051,20 +4098,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
try {
|
try {
|
||||||
// Mark as failure and try to reach a recovery point
|
// Mark as failure and try to reach a recovery point
|
||||||
failParse(b);
|
IASTProblem p = failParse(b);
|
||||||
|
IASTProblemDeclaration pd = createProblemDeclaration();
|
||||||
|
p.setParent( pd );
|
||||||
|
pd.setProblem( p );
|
||||||
|
((CPPASTNode)pd).setOffset( ((CPPASTNode)p).getOffset() );
|
||||||
|
p.setPropertyInParent( IASTProblemDeclaration.PROBLEM );
|
||||||
|
translationUnit.addDeclaration( pd );
|
||||||
|
pd.setParent( translationUnit );
|
||||||
|
pd.setPropertyInParent( IASTTranslationUnit.OWNED_DECLARATION );
|
||||||
errorHandling();
|
errorHandling();
|
||||||
// if (lastBacktrack != -1 && lastBacktrack ==
|
|
||||||
// LA(1).hashCode())
|
|
||||||
// {
|
|
||||||
// // we haven't progressed from the last backtrack
|
|
||||||
// // try and find tne next definition
|
|
||||||
// failParseWithErrorHandling();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // start again from here
|
|
||||||
// lastBacktrack = LA(1).hashCode();
|
|
||||||
// }
|
|
||||||
} catch (EndOfFileException e) {
|
} catch (EndOfFileException e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4091,6 +4134,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTProblemDeclaration createProblemDeclaration() {
|
||||||
|
return new CPPASTProblemDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -4431,5 +4481,31 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
translationUnit = null;
|
translationUnit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#createProblemStatement()
|
||||||
|
*/
|
||||||
|
protected IASTProblemStatement createProblemStatement() {
|
||||||
|
return new CPPASTProblemStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#createProblemExpression()
|
||||||
|
*/
|
||||||
|
protected IASTProblemExpression createProblemExpression() {
|
||||||
|
return new CPPASTProblemExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#createProblem(int,
|
||||||
|
* int, int)
|
||||||
|
*/
|
||||||
|
protected IASTProblem createProblem(int signal, int offset, int length) {
|
||||||
|
IASTProblem result = new CPPASTProblem(signal, EMPTY_STRING, false, true);
|
||||||
|
((ASTNode) result).setOffset(offset);
|
||||||
|
((ASTNode) result).setLength(length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CASTProblem;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.ImagedExpansionToken;
|
import org.eclipse.cdt.internal.core.parser.token.ImagedExpansionToken;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.ImagedToken;
|
import org.eclipse.cdt.internal.core.parser.token.ImagedToken;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.SimpleExpansionToken;
|
import org.eclipse.cdt.internal.core.parser.token.SimpleExpansionToken;
|
||||||
|
@ -180,7 +180,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#handleProblem(int, int, char[])
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#handleProblem(int, int, char[])
|
||||||
*/
|
*/
|
||||||
protected void handleProblem(int id, int startOffset, char[] arg) {
|
protected void handleProblem(int id, int startOffset, char[] arg) {
|
||||||
IASTProblem problem = new ASTProblem(id, arg, true, false );
|
IASTProblem problem = new CASTProblem(id, arg, true, false );
|
||||||
locationMap.encounterProblem(problem);
|
locationMap.encounterProblem(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ 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;
|
||||||
|
@ -32,7 +31,6 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
|
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||||
|
@ -58,12 +56,6 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
"GNUC", //$NON-NLS-1$
|
"GNUC", //$NON-NLS-1$
|
||||||
"GNUC++" }; //$NON-NLS-1$
|
"GNUC++" }; //$NON-NLS-1$
|
||||||
private static final ISourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
private static final ISourceElementRequestor NULL_REQUESTOR = new NullSourceElementRequestor();
|
||||||
private static final IProblemRequestor PROBLEM_REQUESTOR = new IProblemRequestor() {
|
|
||||||
|
|
||||||
public boolean acceptProblem(IASTProblem problem) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -124,9 +116,9 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
ParserUtil.getScannerLogService(), Collections.EMPTY_LIST);
|
ParserUtil.getScannerLogService(), Collections.EMPTY_LIST);
|
||||||
//assume GCC
|
//assume GCC
|
||||||
if( l == ParserLanguage.C )
|
if( l == ParserLanguage.C )
|
||||||
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), new GCCParserExtensionConfiguration() );
|
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GCCParserExtensionConfiguration() );
|
||||||
else
|
else
|
||||||
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), new GNUCPPParserExtensionConfiguration() );
|
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GNUCPPParserExtensionConfiguration() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -145,22 +137,22 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
if( dialect.equals( dialects[0]))
|
if( dialect.equals( dialects[0]))
|
||||||
{
|
{
|
||||||
ICParserExtensionConfiguration config = new ANSICParserExtensionConfiguration();
|
ICParserExtensionConfiguration config = new ANSICParserExtensionConfiguration();
|
||||||
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), config );
|
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
|
||||||
}
|
}
|
||||||
else if( dialect.equals( dialects[1] ))
|
else if( dialect.equals( dialects[1] ))
|
||||||
{
|
{
|
||||||
ICPPParserExtensionConfiguration config = new ANSICPPParserExtensionConfiguration();
|
ICPPParserExtensionConfiguration config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), config );
|
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
|
||||||
}
|
}
|
||||||
else if( dialect.equals( dialects[2]))
|
else if( dialect.equals( dialects[2]))
|
||||||
{
|
{
|
||||||
ICParserExtensionConfiguration config = new GCCParserExtensionConfiguration();
|
ICParserExtensionConfiguration config = new GCCParserExtensionConfiguration();
|
||||||
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), config );
|
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
|
||||||
}
|
}
|
||||||
else if( dialect.equals( dialects[3]))
|
else if( dialect.equals( dialects[3]))
|
||||||
{
|
{
|
||||||
ICPPParserExtensionConfiguration config = new GNUCPPParserExtensionConfiguration();
|
ICPPParserExtensionConfiguration config = new GNUCPPParserExtensionConfiguration();
|
||||||
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, PROBLEM_REQUESTOR, ParserUtil.getParserLogService(), config );
|
parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IASTTranslationUnit tu = parser.parse();
|
IASTTranslationUnit tu = parser.parse();
|
||||||
|
|
Loading…
Add table
Reference in a new issue