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

📄 constdef.h

📁 我的简易编译器终于在花了近20个工作日后完成了。按照设计是做成一个FormulaEx.dll
💻 H
字号:
/*
 * Generated by MyEclipse Struts
 * 
 * Written by Yang Huaisheng 
 * Homepage: http://codefan.spaces.live.com
 * version 0.01
 * create at 2006-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
 *  
 */

#if !defined(INTERFACE_CONST_DEFINE_HEADER_H)
#define INTERFACE_CONST_DEFINE_HEADER_H

#if 0
enum VAR_DATA_TYPE{
	VDT_VOID		= 0x00,
	VDT_NUMBER		= 0x01,
	VDT_STRING		= 0x02,
	VDT_DATE		= 0x03,
	VDT_ARRAY_VOID  = 0x10,
	VDT_ARRAY_NUMBER= 0x11,
	VDT_ARRAY_STRING= 0x12,
	VDT_ARRAY_DATE  = 0x13,
	VDT_FUNCTION    = 0x21
};

#else

typedef  int VAR_DATA_TYPE ;

#define	VDT_VOID	0
#define	VDT_NUMBER	1
#define	VDT_STRING	2
#define	VDT_DATE	3
#define	VDT_ARRAY_VOID 10
#define	VDT_ARRAY_NUMBER 11
#define	VDT_ARRAY_STRING 12
#define	VDT_ARRAY_DATE   13
#define	VDT_FUNCTION     21

#endif

enum WORD_TYPE {
	WT_UNKNOWN		= 0x00,
	WT_CONST		= 0x01,
	WT_RESKEY		= 0x02,
	WT_SIGN			= 0x03,
	WT_OPERATOR		= 0x04,
	WT_EVALUATE		= 0x05,
	WT_SYSFUNC		= 0x06,
	WT_MODULE		= 0x07,
	WT_SEPARATOR	= 0x08
};


#define  SIGNLENGTH 31

///////  func type
#define  FUNC_SYS		1 
#define  FUNC_LIB		2
#define  FUNC_SELF		3

////////// ISN assign

#define	 ISN_TEMP   		-1
#define	 ISN_JMP_TAG 		-2
#define	 ISN_EMPTY			0

#define	 ISN_NULL   		99
#define  ISN_SYSFUNC_BEG	100

#define  VARISN_START     100001
#define  TEMPISN_START    800001
#define  CONSTISN_START   900001
#define  MODUALISN_SPACE 1000000

////// System  function 
#define  SYS_FUN_SUM    37
#define  FUNC_PRINT		(ISN_SYSFUNC_BEG + 0)
#define  FUNC_AVE		(ISN_SYSFUNC_BEG + 1)
#define  FUNC_BYTE		(ISN_SYSFUNC_BEG + 2)
#define	 FUNC_CAPITAL	(ISN_SYSFUNC_BEG + 3)
#define  FUNC_MAX		(ISN_SYSFUNC_BEG + 4)
#define  FUNC_MIN		(ISN_SYSFUNC_BEG + 5)
#define  FUNC_SUM		(ISN_SYSFUNC_BEG + 6)
#define  FUNC_STRCAT	(ISN_SYSFUNC_BEG + 7)
#define  FUNC_ROUND		(ISN_SYSFUNC_BEG + 8)
#define  FUNC_PRECISION	(ISN_SYSFUNC_BEG + 9) // not support
#define  FUNC_SUBSTR    (ISN_SYSFUNC_BEG + 10)
#define  FUNC_MATCH		(ISN_SYSFUNC_BEG + 11)	
#define  FUNC_COUNT		(ISN_SYSFUNC_BEG + 12)
#define  FUNC_LN        (ISN_SYSFUNC_BEG + 13)
#define  FUNC_EXP		(ISN_SYSFUNC_BEG + 14)
#define  FUNC_SQRT      (ISN_SYSFUNC_BEG + 15)
#define  FUNC_LOG       (ISN_SYSFUNC_BEG + 16)
#define  FUNC_SIN       (ISN_SYSFUNC_BEG + 17)
#define  FUNC_COS		(ISN_SYSFUNC_BEG + 18)
#define  FUNC_TAN       (ISN_SYSFUNC_BEG + 19)
#define  FUNC_CTAN		(ISN_SYSFUNC_BEG + 20)
#define  FUNC_FIND		(ISN_SYSFUNC_BEG + 21)
#define  FUNC_FREQUENCE (ISN_SYSFUNC_BEG + 22)
#define  FUNC_INT		(ISN_SYSFUNC_BEG + 23)	
#define  FUNC_FRAC		(ISN_SYSFUNC_BEG + 24)
#define  FUNC_DAY		(ISN_SYSFUNC_BEG + 25)
#define  FUNC_MONTH		(ISN_SYSFUNC_BEG + 26)
#define  FUNC_YEAR		(ISN_SYSFUNC_BEG + 27)
#define  FUNC_DAY_SPAN	(ISN_SYSFUNC_BEG + 28)
#define  FUNC_MONTH_SPAN	(ISN_SYSFUNC_BEG + 29)
#define  FUNC_YEAR_SPAN	(ISN_SYSFUNC_BEG + 30)
#define  FUNC_TODAY		(ISN_SYSFUNC_BEG + 31)
#define  FUNC_STDDEV	(ISN_SYSFUNC_BEG + 32)
#define  FUNC_GET_TIME	(ISN_SYSFUNC_BEG + 33)
#define  FUNC_GET_TICK	(ISN_SYSFUNC_BEG + 34)
#define  FUNC_GET_STR	(ISN_SYSFUNC_BEG + 35)
#define  FUNC_GET_PY	(ISN_SYSFUNC_BEG + 36)
#define  FUNC_MAKE_ARRAY	(ISN_SYSFUNC_BEG + 37)

//////   reserve key

#define  UNKNOWN	   -1
#define  KEY_UNKNOWN    UNKNOWN
#define  WORD_UNKNOWN   UNKNOWN
#define  SEN_EMPTY	   0
#define  CODE_END	   -2

#define  RES_KEY_SUM			24

#define  RES_CALL				1
#define  RES_DEFINE				2
#define  RES_ELSE				3	
#define  RES_FUNC				4
#define  RES_IF					5
#define  RES_IMPORT 			6
#define  RES_INCLUDE			7
#define  RES_INT				8
#define  RES_FLOAT				9
#define  RES_STRING				10  
#define  RES_RETURN				11  
#define  RES_WHILE				12
#define	 RES_VOID				13
#define	 RES_FOR				14
#define	 RES_CASE				15
#define	 RES_DO					16
#define	 RES_UNTIL				17
#define	 RES_LOOP				18
#define	 RES_NULL				19
#define	 RES_SWITCH				20
#define	 RES_BREAK				21
#define	 RES_CONTINUE			22
#define	 RES_DEFAULT			23
#define	 RES_METHOD				24

//////   operator
#define  ISN_OPT_BEG			30
#define  ISN_OPT_END			44

#define  OP_ADD                 30  // +
#define  OP_SUB					31  // -
#define  OP_MUL					32  // *
#define  OP_DIV					33  // /

#define  OP_EQ                  34   //==
#define  OP_BG                  35   //>
#define  OP_LT                  36   //<
#define  OP_EL                  37   //<=
#define  OP_EB                  38   //>=
#define  OP_NE                  39   //!=
#define  OP_OR					40   //|(|)	
#define  OP_AND                 41   //&(&)
#define  OP_MOD                 42   //%	
#define  OP_NOT                 43   //!	


#define  OP_EVALUATE			45   //=
#define  OP_E_ADD				46
#define  OP_E_SUB				47
#define  OP_E_MUL				48
#define  OP_E_DIV				49
#define  OP_INC					50
#define  OP_DEC					51

#define  OP_POP					52  // 	
#define  OP_PUSH				53  // 	
#define  OP_RET					54  // 

#define  OP_GET_AT				55  //
#define  OP_CALL_FUNC			56  //
#define  OP_CALL_MODULE			57  //

#define  OP_END					59  //

// jump operator
#define  OP_JMP					60  //
#define  OP_JZ					61  //
#define  OP_JNZ					62  //
#define  OP_JE					63  //
#define  OP_JNE					64  //
#define  OP_JBG					65  //
#define  OP_JLT					66  //
#define  OP_JEB					67  //
#define  OP_JEL					68  //

#define  BS_COMMA          80   //,
#define  BS_SEMICOLON	   81	//;
#define  BS_DOT            82   //.
#define  BS_COLON		   83	//:
#define  BS_DMARK		   84	//"
#define  BS_LBRACKET	   85   //(
#define  BS_RBRACKET	   86   //)
#define  BS_LFBRACKET	   87	//{
#define  BS_RFBRACKET	   88   //}
#define  BS_LRBRACKET	   89	//[
#define  BS_RRBRACKET	   90   //]
#define  BS_ELLIPSIS 	   91   //...
#define  BS_SHARP	 	   92   //#
#define  BS_AT		 	   93   //@

struct SResKey{
	LPCTSTR  sName;//char[32]
	UINT     nIsn;
};

struct SSysFuncInfo{
	LPCTSTR sName;
	int		nPrmSum;
	int		nFuncID;
	VAR_DATA_TYPE nRetType;
};

typedef const SSysFuncInfo * PFUNCINFO;

struct SSysString{
	LPCTSTR sName;
	LPCTSTR	sValue;
};

class CConstDef{
private:
	CConstDef();
	~CConstDef();
public:
	static const  UINT	OPTPRI[];
				   //{ 5,5,6,6, 4,4,4, 4, 4, 4,3,3,0,0,0,0};
					 //+ - * / == > < <= >= != | &
					 //5 is normal	
	static const  UINT	RESKEYSUM;
	static const  SResKey RESKEYS[];
	static const  UINT SYSFUNSUM;
	static const  SSysFuncInfo SYSFUNCS[];

	static const  UINT SYSSTRSUM;
	static const  SSysString SYSSTRINGS[];

	static UINT		GetOptPri(int optIsn);
	static PFUNCINFO	GetSysFunc(int funcID);
};

#endif //!defined( INTERFACE_CONST_DEFINE_HEADER_H)

⌨️ 快捷键说明

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