?? commstruct.h
字號:
#ifndef __CommStruct_HeaderFile_hth_
#define __CommStruct_HeaderFile_hth_
//token串結點結構定義
typedef struct __tokenode
{
unsigned char keycode; //種別碼
unsigned int strId; //自身值:符號表的入口地址
__tokenode *next; //
}*PTokenNode,TokenNode;
//符號表中類型枚舉定義
typedef enum __symbol_type
{
Identifier, //標識符
Char, //字符常數
Real, //數字常數-實型
Integer, //數字常數-整型
Bool //Bool型
}SType;
//符號表中種類枚舉定義
typedef enum __symbol_kind
{
Simple, //簡單變量
Array, //數組
Const, //常量
}SKind;
//符號子表結構定義
typedef struct __symbol_subtable
{
struct __name
{
unsigned int headp; //字符串表中首地址
unsigned char length; //在字符串中的長度
}name; //
SType type; //標識符或常數類型
SKind kind; //標識符或常數種類
double val; //數字常數值
BYTE *addr; //標識符入口地址
}SSubTable,*PSSubTable;
//符號表結構定義
typedef struct __symbol_table
{
PSSubTable sSubTable; //符號子表
unsigned int intSubTableSize; //符號子表長度
unsigned int intSubTableLen; //符號子表已用空間
char *stringTable; //字符串表
unsigned int intTableSize; //字符串表長度
unsigned int intTableLen; //字符串表已用空間
}STable,*PSTable;
//錯誤結構定義
typedef struct __error_
{
unsigned int intRows;
unsigned int intCols;
char *description;
__error_ *next;
}ErrorNode,*PErrorNode;
//文法符號類型枚舉
typedef enum grammar_type_
{
Terminal, //終結符
Nonterminal, //非終結符
Other //結束占位符:可用于表示表達式結束
}GType;
//文法符號結構定義
typedef struct grammar_symbol_
{
GType sType; //符號類型
union __grammar_symbol_value_ //符號自身值
{
double dValue; //非終結符,運算結果
PTokenNode pToken; //終結符,須token字
}value; //符號自身值
char word; //產生式中的符號表示
grammar_symbol_ *next; //鏈表指針
}*PGSymbol,GSymbol;
//四元式操作符類型枚舉
typedef enum __op_enum_
{
OPJump=0, //無條件跳轉
OPJumpLarger=1, //大于時跳轉
OPJumpLE=2, //大于等于時跳轉
OPJumpNZero=3, //不等于零時跳轉
OPJumpEqual=17, //等于時跳轉
OPJumpUEqual=18, //不等于時跳轉
OPJumpSmaller=4, //小于時跳轉
OPjumpSE=5, //小于等于時跳轉
OPLarger=6, //大于
OPSmaller=7, //小于
OPEqual=8, //等于
OPEvaluate=9, //賦值
OPUnequal=10, //不等于
OPPlus=11, //加
OPMinus=12, //減
OPMultiply=13, //乘
OPDivide=14, //除
OPProgram=15, //程序開始標識
OPSys=16 //程序結束標識
}EOP;
//四元式結構預定義
typedef struct four_symbol_ *PFSymbol,FSymbol;
typedef enum __ag_enum_
{
ST=0, //臨時變量
PT=1, //token字
PF=2 //下一個四元式入口
}EAGType;
//四元式操作符和運算結果數據類型定義
typedef struct ag_struct_
{
char *des; //用于打印四元式的描述
EAGType type; //四元式操作符入口類型
union __ag_union_
{
double value; //臨時變量
PTokenNode token; //token字
PFSymbol fSymbol; //下一個四元式入口
}value; //四元式操作符入口
}*PFSAG,FSAG;
//四元式結構定義
struct four_symbol_
{
unsigned long no; //編號
EOP op; //操作符
PFSAG ag1; //運算對象一
PFSAG ag2; //運算對象二
PFSAG result; //運算結果
four_symbol_ *next; //鏈表節點指針
};
//文法產生式結構定義
typedef struct grammar_production_symbol_
{
GType sType; //符號類型
char word; //符號表示
}*PGProduction,GProduction;
//標識符最大長度為10
#define MAXIDLEN 10
//定義NULL
#define NULL 0
//定義每行最大字符數
#define MAXLINE 250
//定義關鍵字的個數
#define KEYWORDCOUNT 60
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -