【文件属性】:
文件名称:编译原理实验词法分析器
文件大小:183KB
文件格式:RAR
更新时间:2012-11-26 09:25:38
词法分析
词法分析
一、 目的
设计、编制并调式一个词法分析程序,加深对词法分析原理的理解。
二、 要求:
各种单词符号及对应的种别码:
单词符号 种别码 单词符号 种别码
begin 1 : 17
if 2 := 18
then 3 < 20
while 4 <> 21
do 5 <= 22
end 6 > 23
letter(letter|digit)* 10 >= 24
digit digit* 11 = 25
+ 13 ; 26
- 14 ( 27
* 15 ) 28
/ 16 # 0
功能:
输入:所给文法的源程序字符串文件。
输出:二元组(syn,token或sum)构成的序列 文件。
其中:syn为单词种别码
token存放的单词自身字符串;
sum为整型常数
例如:对输入源程序:
s.txt文件:
begin
x:=9;
if x > 0 then x:=2 * x + 1/3;
end#
输出为t.txt文件:
(1, begin)(10, ‘x’) (18,:=) (11,9) (26,;) (2,if) ….
输入:
begin
x:=9;
if x > 0 then x:=2 * x + 1/3;
age1:=25;
while age1<>20 do
begin
age1:=age1-1;
end
end#
【文件预览】:
词法分析器
----Cpp1.opt(53KB)
----s.txt(59B)
----Cpp1.ncb(49KB)
----t.txt(183B)
----Cpp1.dsp(3KB)
----Debug()
--------vc60.pdb(52KB)
--------vc60.idb(41KB)
--------Cpp1.exe(184KB)
--------Cpp1.ilk(210KB)
--------Cpp1.obj(15KB)
--------Cpp1.pch(212KB)
--------Cpp1.pdb(465KB)
----Cpp1.dsw(516B)
----Cpp1.plg(736B)
----Cpp1.cpp(6KB)