1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Infrastructure to help fix all the ambiguity bugs.

This commit is contained in:
John Camelon 2005-04-08 15:08:30 +00:00
parent 7fec8ae423
commit a65769ef8a
15 changed files with 106 additions and 22 deletions

View file

@ -383,18 +383,22 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
public IASTTranslationUnit parse() { public IASTTranslationUnit parse() {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
translationUnit(); translationUnit();
// For the debuglog to take place, you have to call
// Util.setDebugging(true);
// Or set debug to true in the core plugin preference
log.traceLog("Parse " //$NON-NLS-1$ log.traceLog("Parse " //$NON-NLS-1$
+ (++parseCount) + ": " //$NON-NLS-1$ + (++parseCount) + ": " //$NON-NLS-1$
+ (System.currentTimeMillis() - startTime) + "ms" //$NON-NLS-1$ + (System.currentTimeMillis() - startTime) + "ms" //$NON-NLS-1$
+ (parsePassed ? "" : " - parse failure")); //$NON-NLS-1$ //$NON-NLS-2$ + (parsePassed ? "" : " - parse failure")); //$NON-NLS-1$ //$NON-NLS-2$
startTime = System.currentTimeMillis();
resolveAmbiguities();
log.traceLog("Ambiguity resolution : " //$NON-NLS-1$
+ (System.currentTimeMillis() - startTime) + "ms" //$NON-NLS-1$
); //$NON-NLS-1$ //$NON-NLS-2$
IASTTranslationUnit result = getTranslationUnit(); IASTTranslationUnit result = getTranslationUnit();
nullifyTranslationUnit(); nullifyTranslationUnit();
return result; return result;
} }
protected abstract void resolveAmbiguities();
/** /**
* *
*/ */

View file

@ -0,0 +1,17 @@
/**********************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTNode;
public interface IASTAmbiguity extends IASTNode {
}

View file

@ -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;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
/**
* @author jcamelon
*/
public interface IASTDeclarationAmbiguity extends IASTDeclaration,
IASTAmbiguity {
/**
* @param decl
*/
public void addDeclaration( IASTDeclaration decl );
/**
* @return
*/
public IASTDeclaration [] getDeclarations();
}

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class CASTBaseDeclSpecifier extends CASTNode implements ICASTDeclSpecifier { public abstract class CASTBaseDeclSpecifier extends CASTNode implements ICASTDeclSpecifier {
protected int storageClass; protected int storageClass;
protected boolean isConst; protected boolean isConst;

View file

@ -10,7 +10,6 @@
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@ -18,7 +17,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class CASTNode extends ASTNode implements IASTNode { public abstract class CASTNode extends ASTNode implements IASTNode {
private IASTNode parent; private IASTNode parent;
private ASTNodeProperty property; private ASTNodeProperty property;
@ -63,7 +62,7 @@ public class CASTNode extends ASTNode implements IASTNode {
return (IASTTranslationUnit) node; return (IASTTranslationUnit) node;
} }
public boolean accept( ASTVisitor action ){ // public boolean accept( ASTVisitor action ){
return true; // return true;
} // }
} }

View file

@ -9,6 +9,7 @@
* IBM Rational Software - Initial API and implementation */ * IBM Rational Software - Initial API and implementation */
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer; import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
/** /**
@ -62,4 +63,8 @@ public class CASTPointer extends CASTNode implements ICASTPointer {
isVolatile = value; isVolatile = value;
} }
public boolean accept(ASTVisitor visitor) {
return true;
}
} }

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
/** /**
* @author jcamelon * @author jcamelon
*/ */
class CASTProblemOwner extends CASTNode { abstract class CASTProblemOwner extends CASTNode {
private IASTProblem problem; private IASTProblem problem;

View file

@ -2600,4 +2600,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
return nc.result; return nc.result;
} }
protected void resolveAmbiguities() {
// TODO Auto-generated method stub
}
} }

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class CPPASTBaseDeclSpecifier extends CPPASTNode implements public abstract class CPPASTBaseDeclSpecifier extends CPPASTNode implements
ICPPASTDeclSpecifier { ICPPASTDeclSpecifier {
private boolean friend; private boolean friend;

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@ -19,7 +18,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class CPPASTNode extends ASTNode implements IASTNode { public abstract class CPPASTNode extends ASTNode implements IASTNode {
private IASTNode parent; private IASTNode parent;
private ASTNodeProperty property; private ASTNodeProperty property;
@ -64,7 +63,4 @@ public class CPPASTNode extends ASTNode implements IASTNode {
this.property = property; this.property = property;
} }
public boolean accept( ASTVisitor action ){
return true;
}
} }

View file

@ -10,6 +10,7 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTPointer; import org.eclipse.cdt.core.dom.ast.IASTPointer;
/** /**
@ -18,34 +19,46 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer;
public class CPPASTPointer extends CPPASTNode implements IASTPointer { public class CPPASTPointer extends CPPASTNode implements IASTPointer {
private boolean isConst; private boolean isConst;
private boolean isVolatile; private boolean isVolatile;
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTPointer#isConst() * @see org.eclipse.cdt.core.dom.ast.IASTPointer#isConst()
*/ */
public boolean isConst() { public boolean isConst() {
return isConst; return isConst;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTPointer#isVolatile() * @see org.eclipse.cdt.core.dom.ast.IASTPointer#isVolatile()
*/ */
public boolean isVolatile() { public boolean isVolatile() {
return isVolatile; return isVolatile;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTPointer#setConst(boolean) * @see org.eclipse.cdt.core.dom.ast.IASTPointer#setConst(boolean)
*/ */
public void setConst(boolean value) { public void setConst(boolean value) {
isConst = value; isConst = value;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTPointer#setVolatile(boolean) * @see org.eclipse.cdt.core.dom.ast.IASTPointer#setVolatile(boolean)
*/ */
public void setVolatile(boolean value) { public void setVolatile(boolean value) {
isVolatile = value; isVolatile = value;
} }
public boolean accept(ASTVisitor action) {
return true;
}
} }

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
/** /**
* @author jcamelon * @author jcamelon
*/ */
class CPPASTProblemOwner extends CPPASTNode { abstract class CPPASTProblemOwner extends CPPASTNode {
private IASTProblem problem; private IASTProblem problem;

View file

@ -10,6 +10,7 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
/** /**
@ -17,5 +18,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
*/ */
public class CPPASTReferenceOperator extends CPPASTNode implements public class CPPASTReferenceOperator extends CPPASTNode implements
ICPPASTReferenceOperator { ICPPASTReferenceOperator {
public boolean accept( ASTVisitor action ){
return true;
}
} }

View file

@ -10,6 +10,7 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
/** /**
@ -34,4 +35,7 @@ public class CPPASTVisibilityLabel extends CPPASTNode implements
this.visibility = visibility; this.visibility = visibility;
} }
public boolean accept( ASTVisitor action ){
return true;
}
} }

View file

@ -5070,4 +5070,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return visitor.found; return visitor.found;
} }
protected void resolveAmbiguities() {
// TODO Auto-generated method stub
}
} }