Natools

Diff
Login

Differences From Artifact [4aefa3cb01]:

To Artifact [d02b7babca]:


294
295
296
297
298
299
300
301

302
303
304
305
306
307
308

309
310
311
312
313
314
315
316
317
318
319
320
321
322

323








324
325

326
327
328
329
330
331
332
333


334
335
336



337
338
339
340
341
342
343
294
295
296
297
298
299
300

301
302
303
304
305
306
307

308
309
310
311
312
313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
329
330
331
332

333
334
335
336
337
338
339
340

341
342
343


344
345
346
347
348
349
350
351
352
353







-
+






-
+













-
+

+
+
+
+
+
+
+
+

-
+







-
+
+

-
-
+
+
+







   end Print;


   procedure Update
     (Param : in out Parameters;
      Expression : in out Lockable.Descriptor'Class)
   is
      Interpreter : Interpreters.Interpreter := Config_Interpreter;
      Interpreter : constant Interpreters.Interpreter := Config_Interpreter;
   begin
      Update (Interpreter, Param, Expression);
   end Update;


   procedure Update
     (Interpreter : in out Interpreters.Interpreter;
     (Interpreter : in Interpreters.Interpreter;
      Param : in out Parameters;
      Expression : in out Lockable.Descriptor'Class) is
   begin
      Interpreter.Execute (Expression, Param, True);
   end Update;



   ------------------------------
   -- Interpreter Constructors --
   ------------------------------

   function Config_Interpreter return Interpreters.Interpreter is
      Result : Interpreters.Interpreter;
      Quoted_SI, Newline_SI, Space_SI, Result : Interpreters.Interpreter;
   begin
      --  Setup subinterpreters
      Add_Separator_Commands (Newline_SI, True, True);
      Add_Newline_Encoding_Commands (Newline_SI);
      Add_Quoted_Commands (Quoted_SI);
      Add_Quoted_Escape_Commands (Quoted_SI);
      Add_Separator_Commands (Space_SI, True, False);

      --  Build final interpreter
      Result.Add_Command (To_Atom ("escape"),
                          Set_Quoted_String'(others => <>));
                          Set_Quoted_String'(Subinterpreter => Quoted_SI));
      Result.Add_Command (To_Atom ("indent"), Set_Indentation'(null record));
      Result.Add_Command (To_Atom ("indentation"),
                          Set_Indentation'(null record));
      Result.Add_Command (To_Atom ("no-indent"),
                          Set_Indentation'(null record));
      Result.Add_Command (To_Atom ("no-indentation"),
                          Set_Indentation'(null record));
      Result.Add_Command (To_Atom ("newline"), Set_Newline'(others => <>));
      Result.Add_Command (To_Atom ("newline"),
                          Set_Newline'(Subinterpreter => Newline_SI));
      Result.Add_Command (To_Atom ("quoted"),
                          Set_Quoted_String'(others => <>));
      Result.Add_Command (To_Atom ("space"), Set_Space_At'(others => <>));
                          Set_Quoted_String'(Subinterpreter => Quoted_SI));
      Result.Add_Command (To_Atom ("space"),
                          Set_Space_At'(Subinterpreter => Space_SI));
      Result.Add_Command (To_Atom ("tab-stop"), Set_Tab_Stop'(null record));
      Result.Add_Command (To_Atom ("width"), Set_Width'(null record));
      Result.Add_Command (To_Atom ("no-width"), Set_Width'(null record));

      Result.Add_Command (To_Atom ("extended-token"),
                          Set_Token'(Value => Extended_Token));
      Result.Add_Command (To_Atom ("no-token"),
520
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536
537
538
539

540
541
542
543
544
545
546
547
548
549
550
551
552
553

554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571

572
573
574
575
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
530
531
532
533
534
535
536

537
538
539
540
541
542
543
544
545
546
547
548

549
550
551
552
553
554
555
556
557
558
559
560
561
562

563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580

581
582
583
584
585
586
587
588
589
590
591
592

593
594
595
596
597
598
599
600







-
+











-
+













-
+

















-
+











-
+









   -------------------------
   -- Invididual Commands --
   -------------------------

   procedure Execute
     (Self : in out Set_Width;
     (Self : in Set_Width;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Self, Context, Name);
   begin
      State.Width := 0;
   end Execute;


   procedure Execute
     (Self : in out Set_Width;
     (Self : in Set_Width;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Self, Context);
      Has_Value : Boolean;
   begin
      Cmd.Next;
      Read_Screen_Offset (Cmd, State.Width, Has_Value);
   end Execute;


   procedure Execute
     (Self : in out Set_Tab_Stop;
     (Self : in Set_Tab_Stop;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Self, Context);
      Value : Screen_Offset := 0;
      Has_Value : Boolean;
   begin
      Cmd.Next;
      Read_Screen_Offset (Cmd, Value, Has_Value);
      if Has_Value and then Value /= 0 then
         State.Tab_Stop := Value;
      end if;
   end Execute;


   procedure Execute
     (Self : in out Set_Indentation;
     (Self : in Set_Indentation;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Self, Context, Name);
   begin
      State.Indentation := 0;
   end Execute;


   procedure Execute
     (Self : in out Set_Indentation;
     (Self : in Set_Indentation;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Self, Context);
      Has_Value : Boolean;
      Event : Events.Event;
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
635
636
637
638
639
640
641
642
643
644

645
646
647
648
649
650
651
652
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
618
619
620
621
622
623
624

625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641

642



643
644
645
646
647
648















649
650
651
652
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







-
+
+
+
+
+
+
+
+
+
+
+
+
+




-
+
-
-
-






-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+











-
+











-
+















-
+















-
+












-
+











-
+












-
+











-
+







            end;
         end if;
      end if;
   end Execute;


   procedure Execute
     (Self : in out Set_Newline;
     (Self : in Set_Newline;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class) is
   begin
      pragma Assert (not Self.Subinterpreter.Is_Empty);
      Cmd.Next;
      Self.Subinterpreter.Execute (Cmd, State, Context);
   end Execute;


   procedure Execute
     (Self : in Set_Space_At;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class) is
   begin
      if Self.Subinterpreter.Is_Empty then
      pragma Assert (not Self.Subinterpreter.Is_Empty);
         Add_Separator_Commands (Self.Subinterpreter, True, True);
         Add_Newline_Encoding_Commands (Self.Subinterpreter);
      end if;
      Cmd.Next;
      Self.Subinterpreter.Execute (Cmd, State, Context);
   end Execute;


   procedure Execute
     (Self : in out Set_Space_At;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class) is
   begin
      if Self.Subinterpreter.Is_Empty then
         Add_Separator_Commands (Self.Subinterpreter, True, False);
      end if;
      Cmd.Next;
      Self.Subinterpreter.Execute (Cmd, State, Context);
   end Execute;


   procedure Execute
     (Self : in out Set_Char_Encoding;
     (Self : in Set_Char_Encoding;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      State.Char_Encoding := Self.Value;
   end Execute;


   procedure Execute
     (Self : in out Set_Newline_Encoding;
     (Self : in Set_Newline_Encoding;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      State.Newline := Self.Value;
   end Execute;


   procedure Execute
     (Self : in out Set_Separator;
     (Self : in Set_Separator;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      if Self.Newline then
         State.Newline_At (Self.Before, Self.After) := Self.Value;
      else
         State.Space_At (Self.Before, Self.After) := Self.Value;
      end if;
   end Execute;


   procedure Execute
     (Self : in out Set_All_Separators;
     (Self : in Set_All_Separators;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      if Self.Newline then
         State.Newline_At := (others => (others => Self.Value));
      else
         State.Space_At := (others => (others => Self.Value));
      end if;
   end Execute;


   procedure Execute
     (Self : in out Set_All_Separators;
     (Self : in Set_All_Separators;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class)
   is
      Subinterpreter : Interpreters.Interpreter;
   begin
      Add_Separator_Commands (Subinterpreter, Self.Value, Self.Newline);
      Subinterpreter.Execute (Cmd, State, Context);
   end Execute;


   procedure Execute
     (Self : in out Set_Hex_Casing;
     (Self : in Set_Hex_Casing;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      State.Hex_Casing := Self.Value;
   end Execute;


   procedure Execute
     (Self : in out Set_Fallback;
     (Self : in Set_Fallback;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context);
   begin
      State.Fallback := Self.Value;
      Update_Casing (State.Hex_Casing, Name);
   end Execute;


   procedure Execute
     (Self : in out Set_Token;
     (Self : in Set_Token;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      State.Token := Self.Value;
   end Execute;


   procedure Execute
     (Self : in out Set_Token;
     (Self : in Set_Token;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Self, Context);
      Event : Events.Event;
   begin
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
811
812
813
814
815
816
817
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
811
812

813




814
815
816
817
818







-
+












-
+











-
+




-
+
-
-
-
-





            State.Token := No_Token;
         end if;
      end;
   end Execute;


   procedure Execute
     (Self : in out Set_Quoted_Escape;
     (Self : in Set_Quoted_Escape;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context);
   begin
      State.Quoted_Escape := Self.Value;
      Update_Casing (State.Hex_Casing, Name);
   end Execute;


   procedure Execute
     (Self : in out Set_Quoted;
     (Self : in Set_Quoted;
      State : in out Parameters;
      Context : in Boolean;
      Name : in Atom)
   is
      pragma Unreferenced (Context, Name);
   begin
      State.Quoted := Self.Value;
   end Execute;


   procedure Execute
     (Self : in out Set_Quoted_String;
     (Self : in Set_Quoted_String;
      State : in out Parameters;
      Context : in Boolean;
      Cmd : in out Lockable.Descriptor'Class) is
   begin
      if Self.Subinterpreter.Is_Empty then
      pragma Assert (not Self.Subinterpreter.Is_Empty);
         Add_Quoted_Commands (Self.Subinterpreter);
         Add_Quoted_Escape_Commands (Self.Subinterpreter);
      end if;

      Cmd.Next;
      Self.Subinterpreter.Execute (Cmd, State, Context);
   end Execute;

end Natools.S_Expressions.Printers.Pretty.Config;