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

📄 lexanalysis.h

📁 表达式分析, 支持算术运算,括号,关系运算,逻辑运算,字符串的like运算等。采用了有限自动机做词法分析, 语法分析用算符优先分析方法
💻 H
字号:
#ifndef CLEXICALANALYSIS_H__
#define CLEXICALANALYSIS_H__

#include "source.h"


#define	IDENTIFIER			0		/* identifier */
#define	CONSTANT			1		/* float point constant */
#define	STRING				2		/* string constand "......" */
#define	LPARENTHESES		3		/* ( */
#define	RPARENTHESES		4		/* ) */
#define	PERIOD				5		/* . */
#define	POSTIVE				6		/* + */
#define	NEGTIVE				7		/* - */
#define	NOT					8		/* NOT, ! */
#define	MULTI				9		/* * */
#define	DIV					10		/* / */
#define	REMAINDER			11		/* % */
#define	PLUS				12		/* + */
#define	MINUS				13		/* - */
#define	GREAT				14		/* > */
#define	LESS				15		/* < */
#define	GREATEQ				16		/* >= */
#define	LESSEQ				17		/* <= */
#define	LIKE				18		/* like */	
#define	EQ					19		/* =, == */
#define	NOTEQ				20		/* <>, != */
#define	AND					21		/* AND, && */
#define	OR					22		/* OR,  || */
#define	EOI					23		/* end of input */





typedef struct
{
	unsigned char type;
	union
	{
		double num_val;
		char   str_val[256];
	};
}Token;

class cLexicalAnalysis
{
private:
	cSource*	m_source;
	int			m_cur_state;
	char		m_parsed[256];
	int			m_parseLen;
	char        m_error_msg[256];
	bool		get_number(Token& token);
	bool		get_id(Token& token);
	bool		get_string(Token& token);
	
public:
				cLexicalAnalysis();
	bool		SetSource(cSource* source);
	bool		GetToken(Token& token);
	char*		GetLastError();
};

#endif	//CLEXICALANALYSIS_H__

⌨️ 快捷键说明

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