//头文件
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include<string.h>
#include<stdio.h>
#include<time.h>
using namespace std;
string instr;//输入符号串
int index;//当前输入符号读入字符的位置
char character;//全局变量字符,存放最新读入的字符
string token;//字符数组,存放已读入的字符序列
map<string, int> Symbol;//标识符集
map<string, int> Digit;//常数集
map<string, int> other;//other
map<string, int>::iterator ite;
const int len = 100;
string Reserve[len];//保留字表
map<string,int> type;
//void init_Reserve() //构造保留字表的函数
//{
// Reserve[1] = "begin";
// Reserve[2] = "end";
// Reserve[3] = "if";
// Reserve[4] = "then";
// Reserve[5] = "while";
// Reserve[6] = "do";
// Reserve[7] = "const";
// Reserve[8] = "var";
// Reserve[9] = "call";
// Reserve[10] = "procedure";
//
//}
void getChar() //读入一个字符
{
character = instr[index++];
}
void getnbc() //读入非空白字符
{
while (character == ' ')
{
getChar();
}
}
void concat() //连接字符串
{
token = token + character;
}
bool letter() //判断是否为字母
{
if ((character >= 'A'&&character <= 'Z') || (character >= 'a'&&character <= 'z'))
return true;
return false;
}
bool digit() //判断是否为数字
{
if (character >= '0'&&character <= '9')
return true;
return false;
}
void retract() //回退字符的函数
{
// character = ' ';
index--;
}
int reserve() //匹配保留字符
{
for (int i = 0; i < len; i++)
if (Reserve[i] == token)
return i;
return -1;
}
void symbol()
{
ite = Symbol.find(token);
if (ite != Symbol.end())
{
// return ite->first;
return ;
}
else
{
Symbol[token] = Symbol.size();
return ;
// return token;
}
}
void constant()
{
ite = Digit.find(token);
if (ite != Digit.end())
{
// return ite->first;
return ;
}
else
{
Digit[token] = Digit.size();
return ;
// return token;
}
}
void Three()
{
ite = other.find(token);
if (ite != other.end())
{
return ;
//