#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;
/*********************下面是一些重要数据结构的声明***************************/
struct token//词法 token结构体
{
int code;//编码
int num;//递增编号
token *next;
};
token *token_head,*token_tail;//token队列
struct str//词法 string结构体
{
int num;//编号
string word;//字符串内容
str *next;
};
str *string_head,*string_tail;//string队列
struct ivan//语法 产生式结构体
{
char left;//产生式的左部
string right;//产生式的右部
int len;//产生式右部的长度
};
ivan css[20];//语法 20个产生式
struct pank//语法 action表结构体
{
char sr;//移进或归约
int state;//转到的状态编号
};
pank action[46][18];//action表
int go_to[46][11];//语法 go_to表
struct ike//语法 分析栈结构体,双链
{
ike *pre;
int num;//状态
int word;//符号编码
ike *next;
};
ike *stack_head,*stack_tail;//分析栈首尾指针
struct L//语义四元式的数据结构
{
int k;
string op;//操作符
string op1;//操作数
string op2;//操作数
string result;//结果
L *next;//语义四元式向后指针
L *Ltrue;//回填true链向前指针
L *Lfalse;//回填false链向前指针
};
L *L_four_head,*L_four_tail,*L_true_head,*L_false_head;//四元式链,true链,false链
struct symb//语义输入时符号表
{
- 1
- 2
前往页