Commit b2ce8696 authored by yoogx's avatar yoogx
Browse files

* (Add_File_To_Parse_List): change the semantics of

          Add_Suffix, if Add_Suffix is false, and no .aadl suffix is
          found, then simply discard the name.

          Fix for ticket #20
parent 75b97566
...@@ -52,7 +52,7 @@ package body Ocarina.Files is ...@@ -52,7 +52,7 @@ package body Ocarina.Files is
procedure Add_File_To_Parse_List procedure Add_File_To_Parse_List
(File_Name : Name_Id; (File_Name : Name_Id;
Add_Suffix : Boolean := True) Add_Suffix : Boolean)
is is
File_Name_With_Extension : Name_Id; File_Name_With_Extension : Name_Id;
...@@ -60,13 +60,17 @@ package body Ocarina.Files is ...@@ -60,13 +60,17 @@ package body Ocarina.Files is
begin begin
Get_Name_String (File_Name); Get_Name_String (File_Name);
if Add_Suffix then
if Name_Len < 5 if Name_Len < 5
or else Name_Buffer (Name_Len - 4 .. Name_Len) /= ".aadl" or else Name_Buffer (Name_Len - 4 .. Name_Len) /= ".aadl"
then then
if Add_Suffix then
Add_Str_To_Name_Buffer (".aadl"); Add_Str_To_Name_Buffer (".aadl");
else
return;
end if; end if;
end if; end if;
File_Name_With_Extension := Name_Find; File_Name_With_Extension := Name_Find;
for J in 1 .. Sources.Last loop for J in 1 .. Sources.Last loop
......
...@@ -51,7 +51,11 @@ package Ocarina.Files is ...@@ -51,7 +51,11 @@ package Ocarina.Files is
procedure Add_File_To_Parse_List procedure Add_File_To_Parse_List
(File_Name : Name_Id; (File_Name : Name_Id;
Add_Suffix : Boolean := True); Add_Suffix : Boolean);
-- Add File_Name to the list of files to be parsed. If Add_Suffix
-- is true, and File_Name does not end with ".aadl", add this
-- suffix. It Add_Suffix is false, and File_Name does not end with
-- ".aadl", simply discard this name.
function Search_File (File_Name : Name_Id) return Name_Id; function Search_File (File_Name : Name_Id) return Name_Id;
......
...@@ -883,7 +883,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is ...@@ -883,7 +883,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is
while Present (I) loop while Present (I) loop
if Kind (I) = K_Identifier then if Kind (I) = K_Identifier then
Ocarina.Files.Add_File_To_Parse_List (Name (I)); Ocarina.Files.Add_File_To_Parse_List
(Name (I), Add_Suffix => True);
elsif Kind (I) = K_Package_Name then elsif Kind (I) = K_Package_Name then
declare declare
J : Node_Id; J : Node_Id;
...@@ -899,7 +900,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is ...@@ -899,7 +900,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is
("-" & Get_Name_String (Name (J))); ("-" & Get_Name_String (Name (J)));
J := Next_Node (J); J := Next_Node (J);
end loop; end loop;
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
end if; end if;
end; end;
end if; end if;
......
...@@ -774,7 +774,8 @@ procedure Ocarina_Cmd is ...@@ -774,7 +774,8 @@ procedure Ocarina_Cmd is
Add_Str_To_Name_Buffer (File_Name & ".aadl"); Add_Str_To_Name_Buffer (File_Name & ".aadl");
end; end;
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
N := Next_Node (N); N := Next_Node (N);
end loop; end loop;
...@@ -788,7 +789,8 @@ procedure Ocarina_Cmd is ...@@ -788,7 +789,8 @@ procedure Ocarina_Cmd is
begin begin
Get_Name_String (Current_Scenario_Dirname); Get_Name_String (Current_Scenario_Dirname);
Add_Str_To_Name_Buffer (File_Name); Add_Str_To_Name_Buffer (File_Name);
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
N := Next_Node (N); N := Next_Node (N);
end; end;
end loop; end loop;
...@@ -963,9 +965,9 @@ procedure Ocarina_Cmd is ...@@ -963,9 +965,9 @@ procedure Ocarina_Cmd is
if Use_CL then if Use_CL then
Set_Str_To_Name_Buffer ("ocarina_components.aadl"); Set_Str_To_Name_Buffer ("ocarina_components.aadl");
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List (Name_Find, Add_Suffix => True);
Set_Str_To_Name_Buffer ("base_types.aadl"); Set_Str_To_Name_Buffer ("base_types.aadl");
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List (Name_Find, Add_Suffix => True);
end if; end if;
Extract_Referencial_Files (Ref_Files, Ref_Map); Extract_Referencial_Files (Ref_Files, Ref_Map);
...@@ -1021,7 +1023,8 @@ procedure Ocarina_Cmd is ...@@ -1021,7 +1023,8 @@ procedure Ocarina_Cmd is
for J in Result'Range loop for J in Result'Range loop
Set_Str_To_Name_Buffer (Result (J).all); Set_Str_To_Name_Buffer (Result (J).all);
Ocarina.Files.Add_File_To_Parse_List (Name_Find); Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
end loop; end loop;
-- Avoid memory leaks -- Avoid memory leaks
...@@ -1161,16 +1164,9 @@ procedure Ocarina_Cmd is ...@@ -1161,16 +1164,9 @@ procedure Ocarina_Cmd is
declare declare
S : constant String := Full_Switch; S : constant String := Full_Switch;
begin begin
-- FIXME: this is not correct. For instance, an
-- unknown switch may be followed by a parameter.
-- The parameter is considered as a file to parse
-- when it is not. Only sections would fix the
-- issue.
-- If there is a new switch, then the previous
-- files must be discarded.
if S (S'First) = '-' then if S (S'First) = '-' then
-- If there is a new switch, then the previous
-- files are discarded.
Sources.Init; Sources.Init;
elsif S (S'First) = '@' then elsif S (S'First) = '@' then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment