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

📄 data.h

📁 与vc++界面十分类似的词法分析器
💻 H
字号:
#if !defined(__DATA_H__)
#define __DATA_H__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// Data.h : header file
//#include "stdafx.h"
//static char drive[_MAX_DRIVE];
//static char dir[_MAX_DIR];
//static char fname[_MAX_FNAME];
//static char ext[_MAX_EXT];

static LPTSTR KeywordList[] =
{
	_T("__asm"),
	_T("enum"),
	_T("__multiple_inheritance"),
	_T("template"),
	_T("auto"),
	_T("__except"),
	_T("__single_inheritance"),
	_T("this"),
	_T("__based"),
	_T("explicit"),
	_T("__virtual_inheritance"),
	_T("thread"),
	_T("bool"),
	_T("extern"),
	_T("mutable"),
	_T("throw"),
	_T("break"),
	_T("false"),
	_T("naked"),
	_T("true"),
	_T("case"),
	_T("__fastcall"),
	_T("namespace"),
	_T("try"),
	_T("catch"),
	_T("__finally"),
	_T("new"),
	_T("__try"),
	_T("__cdecl"),
	_T("float"),
	_T("operator"),
	_T("typedef"),
	_T("char"),
	_T("for"),
	_T("private"),
	_T("typeid"),
	_T("class"),
	_T("friend"),
	_T("protected"),
	_T("typename"),
	_T("const"),
	_T("goto"),
	_T("public"),
	_T("union"),
	_T("const_cast"),
	_T("if"),
	_T("register"),
	_T("unsigned"),
	_T("continue"),
	_T("inline"),
	_T("reinterpret_cast"),
	_T("using"),
	_T("__declspec"),
	_T("__inline"),
	_T("return"),
	_T("uuid"),
	_T("default"),
	_T("int"),
	_T("byte"),
	_T("short"),
	_T("__uuidof"),
	_T("delete"),
	_T("__int8"),
	_T("signed"),
	_T("virtual"),
	_T("dllexport"),
	_T("__int16"),
	_T("sizeof"),
	_T("void"),
	_T("dllimport"),
	_T("__int32"),
	_T("static"),
	_T("volatile"),
	_T("do"),
	_T("__int64"),
	_T("static_cast"),
	_T("wmain"),
	_T("double"),
	_T("__leave"),
	_T("__stdcall"),
	_T("while"),
	_T("dynamic_cast"),
	_T("long"),
	_T("struct"),
	_T("xalloc"),
	_T("else"),
	_T("main"),
	_T("switch"),
	_T("interface"),
	//	Added by a.s.
	_T("persistent"),
	_T("_persistent"),
	_T("transient"),
	_T("depend"),
	_T("ondemand"),
	_T("transient"),
	_T("cset"),
	_T("useindex"),
	_T("indexdef"),
	_T("#include"),
	_T("#define"),
	_T("#ifdef"),
	_T("#ifndef"),
	_T("#endif"),
	_T("#pragma once"),
	_T("#undef"),
	NULL
};

static LPTSTR OperateorList[] =
{
		_T("?:"),
		_T("sizeof"),
		_T("->"),
		_T("."),
		_T("!"),
		_T("~"),
		_T("++"),
		_T("--"),
		_T("&"),//取地址运算符或按位与运算符
		_T("*"),//指针运算符或乘法运算符
		_T("/"),
		_T("%"),
		_T("+"),
		_T("-"),
		_T("<<"),
		_T(">>"),
		_T("<"),
		_T("<="),
		_T(">"),
		_T(">="),
		_T("=="),
		_T("!="),
		_T("^"),
		_T("|"),
		_T("&&"),
		_T("||"),
		_T("="),
		_T("+="),
		_T("-="),
		_T("*="),
		_T("/="),
		_T("%="),
		_T(">>="),
		_T("<<="),
		_T("&="),
		_T("^="),
		_T("|="),
		_T("::"),
		_T(":"),
	    NULL
};

static char BoundaryList[] =
{
	',',
	';',
	'{',
	'}',
	'(',
	')',
	'[',
	']',
	' ',
	NULL
};

enum TYPE{
	KeyWord,
	Identifier,			//标识符
	Constant,
	Operator,
	Boundary
};

struct Word
{
	TYPE type;
	int name;
};

static CArray<Word,Word&>theData;
static CArray<CString,CString&>errorlist;
static CArray<CString,CString&>identifierlist;
static CArray<CString,CString&>constantlist;

int IsKeyWord(LPCTSTR pszChars, int nLength);
int IsOperator(LPCTSTR pszChars, int nLength);
int IsBoundary(char *pszChars);
void SpliterPath(CString Path);

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(__EDITBAR_H__)

⌨️ 快捷键说明

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