Beispiel #1
0
int Scanner::getNextToken(token_type& t, location_type& l)
{
  int tokid;
  bool done = false;

  do {
    tokid = next(t);
    if (tokid != 0) { // not EOF
      for (const char *s = t.rawText.c_str(); *s; s++) {
        if (*s == '\n') {
          m_line++;
          m_column = 0;
        } else {
          m_column++;
        }
      }
    }
    switch (tokid) {
    case T_COMMENT:
    case T_DOC_COMMENT:
    case T_OPEN_TAG:
    case T_WHITESPACE:
      break;
    default:
      done = true;
      break;
    }
  } while (!done);

  l.last_line(m_line);
  l.last_column(m_column);
  return tokid;
}
Beispiel #2
0
int Scanner::getNextToken(token_type& t, location_type& l) {
  int tokid;
  bool done = false;

  do {
    tokid = next(t);
    switch (tokid) {
    case T_COMMENT:
    case T_DOC_COMMENT:
    case T_OPEN_TAG:
    case T_WHITESPACE:
      break;
    default:
      done = true;
      break;
    }
  } while (!done && !m_full);

  l.first_line(m_firstLine);
  l.first_column(m_firstColumn);
  l.last_line(m_line);
  l.last_column(m_column);
  return tokid;
}