public void endScope() throws AnalysisException {
		
		int numPops = 0;
		Iterator<Symbol> entries = symbolStack.iterator();
		
	    while (entries.hasNext()) {
	        
	        Symbol S = entries.next();
	        	        
	        if(S.getDecl() instanceof VarDecl && S.getScope() == Globals.class_scope && currScope == Globals.local_scope) { // If we're in local scope, don't delete class-level variables 
	        	// leave global variables on the symbol stack!!!
	        } else if(S.getScope() == currScope) {	        
	        	++numPops; // To avoid messing up our iterator, just keep track of the number of symbols to pop	        	
	        }
	    }
	    
	    for(int i = 0; i < numPops; ++i) {
	    	symbolStack.pop(); // OK, actually pop them now
	    }
		
	    // Decrement the scope unless doing so would cause the scope to drop below 0
		if((currScope - 1) < 0) {
			throw new AnalysisException("Decrementing scope level would cause scope to drop below 0");
		} else {
			--currScope;
		}
	}