Overview
Comment: | s_expressions-printers-pretty-config: update to match the new read-only interpreters |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e3c30c2e3d621fc51d9ffdc80fd1f4d5 |
User & Date: | nat on 2014-05-15 21:26:23 |
Other Links: | manifest | tags |
Context
2014-05-16
| ||
17:48 | s_expressions-interpreters: add constructor functions to make possible library-level constants check-in: bbcfe6dddf user: nat tags: trunk | |
2014-05-15
| ||
21:26 | s_expressions-printers-pretty-config: update to match the new read-only interpreters check-in: e3c30c2e3d user: nat tags: trunk | |
2014-05-14
| ||
18:33 | s_expressions-interpreters: make commands and interpreters read-only during execution check-in: 07db27cc2f user: nat tags: trunk | |
Changes
Modified src/natools-s_expressions-printers-pretty-config.adb from [4aefa3cb01] to [d02b7babca].
︙ | ︙ | |||
294 295 296 297 298 299 300 | end Print; procedure Update (Param : in out Parameters; Expression : in out Lockable.Descriptor'Class) is | | | | > > > > > > > > | | > | | > | 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 : constant Interpreters.Interpreter := Config_Interpreter; begin Update (Interpreter, Param, Expression); end Update; procedure Update (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 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'(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'(Subinterpreter => Newline_SI)); Result.Add_Command (To_Atom ("quoted"), 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 | ------------------------- -- Invididual Commands -- ------------------------- procedure Execute | | | | | | | 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 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 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 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 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 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 | end; end if; end if; end Execute; procedure Execute | | > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < | | | | | | | | | | 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 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 pragma Assert (not Self.Subinterpreter.Is_Empty); Cmd.Next; Self.Subinterpreter.Execute (Cmd, State, Context); end Execute; procedure Execute (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 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 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 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 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 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 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 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 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 | State.Token := No_Token; end if; end; end Execute; procedure Execute | | | | | < < < < | 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 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 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 Set_Quoted_String; 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; end Natools.S_Expressions.Printers.Pretty.Config; |
Modified src/natools-s_expressions-printers-pretty-config.ads from [497cc9a6a7] to [fbe63e1d08].
︙ | ︙ | |||
40 41 42 43 44 45 46 | procedure Update (Param : in out Parameters; Expression : in out Lockable.Descriptor'Class); -- Update parameters using a temporary interpreter procedure Update | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | procedure Update (Param : in out Parameters; Expression : in out Lockable.Descriptor'Class); -- Update parameters using a temporary interpreter procedure Update (Interpreter : in Interpreters.Interpreter; Param : in out Parameters; Expression : in out Lockable.Descriptor'Class); -- Update parameters using Interpreter (wrapper around its Execute) procedure Print (Output : in out Printers.Printer'Class; Param : in Parameters); |
︙ | ︙ | |||
73 74 75 76 77 78 79 | (Interpreter : in out Interpreters.Interpreter; Value : in Boolean; Newline : in Boolean); -- Inject commands into subinterpreter type Set_Width is new Interpreters.Command with null record; procedure Execute | | | | | | | | | | | | | | | | | | | | | 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 149 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 | (Interpreter : in out Interpreters.Interpreter; Value : in Boolean; Newline : in Boolean); -- Inject commands into subinterpreter type Set_Width is new Interpreters.Command with null record; procedure Execute (Self : in Set_Width; State : in out Parameters; Context : in Boolean; Name : in Atom); procedure Execute (Self : in Set_Width; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Space_At is new Interpreters.Command with record Subinterpreter : Interpreters.Interpreter; end record; procedure Execute (Self : in Set_Space_At; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Tab_Stop is new Interpreters.Command with null record; procedure Execute (Self : in Set_Tab_Stop; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Indentation is new Interpreters.Command with null record; procedure Execute (Self : in Set_Indentation; State : in out Parameters; Context : in Boolean; Name : in Atom); procedure Execute (Self : in Set_Indentation; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Quoted is new Interpreters.Command with record Value : Quoted_Option; end record; procedure Execute (Self : in Set_Quoted; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Token is new Interpreters.Command with record Value : Token_Option; end record; procedure Execute (Self : in Set_Token; State : in out Parameters; Context : in Boolean; Name : in Atom); procedure Execute (Self : in Set_Token; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Hex_Casing is new Interpreters.Command with record Value : Encodings.Hex_Casing; end record; procedure Execute (Self : in Set_Hex_Casing; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Quoted_Escape is new Interpreters.Command with record Value : Quoted_Escape_Type; end record; procedure Execute (Self : in Set_Quoted_Escape; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Char_Encoding is new Interpreters.Command with record Value : Character_Encoding; end record; procedure Execute (Self : in Set_Char_Encoding; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Fallback is new Interpreters.Command with record Value : Atom_Encoding; end record; procedure Execute (Self : in Set_Fallback; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Newline is new Interpreters.Command with record Subinterpreter : Interpreters.Interpreter; end record; procedure Execute (Self : in Set_Newline; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Newline_Encoding is new Interpreters.Command with record Value : Newline_Encoding; end record; procedure Execute (Self : in Set_Newline_Encoding; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_Separator is new Interpreters.Command with record Before : Entity; After : Entity; Value : Boolean; Newline : Boolean; end record; procedure Execute (Self : in Set_Separator; State : in out Parameters; Context : in Boolean; Name : in Atom); type Set_All_Separators is new Interpreters.Command with record Value : Boolean; Newline : Boolean; end record; procedure Execute (Self : in Set_All_Separators; State : in out Parameters; Context : in Boolean; Name : in Atom); procedure Execute (Self : in Set_All_Separators; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); type Set_Quoted_String is new Interpreters.Command with record Subinterpreter : Interpreters.Interpreter; end record; procedure Execute (Self : in Set_Quoted_String; State : in out Parameters; Context : in Boolean; Cmd : in out Lockable.Descriptor'Class); end Natools.S_Expressions.Printers.Pretty.Config; |