Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Documenting use of ParserSymbolTableException (52120)

Clean up and document the use of ParserSymbolTableException to help 
John.with his IProblems

ran the core suite tests on windows

-Andrew

Index: parser/ChangeLog-parser
===================================================================
retrieving revision 1.55
diff -u -r1.55 ChangeLog-parser
--- parser/ChangeLog-parser	13 Feb 2004 15:40:03 -0000	1.55
+++ parser/ChangeLog-parser	16 Feb 2004 16:47:48 -0000
@@ -1,3 +1,7 @@
+2004-02-16 Andrew Niefer
+	bug 52120 document symbol table use of ParserSymbolTableException
+	also clean up a couple of exceptions
+
 2004-02-12 Andrew Niefer
 	Fixed up symbol table handling of const & volatile
 	fixed bug 47628 - signed char is parsed as char 
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
retrieving revision 1.75
diff -u -r1.75 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java	13 Feb 2004 15:40:03 -0000	1.75
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java	16 Feb 2004 16:47:52 -0000
@@ -29,7 +29,6 @@
 import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
 import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
 import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
 import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
 import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
 import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
@@ -2622,12 +2621,7 @@
                 	throw new ASTSemanticException();
                 }
 			} else if( isFriend ){
-				try {
-					((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
-				} catch (ParserSymbolTableException e1) {
-					throw new ASTSemanticException();
-				}
-				
+				((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
 			}
  		}
  		
Index: parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java
===================================================================
retrieving revision 1.7
diff -u -r1.7 DerivableContainerSymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java	13 Feb 2004 15:40:03 -0000	1.7
+++ parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java	16 Feb 2004 16:47:54 -0000
@@ -173,7 +173,12 @@
 		TypeInfo param = new TypeInfo( TypeInfo.t_type, TypeInfo.isConst, this, new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference, false, false ), false ); 
 		parameters.add( param );
 		
-		IParameterizedSymbol constructor = lookupConstructor( parameters );
+		IParameterizedSymbol constructor = null;
+		try{
+			constructor = lookupConstructor( parameters );
+		} catch ( ParserSymbolTableException e ){
+			
+		}
 		
 		if( constructor == null ){
 			constructor = getSymbolTable().newParameterizedSymbol( getName(), TypeInfo.t_constructor );
@@ -280,7 +285,7 @@
 	 * TODO: if/when the parser symbol table starts caring about visibility
 	 * (public/protected/private) we will need to do more to record friendship.
 	 */
-	public void addFriend( ISymbol friend ) throws ParserSymbolTableException{
+	public void addFriend( ISymbol friend ){
 		//is this symbol already in the table?
 		IContainerSymbol containing = friend.getContainingSymbol();
 		if( containing == null ){
@@ -292,7 +297,10 @@
 			
 			friend.setIsInvisible( true );
 			friend.setIsForwardDeclaration( true );
-			enclosing.addSymbol( friend );
+			try {
+				enclosing.addSymbol( friend );
+			} catch (ParserSymbolTableException e) {
+			}
 		}
 		
 		getFriends().add( friend );
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java
===================================================================
retrieving revision 1.12
diff -u -r1.12 IContainerSymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java	11 Feb 2004 03:07:26 -0000	1.12
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java	16 Feb 2004 16:47:54 -0000
@@ -26,19 +26,73 @@
  */
 public interface IContainerSymbol extends ISymbol {
 	
+	/**
+	 * Add a symbol to this container
+	 * @param symbol
+	 * @throws ParserSymbolTableException
+	 *    Reason : r_BadTemplate if (14-2) the symbol is a template declaration is outside a namespace or class scope
+	 *                        or if (14.5.2-3) the symbol is a member function template and is virtual
+	 *             r_RedeclaredTemplateParam if (14.6.1-4) a template parameter is redeclared in its scope
+	 *             r_InvalidOverload if there already exists a symbol with the same name and the new symbol does not
+	 *                               hide the first symbol (3.3.7) or is not a valid function overload (3.4-1)
+	 */
 	public void addSymbol( ISymbol symbol ) throws ParserSymbolTableException;
 
 	public boolean hasUsingDirectives();
 	public List getUsingDirectives();
+	
+	/**
+	 * Add a using directive to this symbol
+	 * @param namespace
+	 * @return
+	 * @throws ParserSymbolTableException
+	 *    Reason: r_InvalidUsing if (7.3.4) the using directive appears in class scope
+	 *                           or if the symbol being added is not a namespace
+	 */
 	public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException;
 	
+	/**
+	 * Add a using declaration to this symbol
+	 * @param name
+	 * @return
+	 * @throws ParserSymbolTableException
+	 *    Reason: r_InvalidUsing if (7.3.3-5) the name is a template-id
+	 *                        or if (7.3.3-4) this using declaration is a member declaration and the name is not a
+	 *                           member of a base class, or an anonymous union that is a member of a base class, or
+	 *                           an enumerator for an enumeration which is a member of a base class
+	 *                        or if the name specified can not be found
+	 *             r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
+	 *             r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
+	 *                            IDerivableContainerSymbol
+	 *             r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
+	 */
 	public ISymbol addUsingDeclaration( String name ) throws ParserSymbolTableException;
 	public ISymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException;
 			
 	public Map getContainedSymbols();
 	
+	/**
+	 * Lookup symbols matching the given prefix
+	 * @param filter
+	 * @param prefix
+	 * @param qualified
+	 * @return
+	 * @throws ParserSymbolTableException
+	 *   Reason: r_BadTypeInfo if during lookup, we come across a class inheriting from a symbol which is not an
+	 *                            IDerivableContainerSymbol
+	 *           r_CircularInheritance if during lookup, we come across a class with a circular inheritance tree
+	 */
 	public List prefixLookup( TypeFilter filter, String prefix, boolean qualified ) throws ParserSymbolTableException;
 	
+	/**
+	 * Lookups
+	 * @throws ParserSymbolTableException
+	 *   Reason:   r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
+	 *             r_UnableToResolveFunction if an overloaded function is found and no parameter information has been provided
+	 *             r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
+	 *                            IDerivableContainerSymbol
+	 *             r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
+	 */
 	public ISymbol elaboratedLookup( TypeInfo.eType type, String name ) throws ParserSymbolTableException; 
 	public ISymbol lookup( String name ) throws ParserSymbolTableException;
 	public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
@@ -50,8 +104,29 @@
 	public IParameterizedSymbol memberFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
 	public IParameterizedSymbol qualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
 	
+	/**
+	 * 
+	 * @param name
+	 * @param arguments
+	 * @return
+	 * @throws ParserSymbolTableException
+	 * In addition to the above lookup reasons, the following also can happen in lookupTemplate
+	 *      r_Ambiguous if (14.5.4.1) more than one specialization can be used and none is more specializaed than all the others
+	 *      r_BadTemplateArgument if (14.3.1, 14.3.2) a template argument is invalid
+	 */
 	public ISymbol lookupTemplate( String name, List arguments ) throws ParserSymbolTableException;
 	
+	/**
+	 * 
+	 * @param name
+	 * @param templateParameters
+	 * @param templateArguments
+	 * @return
+	 * @throws ParserSymbolTableException
+	 * In addition to the Exception thrown in lookup functions, and lookupTemplate, lookupTemplateForMemberDefinition can also throw:
+	 *      r_BadTemplateParameter if (14.5.1-3) the parameters provided can't be matched up to a template declaration
+	 *      r_BadTemplate if the parameter and argument list can't be resolved to either the template or a specialization
+	 */
 	public ITemplateFactory lookupTemplateForMemberDefinition( String name, List templateParameters, 
 			                                                                List templateArguments ) throws ParserSymbolTableException;
 	
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java
===================================================================
retrieving revision 1.10
diff -u -r1.10 IDerivableContainerSymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java	11 Feb 2004 03:07:26 -0000	1.10
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java	16 Feb 2004 16:47:54 -0000
@@ -33,12 +33,40 @@
 	public List getParents();
 	public boolean hasParents();
 	
+	/**
+	 * 
+	 * @param constructor
+	 * @throws ParserSymbolTableException
+	 * Reason:
+	 *    r_BadTypeInfo if the symbol being added is not of type TypeInfo.t_constructor
+	 *    r_InvalidOverload if the constructor being added is not a valid overload of existing constructors
+	 */
 	public void addConstructor( IParameterizedSymbol constructor ) throws ParserSymbolTableException;
 	public void addCopyConstructor() throws ParserSymbolTableException;
+	
+	/**
+	 * 
+	 * @param parameters
+	 * @return
+	 * @throws ParserSymbolTableException
+	 * Reason:
+	 *    r_Ambiguous if more than one constructor can be used with the given parameters
+	 */
 	public IParameterizedSymbol lookupConstructor( List parameters ) throws ParserSymbolTableException;
+	
 	public List getConstructors();
 	
-	public void addFriend( ISymbol friend ) throws ParserSymbolTableException;
+	public void addFriend( ISymbol friend );
+	
+	/**
+	 * Lookups
+	 * @throws ParserSymbolTableException
+	 *   Reason:   r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
+	 *             r_UnableToResolveFunction if an overloaded function is found and no parameter information has been provided
+	 *             r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
+	 *                            IDerivableContainerSymbol
+	 *             r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
+	 */
 	public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException;
 	public IParameterizedSymbol lookupFunctionForFriendship( String name, List parameters ) throws ParserSymbolTableException;
 	
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
===================================================================
retrieving revision 1.12
diff -u -r1.12 ISymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java	11 Feb 2004 03:07:26 -0000	1.12
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java	16 Feb 2004 16:47:54 -0000
@@ -20,7 +20,17 @@
 public interface ISymbol extends Cloneable,  IExtensibleSymbol {
 
 	public Object clone();
-		
+	
+	/**
+	 * 
+	 * @param args
+	 * @return
+	 * @throws ParserSymbolTableException
+	 * Exceptions can be thrown when a IDeferredTemplateInstance must be instantiated
+	 * Reason:
+	 *     r_BadTemplateArgument if an argument does not match the corresponding parameter type
+	 *     r_Ambiguous if more than one specialization can be used but none is more specialized than all the others
+	 */
 	public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException;
 
 	public void setName(String name);
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ITemplateSymbol.java
===================================================================
retrieving revision 1.1
diff -u -r1.1 ITemplateSymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/ITemplateSymbol.java	11 Feb 2004 03:07:26 -0000	1.1
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ITemplateSymbol.java	16 Feb 2004 16:47:54 -0000
@@ -19,6 +19,15 @@
 
 public interface ITemplateSymbol extends IParameterizedSymbol {
 	
+	/**
+	 * 
+	 * @param param
+	 * @throws ParserSymbolTableException
+	 * Reason:
+	 *    r_BadTemplateParameter if the Parameter does not have type TypeInfo.t_templateParameter
+	 *                           or if the parameter has the same name as the template
+	 *                           or if the parameter is a non-type parameter and does not have a valid type (14.1-4, 14.1-7)
+	 */
 	public void addTemplateParameter( ISymbol param ) throws ParserSymbolTableException;
 	
 	public boolean	hasSpecializations();
@@ -34,7 +43,18 @@
 	public List findArgumentsFor( IContainerSymbol instance );
 	
 	public void addInstantiation( IContainerSymbol instance, List args );
-	public ISymbol instantiate( List args ) throws ParserSymbolTableException; 
+	
+	/**
+	 * 
+	 * @param args
+	 * @return
+	 * @throws ParserSymbolTableException
+	 * Reason:
+	 *     r_BadTemplateArgument if an argument does not match the corresponding parameter type
+	 *     r_Ambiguous if more than one specialization can be used but none is more specialized than all the others
+	 */
+	public ISymbol instantiate( List args ) throws ParserSymbolTableException;
+	
 	public IDeferredTemplateInstance deferredInstance( List args );
 
 }
Index: parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java
===================================================================
retrieving revision 1.3
diff -u -r1.3 TemplateEngine.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java	13 Feb 2004 15:40:03 -0000	1.3
+++ parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java	16 Feb 2004 16:47:54 -0000
@@ -731,7 +731,7 @@
 		
 		IContainerSymbol templatedSymbol = spec1.getTemplatedSymbol();
 		if( !( templatedSymbol instanceof IParameterizedSymbol ) )
-			throw new ParserSymbolTableException( ParserSymbolTableException.r_InternalError );
+			throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
 		
 		IParameterizedSymbol function = (IParameterizedSymbol)templatedSymbol;
 		function = (IParameterizedSymbol) function.instantiate( spec1, map );
@@ -742,7 +742,7 @@
 		
 		templatedSymbol = spec2.getTemplatedSymbol();
 		if( !( templatedSymbol instanceof IParameterizedSymbol ) )
-			throw new ParserSymbolTableException( ParserSymbolTableException.r_InternalError );
+			throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
 		
 		function = (IParameterizedSymbol)templatedSymbol;
 		function = (IParameterizedSymbol) function.instantiate( spec2, map );

Back to the top