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

📄 constdef.cpp

📁 我的简易编译器终于在花了近20个工作日后完成了。按照设计是做成一个FormulaEx.dll
💻 CPP
字号:
/*
 * Generated by MyEclipse Struts
 * 
 * written by Yang Huaisheng 
 * Homepage: http://codefan.spaces.live.com
 * version 0.01
 * create at 2008-04-30
 * 
 *  Distribute freely, except: don't remove my name from the source or
 *  documentation (don't take credit for my work), mark your changes (don't
 *  get me blamed for your possible bugs), don't alter or remove this
 *  notice.
 *  No warrantee of any kind, express or implied, is included with this
 *  software; use at your own risk, responsibility for damages (if any) to
 *  anyone resulting from the use of this software rests entirely with the
 *  user.
 * 
 *  Send bug reports, bug fixes, enhancements, requests, flames, etc. to
 *     codefan@hotmial.com
 *  
 */
#include "stdafx.h"
#include "ConstDef.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

CConstDef::CConstDef()
{
}

CConstDef::~CConstDef()
{
}

const UINT CConstDef::OPTPRI[16] = { 5,5,6,6, 4,4,4, 4, 4, 4,3,3,6,5,5,5};
							       //+ - * / == > < <= >= != | & %
								   //5 is normal
UINT	CConstDef::GetOptPri(int optIsn)
{
	if(optIsn >= ISN_OPT_BEG && optIsn <= ISN_OPT_END) 
		return OPTPRI[optIsn-ISN_OPT_BEG];
	return 0;
}

const UINT CConstDef::RESKEYSUM = RES_KEY_SUM;
const SResKey CConstDef::RESKEYS[RES_KEY_SUM]=
{
	{"call",	RES_CALL	},
	{"define",	RES_DEFINE	},
	{"else",	RES_ELSE	},
	{"function",RES_FUNC	},
	{"if",		RES_IF		},
	{"import",	RES_IMPORT 	},
	{"include",	RES_INCLUDE	},
	{"int",		RES_INT		},
	{"float",	RES_FLOAT	},
	{"string",	RES_STRING	},
	{"return",	RES_RETURN	},
	{"while",	RES_WHILE	},
	{"void",    RES_VOID	},
	{"for",		RES_FOR		},
	{"case",	RES_CASE	},
	{"switch",	RES_SWITCH	},
	{"do",		RES_DO		},
	{"until",	RES_UNTIL	},
	{"loop",	RES_LOOP	},
	{"break",	RES_BREAK	},
	{"method",	RES_METHOD	},
	{"continue",RES_CONTINUE},
	{"default",	RES_DEFAULT	},
	{"unll",	RES_NULL	}
};

const UINT CConstDef::SYSFUNSUM = SYS_FUN_SUM;
const SSysFuncInfo CConstDef::SYSFUNCS[SYS_FUN_SUM] =
{
	{"ave",			-1,	FUNC_AVE,			VDT_NUMBER},	//求均值  ave(1,2,3)=2
	{"byte",		2,	FUNC_BYTE,			VDT_NUMBER},	//求位值  byte(4321.789,2)=2  
											//		  byte(4321.789,-2)=8  
											//		  byte("4321.789",2)=3
	{"capital",		1,	FUNC_CAPITAL,		VDT_STRING},  // capital(123.45)="一百二十三点四五"
	{"printmsg",	1,	FUNC_PRINT,			VDT_STRING},      // 
	{"match",		2,	FUNC_MATCH,			VDT_NUMBER}, //匹配*?为通配符 match("abcd","a??d")=1
											//             match("abcd","a*d")=1 
	{"max",			-1,	FUNC_MAX,			VDT_NUMBER},   // 求最大值 max(1,2,3,5,4) = 5
	{"min",			-1,	FUNC_MIN,			VDT_NUMBER},	// 求最小值 max(1,2,3,5,4) = 1
	{"count",		-1,	FUNC_COUNT,			VDT_NUMBER},	// 计数 max(1,"2",3,"5",1,1,4) = 7
	{"round",		1,	FUNC_ROUND,			VDT_NUMBER},	// 四舍五入
	{"strcat",		-1,	FUNC_STRCAT,		VDT_STRING},	// 连接字符串 strcat("12","34","56")="123456"
	{"sum",			-1,	FUNC_SUM,			VDT_NUMBER},	// 求和 sum(1,2,3,4,5) = 15
	{"stddev",		-1,	FUNC_STDDEV,		VDT_NUMBER},	// 求标准偏差
	{"log",			1,	FUNC_LOG,			VDT_NUMBER},	// 求以10为底的对数
	{"ln",			1,	FUNC_LN,			VDT_NUMBER},		// 求自然对数
	{"sin",			1,	FUNC_SIN,			VDT_NUMBER},	// 求正弦
	{"cos",			1,	FUNC_COS,			VDT_NUMBER},	// 求余弦
	{"tan",			1,	FUNC_TAN,			VDT_NUMBER},	// 求正切
	{"ctan",		1,	FUNC_CTAN,			VDT_NUMBER},	// 求正切
	{"exp",			1,	FUNC_EXP,			VDT_NUMBER},	// 求以e为底的指数
	{"sqrt",		1,	FUNC_SQRT,			VDT_NUMBER},	// 求平方根
	{"substr",		2,	FUNC_SUBSTR,		VDT_STRING}, // 求字符串子串 substr("123456",2,3)="345"
	{"find",		2,	FUNC_FIND,			VDT_NUMBER},  //求子串位置 find("123456","34")=2  find("123456","35")=-1
	{"frequence",	2,	FUNC_FREQUENCE,		VDT_NUMBER}, // 求子串个数 find("12345236","23")=2 
	{"integer",		1,	FUNC_INT,			VDT_NUMBER}, // 求整数部分 int(12.34)=12 int(-12.34)=-12 
	{"frac",		1,	FUNC_FRAC,			VDT_NUMBER}, // 求小数部分 frac(12.34)=0.34 frac(-12.34)=-0.34
	{"today",		0,	FUNC_TODAY,			VDT_NUMBER},//当前日期  
	{"day",			-1,	FUNC_DAY,			VDT_NUMBER},//日期函数  
	{"month",		-1,	FUNC_MONTH,			VDT_NUMBER},//日期函数   
	{"year",		-1,	FUNC_YEAR,			VDT_NUMBER},//日期函数  
	{"dayspan",		1,	FUNC_DAY_SPAN,		VDT_NUMBER},//日期函数  求两日期之间的天数
	{"monthspan",	1,	FUNC_MONTH_SPAN,	VDT_NUMBER},//日期函数   求两日期之间的月数
	{"getsysstr",	1,	FUNC_GET_STR,		VDT_STRING},//取系统字符串
	{"now",			0,	FUNC_GET_TIME,		VDT_STRING},//取系统时间
	{"gettickcount",	0,	FUNC_GET_TICK,	VDT_NUMBER},//取系统the number of milliseconds that have elapsed since the system was started.
	{"getpy",		1,	FUNC_GET_PY,		VDT_STRING},//取汉字拼音
	{"yearspan",	1,	FUNC_YEAR_SPAN,		VDT_NUMBER},//日期函数   求两日期之间的年数
	{"make_array",	-1,	FUNC_MAKE_ARRAY,	VDT_ARRAY_NUMBER}//
};

PFUNCINFO	CConstDef::GetSysFunc(int funcID)
{
	for(int i=0;i<SYSFUNSUM; i++)
		if(SYSFUNCS[i].nFuncID == funcID)
			return &SYSFUNCS[i];
	return NULL;
}

const UINT CConstDef::SYSSTRSUM = 4;
const SSysString CConstDef::SYSSTRINGS[4]=
{
	{"vsersion",	"1.00a"},
	{"company",		"centit"},
	{"author",		"杨淮生"},
	{"e-mail",		"codefan@hotmail.com"}
};

⌨️ 快捷键说明

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