#include"mkf_identifier.hpp"
#include<cctype>
#include<cstring>
#include<cstdio>




Identifier::
Identifier():
length(0)
{
}


Identifier::
Identifier(const char*  p)
{
  *this = p;
}




Identifier&
Identifier::
operator=(const char*  p)
{
  length = 0;

    while(isalnum(*p) || (*p == '_'))
    {
      buffer[length++] = *p++;
    }


  buffer[length] = 0;

  return *this;
}


bool
Identifier::
operator==(const Identifier&  rhs) const
{
    if(length == rhs.length)
    {
      return(std::memcmp(buffer,rhs.buffer,length) == 0);
    }


  return false;
}


const char*  Identifier::get_buffer() const{return buffer;}

size_t  Identifier::get_length() const{return length;}


bool
Identifier::
compare(const char*  s) const
{
  return(std::strncmp(buffer,s,length) == 0);
}




