--- trunk/src/antlr/CircularQueue.hpp 2010/05/10 17:28:26 1442 +++ branches/development/src/antlr/CircularQueue.hpp 2011/09/15 13:39:36 1633 @@ -56,7 +56,18 @@ class ANTLR_API CircularQueue { (public) } inline void removeItems( size_t nb ) { - assert(nb <= entries()); + // it would be nice if we would not get called with nb > entries + // (or to be precise when entries() == 0) + // This case is possible when lexer/parser::recover() calls + // consume+consumeUntil when the queue is empty. + // In recover the consume says to prepare to read another + // character/token. Then in the subsequent consumeUntil the + // LA() call will trigger + // syncConsume which calls this method *before* the same queue + // has been sufficiently filled. + if( nb > entries() ) + nb = entries(); + if (m_offset >= OFFSET_MAX_RESIZE) { storage.erase( storage.begin(), storage.begin() + m_offset + nb ); @@ -75,7 +86,7 @@ class ANTLR_API CircularQueue { (public) } private: - typename ANTLR_USE_NAMESPACE(std)vector storage; + ANTLR_USE_NAMESPACE(std)vector storage; size_t m_offset; CircularQueue(const CircularQueue&);