token.h

来自「an easy compiler to compile C」· C头文件 代码 · 共 37 行

H
37
字号
// Token.h: interface for the Token class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TOKEN_H__54D3F2E2_73B8_4263_87FF_7508EEA45273__INCLUDED_)
#define AFX_TOKEN_H__54D3F2E2_73B8_4263_87FF_7508EEA45273__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
using namespace std;

class Token {
public:
  enum {NUM=256, DIV=257, MOD=258, ID=259,
	    DONE=260, EMPTY=261, NONE=-1 };
  // Token's type: NUM, DIV, MOD, ID
  // DONE: pseudo type indicate EOF
  // NONE: empty token value and token_type is input char
  // EMPTY: pseudo type indicate Token object's initial  					   	
  
  int type;
  int value;						// index if type is ID, or keywords(DIV,MOD)
									// digit value if type is NUM
									// NONE otherwise

  Token(int atype, int avalue=Token::NONE);
  Token();
  bool operator==(const Token& tk) const;

  string toStr() const;
};

#endif // !defined(AFX_TOKEN_H__54D3F2E2_73B8_4263_87FF_7508EEA45273__INCLUDED_)

⌨️ 快捷键说明

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