开发工具:
文件大小: 165kb
下载次数: 0
上传时间: 2010-06-28
详细说明: 一,实验目的: 通过设计编制调试一个具体的词法分析程序,加深对词法分析原理的理解。并掌握在对程序设计语言源程序进行扫描过程中将其分解为各类单词的词法分析方法。 二、实验要求: 1.对给定的程序通过词法分析器弄够识别一个个单词符号,并以二元式(单词种别码,单词符号的属性值)显示。而本程序则是通过对给定路径的文件的分析后以单词符号和文字提示显示。 2.本程序自行规定: (1)关键字"begin","end","if","then","else","while","write","read", "do", "call","const","char","until","procedure","repeat" (2)运算符:"+","-","*","/","=" (3 )界符:"{","}","[","]",";",",",".","(",")",":" (4)其他标记 如字符串,表示以字母开头的标识符。 (5)空格、回车、换行符跳过。 部分程序代码如下: #include "stdio.h" #include "string.h" //----------------------Global Declarition--------------------------------- #define SIZE 20 #define sSIZE 12 //There are sSIZE status #define aSIZE 6 //There will ecounter aSIZE symbol #define gSIZE 3 //May be goto next gSIZE status #define geSIZE 6 //There are geSIZE generate expression #define MAXSIZE 3 //---------------------Finish defining struct------------------------------------- typedef struct Ge { char head; //Leftpart of Generate Expression char gen[4]; //Rightpart of Generate Expression }Generate;//--------------------------------Generate Expression base datastruct typedef struct A { int st[aSIZE]; //aSIZE status when encountering terminated symbol int re[aSIZE]; //Using reduce }Action;//----------------------------------Action table base datastruct typedef struct G { char head[gSIZE]; //Nonterminated symbol :'E' 'F' 'T'..etc int gt[gSIZE]; //Mark the next status }GOTO;//------------------------------------GOTO table base datastruct int status[SIZE]; //stack of status int sta_Index; //top of stack of status char symbol[SIZE]; //stack of symbol int sym_Index; //Current index of symbol stack char expression[SIZE]; //Inputed expression int exp_Index; //index of inputed expression int exp_top; //top of expression that inputed int step; //accumulated steps int IsAccept = 0; //Initlize accept flag to 0 Generate gene[geSIZE +1]; Action act[sSIZE]; ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.