KiCad PCB EDA Suite
LIBEVAL::TOKENIZER Class Reference

#include <libeval_compiler.h>

Public Member Functions

void Restart (const wxString &aStr)
 
void Clear ()
 
int GetChar () const
 
bool Done () const
 
void NextChar (int aAdvance=1)
 
size_t GetPos () const
 
wxString GetChars (const std::function< bool(wxUniChar)> &cond) const
 
bool MatchAhead (const wxString &match, const std::function< bool(wxUniChar)> &stopCond) const
 

Private Attributes

wxString m_str
 
size_t m_pos = 0
 

Detailed Description

Definition at line 410 of file libeval_compiler.h.

Member Function Documentation

◆ Clear()

void LIBEVAL::TOKENIZER::Clear ( )
inline

Definition at line 419 of file libeval_compiler.h.

420  {
421  m_str = "";
422  m_pos = 0;
423  }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::Clear().

◆ Done()

bool LIBEVAL::TOKENIZER::Done ( ) const
inline

Definition at line 433 of file libeval_compiler.h.

434  {
435  return m_pos >= m_str.length();
436  }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::lexDefault().

◆ GetChar()

int LIBEVAL::TOKENIZER::GetChar ( ) const
inline

Definition at line 425 of file libeval_compiler.h.

426  {
427  if( m_pos >= m_str.length() )
428  return 0;
429 
430  return m_str[m_pos];
431  }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::lexDefault().

◆ GetChars()

wxString LIBEVAL::TOKENIZER::GetChars ( const std::function< bool(wxUniChar)> &  cond) const

Definition at line 203 of file libeval_compiler.cpp.

204 {
205  wxString rv;
206  size_t p = m_pos;
207 
208  while( p < m_str.length() && cond( m_str[p] ) )
209  {
210  rv.append( 1, m_str[p] );
211  p++;
212  }
213 
214  return rv;
215 }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::lexDefault(), and LIBEVAL::COMPILER::lexString().

◆ GetPos()

size_t LIBEVAL::TOKENIZER::GetPos ( ) const
inline

Definition at line 443 of file libeval_compiler.h.

444  {
445  return m_pos;
446  }

References m_pos.

Referenced by LIBEVAL::COMPILER::Compile(), and LIBEVAL::COMPILER::lexDefault().

◆ MatchAhead()

bool LIBEVAL::TOKENIZER::MatchAhead ( const wxString &  match,
const std::function< bool(wxUniChar)> &  stopCond 
) const

Definition at line 217 of file libeval_compiler.cpp.

219 {
220  int remaining = (int) m_str.Length() - m_pos;
221 
222  if( remaining < (int) match.length() )
223  return false;
224 
225  if( m_str.substr( m_pos, match.length() ) == match )
226  return ( remaining == (int) match.length() || stopCond( m_str[m_pos + match.length()] ) );
227 
228  return false;
229 }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::lexDefault(), and LIBEVAL::COMPILER::resolveUnits().

◆ NextChar()

void LIBEVAL::TOKENIZER::NextChar ( int  aAdvance = 1)
inline

Definition at line 438 of file libeval_compiler.h.

439  {
440  m_pos += aAdvance;
441  }

References m_pos.

Referenced by LIBEVAL::COMPILER::lexDefault(), LIBEVAL::COMPILER::lexString(), and LIBEVAL::COMPILER::resolveUnits().

◆ Restart()

void LIBEVAL::TOKENIZER::Restart ( const wxString &  aStr)
inline

Definition at line 413 of file libeval_compiler.h.

414  {
415  m_str = aStr;
416  m_pos = 0;
417  }

References m_pos, and m_str.

Referenced by LIBEVAL::COMPILER::newString().

Member Data Documentation

◆ m_pos

size_t LIBEVAL::TOKENIZER::m_pos = 0
private

Definition at line 455 of file libeval_compiler.h.

Referenced by Clear(), Done(), GetChar(), GetChars(), GetPos(), MatchAhead(), NextChar(), and Restart().

◆ m_str

wxString LIBEVAL::TOKENIZER::m_str
private

Definition at line 454 of file libeval_compiler.h.

Referenced by Clear(), Done(), GetChar(), GetChars(), MatchAhead(), and Restart().


The documentation for this class was generated from the following files: