#ifndef GOOSE_LEX_VECTORADAPTER_INL
#define GOOSE_LEX_VECTORADAPTER_INL
namespace goose::lex
{
template< typename V >
bool VectorAdapter< V >::eos() const
{
return m_index >= m_vector.size();
}
template< typename V >
optional< TermLoc > VectorAdapter< V >::consume()
{
if( eos() )
return nullopt;
return m_vector[m_index++];
}
template< typename V >
optional< TermLoc > VectorAdapter< V >::lookAhead( size_t distance )
{
if( ( m_index + distance ) >= m_vector.size() )
return nullopt;
return m_vector[m_index + distance];
}
// This is a bit approximative, might have to figure out a way to improve this.
// Especially since almost all non top-level code is parsed through a vector adapter.
template< typename V >
uint32_t VectorAdapter< V >::getCurrentLocation()
{
if( m_vector.empty() )
return 0;
if( eos() )
return m_vector.back().second;
return lookAhead()->second;
}
}
#endif