合肥工业大学编译原理实验

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

宣城校区

实验报告

课程名称编译原理

专业班级计算机0001班

学生姓名及学号赵保飞 68

指导教师李芒宏

实验地点计算机中心楼第四机房

2017 ~ 2018 学年第一学期

《编译原理》课程实验报告实验名称词法分析设计

姓名赵保飞系院专业计算机科学

与技术

班级

计算机01

学号68

实验日期指导教师李芒宏成绩

一、实验目的和要求

通过本实验的编程实践,使学生了解词法分析的任务,掌握词法分析程序设

计的原理和构造方法,使学生对编译的基本概念、原理和方法有完整的和清楚的

理解,并能正确地、熟练地运用。

二、实验原理

(1)实验数据结构说明

K[]String数组-关键字表;s[]char数组—分界符;m[]char数组—算术运算符;r[]String数组—关系运算符;ArrayList型String数组ci—常数;ArrayList型String数组id—标识符(2)实验算法描述

(3)算法流程图

三、源程序代码和测试结果

package lexicalAnalysis;

import.*;

import.*;

public class lexicalAnalysis{

static String

k[]={"for","main","if","while","void","public","static","printf","scanf","asm","do","return","typedef ","auto","double","break","short","using","default","long"};ength()==1){quals(b))){

display(4,r[i],' ');ength()==2){quals(a))){

display(4,r[i],' ');

;

import.*;

import WinGrid extends JFrame{

GridLayout grid;

JPanel chessboard;

JTextField text;

JTextArea textShow;

JButton button;

ReaderListen listener;

WinGrid(){

init();

setVisible(true);

setDefaultCloseOperation;

}

void init(){

setLayout(new FlowLayout());

text=new JTextField(10);

setBounds(466,166,500,400);

button=new JButton("读取");

textShow=new JTextArea(9,30);

listener=new ReaderListen();

tempp[k][1]=temp0_string; tempp[k][2]=(i);

tempp[k][3]=rule;

tempp[k][4]=();

v=();

action="pop";

if(vnNum(v)!=-1){

left = 'E';

strcpy(s_have[1].sright, "E+T");left = 'E';

strcpy(s_have[2].sright, "T");left = 'T';

strcpy(s_have[3].sright, "T*F");left = 'T';

strcpy(s_have[4].sright, "F");left = 'F';

strcpy(s_have[5].sright, "(E)");left = 'F';

strcpy(s_have[6].sright, "i");ove[0] = 5;

action[0].move[3] = 4;

action[1].move[1] = 6;

action[2].change[1] = 2;

action[2].move[2] = 7;

action[2].change[4] = 2;

action[2].change[5] = 2;

action[3].change[1] = 4;

action[3].change[2] = 4;

action[3].change[4] = 4;

action[3].change[5] = 4;

action[4].move[1] = 5;

action[4].move[3] = 4;

action[5].change[1] = 6;

action[5].change[2] = 6;

action[5].change[4] = 6;

action[5].change[5] = 6;

action[6].move[0] = 5;

action[6].move[3] = 4;

action[7].move[0] = 5;

action[7].move[3] = 4;

action[8].change[1] = 6;

action[8].change[4] = 11;

相关文档
最新文档