ocarina-be_aadl-properties-values.adb 30.4 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--    O C A R I N A . B E _ A A D L . P R O P E R T I E S . V A L U E S     --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
--    Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE.      --
--                                                                          --
-- Ocarina  is free software; you can redistribute it and/or modify under   --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
jhugues's avatar
jhugues committed
27 28
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
29 30 31
--                                                                          --
------------------------------------------------------------------------------

32
with Ocarina.Output;
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
with Charset;

with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Tree.Nutils;
with Ocarina.AADL_Values;
with Ocarina.ME_AADL.AADL_Tree.Entities.Properties;
with Ocarina.ME_AADL.AADL_Tree.Entities;
with Ocarina.BE_AADL.Identifiers;
with Ocarina.BE_AADL.Components;
with Ocarina.BE_AADL.Annexes;
with Ocarina.BE_AADL.Components.Arrays;

package body Ocarina.BE_AADL.Properties.Values is

48
   use Ocarina.Output;
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
   use Charset;

   use Ocarina.ME_AADL;
   use Ocarina.ME_AADL.AADL_Tree.Nodes;
   use Ocarina.ME_AADL.AADL_Tree.Nutils;
   use Ocarina.AADL_Values;
   use Ocarina.ME_AADL.AADL_Tree.Entities.Properties;
   use Ocarina.ME_AADL.AADL_Tree.Entities;
   use Ocarina.BE_AADL.Identifiers;
   use Ocarina.BE_AADL.Components;
   use Ocarina.BE_AADL.Components.Arrays;
   use Ocarina.BE_AADL.Annexes;

   procedure Print_And_Boolean_Term (Node : Node_Id);
   procedure Print_Not_Boolean_Term (Node : Node_Id);
   procedure Print_Parenthesis_Boolean_Term (Node : Node_Id);
   procedure Print_Boolean_Term (Node : Node_Id);
   procedure Print_Number_Range_Term (Node : Node_Id);
   procedure Print_Referable_Element_Category (Node : Node_Id);
   procedure Print_Record_Term_Element (Node : Node_Id);
   procedure Print_Record_Type_Element (Node : Node_Id);
   procedure Print_Reference_Term (Node : Node_Id);
   procedure Print_Minus_Numeric_Term (Node : Node_Id);
   procedure Print_Unique_Property_Constant_Identifier (Node : Node_Id);
   procedure Print_Unit_Definition (Node : Node_Id);
   procedure Print_Component_Classifier_Term (Node : Node_Id);
   procedure Print_Named_Element_Identifier (N : Named_Element);

   -------------------------------------
   -- Print_Component_Classifier_Term --
   -------------------------------------

   procedure Print_Component_Classifier_Term (Node : Node_Id) is
   begin
      case AADL_Version is
         when AADL_V1 =>
            Print_Component_Category (Component_Cat (Node));
            Write_Space;
         when AADL_V2 =>
            Print_Token (T_Classifier);
            Write_Space;
            Print_Token (T_Left_Parenthesis);
      end case;

      if Identifier (Node) /= No_Node then
         Print_Entity_Reference (Node);
      end if;

      case AADL_Version is
         when AADL_V2 =>
            Print_Token (T_Right_Parenthesis);
         when others =>
            null;
      end case;
   end Print_Component_Classifier_Term;

   ----------------------------
   -- Print_Not_Boolean_Term --
   ----------------------------

   procedure Print_Not_Boolean_Term (Node : Node_Id) is
   begin
      Print_Token (T_Not);
      Write_Space;
      Print_Boolean_Term (Boolean_Term (Node));
   end Print_Not_Boolean_Term;

   -----------------------------
   -- Print_Number_Range_Term --
   -----------------------------

   procedure Print_Number_Range_Term (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Number_Range_Term);

      Delta_Term : constant Node_Id :=
        Ocarina.ME_AADL.AADL_Tree.Nodes.Delta_Term (Node);
   begin
      Print_Numeric_Term (Lower_Bound (Node));
      Write_Space;

      Print_Token (T_Interval);
      Write_Space;

      Print_Numeric_Term (Upper_Bound (Node));

      if Present (Delta_Term) then
         Write_Space;
         Print_Token (T_Delta);

         Write_Space;
         Print_Numeric_Term (Delta_Term);
      end if;
   end Print_Number_Range_Term;

   -----------------------
   -- Print_Number_Type --
   -----------------------

   procedure Print_Number_Type (Node : Node_Id) is
      Number_Kind : constant Node_Kind := Kind (Node);
149
      Type_Range  : constant Node_Id   :=
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
        Ocarina.ME_AADL.AADL_Tree.Nodes.Type_Range (Node);
      Unit_Design : constant Node_Id := Unit_Designator (Node);
   begin
      if Number_Kind = K_Real_Type then
         Print_Token (T_AADLReal);
      else
         Print_Token (T_AADLInteger);
      end if;

      if Present (Type_Range) then
         Write_Space;
         Print_Range (Type_Range);
      end if;

      if Present (Unit_Design) then
         Write_Space;
         if Kind (Unit_Design) = K_Units_Type then
            Print_Units_Type (Unit_Design);
         else
            Print_Token (T_Units);
            Write_Space;
            Print_Entity_Reference (Unit_Design);
         end if;
      end if;
   end Print_Number_Type;

   ------------------------
   -- Print_Boolean_Term --
   ------------------------

   procedure Print_Boolean_Term (Node : Node_Id) is
   begin
      case Kind (Node) is
         when K_Literal =>
            Print_Literal (Node);
         when K_Not_Boolean_Term =>
            Print_Not_Boolean_Term (Node);
         when K_And_Boolean_Term =>
            Print_And_Boolean_Term (Node);
         when K_Or_Boolean_Term =>
            Print_Or_Boolean_Term (Node);
         when K_Parenthesis_Boolean_Term =>
            Print_Parenthesis_Boolean_Term (Node);
         when K_Property_Term =>
            Print_Unique_Property_Constant_Identifier (Node);
         when others =>
            Node_Not_Handled (Node);
      end case;
   end Print_Boolean_Term;

   ---------------------------
   -- Print_Or_Boolean_Term --
   ---------------------------

   procedure Print_Or_Boolean_Term (Node : Node_Id) is
   begin
      Print_Boolean_Term (First_Term (Node));
      Write_Space;

      Print_Token (T_Or);
      Write_Space;

      Print_Boolean_Term (Second_Term (Node));
   end Print_Or_Boolean_Term;

   ------------------------------------
   -- Print_Parenthesis_Boolean_Term --
   ------------------------------------

   procedure Print_Parenthesis_Boolean_Term (Node : Node_Id) is
   begin
      Print_Token (T_Left_Parenthesis);
      Print_Boolean_Term (Boolean_Term (Node));
      Print_Token (T_Right_Parenthesis);
   end Print_Parenthesis_Boolean_Term;

   -----------------
   -- Print_Range --
   -----------------

   procedure Print_Range (Node : Node_Id) is
   begin
      Print_Numeric_Term (Lower_Bound (Node));
      Write_Space;
      Print_Token (T_Interval);
      Write_Space;
      Print_Numeric_Term (Upper_Bound (Node));
   end Print_Range;

   ----------------------
   -- Print_Range_Type --
   ----------------------

   procedure Print_Range_Type (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Range_Type);

246
      Number_Type : constant Node_Id :=
247 248 249 250 251 252 253
        Ocarina.ME_AADL.AADL_Tree.Nodes.Number_Type (Node);
      Range_Type_Kind : constant Node_Kind := Kind (Number_Type);
   begin
      Print_Tokens ((T_Range, T_Of));
      Write_Space;

      if Range_Type_Kind = K_Integer_Type
254 255
        or else Range_Type_Kind = K_Real_Type
      then
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
         Print_Number_Type (Number_Type);
      else
         Print_Entity_Reference (Number_Type);
      end if;
   end Print_Range_Type;

   --------------------------------------
   -- Print_Referable_Element_Category --
   --------------------------------------

   procedure Print_Referable_Element_Category (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Referable_Element_Category);
   begin
      case Referable_Element_Category'Val (Category (Node)) is
         when REC_Component_Category =>
            Print_Component_Category (Component_Cat (Node));

         when REC_Connections =>
            Print_Token (T_Connections);

         when REC_Server_Subprogram =>
            Print_Tokens ((T_Server, T_Subprogram));

         when REC_Identifier =>
            Print_Identifier (Identifier (Node));

         when REC_Subprogram_Call_Sequence =>
            Print_Component_Category (Component_Cat (Node));
            Write_Space;

      end case;
   end Print_Referable_Element_Category;

   -------------------------
   -- Print_Computed_Term --
   -------------------------

   procedure Print_Computed_Term (Node : Node_Id) is
   begin
      Print_Token (T_Compute);
      Write_Space;
      Print_Token (T_Left_Parenthesis);
      Write_Space;
      Print_Identifier (Identifier (Node));
      Write_Space;
      Print_Token (T_Right_Parenthesis);
   end Print_Computed_Term;

   -----------------------
   -- Print_Record_Term --
   -----------------------

   procedure Print_Record_Term (Node : Node_Id) is
309
      pragma Assert (Kind (Node) = K_Record_Term);
310 311 312

      List_Node : Node_Id;
   begin
313
      Print_Token (T_Left_Square_Bracket);
314 315
      Write_Space;

316 317
      List_Node :=
        First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.List_Items (Node));
318 319 320 321 322

      while Present (List_Node) loop
         case Kind (List_Node) is
            when K_Record_Term_Element =>
               Print_Record_Term_Element (List_Node);
323 324
               Print_Token (T_Semicolon);
               Write_Space;
325 326 327 328 329 330 331 332
            when others =>
               Node_Not_Handled (Node);
         end case;

         List_Node := Next_Node (List_Node);
      end loop;

      Write_Space;
333
      Print_Token (T_Right_Square_Bracket);
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
   end Print_Record_Term;

   -------------------------------
   -- Print_Record_Term_Element --
   -------------------------------

   procedure Print_Record_Term_Element (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Record_Term_Element);
   begin
      Print_Identifier (Identifier (Node));
      Write_Space;
      Print_Token (T_Association);
      Write_Space;
      Print_Property_Value (Property_Expression (Node));
   end Print_Record_Term_Element;

   -----------------------
   -- Print_Record_Type --
   -----------------------

   procedure Print_Record_Type (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Record_Type);

      List_Node : Node_Id;
   begin
      Print_Token (T_Record);
      Write_Space;
      Print_Token (T_Left_Parenthesis);

363 364
      List_Node :=
        First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.List_Items (Node));
365 366 367

      while Present (List_Node) loop
         if List_Node /=
368 369
           First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.List_Items (Node))
         then
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
            Write_Space;
         end if;

         case Kind (List_Node) is
            when K_Record_Type_Element =>
               Print_Record_Type_Element (List_Node);
            when others =>
               Node_Not_Handled (Node);
         end case;

         List_Node := Next_Node (List_Node);
      end loop;

      Print_Token (T_Right_Parenthesis);
   end Print_Record_Type;

   -------------------------------
   -- Print_Record_Type_Element --
   -------------------------------

   procedure Print_Record_Type_Element (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Record_Type_Element);
   begin
      Print_Identifier (Identifier (Node));
      Write_Space;
      Print_Token (T_Colon);
396 397 398 399 400 401
      if Is_List (Node) then
         Write_Space;
         Print_Token (T_List);
         Write_Space;
         Print_Token (T_Of);
      end if;
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
      Write_Space;
      Print_Property_Type_Designator (Property_Type_Designator (Node));
      Print_Token (T_Semicolon);
   end Print_Record_Type_Element;

   --------------------------
   -- Print_Reference_Term --
   --------------------------

   procedure Print_Reference_Term (Node : Node_Id) is
   begin
      Print_Token (T_Reference);
      Write_Space;
      case AADL_Version is
         when AADL_V2 =>
            Print_Token (T_Left_Parenthesis);
            Write_Space;
            Print_Contained_Element_Path (Reference_Term (Node));
            Write_Space;
            Print_Token (T_Right_Parenthesis);
         when AADL_V1 =>
            Print_Entity_Reference (Reference_Term (Node));
      end case;
   end Print_Reference_Term;

   --------------------------
   -- Print_Reference_Type --
   --------------------------

   procedure Print_Reference_Type (L : List_Id) is
      List_Node : Node_Id;
   begin
      Print_Token (T_Reference);

      if not Is_Empty (L) then
         Write_Space;
         Print_Token (T_Left_Parenthesis);
         Write_Eol;

         if not Is_Empty (L) then
            List_Node := First_Node (L);

            while Present (List_Node) loop
               if List_Node /= First_Node (L) then
                  Print_Token (T_Comma);
                  Write_Space;
               end if;

               case Kind (List_Node) is
                  when K_Referable_Element_Category =>
                     Print_Referable_Element_Category (List_Node);
                  when K_Reference_Category =>
                     Print_Named_Element (List_Node);
                  when others =>
                     Node_Not_Handled (List_Node);
               end case;

               List_Node := Next_Node (List_Node);
            end loop;
         end if;

         Print_Token (T_Right_Parenthesis);

      end if;
   end Print_Reference_Type;

   ------------------------
   -- Print_Numeric_Term --
   ------------------------

   procedure Print_Numeric_Term (Node : Node_Id) is
473 474 475 476 477 478
      pragma Assert
        (Kind (Node) = K_Minus_Numeric_Term
         or else Kind (Node) = K_Signed_AADLNumber
         or else Kind (Node) = K_Property_Term
         or else Kind (Node) = K_Unique_Property_Const_Identifier
         or else Kind (Node) = K_Entity_Reference);
479 480 481 482 483 484
   begin
      case Kind (Node) is
         when K_Minus_Numeric_Term =>
            Print_Minus_Numeric_Term (Node);
         when K_Signed_AADLNumber =>
            Print_Signed_AADLNumber (Node);
485 486 487
         when K_Property_Term                 |
           K_Entity_Reference                 |
           K_Unique_Property_Const_Identifier =>
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
            Print_Unique_Property_Constant_Identifier (Node);
         when others =>
            raise Program_Error;
      end case;
   end Print_Numeric_Term;

   ------------------------------
   -- Print_Minus_Numeric_Term --
   ------------------------------

   procedure Print_Minus_Numeric_Term (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Minus_Numeric_Term);
   begin
      Print_Token (T_Minus);
      Print_Numeric_Term (Numeric_Term (Node));
   end Print_Minus_Numeric_Term;

   -----------------------------
   -- Print_Signed_AADLNumber --
   -----------------------------

   procedure Print_Signed_AADLNumber (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Signed_AADLNumber);

512 513
      Value : constant Node_Id := Number_Value (Node);
      Unit  : constant Node_Id := Unit_Identifier (Node);
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539

   begin
      if Kind (Value) = K_Literal then
         --  Node is a Signed_AADLReal or a Signed_AADLInteger

         Print_Literal (Value);

         if Present (Unit) then
            Write_Space;
            Print_Identifier (Unit);
         end if;
      else
         Print_Unique_Property_Constant_Identifier (Value);
      end if;
   end Print_Signed_AADLNumber;

   --------------------------
   -- Print_Property_Value --
   --------------------------

   procedure Print_Property_Value (Node : Node_Id) is
   begin
      case Kind (Node) is
         when K_Identifier =>
            Print_Identifier (Node);

540
         when K_Signed_AADLNumber | K_Minus_Numeric_Term =>
541 542 543 544 545 546 547 548
            Print_Numeric_Term (Node);

         when K_Literal =>
            Print_Literal (Node);

         when K_Number_Range_Term =>
            Print_Number_Range_Term (Node);

549 550 551 552
         when K_Not_Boolean_Term      |
           K_And_Boolean_Term         |
           K_Or_Boolean_Term          |
           K_Parenthesis_Boolean_Term =>
553 554
            Print_Boolean_Term (Node);

555 556 557
         when K_Unique_Property_Const_Identifier |
           K_Property_Term                       |
           K_Enumeration_Term                    =>
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
            Print_Unique_Property_Constant_Identifier (Node);

         when K_Reference_Term =>
            Print_Reference_Term (Node);

         when K_Component_Classifier_Term =>
            Print_Component_Classifier_Term (Node);

         when K_Record_Term =>
            Print_Record_Term (Node);

         when K_Computed_Term =>
            Print_Computed_Term (Node);

         when others =>
            Node_Not_Handled (Node);
      end case;
   end Print_Property_Value;

   ------------------------------------
   -- Print_Property_Type_Designator --
   ------------------------------------

   procedure Print_Property_Type_Designator (Node : Node_Id) is
582 583 584 585 586 587 588 589 590 591 592 593
      pragma Assert
        (Kind (Node) = K_Unique_Property_Type_Identifier
         or else Kind (Node) = K_String_Type
         or else Kind (Node) = K_Boolean_Type
         or else Kind (Node) = K_Real_Type
         or else Kind (Node) = K_Integer_Type
         or else Kind (Node) = K_Range_Type
         or else Kind (Node) = K_Enumeration_Type
         or else Kind (Node) = K_Reference_Type
         or else Kind (Node) = K_Classifier_Type
         or else Kind (Node) = K_Units_Type
         or else Kind (Node) = K_Record_Type);
594 595 596 597 598
   begin
      case Kind (Node) is
         when K_Unique_Property_Type_Identifier =>
            Print_Entity_Reference (Node);

599 600 601 602
         when K_String_Type =>
            Print_Token (T_AADLString);
         when K_Boolean_Type =>
            Print_Token (T_AADLBoolean);
603

604
         when K_Real_Type | K_Integer_Type =>
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
            Print_Number_Type (Node);

         when K_Range_Type =>
            Print_Range_Type (Node);

         when K_Enumeration_Type =>
            Print_Enumeration_Type (Node);

         when K_Reference_Type =>
            Print_Reference_Type (List_Items (Node));

         when K_Classifier_Type =>
            Print_Classifier_Type (List_Items (Node));

         when K_Units_Type =>
            Print_Units_Type (Node);

         when K_Record_Type =>
            Print_Record_Type (Node);

         when others =>
            Node_Not_Handled (Node);
      end case;
   end Print_Property_Type_Designator;

   -----------------------------------------------
   -- Print_Unique_Property_Constant_Identifier --
   -----------------------------------------------

   procedure Print_Unique_Property_Constant_Identifier (Node : Node_Id) is
635 636 637 638 639
      pragma Assert
        (Kind (Node) = K_Unique_Property_Const_Identifier
         or else Kind (Node) = K_Property_Term
         or else Kind (Node) = K_Enumeration_Term
         or else Kind (Node) = K_Entity_Reference);
640 641 642 643 644 645
   begin
      if AADL_Version = AADL_V1 then
         Print_Tokens ((T_Value, T_Left_Parenthesis));
      end if;

      case Kind (Node) is
646 647 648 649 650
         when K_Entity_Reference              |
           K_Unique_Property_Type_Identifier  |
           K_Property_Term                    |
           K_Enumeration_Term                 |
           K_Unique_Property_Const_Identifier =>
651
            Print_Entity_Reference (Node);
652
         when K_Real_Type | K_Integer_Type =>
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
            Print_Number_Type (Node);
         when others =>
            Node_Not_Handled (Node);
      end case;

      if AADL_Version = AADL_V1 then
         Print_Token (T_Right_Parenthesis);
      end if;
   end Print_Unique_Property_Constant_Identifier;

   ---------------------------
   -- Print_Unit_Definition --
   ---------------------------

   procedure Print_Unit_Definition (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Unit_Definition);
   begin
      Print_Identifier (Identifier (Node));
      Write_Space;

      Print_Token (T_Association);
      Write_Space;

      Print_Identifier (Unit_Identifier (Node));
      Write_Space;

      Print_Token (T_Multiply);
      Write_Space;

      Print_Literal (Numeric_Literal (Node));
   end Print_Unit_Definition;

   ----------------------
   -- Print_Units_Type --
   ----------------------

   procedure Print_Units_Type (Node : Node_Id) is
      Definitions : constant List_Id := Unit_Definitions (Node);
      List_Node   : Node_Id;
   begin
      Print_Tokens ((T_Units, T_Left_Parenthesis));

      if No (Definitions) then
         Print_Identifier (Base_Identifier (Node));
         Print_Token (T_Right_Parenthesis);
      else
         Write_Eol;

         Increment_Indentation;
         Write_Indentation;
         Print_Identifier (Base_Identifier (Node));

         Print_Token (T_Comma);
         Write_Eol;
         Write_Indentation;

         if not Is_Empty (Definitions) then
            List_Node := First_Node (Definitions);

            while Present (List_Node) loop
               if List_Node /= First_Node (Definitions) then
                  Print_Token (T_Comma);
                  Write_Eol;
                  Write_Indentation;
               end if;

               case Kind (List_Node) is
                  when K_Unit_Definition =>
                     Print_Unit_Definition (List_Node);
                  when others =>
                     Node_Not_Handled (List_Node);
               end case;

               List_Node := Next_Node (List_Node);
            end loop;
         end if;

         Decrement_Indentation;
         Print_Token (T_Right_Parenthesis);
      end if;
   end Print_Units_Type;

   ----------------------------
   -- Print_And_Boolean_Term --
   ----------------------------

   procedure Print_And_Boolean_Term (Node : Node_Id) is
   begin
      Print_Boolean_Term (First_Term (Node));
      Write_Space;

      Print_Token (T_And);
      Write_Space;

      Print_Boolean_Term (Second_Term (Node));
   end Print_And_Boolean_Term;

   -------------------
   -- Print_Literal --
   -------------------

   procedure Print_Literal (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Literal);
   begin
      Write_Str (Ocarina.AADL_Values.Image (Value (Node)));
   end Print_Literal;

   ---------------------------
   -- Print_Classifier_Type --
   ---------------------------

   procedure Print_Classifier_Type (L : List_Id) is
      List_Node : Node_Id;
   begin
      Print_Token (T_Classifier);
      if not Is_Empty (L) then
         Write_Space;
         Print_Token (T_Left_Parenthesis);
         Write_Eol;

         if not Is_Empty (L) then
            List_Node := First_Node (L);

            while Present (List_Node) loop
               if List_Node /= First_Node (L) then
                  Print_Token (T_Comma);
                  Write_Space;
               end if;

               case Kind (List_Node) is
                  when K_Component_Category =>
                     Print_Component_Category (Category (List_Node));

                  when K_Classifier_Category_Ref =>
                     Print_Named_Element (List_Node);

                  when others =>
                     Node_Not_Handled (List_Node);
               end case;

               List_Node := Next_Node (List_Node);
            end loop;
         end if;

         Print_Token (T_Right_Parenthesis);
      end if;
   end Print_Classifier_Type;

   ----------------------------
   -- Print_Enumeration_Type --
   ----------------------------

   procedure Print_Enumeration_Type (Node : Node_Id) is
      List_Node : Node_Id;
   begin
      Print_Tokens ((T_Enumeration, T_Left_Parenthesis));

      if not Is_Empty (Ocarina.ME_AADL.AADL_Tree.Nodes.Identifiers (Node)) then
811 812
         List_Node :=
           First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Identifiers (Node));
813 814

         while Present (List_Node) loop
815 816 817
            if List_Node /=
              First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Identifiers (Node))
            then
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
               Print_Token (T_Comma);
               Write_Space;
            end if;

            case Kind (List_Node) is
               when K_Identifier =>
                  Print_Identifier (List_Node);
               when others =>
                  Node_Not_Handled (Node);
            end case;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      Print_Token (T_Right_Parenthesis);
   end Print_Enumeration_Type;

   ------------------------------------
   -- Print_Named_Element_Identifier --
   ------------------------------------

   procedure Print_Named_Element_Identifier (N : Named_Element) is
      S : String := Named_Element'Image (N);
   begin

      To_Lower (S);
845 846 847
      for J in S'Range loop
         if S (J) = '_' then
            S (J) := ' ';
848 849 850 851 852 853 854 855 856 857 858
         end if;
      end loop;
      Write_Str (S (4 .. S'Last));

   end Print_Named_Element_Identifier;

   -------------------------
   -- Print_Named_Element --
   -------------------------

   procedure Print_Named_Element (Node : Node_Id) is
859
      Class_Ref : constant Node_Id := Classifier_Ref (Node);
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902
   begin
      case Named_Element'Val (Category (Node)) is
         when PO_Port_Group =>
            Print_Tokens ((T_Port, T_Group));
         when PO_Server_Subprogram =>
            Print_Tokens ((T_Server, T_Subprogram));
         when PO_Connections =>
            Print_Token (T_Connections);
         when PO_Port_Connections =>
            Print_Tokens ((T_Port, T_Connections));
         when PO_Port_Group_Connections =>
            Print_Tokens ((T_Port, T_Group, T_Connections));
         when PO_Event_Port_Connections =>
            Print_Tokens ((T_Event, T_Port, T_Connections));
         when PO_Data_Port_Connections =>
            Print_Tokens ((T_Data, T_Port, T_Connections));
         when PO_Event_Data_Port_Connections =>
            Print_Tokens ((T_Event, T_Data, T_Port, T_Connections));
         when PO_Parameter_Connections =>
            Print_Tokens ((T_Parameter, T_Connections));
         when PO_Mode =>
            Print_Token (T_Mode);
         when PO_Flow =>
            Print_Token (T_Flow);
         when PO_Port =>
            Print_Token (T_Port);
         when PO_Event_Port =>
            Print_Tokens ((T_Event, T_Port));
         when PO_Data_Port =>
            Print_Tokens ((T_Data, T_Port));
         when PO_Event_Data_Port =>
            Print_Tokens ((T_Event, T_Data, T_Port));
         when PO_Access_Connection =>
            Print_Tokens ((T_Access, T_Connections));
         when PO_Parameter =>
            Print_Token (T_Parameter);
         when PO_Identifier =>
            Print_Identifier (Identifier (Node));
         when PO_Feature_Group =>
            Print_Tokens ((T_Feature, T_Group));
         when PO_Feature =>
            Print_Token (T_Feature);
         when PO_Connection =>
903
            Print_Named_Element_Identifier (PO_Connection);
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
         when PO_Feature_Group_Connection =>
            Print_Tokens ((T_Feature, T_Group, T_Connections));
         when PO_Component_Category =>
            Print_Component_Category (Component_Cat (Node));
         when PO_Access =>
            Print_Token (T_Access);
         when PO_Component_Classifier =>
            Print_Component_Category (Component_Cat (Node));
            Write_Space;
            Print_Token (T_Classifier);
         when PO_Classifier =>
            Print_Token (T_Classifier);
         when PO_Package =>
            Print_Token (T_Package);
         when PO_Component_Implementation =>
            if Component_Category'Val (Component_Cat (Node)) = CC_Unknown then
               Print_Identifier (Identifier (Node));
            else
               Print_Component_Category (Component_Cat (Node));
            end if;
            Write_Space;
            Print_Token (T_Implementation);

            if Present (Class_Ref) then
               Write_Space;
               Print_Entity_Reference (Class_Ref);
            end if;
931 932 933 934 935 936 937 938
         when PO_Component_Access =>
            if Component_Category'Val (Component_Cat (Node)) = CC_Unknown then
               Print_Identifier (Identifier (Node));
            else
               Print_Component_Category (Component_Cat (Node));
            end if;
            Write_Space;
            Print_Token (T_Access);
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956

         when others =>
            Print_Named_Element_Identifier
              (Named_Element'Val (Category (Node)));
      end case;
   end Print_Named_Element;

   ----------------------------------
   -- Print_Contained_Element_Path --
   ----------------------------------

   procedure Print_Contained_Element_Path (Node : Node_Id) is
      Contained_Elts : List_Id;
      List_Node      : Node_Id;
      Ann_Path       : Node_Id;

   begin
      Contained_Elts := List_Items (Node);
957
      Ann_Path       := Annex_Path (Node);
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987

      if not Is_Empty (Contained_Elts) then
         List_Node := First_Node (Contained_Elts);

         while Present (List_Node) loop
            case Kind (List_Node) is
               when K_Identifier =>
                  Print_Identifier (List_Node);

               when K_Array_Selection =>
                  Print_Array_Selections (List_Node);

               when others =>
                  raise Program_Error;
            end case;

            exit when No (Next_Node (List_Node));
            Print_Token (T_Dot);

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      if Present (Ann_Path) then
         Print_Annex_Path (Ann_Path);
      end if;

   end Print_Contained_Element_Path;

end Ocarina.BE_AADL.Properties.Values;