armiya
پنج شنبه 10 تیر 1389, 15:59 عصر
با سلام
کسی نحوه عملکرد پارسینگ بازگشتی پایینگرد رو می دونه برام توضییح بده یعنی می خوام الگوریتمش رو درک کنم
یه مثال می زنم برای دوستان ببینید , در این مثال من متوجه نمی شم چطوری عمل تطبیق رو انجام میده
type-> simple|^id|array[simple]of type
simple->integer|char|num dot dot num
شبه کدش هم اینه :
procedure match(t:token);
begin
if lookahead:=t then
lookahead:=nexttoken;
else
error
end;
procedure type;
begin
if lookahead is in {integer,char,num} then simple;
else if lookahead is array then begin
match(array);
match('[');
simple;
match(']');
match(of);
type;
end;
else error;
end;
procedure simple ;
begin
if lookahead=integer=then match(integer);
else if lookahead=char then match(char);
else if lookahead=num then begin
match(num);match(dotdot);match(num);
end;
else error;
end;
تو تحلیلش گیر دارم کمکم کنید
با تشکر
کسی نحوه عملکرد پارسینگ بازگشتی پایینگرد رو می دونه برام توضییح بده یعنی می خوام الگوریتمش رو درک کنم
یه مثال می زنم برای دوستان ببینید , در این مثال من متوجه نمی شم چطوری عمل تطبیق رو انجام میده
type-> simple|^id|array[simple]of type
simple->integer|char|num dot dot num
شبه کدش هم اینه :
procedure match(t:token);
begin
if lookahead:=t then
lookahead:=nexttoken;
else
error
end;
procedure type;
begin
if lookahead is in {integer,char,num} then simple;
else if lookahead is array then begin
match(array);
match('[');
simple;
match(']');
match(of);
type;
end;
else error;
end;
procedure simple ;
begin
if lookahead=integer=then match(integer);
else if lookahead=char then match(char);
else if lookahead=num then begin
match(num);match(dotdot);match(num);
end;
else error;
end;
تو تحلیلش گیر دارم کمکم کنید
با تشکر