inputstream.h
来自「用于词法分析的词法分析器」· C头文件 代码 · 共 67 行
H
67 行
/* $Id: InputStream.h,v 1.2 1996/05/25 01:37:34 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. */#ifndef _INPUTSTR_H#define _INPUTSTR_H#include <iostream.h>#include <std/string.h>class InputStream{public: enum {EOFChar = -1}; // bit values for state enum {stClear = 0x00, stWdBoundary = 0x01, stBegLine = 0x02, stEndLine = 0x04}; InputStream (istream &s, string &fname); InputStream (istream &s); InputStream (const InputStream &s); virtual ~InputStream () {} string filename; int line, col; int eof () const {return current == EOFChar;} int peek () const {return current;} int peekPrev () const {return prev;} // get next char virtual void get (); int getLine () const {return line;} int getColumn () const {return col;} string getFilename () const {return filename;} int getPoint () const {return 0;} // current input point void setPoint (int point) {}; void resetPoint () {}; // flush backtrack buffer unsigned getState () const; static int inState (unsigned state, unsigned flag) {return state & flag;}protected: int doPeek () const {return str.eof () ? EOFChar : str.peek ();} istream &str; int prev, current;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?