词法分析的源代码与运行结果: #include<stdio.h> /*定义I/O库所用的某些宏和变量*/#include<string.h> /*定义字符串库函数*/#include<conio.h> /*提供有关屏幕窗口操作函数*/#include<ctype.h> /*分类函数*/char pr ...
分类:
其他好文 时间:
2016-09-30 21:17:24
阅读次数:
210
#include /*定义I/O库所用的某些宏和变量*/ #include /*定义字符串库函数*/ #include /*提供有关屏幕窗口操作函数*/ #include /*分类函数*/ char prog[80]={'\0'}, token[8]; /*存放构成单词符号的字符串*/ char c ...
分类:
其他好文 时间:
2016-09-30 21:00:22
阅读次数:
163
一.实验目的: 编写一个词法分析程序 二.实验要求: ①输入源程序字符串 ②输出二元组(种别,单词符号本身) 三.各种单词符号对应的种别码(删减版) 四.程序代码 五.程序结果 六.个人心得: 通过存储输入的字符串,用循环的方式逐个提取出来与种别码比较,然后进行输出。 本人觉得该实验难点在于如何让程 ...
分类:
其他好文 时间:
2016-09-30 20:59:42
阅读次数:
175
词法分析程序功能:根据输入的字符串,按照种别码分类识别出对应的单词符号; 符号与种别码对照表 单词符号 种别码 单词符号 种别码 begin 1 : 17 if 2 := 18 then 3 < 20 while 4 <= 21 do 5 <> 22 end 6 > 23 l(l|d)* 10 >= ...
分类:
其他好文 时间:
2016-09-30 20:53:34
阅读次数:
146
1词法分析器的功能 1)输入源程序 2)从左至右地对源程序进行扫描,按照语言的词法规则识别各类单词,并产生相应单词的属性字 2. 单词符号 种别码 单词符号 种别码 begin 1 : 17 if 2 := 18 then 3 < 20 while 4 <= 21 do 5 <> 22 end 6 ...
分类:
其他好文 时间:
2016-09-30 20:47:34
阅读次数:
163
百度找来的源代码 #include<stdio.h> /*定义I/O库所用的某些宏和变量*/#include<string.h> /*定义字符串库函数*/#include<conio.h> /*提供有关屏幕窗口操作函数*/#include<ctype.h> /*分类函数*/char prog[80] ...
分类:
其他好文 时间:
2016-09-30 20:44:09
阅读次数:
117
#include<stdio.h>#include<stdlib.h>#include<string.h>#define _KEY_WOED_END "waiting for your expanding" //关键字结束标志typedef struct{int typenum;char * wor ...
分类:
其他好文 时间:
2016-09-30 20:42:01
阅读次数:
153
1、待分析的简单的词法 (1)关键字: begin if then while do end 所有的关键字都是小写。 (2)运算符和界符 := + - * / < <= <> > >= = ; ( ) # (3)其他单词是标识符(ID)和整型常数(SUM),通过以下正规式定义: ID = lette ...
分类:
其他好文 时间:
2016-09-30 20:41:15
阅读次数:
142
#include <stdio.h>#include <string.h> char string[80],simbol[8],ch;int wordID,index,m,n,sum;char *rwtab[6]={"begin","if","then","while","do","end"}; v ...
分类:
其他好文 时间:
2016-09-30 20:40:38
阅读次数:
165