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

📄 semantics.h

📁 编译原理实验
💻 H
字号:
// -------------------------- semantics.h ------------------------------
#ifndef SEMANTICS_H
#define SEMANTICS_H
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "y_tab.h"				 // 由XDYACC根据源程序生成

#define MAX_CHARS 200
#define black RGB(0,0,0)
#define red RGB(255,0,0)
HDC hDC;						// 窗口句柄,全局变量

typedef double (*MathFuncPtr) (double);
typedef double (* FuncPtr) (double);
struct Token {
	char * lexeme;				// 记号的字符串
	int    type;				// 记号的种别
	double value;				// 如果是常数,常数的值
	double (* FuncPtr)(double);	// 如果是函数,函数的指针
};
struct ExprNode	{				// 语法树节点类型的定义
	enum Token_Type OpCode;		// PLUS, MINUS, MUL, DIV, POWER, FUNC, CONST_ID
	union
	{	struct  {struct ExprNode *Left, *Right;} CaseOperator;
		struct  {struct ExprNode *Child; FuncPtr MathFuncPtr;} CaseFunc;
		double  CaseConst;
		double  * CaseParmPtr;
	} Content;
};

extern struct ExprNode * MakeExprNode(enum Token_Type opcode,...);
extern void DrawLoop(double Start,					// 循环绘制点的坐标
					 double End,
					 double Step,
					 struct ExprNode * HorPtr,
					 struct ExprNode * VerPtr);
extern void DrawPixel(unsigned long x,				// 绘制一个点
					  unsigned long y);
extern double GetExprValue(struct ExprNode * root);	// 计算表达式的值
extern yyparse();									// 语法分析器
#endif

⌨️ 快捷键说明

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