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 {
|
||||||
|
|
||||||
|
}
|
|
@ -56,6 +56,10 @@ 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.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
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.IASTProblemDeclaration;
|
||||||
|
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;
|
||||||
|
@ -90,28 +94,24 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IProblemRequestor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
|
|
||||||
private final boolean supportGCCStyleDesignators;
|
private final boolean supportGCCStyleDesignators;
|
||||||
|
|
||||||
private static final int DEFAULT_DECLARATOR_LIST_SIZE = 4;
|
private static final int DEFAULT_DECLARATOR_LIST_SIZE = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scanner
|
* @param scanner
|
||||||
* @param logService
|
|
||||||
* @param parserMode
|
* @param parserMode
|
||||||
* @param callback
|
* @param logService
|
||||||
*/
|
*/
|
||||||
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
|
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
|
||||||
IProblemRequestor callback, IParserLogService logService,
|
IParserLogService logService, ICParserExtensionConfiguration config) {
|
||||||
ICParserExtensionConfiguration config) {
|
super(scanner, logService, parserMode, config
|
||||||
super(scanner, logService, parserMode, callback, config
|
|
||||||
.supportStatementsInExpressions(), config
|
.supportStatementsInExpressions(), config
|
||||||
.supportTypeofUnaryExpressions(), config
|
.supportTypeofUnaryExpressions(), config
|
||||||
.supportAlignOfUnaryExpression());
|
.supportAlignOfUnaryExpression());
|
||||||
|
@ -159,29 +159,32 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
IASTInitializer initializer = cInitializerClause(newDesignators);
|
IASTInitializer initializer = cInitializerClause(newDesignators);
|
||||||
|
|
||||||
if( newDesignators.isEmpty() )
|
if (newDesignators.isEmpty()) {
|
||||||
{
|
|
||||||
result.addInitializer(initializer);
|
result.addInitializer(initializer);
|
||||||
initializer.setParent(result);
|
initializer.setParent(result);
|
||||||
initializer.setPropertyInParent( IASTInitializerList.NESTED_INITIALIZER );
|
initializer
|
||||||
}
|
.setPropertyInParent(IASTInitializerList.NESTED_INITIALIZER);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
|
ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
|
||||||
((CASTNode)desigInitializer).setOffset( ((CASTNode)newDesignators.get(0)).getOffset());
|
((CASTNode) desigInitializer)
|
||||||
for( int i = 0; i < newDesignators.size(); ++i )
|
.setOffset(((CASTNode) newDesignators.get(0))
|
||||||
{
|
.getOffset());
|
||||||
ICASTDesignator d = (ICASTDesignator) newDesignators.get(i);
|
for (int i = 0; i < newDesignators.size(); ++i) {
|
||||||
|
ICASTDesignator d = (ICASTDesignator) newDesignators
|
||||||
|
.get(i);
|
||||||
d.setParent(desigInitializer);
|
d.setParent(desigInitializer);
|
||||||
d.setPropertyInParent( ICASTDesignatedInitializer.DESIGNATOR );
|
d
|
||||||
|
.setPropertyInParent(ICASTDesignatedInitializer.DESIGNATOR);
|
||||||
desigInitializer.addDesignator(d);
|
desigInitializer.addDesignator(d);
|
||||||
}
|
}
|
||||||
desigInitializer.setOperandInitializer(initializer);
|
desigInitializer.setOperandInitializer(initializer);
|
||||||
initializer.setParent(desigInitializer);
|
initializer.setParent(desigInitializer);
|
||||||
initializer.setPropertyInParent( ICASTDesignatedInitializer.OPERAND );
|
initializer
|
||||||
|
.setPropertyInParent(ICASTDesignatedInitializer.OPERAND);
|
||||||
result.addInitializer(desigInitializer);
|
result.addInitializer(desigInitializer);
|
||||||
desigInitializer.setParent(result);
|
desigInitializer.setParent(result);
|
||||||
desigInitializer.setPropertyInParent( IASTInitializerList.NESTED_INITIALIZER );
|
desigInitializer
|
||||||
|
.setPropertyInParent(IASTInitializerList.NESTED_INITIALIZER);
|
||||||
}
|
}
|
||||||
// can end with just a '}'
|
// can end with just a '}'
|
||||||
if (LT(1) == IToken.tRBRACE)
|
if (LT(1) == IToken.tRBRACE)
|
||||||
|
@ -193,7 +196,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break;
|
break;
|
||||||
if (checkHashcode == LA(1).hashCode()) {
|
if (checkHashcode == LA(1).hashCode()) {
|
||||||
IToken l2 = LA(1);
|
IToken l2 = LA(1);
|
||||||
throwBacktrack(startingOffset, l2.getEndOffset() - startingOffset);
|
throwBacktrack(startingOffset, l2.getEndOffset()
|
||||||
|
- startingOffset);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +214,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTExpression assignmentExpression = assignmentExpression();
|
IASTExpression assignmentExpression = assignmentExpression();
|
||||||
IASTInitializerExpression result = createInitializerExpression();
|
IASTInitializerExpression result = createInitializerExpression();
|
||||||
result.setExpression(assignmentExpression);
|
result.setExpression(assignmentExpression);
|
||||||
((ASTNode)result).setOffset(((ASTNode)assignmentExpression).getOffset());
|
((ASTNode) result).setOffset(((ASTNode) assignmentExpression)
|
||||||
|
.getOffset());
|
||||||
assignmentExpression.setParent(result);
|
assignmentExpression.setParent(result);
|
||||||
assignmentExpression
|
assignmentExpression
|
||||||
.setPropertyInParent(IASTInitializerExpression.INITIALIZER_EXPRESSION);
|
.setPropertyInParent(IASTInitializerExpression.INITIALIZER_EXPRESSION);
|
||||||
|
@ -261,7 +266,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
} else if (LT(1) == IToken.tLBRACKET) {
|
} else if (LT(1) == IToken.tLBRACKET) {
|
||||||
IToken mark = consume(IToken.tLBRACKET);
|
IToken mark = consume(IToken.tLBRACKET);
|
||||||
|
@ -273,9 +279,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((ASTNode) designator).setOffset(offset);
|
((ASTNode) designator).setOffset(offset);
|
||||||
designator.setSubscriptExpression(constantExpression);
|
designator.setSubscriptExpression(constantExpression);
|
||||||
constantExpression.setParent(designator);
|
constantExpression.setParent(designator);
|
||||||
constantExpression.setPropertyInParent( ICASTArrayDesignator.SUBSCRIPT_EXPRESSION );
|
constantExpression
|
||||||
|
.setPropertyInParent(ICASTArrayDesignator.SUBSCRIPT_EXPRESSION);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -290,16 +298,19 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((ASTNode) designator).setOffset(startOffset);
|
((ASTNode) designator).setOffset(startOffset);
|
||||||
designator.setRangeFloor(constantExpression1);
|
designator.setRangeFloor(constantExpression1);
|
||||||
constantExpression1.setParent(designator);
|
constantExpression1.setParent(designator);
|
||||||
constantExpression1.setPropertyInParent( IGCCASTArrayRangeDesignator.SUBSCRIPT_FLOOR_EXPRESSION );
|
constantExpression1
|
||||||
|
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_FLOOR_EXPRESSION);
|
||||||
designator.setRangeCeiling(constantExpression2);
|
designator.setRangeCeiling(constantExpression2);
|
||||||
constantExpression2.setParent(designator);
|
constantExpression2.setParent(designator);
|
||||||
constantExpression2.setPropertyInParent( IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION );
|
constantExpression2
|
||||||
|
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
}
|
}
|
||||||
} else if ( supportGCCStyleDesignators && LT(1) == IToken.tIDENTIFIER )
|
} else if (supportGCCStyleDesignators
|
||||||
{
|
&& LT(1) == IToken.tIDENTIFIER) {
|
||||||
IToken identifier = identifier();
|
IToken identifier = identifier();
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
ICASTFieldDesignator designator = createFieldDesignator();
|
ICASTFieldDesignator designator = createFieldDesignator();
|
||||||
|
@ -309,7 +320,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +339,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
n.setParent(designator);
|
n.setParent(designator);
|
||||||
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
n.setPropertyInParent(ICASTFieldDesignator.FIELD_NAME);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
} else if (LT(1) == IToken.tLBRACKET) {
|
} else if (LT(1) == IToken.tLBRACKET) {
|
||||||
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
int startOffset = consume(IToken.tLBRACKET).getOffset();
|
||||||
|
@ -339,12 +352,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((ASTNode) designator).setOffset(startOffset);
|
((ASTNode) designator).setOffset(startOffset);
|
||||||
designator.setRangeFloor(constantExpression1);
|
designator.setRangeFloor(constantExpression1);
|
||||||
constantExpression1.setParent(designator);
|
constantExpression1.setParent(designator);
|
||||||
constantExpression1.setPropertyInParent( IGCCASTArrayRangeDesignator.SUBSCRIPT_FLOOR_EXPRESSION );
|
constantExpression1
|
||||||
|
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_FLOOR_EXPRESSION);
|
||||||
designator.setRangeCeiling(constantExpression2);
|
designator.setRangeCeiling(constantExpression2);
|
||||||
constantExpression2.setParent(designator);
|
constantExpression2.setParent(designator);
|
||||||
constantExpression2.setPropertyInParent( IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION );
|
constantExpression2
|
||||||
|
.setPropertyInParent(IGCCASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION);
|
||||||
if (designatorList == Collections.EMPTY_LIST)
|
if (designatorList == Collections.EMPTY_LIST)
|
||||||
designatorList = new ArrayList( DEFAULT_DESIGNATOR_LIST_SIZE );
|
designatorList = new ArrayList(
|
||||||
|
DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
designatorList.add(designator);
|
designatorList.add(designator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,8 +402,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* @throws EndOfFileException
|
* @throws EndOfFileException
|
||||||
|
@ -537,7 +551,16 @@ public class GNUCSourceParser 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();
|
||||||
|
pd.setProblem(p);
|
||||||
|
((CASTNode) pd).setOffset(((CASTNode) p).getOffset());
|
||||||
|
p.setParent(pd);
|
||||||
|
p.setPropertyInParent(IASTProblemDeclaration.PROBLEM);
|
||||||
|
pd.setParent(translationUnit);
|
||||||
|
pd
|
||||||
|
.setPropertyInParent(IASTTranslationUnit.OWNED_DECLARATION);
|
||||||
|
translationUnit.addDeclaration(pd);
|
||||||
errorHandling();
|
errorHandling();
|
||||||
if (lastBacktrack != -1
|
if (lastBacktrack != -1
|
||||||
&& lastBacktrack == LA(1).hashCode()) {
|
&& lastBacktrack == LA(1).hashCode()) {
|
||||||
|
@ -576,6 +599,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// compilationUnit.exitScope( requestor );
|
// compilationUnit.exitScope( requestor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTProblemDeclaration createProblemDeclaration() {
|
||||||
|
return new CASTProblemDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
|
@ -584,31 +614,49 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
BacktrackException {
|
BacktrackException {
|
||||||
IASTExpression conditionalExpression = conditionalExpression();
|
IASTExpression conditionalExpression = conditionalExpression();
|
||||||
// if the condition not taken, try assignment operators
|
// if the condition not taken, try assignment operators
|
||||||
if (conditionalExpression != null && conditionalExpression instanceof IASTConditionalExpression ) //&&
|
if (conditionalExpression != null
|
||||||
|
&& conditionalExpression instanceof IASTConditionalExpression) //&&
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.tASSIGN:
|
case IToken.tASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_assign, conditionalExpression);
|
return assignmentOperatorExpression(IASTBinaryExpression.op_assign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tSTARASSIGN:
|
case IToken.tSTARASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_multiplyAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_multiplyAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tDIVASSIGN:
|
case IToken.tDIVASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_divideAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_divideAssign, conditionalExpression);
|
||||||
case IToken.tMODASSIGN:
|
case IToken.tMODASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_moduloAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_moduloAssign, conditionalExpression);
|
||||||
case IToken.tPLUSASSIGN:
|
case IToken.tPLUSASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_plusAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_plusAssign, conditionalExpression);
|
||||||
case IToken.tMINUSASSIGN:
|
case IToken.tMINUSASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_minusAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_minusAssign, conditionalExpression);
|
||||||
case IToken.tSHIFTRASSIGN:
|
case IToken.tSHIFTRASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_shiftRightAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_shiftRightAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tSHIFTLASSIGN:
|
case IToken.tSHIFTLASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_shiftLeftAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_shiftLeftAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tAMPERASSIGN:
|
case IToken.tAMPERASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_binaryAndAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_binaryAndAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tXORASSIGN:
|
case IToken.tXORASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_binaryXorAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_binaryXorAssign,
|
||||||
|
conditionalExpression);
|
||||||
case IToken.tBITORASSIGN:
|
case IToken.tBITORASSIGN:
|
||||||
return assignmentOperatorExpression(IASTBinaryExpression.op_binaryOrAssign, conditionalExpression);
|
return assignmentOperatorExpression(
|
||||||
|
IASTBinaryExpression.op_binaryOrAssign,
|
||||||
|
conditionalExpression);
|
||||||
}
|
}
|
||||||
return conditionalExpression;
|
return conditionalExpression;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +692,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
operator = IASTBinaryExpression.op_greaterEqual;
|
operator = IASTBinaryExpression.op_greaterEqual;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
firstExpression = buildBinaryExpression( operator, firstExpression, secondExpression );
|
firstExpression = buildBinaryExpression(operator,
|
||||||
|
firstExpression, secondExpression);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return firstExpression;
|
return firstExpression;
|
||||||
|
@ -678,7 +727,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
operator = IASTBinaryExpression.op_modulo;
|
operator = IASTBinaryExpression.op_modulo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
firstExpression = buildBinaryExpression( operator, firstExpression, secondExpression );
|
firstExpression = buildBinaryExpression(operator,
|
||||||
|
firstExpression, secondExpression);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return firstExpression;
|
return firstExpression;
|
||||||
|
@ -709,7 +759,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throwBacktrack(bte);
|
throwBacktrack(bte);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildTypeIdUnaryExpression( IASTCastExpression.op_cast, typeId, castExpression, startingOffset );
|
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||||
|
typeId, castExpression, startingOffset);
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -760,8 +811,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
mark = null;
|
mark = null;
|
||||||
if (typeId == null && unaryExpression != null)
|
if (typeId == null && unaryExpression != null)
|
||||||
return buildUnaryExpression( IASTUnaryExpression.op_sizeof, unaryExpression, startingOffset );
|
return buildUnaryExpression(IASTUnaryExpression.op_sizeof,
|
||||||
return buildTypeIdExpression( IASTTypeIdExpression.op_sizeof, typeId, startingOffset );
|
unaryExpression, startingOffset);
|
||||||
|
return buildTypeIdExpression(IASTTypeIdExpression.op_sizeof,
|
||||||
|
typeId, startingOffset);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (LT(1) == IGCCToken.t_typeof && supportTypeOfUnaries) {
|
if (LT(1) == IGCCToken.t_typeof && supportTypeOfUnaries) {
|
||||||
|
@ -784,7 +837,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @param startingOffset
|
* @param startingOffset
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTExpression buildTypeIdExpression(int op_sizeof, IASTTypeId typeId, int startingOffset) {
|
protected IASTExpression buildTypeIdExpression(int op_sizeof,
|
||||||
|
IASTTypeId typeId, int startingOffset) {
|
||||||
IASTTypeIdExpression result = createTypeIdExpression();
|
IASTTypeIdExpression result = createTypeIdExpression();
|
||||||
result.setOperator(op_sizeof);
|
result.setOperator(op_sizeof);
|
||||||
((ASTNode) result).setOffset(startingOffset);
|
((ASTNode) result).setOffset(startingOffset);
|
||||||
|
@ -814,17 +868,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// ( type-name ) { initializer-list }
|
// ( type-name ) { initializer-list }
|
||||||
// ( type-name ) { initializer-list , }
|
// ( type-name ) { initializer-list , }
|
||||||
IToken m = mark();
|
IToken m = mark();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
int offset = consume(IToken.tLPAREN).getOffset();
|
int offset = consume(IToken.tLPAREN).getOffset();
|
||||||
IASTTypeId t = typeId(false);
|
IASTTypeId t = typeId(false);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
|
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
|
||||||
firstExpression = buildTypeIdInitializerExpression(t, i, offset);
|
firstExpression = buildTypeIdInitializerExpression(t, i, offset);
|
||||||
break;
|
break;
|
||||||
}
|
} catch (BacktrackException bt) {
|
||||||
catch( BacktrackException bt )
|
|
||||||
{
|
|
||||||
backup(m);
|
backup(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,13 +892,16 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
secondExpression = expression();
|
secondExpression = expression();
|
||||||
consume(IToken.tRBRACKET);
|
consume(IToken.tRBRACKET);
|
||||||
IASTArraySubscriptExpression s = createArraySubscriptExpression();
|
IASTArraySubscriptExpression s = createArraySubscriptExpression();
|
||||||
((ASTNode)s).setOffset( ((ASTNode)firstExpression).getOffset() );
|
((ASTNode) s)
|
||||||
|
.setOffset(((ASTNode) firstExpression).getOffset());
|
||||||
s.setArrayExpression(firstExpression);
|
s.setArrayExpression(firstExpression);
|
||||||
firstExpression.setParent(s);
|
firstExpression.setParent(s);
|
||||||
firstExpression.setPropertyInParent( IASTArraySubscriptExpression.ARRAY );
|
firstExpression
|
||||||
|
.setPropertyInParent(IASTArraySubscriptExpression.ARRAY);
|
||||||
s.setSubscriptExpression(secondExpression);
|
s.setSubscriptExpression(secondExpression);
|
||||||
secondExpression.setParent(s);
|
secondExpression.setParent(s);
|
||||||
secondExpression.setPropertyInParent( IASTArraySubscriptExpression.SUBSCRIPT );
|
secondExpression
|
||||||
|
.setPropertyInParent(IASTArraySubscriptExpression.SUBSCRIPT);
|
||||||
firstExpression = s;
|
firstExpression = s;
|
||||||
break;
|
break;
|
||||||
case IToken.tLPAREN:
|
case IToken.tLPAREN:
|
||||||
|
@ -857,37 +911,45 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
secondExpression = expression();
|
secondExpression = expression();
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
IASTFunctionCallExpression f = createFunctionCallExpression();
|
IASTFunctionCallExpression f = createFunctionCallExpression();
|
||||||
((ASTNode)f).setOffset( ((ASTNode)firstExpression).getOffset() );
|
((ASTNode) f)
|
||||||
|
.setOffset(((ASTNode) firstExpression).getOffset());
|
||||||
f.setFunctionNameExpression(firstExpression);
|
f.setFunctionNameExpression(firstExpression);
|
||||||
firstExpression.setParent(f);
|
firstExpression.setParent(f);
|
||||||
firstExpression.setPropertyInParent( IASTFunctionCallExpression.FUNCTION_NAME );
|
firstExpression
|
||||||
|
.setPropertyInParent(IASTFunctionCallExpression.FUNCTION_NAME);
|
||||||
|
|
||||||
if( secondExpression != null )
|
if (secondExpression != null) {
|
||||||
{
|
|
||||||
f.setParameterExpression(secondExpression);
|
f.setParameterExpression(secondExpression);
|
||||||
secondExpression.setParent(f);
|
secondExpression.setParent(f);
|
||||||
secondExpression.setPropertyInParent( IASTFunctionCallExpression.PARAMETERS );
|
secondExpression
|
||||||
|
.setPropertyInParent(IASTFunctionCallExpression.PARAMETERS);
|
||||||
}
|
}
|
||||||
firstExpression = f;
|
firstExpression = f;
|
||||||
break;
|
break;
|
||||||
case IToken.tINCR:
|
case IToken.tINCR:
|
||||||
int offset = consume(IToken.tINCR).getOffset();
|
int offset = consume(IToken.tINCR).getOffset();
|
||||||
firstExpression = buildUnaryExpression( IASTUnaryExpression.op_postFixIncr, firstExpression, offset );
|
firstExpression = buildUnaryExpression(
|
||||||
|
IASTUnaryExpression.op_postFixIncr, firstExpression,
|
||||||
|
offset);
|
||||||
break;
|
break;
|
||||||
case IToken.tDECR:
|
case IToken.tDECR:
|
||||||
offset = consume().getOffset();
|
offset = consume().getOffset();
|
||||||
firstExpression = buildUnaryExpression( IASTUnaryExpression.op_postFixDecr, firstExpression, offset );
|
firstExpression = buildUnaryExpression(
|
||||||
|
IASTUnaryExpression.op_postFixDecr, firstExpression,
|
||||||
|
offset);
|
||||||
break;
|
break;
|
||||||
case IToken.tDOT:
|
case IToken.tDOT:
|
||||||
// member access
|
// member access
|
||||||
consume(IToken.tDOT);
|
consume(IToken.tDOT);
|
||||||
IASTName name = createName(identifier());
|
IASTName name = createName(identifier());
|
||||||
IASTFieldReference result = createFieldReference();
|
IASTFieldReference result = createFieldReference();
|
||||||
((ASTNode)result).setOffset( ((ASTNode)firstExpression).getOffset() );
|
((ASTNode) result).setOffset(((ASTNode) firstExpression)
|
||||||
|
.getOffset());
|
||||||
result.setFieldOwner(firstExpression);
|
result.setFieldOwner(firstExpression);
|
||||||
result.setIsPointerDereference(false);
|
result.setIsPointerDereference(false);
|
||||||
firstExpression.setParent(result);
|
firstExpression.setParent(result);
|
||||||
firstExpression.setPropertyInParent( IASTFieldReference.FIELD_OWNER );
|
firstExpression
|
||||||
|
.setPropertyInParent(IASTFieldReference.FIELD_OWNER);
|
||||||
result.setFieldName(name);
|
result.setFieldName(name);
|
||||||
name.setParent(result);
|
name.setParent(result);
|
||||||
name.setPropertyInParent(IASTFieldReference.FIELD_NAME);
|
name.setPropertyInParent(IASTFieldReference.FIELD_NAME);
|
||||||
|
@ -898,11 +960,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume(IToken.tARROW);
|
consume(IToken.tARROW);
|
||||||
name = createName(identifier());
|
name = createName(identifier());
|
||||||
result = createFieldReference();
|
result = createFieldReference();
|
||||||
((ASTNode)result).setOffset( ((ASTNode)firstExpression).getOffset() );
|
((ASTNode) result).setOffset(((ASTNode) firstExpression)
|
||||||
|
.getOffset());
|
||||||
result.setFieldOwner(firstExpression);
|
result.setFieldOwner(firstExpression);
|
||||||
result.setIsPointerDereference(true);
|
result.setIsPointerDereference(true);
|
||||||
firstExpression.setParent(result);
|
firstExpression.setParent(result);
|
||||||
firstExpression.setPropertyInParent( IASTFieldReference.FIELD_OWNER );
|
firstExpression
|
||||||
|
.setPropertyInParent(IASTFieldReference.FIELD_OWNER);
|
||||||
result.setFieldName(name);
|
result.setFieldName(name);
|
||||||
name.setParent(result);
|
name.setParent(result);
|
||||||
name.setPropertyInParent(IASTFieldReference.FIELD_NAME);
|
name.setPropertyInParent(IASTFieldReference.FIELD_NAME);
|
||||||
|
@ -934,7 +998,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @param offset
|
* @param offset
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected ICASTTypeIdInitializerExpression buildTypeIdInitializerExpression(IASTTypeId t, IASTInitializer i, int offset) {
|
protected ICASTTypeIdInitializerExpression buildTypeIdInitializerExpression(
|
||||||
|
IASTTypeId t, IASTInitializer i, int offset) {
|
||||||
ICASTTypeIdInitializerExpression result = createTypeIdInitializerExpression();
|
ICASTTypeIdInitializerExpression result = createTypeIdInitializerExpression();
|
||||||
((ASTNode) result).setOffset(offset);
|
((ASTNode) result).setOffset(offset);
|
||||||
result.setTypeId(t);
|
result.setTypeId(t);
|
||||||
|
@ -973,7 +1038,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.tINTEGER:
|
case IToken.tINTEGER:
|
||||||
t = consume();
|
t = consume();
|
||||||
literalExpression = createLiteralExpression();
|
literalExpression = createLiteralExpression();
|
||||||
literalExpression.setKind( IASTLiteralExpression.lk_integer_constant);
|
literalExpression
|
||||||
|
.setKind(IASTLiteralExpression.lk_integer_constant);
|
||||||
literalExpression.setValue(t.getImage());
|
literalExpression.setValue(t.getImage());
|
||||||
((ASTNode) literalExpression).setOffset(t.getOffset());
|
((ASTNode) literalExpression).setOffset(t.getOffset());
|
||||||
return literalExpression;
|
return literalExpression;
|
||||||
|
@ -1046,13 +1112,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTDeclSpecifier declSpecifier = null;
|
IASTDeclSpecifier declSpecifier = null;
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
declSpecifier = declSpecifierSeq(false);
|
declSpecifier = declSpecifierSeq(false);
|
||||||
declarator = declarator();
|
declarator = declarator();
|
||||||
}
|
} catch (BacktrackException bt) {
|
||||||
catch( BacktrackException bt )
|
|
||||||
{
|
|
||||||
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
int endingOffset = lastToken == null ? 0 : lastToken.getEndOffset();
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(startingOffset, endingOffset - startingOffset);
|
throwBacktrack(startingOffset, endingOffset - startingOffset);
|
||||||
|
@ -1103,8 +1166,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
boolean isConst = false, isVolatile = false, isRestrict = false;
|
boolean isConst = false, isVolatile = false, isRestrict = false;
|
||||||
|
|
||||||
if( LT(1) != IToken.tSTAR )
|
if (LT(1) != IToken.tSTAR) {
|
||||||
{
|
|
||||||
backup(mark);
|
backup(mark);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1233,12 +1295,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.t_long:
|
case IToken.t_long:
|
||||||
flags.setEncounteredRawType(true);
|
flags.setEncounteredRawType(true);
|
||||||
consume();
|
consume();
|
||||||
if( isLong )
|
if (isLong) {
|
||||||
{
|
|
||||||
isLongLong = true;
|
isLongLong = true;
|
||||||
isLong = false;
|
isLong = false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
isLong = true;
|
isLong = true;
|
||||||
break;
|
break;
|
||||||
case IToken.t_float:
|
case IToken.t_float:
|
||||||
|
@ -1286,10 +1346,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (lookAheadForDeclarator(flags)) {
|
if (lookAheadForDeclarator(flags)) {
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
switch( LT(2) )
|
switch (LT(2)) {
|
||||||
{
|
|
||||||
case IToken.tLPAREN:
|
case IToken.tLPAREN:
|
||||||
if (isTypedef) break;
|
if (isTypedef)
|
||||||
|
break;
|
||||||
case IToken.tSEMI:
|
case IToken.tSEMI:
|
||||||
case IToken.tASSIGN:
|
case IToken.tASSIGN:
|
||||||
//TODO more
|
//TODO more
|
||||||
|
@ -1333,8 +1393,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( structSpec != null )
|
if (structSpec != null) {
|
||||||
{
|
|
||||||
((ASTNode) structSpec).setOffset(startingOffset);
|
((ASTNode) structSpec).setOffset(startingOffset);
|
||||||
structSpec.setConst(isConst);
|
structSpec.setConst(isConst);
|
||||||
((ICASTCompositeTypeSpecifier) structSpec).setRestrict(isRestrict);
|
((ICASTCompositeTypeSpecifier) structSpec).setRestrict(isRestrict);
|
||||||
|
@ -1345,8 +1404,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return structSpec;
|
return structSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( enumSpec != null )
|
if (enumSpec != null) {
|
||||||
{
|
|
||||||
((ASTNode) enumSpec).setOffset(startingOffset);
|
((ASTNode) enumSpec).setOffset(startingOffset);
|
||||||
enumSpec.setConst(isConst);
|
enumSpec.setConst(isConst);
|
||||||
((CASTEnumerationSpecifier) enumSpec).setRestrict(isRestrict);
|
((CASTEnumerationSpecifier) enumSpec).setRestrict(isRestrict);
|
||||||
|
@ -1356,8 +1414,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return enumSpec;
|
return enumSpec;
|
||||||
|
|
||||||
}
|
}
|
||||||
if( elabSpec != null )
|
if (elabSpec != null) {
|
||||||
{
|
|
||||||
((ASTNode) elabSpec).setOffset(startingOffset);
|
((ASTNode) elabSpec).setOffset(startingOffset);
|
||||||
elabSpec.setConst(isConst);
|
elabSpec.setConst(isConst);
|
||||||
((CASTElaboratedTypeSpecifier) elabSpec).setRestrict(isRestrict);
|
((CASTElaboratedTypeSpecifier) elabSpec).setRestrict(isRestrict);
|
||||||
|
@ -1419,6 +1476,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
*
|
*
|
||||||
* classSpecifier : classKey name (baseClause)? "{" (memberSpecification)*
|
* classSpecifier : classKey name (baseClause)? "{" (memberSpecification)*
|
||||||
* "}"
|
* "}"
|
||||||
|
*
|
||||||
* @param owner
|
* @param owner
|
||||||
* IParserCallback object that represents the declaration that
|
* IParserCallback object that represents the declaration that
|
||||||
* owns this classSpecifier
|
* owns this classSpecifier
|
||||||
|
@ -1475,8 +1533,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
((ASTNode) result).setOffset(classKey.getOffset());
|
((ASTNode) result).setOffset(classKey.getOffset());
|
||||||
|
|
||||||
result.setName(name);
|
result.setName(name);
|
||||||
if( name != null )
|
if (name != null) {
|
||||||
{
|
|
||||||
name.setParent(result);
|
name.setParent(result);
|
||||||
name.setPropertyInParent(IASTCompositeTypeSpecifier.TYPE_NAME);
|
name.setPropertyInParent(IASTCompositeTypeSpecifier.TYPE_NAME);
|
||||||
}
|
}
|
||||||
|
@ -1491,7 +1548,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
IASTDeclaration d = declaration();
|
IASTDeclaration d = declaration();
|
||||||
d.setParent(result);
|
d.setParent(result);
|
||||||
d.setPropertyInParent( IASTCompositeTypeSpecifier.MEMBER_DECLARATION );
|
d
|
||||||
|
.setPropertyInParent(IASTCompositeTypeSpecifier.MEMBER_DECLARATION);
|
||||||
result.addMemberDeclaration(d);
|
result.addMemberDeclaration(d);
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
if (checkToken == LA(1).hashCode())
|
if (checkToken == LA(1).hashCode())
|
||||||
|
@ -1600,8 +1658,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declaratorName = createName();
|
declaratorName = createName();
|
||||||
} else if (LT(1) == IToken.tIDENTIFIER) {
|
} else if (LT(1) == IToken.tIDENTIFIER) {
|
||||||
declaratorName = createName(identifier());
|
declaratorName = createName(identifier());
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
declaratorName = createName();
|
declaratorName = createName();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1630,7 +1687,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
int endOffset = (lastToken != null) ? lastToken
|
int endOffset = (lastToken != null) ? lastToken
|
||||||
.getEndOffset() : 0;
|
.getEndOffset() : 0;
|
||||||
if (seenParameter)
|
if (seenParameter)
|
||||||
throwBacktrack(startingOffset, endOffset - startingOffset);
|
throwBacktrack(startingOffset, endOffset
|
||||||
|
- startingOffset);
|
||||||
IASTParameterDeclaration pd = parameterDeclaration();
|
IASTParameterDeclaration pd = parameterDeclaration();
|
||||||
if (parameters == Collections.EMPTY_LIST)
|
if (parameters == Collections.EMPTY_LIST)
|
||||||
parameters = new ArrayList(
|
parameters = new ArrayList(
|
||||||
|
@ -1663,32 +1721,28 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
IASTFunctionDeclarator fc = createFunctionDeclarator();
|
IASTFunctionDeclarator fc = createFunctionDeclarator();
|
||||||
fc.setVarArgs(encounteredVarArgs);
|
fc.setVarArgs(encounteredVarArgs);
|
||||||
for (int i = 0; i < parameters.size(); ++i)
|
for (int i = 0; i < parameters.size(); ++i) {
|
||||||
{
|
|
||||||
IASTParameterDeclaration p = (IASTParameterDeclaration) parameters
|
IASTParameterDeclaration p = (IASTParameterDeclaration) parameters
|
||||||
.get(i);
|
.get(i);
|
||||||
p.setParent(fc);
|
p.setParent(fc);
|
||||||
p.setPropertyInParent( IASTFunctionDeclarator.FUNCTION_PARAMETER );
|
p
|
||||||
|
.setPropertyInParent(IASTFunctionDeclarator.FUNCTION_PARAMETER);
|
||||||
fc.addParameterDeclaration(p);
|
fc.addParameterDeclaration(p);
|
||||||
}
|
}
|
||||||
d = fc;
|
d = fc;
|
||||||
} else if( arrayMods != Collections.EMPTY_LIST )
|
} else if (arrayMods != Collections.EMPTY_LIST) {
|
||||||
{
|
|
||||||
d = createArrayDeclarator();
|
d = createArrayDeclarator();
|
||||||
for( int i = 0; i < arrayMods.size(); ++i )
|
for (int i = 0; i < arrayMods.size(); ++i) {
|
||||||
{
|
|
||||||
IASTArrayModifier m = (IASTArrayModifier) arrayMods.get(i);
|
IASTArrayModifier m = (IASTArrayModifier) arrayMods.get(i);
|
||||||
m.setParent(d);
|
m.setParent(d);
|
||||||
m.setPropertyInParent(IASTArrayDeclarator.ARRAY_MODIFIER);
|
m.setPropertyInParent(IASTArrayDeclarator.ARRAY_MODIFIER);
|
||||||
((IASTArrayDeclarator) d).addArrayModifier(m);
|
((IASTArrayDeclarator) d).addArrayModifier(m);
|
||||||
}
|
}
|
||||||
}
|
} else if (bitField != null) {
|
||||||
else if (bitField != null) {
|
|
||||||
IASTFieldDeclarator fl = createFieldDeclarator();
|
IASTFieldDeclarator fl = createFieldDeclarator();
|
||||||
fl.setBitFieldSize(bitField);
|
fl.setBitFieldSize(bitField);
|
||||||
d = fl;
|
d = fl;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
d = createDeclarator();
|
d = createDeclarator();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < pointerOps.size(); ++i) {
|
for (int i = 0; i < pointerOps.size(); ++i) {
|
||||||
|
@ -1711,7 +1765,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTArrayDeclarator createArrayDeclarator() {
|
protected IASTArrayDeclarator createArrayDeclarator() {
|
||||||
return new CASTArrayDeclarator();
|
return new CASTArrayDeclarator();
|
||||||
}
|
}
|
||||||
|
@ -1730,9 +1783,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTFunctionDeclarator();
|
return new CASTFunctionDeclarator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param t
|
* @param t
|
||||||
* @return
|
* @return
|
||||||
|
@ -1803,8 +1853,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTArrayModifier arrayMod = null;
|
IASTArrayModifier arrayMod = null;
|
||||||
if (!(isStatic || isRestrict || isConst || isVolatile))
|
if (!(isStatic || isRestrict || isConst || isVolatile))
|
||||||
arrayMod = createArrayModifier();
|
arrayMod = createArrayModifier();
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
ICASTArrayModifier temp = createCArrayModifier();
|
ICASTArrayModifier temp = createCArrayModifier();
|
||||||
temp.setStatic(isStatic);
|
temp.setStatic(isStatic);
|
||||||
temp.setConst(isConst);
|
temp.setConst(isConst);
|
||||||
|
@ -1814,8 +1863,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
arrayMod = temp;
|
arrayMod = temp;
|
||||||
}
|
}
|
||||||
((ASTNode) arrayMod).setOffset(startOffset);
|
((ASTNode) arrayMod).setOffset(startOffset);
|
||||||
if( exp != null )
|
if (exp != null) {
|
||||||
{
|
|
||||||
arrayMod.setConstantExpression(exp);
|
arrayMod.setConstantExpression(exp);
|
||||||
exp.setParent(arrayMod);
|
exp.setParent(arrayMod);
|
||||||
exp.setPropertyInParent(IASTArrayModifier.CONSTANT_EXPRESSION);
|
exp.setPropertyInParent(IASTArrayModifier.CONSTANT_EXPRESSION);
|
||||||
|
@ -1887,11 +1935,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
try {
|
try {
|
||||||
return simpleDeclaration();
|
return simpleDeclaration();
|
||||||
} catch (BacktrackException b) {
|
} catch (BacktrackException b) {
|
||||||
failParse(b);
|
IASTProblem p = failParse(b);
|
||||||
throwBacktrack(b);
|
IASTProblemExpression pe = createProblemExpression();
|
||||||
|
((CASTNode) pe).setOffset(((CASTNode) p).getOffset());
|
||||||
|
pe.setProblem(p);
|
||||||
|
p.setParent(pe);
|
||||||
|
p.setPropertyInParent(IASTProblemExpression.PROBLEM);
|
||||||
|
return pe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1921,35 +1973,45 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTBinaryExpression();
|
return new CASTBinaryExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createConditionalExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createConditionalExpression()
|
||||||
*/
|
*/
|
||||||
protected IASTConditionalExpression createConditionalExpression() {
|
protected IASTConditionalExpression createConditionalExpression() {
|
||||||
return new CASTConditionalExpression();
|
return new CASTConditionalExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createUnaryExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createUnaryExpression()
|
||||||
*/
|
*/
|
||||||
protected IASTUnaryExpression createUnaryExpression() {
|
protected IASTUnaryExpression createUnaryExpression() {
|
||||||
return new CASTUnaryExpression();
|
return new CASTUnaryExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatementExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatementExpression()
|
||||||
*/
|
*/
|
||||||
protected IGNUASTCompoundStatementExpression createCompoundStatementExpression() {
|
protected IGNUASTCompoundStatementExpression createCompoundStatementExpression() {
|
||||||
return new CASTCompoundStatementExpression();
|
return new CASTCompoundStatementExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createExpressionList()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createExpressionList()
|
||||||
*/
|
*/
|
||||||
protected IASTExpressionList createExpressionList() {
|
protected IASTExpressionList createExpressionList() {
|
||||||
return new CASTExpressionList();
|
return new CASTExpressionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerator()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerator()
|
||||||
*/
|
*/
|
||||||
protected IASTEnumerator createEnumerator() {
|
protected IASTEnumerator createEnumerator() {
|
||||||
|
@ -2079,7 +2141,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTCastExpression();
|
return new CASTCastExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTStatement statement() throws EndOfFileException, BacktrackException {
|
protected IASTStatement statement() throws EndOfFileException,
|
||||||
|
BacktrackException {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
// labeled statements
|
// labeled statements
|
||||||
case IToken.t_case:
|
case IToken.t_case:
|
||||||
|
@ -2124,12 +2187,44 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#nullifyTranslationUnit()
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#nullifyTranslationUnit()
|
||||||
*/
|
*/
|
||||||
protected void nullifyTranslationUnit() {
|
protected void nullifyTranslationUnit() {
|
||||||
translationUnit = null;
|
translationUnit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#createProblemStatement()
|
||||||
|
*/
|
||||||
|
protected IASTProblemStatement createProblemStatement() {
|
||||||
|
return new CASTProblemStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser#createProblemExpression()
|
||||||
|
*/
|
||||||
|
protected IASTProblemExpression createProblemExpression() {
|
||||||
|
return new CASTProblemExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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 CASTProblem(signal, EMPTY_STRING, false, true);
|
||||||
|
((ASTNode) result).setOffset(offset);
|
||||||
|
((ASTNode) result).setLength(length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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);
|
||||||
try {
|
|
||||||
boolean isEllipsis = false;
|
boolean isEllipsis = false;
|
||||||
IASTDeclaration decl = null;
|
IASTDeclaration decl = null;
|
||||||
|
try {
|
||||||
if (LT(1) == IToken.tELLIPSIS)
|
if (LT(1) == IToken.tELLIPSIS)
|
||||||
{
|
{
|
||||||
consume(IToken.tELLIPSIS);
|
consume(IToken.tELLIPSIS);
|
||||||
|
@ -3945,6 +3986,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
}
|
||||||
|
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();
|
IASTStatement compoundStatement = catchBlockCompoundStatement();
|
||||||
ICPPASTCatchHandler handler = createCatchHandler();
|
ICPPASTCatchHandler handler = createCatchHandler();
|
||||||
|
@ -3963,10 +4014,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
compoundStatement.setPropertyInParent( ICPPASTCatchHandler.CATCH_BODY );
|
compoundStatement.setPropertyInParent( ICPPASTCatchHandler.CATCH_BODY );
|
||||||
}
|
}
|
||||||
collection.add( handler );
|
collection.add( handler );
|
||||||
} catch (BacktrackException bte) {
|
|
||||||
failParse(bte);
|
|
||||||
failParseWithErrorHandling();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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