如何调试Ada程序?
我解决了这个问题,当我试图编译它时,它说标识符是预期的,但我做得很好如何调试Ada程序?,ada,Ada,我解决了这个问题,当我试图编译它时,它说标识符是预期的,但我做得很好 with.Ada.TexT_IO;use Ada.Text_IO; Procedure Isort1 is type node; type link is access node; type node is record value:integer; rest:Character; next:link; end record;
with.Ada.TexT_IO;use Ada.Text_IO;
Procedure Isort1 is
type node;
type link is access node;
type node is
record
value:integer;
rest:Character;
next:link;
end record;
package IntIO is new Ada.Text_IO.Integer_IO(integer);use IntIO;
int:integer;
l:link;
pt:array(1..100)of link;
ch:character;
begin
for i in 1..10 loop pt(i):=null;
end loop;
loop
put("put an integer key (1 thru 10),99 to stop ");
get(int);
exit when int=99;
put("enter the other info,1 char ");
get(ch);
pt(int):= new node'(int,ch,pt(int));
end loop;
for i in 1..10 loop
i:=pt(i);
while I /=null loop
put(I.value);
put("... ");
put(I.rest);
new_line;
I:=I.next;
end loop;
end loop;
end Isort1;
你认为你“做得很好”的假设显然是错误的。
看来您是在了解了其他编程语言之后才开始学习Ada的。您似乎正在将其他语言的想法混合到您的Ada代码中
让我们先组织并缩进代码
with.Ada.TexT_IO;use Ada.Text_IO;
Procedure Isort1 is
type node;
type link is access node;
type node is
record
value:integer;
rest:Character;
next:link;
end record;
package IntIO is new Ada.Text_IO.Integer_IO(integer);use IntIO;
int:integer;
l:link;
pt:array(1..100)of link;
ch:character;
begin
for i in 1..10 loop pt(i):=null;
end loop;
loop
put("put an integer key (1 thru 10),99 to stop ");
get(int);
exit when int=99;
put("enter the other info,1 char ");
get(ch);
pt(int):= new node'(int,ch,pt(int));
end loop;
for i in 1..10 loop
i:=pt(i);
while I /=null loop
put(I.value);
put("... ");
put(I.rest);
new_line;
I:=I.next;
end loop;
end loop;
end Isort1;
第一行以“with.Ada.TexT_IO;”开头。它应该说“with Ada.Text_I0;”。资本化差异不是问题所在。问题是保留字“with”后面的句点“.”
一旦该问题得到解决,编译器将告诉您在包含
i:=pt(i);
来自编译器的错误消息显示在下面的屏幕截图中。
您似乎希望变量I包含node类型的实例,但变量I从未声明,也从未赋值。您的第一行有一个额外的句点。应使用Ada.Text\u IO读取
代码>不with.Ada.Text\u IO代码>不能在for循环中修改for循环的控制变量。“对于1..10循环中的i:=pt(i)”是非法的。程序正在赋值的左侧查找变量。在循环体中,标识符“i”是不可变的。会出现什么错误?您得到了哪些您不期望的输出?