一千分啊!!!一定给分!!!

Agelboy 2003-01-04 04:57:16
继续加分
http://expert.csdn.net/Expert/topic/1325/1325470.xml?temp=.6070825
http://expert.csdn.net/Expert/topic/1325/1325207.xml?temp=.7375757
http://expert.csdn.net/Expert/topic/1325/1325204.xml?temp=.6241114
能改了源代码以至可以调试成功的话。能分1000
...全文
100 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
yizhou21cn 2003-01-08
  • 打赏
  • 举报
回复
发了
Agelboy 2003-01-05
  • 打赏
  • 举报
回复
能寄源代码给我的 就可以拿分
meimei5270@163.com
ccc_wh 2003-01-05
  • 打赏
  • 举报
回复
UP
sjd163 2003-01-04
  • 打赏
  • 举报
回复
up
ly_liuyang 2003-01-04
  • 打赏
  • 举报
回复
编译作业来的,呵呵,不难的,自己做,很有帮助的
ambition2005 2003-01-04
  • 打赏
  • 举报
回复
呵呵

好好些吧
愿你好运
xuchunqiang 2003-01-04
  • 打赏
  • 举报
回复
UP :_)
findya 2003-01-04
  • 打赏
  • 举报
回复
呵呵,在做编译作业是吧
outer2000 2003-01-04
  • 打赏
  • 举报
回复
这是抄袭的;呵呵,还没测试;
zhenxizhou 2003-01-04
  • 打赏
  • 举报
回复
up
rikky 2003-01-04
  • 打赏
  • 举报
回复
不好意思,楼上的大哥这么快就给出答案了,厉害!!
rikky 2003-01-04
  • 打赏
  • 举报
回复
为什么没人去帮你去解决这个问题,你应该也清楚,不是这个问题难,恰恰因为这个问题太简单了,所以没有去做,我觉得这个题目是大一时候的习题啊。自己再分析分析,说不定会有答案!
outer2000 2003-01-04
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
function find_lable(tmp:String):boolean;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
baoliuzi:array[1..25] of String;
implementation

{$R *.dfm}
function tform1.find_lable(tmp:String):boolean;
var
i:integer;
begin
for i:=1 to 25 do
begin
if tmp=baoliuzi[i] then
begin
result:=true;
exit;
end;
end;
result:=false;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
baoliuzi[1]:=('and'); baoliuzi[2]:=('array');
baoliuzi[3]:=('begin'); baoliuzi[4]:=('case');
baoliuzi[5]:=('const'); baoliuzi[6]:=('else');
baoliuzi[7]:=('end'); baoliuzi[8]:=('for');
baoliuzi[9]:=('function');baoliuzi[10]:=('if');
baoliuzi[11]:=('not'); baoliuzi[12]:=('of');
baoliuzi[13]:=('or'); baoliuzi[14]:=('procedure');
baoliuzi[15]:=('program');baoliuzi[16]:=('record');
baoliuzi[17]:=('repeat'); baoliuzi[18]:=('set');
baoliuzi[19]:=('then'); baoliuzi[20]:=('to');
baoliuzi[21]:=('type'); baoliuzi[22]:=('until');
baoliuzi[23]:=('var'); baoliuzi[24]:=('while');
baoliuzi[25]:=('with');
//以上程序初始化部分
end;

procedure TForm1.Button1Click(Sender: TObject); //词法分析主程序
var
first_ch_id:integer;
flag:boolean;
i,j,len,mynum:integer;
buff,beginmystr,mystr,before_ch:string;
ch:char;
begin
for i:=0 to memo1.Lines.Count-1 do
begin
buff:=memo1.Lines[i];
j:=0;
while j<length(buff) do
begin //11
j:=j+1;
ch:=buff[j];

if ch<>' ' then
begin //22
first_ch_id:=0;
if ch in ['a'..'z','A'..'Z'] then
first_ch_id:=1
else
begin //33
if ch in ['0'..'9'] then
first_ch_id:=2
else
begin //44
if ch in [';',',','(',')','.','[',']']then
first_ch_id:=3
else
begin //55
if ch in ['<','>','=','+','-','*','/',':'] then
first_ch_id:=4
else first_ch_id:=5
end; //55
end;//44
end;//33

case first_ch_id of
1: begin
len:=1;mystr:=ch;
while j<length(buff) do
begin
j:=j+1;
ch:=buff[j];
if ch in ['a'..'z','A'..'Z','0'..'9'] then
begin
if len<10 then
beginmystr:=mystr+ch;len:=len+1;
if j=length(buff) then
begin
if find_lable(mystr) then //查表是否保留字
memo2.Lines.Add(mystr+' 保留字')
else memo2.Lines.Add(mystr+' 标识符');
break;
end;
end
else
begin
if find_lable(mystr) then //查表是否保留字
memo2.Lines.Add(mystr+' 保留字')
else memo2.Lines.Add(mystr+' 标识符');
j:=j-1;
break;
end;
end;
end;

2: begin
myNum:=strtoint(ch);
while j<=length(buff) do
begin
j:=j+1;
ch:=buff[j];
if ch in ['0'..'9'] then
myNum:=myNum*10+strtoint(ch)
else begin memo2.Lines.Add(inttostr(myNum)+' 整型常量');j:=j-1;break;end;
end;
end;
3: begin mystr:=ch;memo2.Lines.Add(mystr+' 界符'); end; //界符
4: begin
mystr:=ch;j:=j+1;before_ch:=ch;
ch:=buff[j]; flag:=false;
if (before_ch= ':') and(ch='=') then
begin mystr:=mystr+ch; flag:=true;end;
if (before_ch= '<') and(ch='=') then
begin mystr:=mystr+ch; flag:=true;end;
if (before_ch= '>') and(ch='=') then
begin mystr:=mystr+ch; flag:=true;end;
if (before_ch='<') and (ch='>') then
begin mystr:=mystr+ch; flag:=true;end;
if (before_ch='-') and (ch='>') then
begin mystr:=mystr+ch; flag:=true;end;
if flag=false then j:=j-1;

memo2.Lines.Add(mystr+' 运算符');
continue;
end; //运算符
5: memo2.Lines.add(ch+' 非法字符');
end //case
end; //22
end;//11
end;
end;



end.
hujianlinsoft 2003-01-04
  • 打赏
  • 举报
回复
up
xylyge 2003-01-04
  • 打赏
  • 举报
回复
up

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧