0

这是我的 ada 代码的一部分。它给了我一些风格错误,请帮忙。

  if (Objective = 0) then
     --  Initial Tower is not Connected to Final Tower yet
     if not (NList.isConnectedTo (InitialTower, FinalTower)) then
        --  Add Main Tower to List of Main Towers
        if (IndexInitial = -1) then
           NumberTowers := NumberTowers + 1;
           IndexInitial := NumberTowers;
           TowerList (NumberTowers) := InitialTower;
        end if;
        --  Add Connection to Main Tower
        NList.addNode (FinalTower, IndexInitial, TowerList);
        InitialTower.NumbLink := InitialTower.NumbLink + 1;
     end if;
  elsif (Objective = 1) then
     --  Invalid Query / Tower was never created
     if (IndexInitial = -1) or else (IndexFinal = -1) then
        Text_IO.Put ("- ");
        Text_IO.Put (SU.To_String (Input1));
        Text_IO.Put (" => ");
        Text_IO.Put (SU.To_String (Input2));
        Text_IO.New_Line; 
     elseif (NList.isConnectedTo (InitialTower, FinalTower)) then
           Text_IO.Put ("+ ");   
     end if;

  end if;

现在,编译器给了我以下错误

main.adb:242:09: (style) incorrect layout
main.adb:242:65: missing ";"
main.adb:246:07: (style) "end" in wrong column, should be in column 10
main.adb:247:03: missing "end if;" for "if" at line 221
gnatmake: "main.adb" compilation error

amd 第 242 行是: elseif (NList.isConnectedTo (InitialTower, FinalTower)) 然后

4

2 回答 2

3

在第 242 行,“elseif”应该是“elsif”。

并且错误只是从那里级联起来——这并不是真正的样式错误,除非您使用 -gnaty_ 选项进行编译。

于 2013-11-04T01:29:01.850 回答
3

在开始担心警告和样式问题之前,您应该始终消除非样式和非警告消息。

两个都

main.adb:242:65: missing ";"

main.adb:247:03: missing "end if;" for "if" at line 221

是“真正的”错误,应该在您开始担心样式问题和警告之前消除。

于 2013-11-05T08:42:41.690 回答