当前位置:首页 > 编译原理实验1
天津理工大学实验报告
学院(系)名称:计算机与通信工程学院
姓名 班级 课程名称 实验时间 批改意见 教师签字: 学号 实验项目 编译原理 专业 实验一:词法分析器 课程代码 实验地点 成绩 一、实验内容:实现标准C语言词法分析器。 二、实验要求: (1)单词种别编码要求 基本字、运算符、界符:一符一种 标识符:统一为一种; 常量:按类型编码; (2)词法分析工作过程中建立符号表、常量表。 并以文本文件形式输出。 (3)词法分析的最后结果以文本文件形式输出。 三、实验代码: 输入的程序: package com.example; public class WordList { 第1页 共14页
private int row; private int type; private int number; private String str; public WordList() { } public WordList(int row, int type, int number, String str) { } public int getRow() { } public void setRow(int row) { } public int getType() { } public void setType(int type) { } public int getNumber() { } public void setNumber(int number) { } public String getStr() { } 第2页 共14页
return str; this.number = number; return number; this.type = type; return type; this.row = row; return row; super(); this.row = row; this.type = type; this.number = number; this.str = str; super(); // TODO Auto-generated constructor stub } package com.example; public class Word { public void setString(String string) { this.string = string; 第3页 共14页
public String getString() { } return string; public void setRow(int row) { } this.row = row; public int getRow() { } return row; public Word(int row, String string) { } super(); this.row = row; this.string = string; private int row; private String string; public Word() { } super(); // TODO Auto-generated constructor stub @Override public String toString() { } return \ + \public void setStr(String str) { } this.str = str; } } @Override public String toString() { } return \ package com.example; import java.io.File; import java.io.FileReader; import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class HanShu { //定义符号表数组,常量表数组,关键字数组 List
changLiangBiao.add(s); return changLiangBiao; fuhaobiao.add(s); return fuhaobiao; ,\\Arrays.asList(\List
共分享92篇相关文档