Esempio n. 1
0
        }
        //else
        //throw std::runtime_error ("Unexpected character: " + std::string (1, cFirstCharacter));
    }

    // we have a word (starting with A-Z) - pull it out
    while (isalnum (*pWord_) || *pWord_ == '_')
        ++pWord_;

    word_ = std::string (pWordStart_, pWord_ - pWordStart_);
    return type_ = NAME;
}   // end of Parser::GetToken

// force load of functions at static initialisation time
static int doLoadOneArgumentFunctions = LoadOneArgumentFunctions (); /*!< TODO */
static int doLoadTwoArgumentFunctions = LoadTwoArgumentFunctions (); /*!< TODO */
static int doLoadThreeArgumentFunctions = LoadThreeArgumentFunctions (); /*!< TODO */

/*!
 \brief

 \fn Parser::Primary
 \param get
 \return const double
*/
const double Parser::Primary (const bool get)   // primary (base) tokens
{

    if (get)
        GetToken ();    // one-token lookahead
Esempio n. 2
0
      }
    else
      throw std::runtime_error ("Carattere inaspettato: " + std::string (1, cFirstCharacter));
    }
  
  // we have a word (starting with A-Z) - pull it out
  while (isalnum (*pWord_) || *pWord_ == '_')
    ++pWord_;
  
  word_ = std::string (pWordStart_, pWord_ - pWordStart_);
  return type_ = NAME;
  }   // end of Parser::GetToken

// force load of functions at static initialisation time
static int doLoadOneArgumentFunctions = LoadOneArgumentFunctions ();
static int doLoadTwoArgumentFunctions = LoadTwoArgumentFunctions ();
static int doLoadThreeArgumentFunctions = LoadThreeArgumentFunctions ();

const double Parser::Primary (const bool get)   // primary (base) tokens
  {
  
  if (get)
    GetToken ();    // one-token lookahead  
  
  switch (type_)
    {
    case NUMBER:  
      {
      double v = value_; 
      GetToken (true);  // get next one (one-token lookahead)
      return v;