Question

This is a part of my code for ada. It is giving me some style errors, please help.

  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;

Now, the compiler is giving me following errors

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 line 242 is: elseif (NList.isConnectedTo (InitialTower, FinalTower)) then

Was it helpful?

Solution

On line 242, "elseif" should be "elsif".

And the errors just kinda cascade from there--this isn't really a style error unless you're compiling with the -gnaty_ options.

OTHER TIPS

You should always eliminate the non-style and non-warning messages before you start worrying about warnings and style issues.

Both

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

and

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

are "real" errors and should be eliminated before you start worrying about style issues and warnings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top