词法分析器基本功能是:
* 输入源程序:输入PASCAL源程序;
* 输出单词,输出形式为:(序号,单词,对应源程序行号,对应源程序列号);
* 输出出错信息,输出形式为:(出错行号,出错列号,出错信息);
* 输出符号表,输出形式为:(单词种别码,单词符号)
测试程序代码
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.
* 输入源程序:输入PASCAL源程序;
* 输出单词,输出形式为:(序号,单词,对应源程序行号,对应源程序列号);
* 输出出错信息,输出形式为:(出错行号,出错列号,出错信息);
* 输出符号表,输出形式为:(单词种别码,单词符号)
测试程序代码
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.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货