⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputstream.cpp

📁 用于词法分析的词法分析器
💻 CPP
字号:
/*  $Id: InputStream.cpp,v 1.2 1997/02/02 02:10:36 matt Exp $  Input streams class.    Provides higher-level view of an istream-derived object, including  line, column information and meta-state information (word boundary,  line end, etc.)    (c) Jan 96 Matt Phillips.  */#include <ctype.h>#include "InputStream.h"InputStream::InputStream (istream &s, string &fname)  : str (s), filename (fname), current ('\n'), line (0){  get ();			// sets line & col}InputStream::InputStream (istream &s)  : str (s), current ('\n'), line (0){  get ();			// sets line & col}InputStream::InputStream (const InputStream &s) :  str (s.str), line (s.line), col (s.col), filename (s.filename),  current (s.current), prev (s.prev){}void InputStream::get (){  if (!eof ())  {    prev = current;    current = doPeek ();    str.get ();      // update line, col    if (!eof ())    {      if (prev == '\n')      {	line++;	col = 1;      } else	col++;    }  }}unsigned InputStream::getState () const{  unsigned state = InputStream::stClear;  // word boundary  if ((isalnum (prev) != 0) !=      (current != InputStream::EOFChar && isalnum (current) != 0))    state |= InputStream::stWdBoundary;  // end of line  if (current == '\n' || eof ())    state |= stEndLine;  // beginning of line  if (col == 1)    state |= stBegLine;  return state;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -