text
stringlengths
0
234
declare
txt : File_Type;
the_dir : String := full_dir (child);
the_file : String := full_file (child);
the_path : String := relative_path (parent, child);
the_indent : Integer := absolute_indent (child);
procedure write_path (parent : String; child : String) is
the_path : String := relative_path (parent, child);
the_indent : Integer := relative_indent (parent, child);
begin
put_line (txt,spc(the_indent)&"$Input{"""&the_path&"""}");
end write_path;
procedure write_line (the_line : String; the_indent : Integer) is
begin
if the_indent > get_strlen(the_line)
then put_line (txt, str(the_line));
else put_line (txt, str(the_line(the_indent+1..the_line'last)));
end if;
end write_line;
begin
if not Path_Exists (the_dir) then
Ada.Directories.Create_Path (the_dir);
end if;
if File_Exists (the_file)
then Open (txt, out_file, the_file);
else Create (txt, out_file, the_file);
end if;
loop
begin
declare
the_line : String := Get_Line (src);
begin
case classify (the_line) is
when beg_tag => write_path (child, the_line);
write_file (child, the_line);
when end_tag => exit;
when others => write_line (the_line, the_indent);
end case;
Function Definition: procedure cdb2ada is
Function Body: target_line_length : constant := 256;
src_file_name : String := read_command_arg ('i',"foo.c");
txt_file_name : String := read_command_arg ('o',"foo.ad");
procedure_name : String := read_command_arg ('n',"foo");
symbol : Character := read_command_arg ('s','t'); -- the 'x' in vars like x0123 or
-- the 't' in t321
-----------------------------------------------------------------------------
procedure rewrite_cdb is
txt : File_Type;
src : File_Type;
start_line : Boolean;
finished : Boolean;
this_lead_in : Integer;
break_at : integer;
found_at : integer;
found : Boolean;
beg_at : integer;
end_at : integer;
var_beg : integer;
var_end : integer;
rhs_beg : integer;
rhs_end : integer;
tail_beg : integer;
tail_end : integer;
max_xvars_width : Integer;
procedure write_procedure_begin is
re_name : String := "([a-zA-Z0-9_-]+)";
the_name : String := grep (procedure_name, re_name, 1, fail => "no_name");
begin
for i in the_name'range loop
if the_name (i) = '-' then
the_name (i) := '_';
end if;
end loop;
Put_Line (txt, "Procedure "&the_name&" is");
end write_procedure_begin;
procedure write_procedure_end is
re_name : String := "([a-zA-Z0-9_-]+)";
the_name : String := grep (procedure_name, re_name, 1, fail => "no_name");
begin
for i in the_name'range loop
if the_name (i) = '-' then
the_name (i) := '_';