phcpack_2.4.88_e448e94a/src/Ada/CtoPHC/Funky/print_poly.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
with text_io,integer_io;               use text_io,integer_io;
with Interfaces.C.Strings;             use Interfaces.C.Strings;
with Standard_Natural_Numbers;         use Standard_Natural_Numbers;
with Symbol_Table;
with Standard_Complex_Polynomials;     use Standard_Complex_Polynomials;
with Standard_Complex_Polynomials_io;  use Standard_Complex_Polynomials_io;
with Standard_Complex_Poly_Strings;    use Standard_Complex_Poly_Strings;

procedure print_poly ( n : in integer; s : in chars_ptr ) is

-- IMPORTANT NOTICE :
--   For one weird reason, the string returned by the Value function
--   starts with the newline symbol which is not recognized as a space
--   by the Ada parser.

  vs : constant string := Value(s);
  p : Poly;

begin
  put("The number of variables : "); put(n,1); new_line;
  put("The string on input : "); put(vs); new_line;
 -- remove comments below to unveil the first symbol of vs :
 -- put("vs'first : "); put(vs'first,1); new_line;
 -- put("vs("); put(vs'first,1); put(") = "); put(vs(vs'first)); new_line;
 -- put("vs("); put(vs'first+1,1); put(") = "); put(vs(vs'first+1)); new_line;
  Symbol_Table.Init(natural32(n));
  p := Parse(natural32(n),vs(vs'first+1..vs'last));
  put("The parsed polynomial : ");
  put(p);
  new_line;
end print_poly;