主题:帮忙编写个程序
帮我设计一个词法分析器啊~~随便用什么语言编写
词法分析器基本功能是:
(1) 输入源程序:输入PASCAL源程序;
(2)输出单词:输出形式为:(序号,单词,对应源程序行号,对应源程序列号);
(3)输出出错信息,输出形式为:(出错行号,出错列号,出错信息);
(4)输出符号表,输出形式为:(单词种别码,单词符号);
(5)打开、保存文件;
输入源程序为:
program example1;
var
a,b,c:integer;
x:char;
begin
if(a+c*3>b) and (b>3) then c:=3;
x:=2+(3*a)-b*c*8;
if (2+3>a) and (b>3) and (a>c) then c:=3;
for x:=1+2 to 3 do b:=100;
while a>b do c:=5;
for x:=1+d to 3 do b:=15;
while t>b do c:=5;
repeat a:=10; until a>b;
end.
词法分析器基本功能是:
(1) 输入源程序:输入PASCAL源程序;
(2)输出单词:输出形式为:(序号,单词,对应源程序行号,对应源程序列号);
(3)输出出错信息,输出形式为:(出错行号,出错列号,出错信息);
(4)输出符号表,输出形式为:(单词种别码,单词符号);
(5)打开、保存文件;
输入源程序为:
program example1;
var
a,b,c:integer;
x:char;
begin
if(a+c*3>b) and (b>3) then c:=3;
x:=2+(3*a)-b*c*8;
if (2+3>a) and (b>3) and (a>c) then c:=3;
for x:=1+2 to 3 do b:=100;
while a>b do c:=5;
for x:=1+d to 3 do b:=15;
while t>b do c:=5;
repeat a:=10; until a>b;
end.