#include<stdio.h>
#include<string.h>
//定义关键字表
char keyword[10][10]={
"int","char","float","if","else","while","break","continue","main","return"};
int len_key=10;
//定义界符表
char del[]={
'+','-','*','/','=','(',')','[',']','{','}',';','>','<'};
int len_del=sizeof(del)/sizeof(del[0]);
//定义常数表
#define len_con 10
float con[len_con];
int pos_con=0;
//定义标识符表
#define len_id 20
char id[len_id][10];
int pos_id=0;
//定义保存token的链表
typedef struct _token{
char name[6];//表示识别单词的分类
int pos;//表示识别单词的位置
struct _token *next;
} _token;
_token *token=NULL;
_token *head=NULL;
int IsKeyword(char word[]);
int deal_id(int p,
C语言词法分析扫描器
最新推荐文章于 2024-06-19 05:15:00 发布