| 5 |
|
* Project led by Terence Parr at http://www.jGuru.com |
| 6 |
|
* Software rights: http://www.antlr.org/license.html |
| 7 |
|
* |
| 8 |
< |
* $Id: CircularQueue.hpp,v 1.1 2005-12-02 15:38:02 tim Exp $ |
| 8 |
> |
* $Id$ |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include <antlr/config.hpp> |
| 56 |
|
} |
| 57 |
|
inline void removeItems( size_t nb ) |
| 58 |
|
{ |
| 59 |
< |
assert(nb <= entries()); |
| 59 |
> |
// it would be nice if we would not get called with nb > entries |
| 60 |
> |
// (or to be precise when entries() == 0) |
| 61 |
> |
// This case is possible when lexer/parser::recover() calls |
| 62 |
> |
// consume+consumeUntil when the queue is empty. |
| 63 |
> |
// In recover the consume says to prepare to read another |
| 64 |
> |
// character/token. Then in the subsequent consumeUntil the |
| 65 |
> |
// LA() call will trigger |
| 66 |
> |
// syncConsume which calls this method *before* the same queue |
| 67 |
> |
// has been sufficiently filled. |
| 68 |
> |
if( nb > entries() ) |
| 69 |
> |
nb = entries(); |
| 70 |
> |
|
| 71 |
|
if (m_offset >= OFFSET_MAX_RESIZE) |
| 72 |
|
{ |
| 73 |
|
storage.erase( storage.begin(), storage.begin() + m_offset + nb ); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
private: |
| 89 |
< |
typename ANTLR_USE_NAMESPACE(std)vector<T> storage; |
| 89 |
> |
ANTLR_USE_NAMESPACE(std)vector<T> storage; |
| 90 |
|
size_t m_offset; |
| 91 |
|
|
| 92 |
|
CircularQueue(const CircularQueue&); |