Natools

Diff
Login

Differences From Artifact [d02b7babca]:

To Artifact [b2995c3780]:


10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34




























































































































































































































































































































































35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------




package body Natools.S_Expressions.Printers.Pretty.Config is

   procedure Read_Screen_Offset
     (Expression : in out Lockable.Descriptor'Class;
      Value : in out Screen_Offset;
      Has_Value : out Boolean);
      --  Decode a screen offset from a S-expression

   procedure Update_Casing
     (Casing : in out Encodings.Hex_Casing;
      Name : in Atom);

   function To_Atom (Value : in Screen_Offset) return Atom;
   function To_Atom (Before, After : in Entity) return Atom;

   function To_String (Value : in Entity) return String;































































































































































































































































































































































   ------------------------------
   -- Local Helper Subprograms --
   ------------------------------

   procedure Read_Screen_Offset
     (Expression : in out Lockable.Descriptor'Class;
      Value : in out Screen_Offset;
      Has_Value : out Boolean)
   is
      Result : Screen_Offset := 0;
   begin
      Has_Value := False;








>
>
>



|














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
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
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
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
396
397
398
399
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

with Natools.S_Expressions.Interpreter_Loop;
with Natools.S_Expressions.Printers.Pretty.Config.Commands;

package body Natools.S_Expressions.Printers.Pretty.Config is

   procedure Read_Screen_Offset
     (Expression : in Lockable.Descriptor'Class;
      Value : in out Screen_Offset;
      Has_Value : out Boolean);
      --  Decode a screen offset from a S-expression

   procedure Update_Casing
     (Casing : in out Encodings.Hex_Casing;
      Name : in Atom);

   function To_Atom (Value : in Screen_Offset) return Atom;
   function To_Atom (Before, After : in Entity) return Atom;

   function To_String (Value : in Entity) return String;


   procedure Main_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom);

   procedure Main_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class);

   procedure Newline_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom);

   procedure Newline_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class);

   procedure Newline_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      Param : in out Parameters);

   procedure Quoted_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom);

   procedure Quoted_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      Param : in out Parameters);

   procedure Separator_Execute
     (State : in out Entity_Separator;
      Value : in Boolean;
      Name : in Atom);

   procedure Separator_Execute
     (State : in out Entity_Separator;
      Value : in Boolean;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class);

   procedure Separator_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      State : in out Entity_Separator;
      Context : in Boolean);


   ------------------
   -- Interpreters --
   ------------------

   procedure Main_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom)
   is
      pragma Unreferenced (Context);
      Command : constant String := To_String (Name);
   begin
      case Commands.Main (Command) is
         when Commands.Set_Char_Encoding =>
            Param.Char_Encoding := Commands.To_Character_Encoding (Command);

         when Commands.Set_Fallback =>
            Param.Fallback := Commands.To_Atom_Encoding (Command);
            Update_Casing (Param.Hex_Casing, Name);

         when Commands.Set_Hex_Casing =>
            Param.Hex_Casing := Commands.To_Hex_Casing (Command);

         when Commands.Set_Indentation =>
            Param.Indentation := 0;

         when Commands.Set_Newline_Encoding =>
            Param.Newline := Commands.To_Newline_Encoding (Command);

         when Commands.Set_Quoted =>
            Param.Quoted := Commands.To_Quoted_Option (Command);

         when Commands.Set_Token =>
            Param.Token := Commands.To_Token_Option (Command);

         when Commands.Set_Width =>
            Param.Width := 0;

         when Commands.Set_Newline
           | Commands.Set_Quoted_String
           | Commands.Set_Space_At
           | Commands.Set_Tab_Stop
         =>
            --  Those commands are meaningless without argument
            null;
      end case;
   end Main_Execute;


   procedure Main_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Context);
      Command : constant String := To_String (Name);
   begin
      case Commands.Main (Command) is
         when Commands.Set_Indentation =>
            declare
               Has_Value : Boolean;
               Event : Events.Event;
            begin
               Read_Screen_Offset (Arguments, Param.Indentation, Has_Value);

               if Has_Value and then Param.Indentation /= 0 then
                  Arguments.Next (Event);

                  if Event = Events.Add_Atom then
                     declare
                        Unit : constant String
                          := To_String (Arguments.Current_Atom);
                        Last : Natural := Unit'Last;
                     begin
                        if Last > 0 and then Unit (Last) = 's' then
                           Last := Last - 1;
                        end if;

                        if Unit (Unit'First .. Last) = "tab" then
                           Param.Indent := Tabs;
                        elsif Unit (Unit'First .. Last) = "space" then
                           Param.Indent := Spaces;
                        elsif Unit (Unit'First .. Last) = "tabbed-space" then
                           Param.Indent := Tabs_And_Spaces;
                        end if;
                     end;
                  end if;
               end if;
            end;

         when Commands.Set_Newline =>
            Newline_Interpreter (Arguments, Param);

         when Commands.Set_Quoted_String =>
            Quoted_Interpreter (Arguments, Param);

         when Commands.Set_Space_At =>
            Separator_Interpreter (Arguments, Param.Space_At, True);

         when Commands.Set_Tab_Stop =>
            declare
               Value : Screen_Offset := 0;
               Has_Value : Boolean;
            begin
               Read_Screen_Offset (Arguments, Value, Has_Value);

               if Has_Value and then Value /= 0 then
                  Param.Tab_Stop := Value;
               end if;
            end;

         when Commands.Set_Token =>
            begin
               if Arguments.Current_Event = Events.Add_Atom then
                  Param.Token := Commands.To_Token_Option
                    (To_String (Arguments.Current_Atom));
               end if;
            exception
               when Constraint_Error => null;
            end;

         when Commands.Set_Width =>
            declare
               Has_Value : Boolean;
            begin
               Read_Screen_Offset (Arguments, Param.Width, Has_Value);
            end;

         when Commands.Set_Char_Encoding
           | Commands.Set_Fallback
           | Commands.Set_Hex_Casing
           | Commands.Set_Newline_Encoding
           | Commands.Set_Quoted
         =>
            --  These commands don't do anything with arguments
            null;
      end case;
   end Main_Execute;


   procedure Newline_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom)
   is
      pragma Unreferenced (Context);
      Command : constant String := To_String (Name);
   begin
      case Commands.Newline (Command) is
         when Commands.Set_Newline_Command_Encoding =>
            Param.Newline := Commands.To_Newline_Encoding (Command);
         when Commands.Set_Newline_Separator =>
            Separator_Execute (Param.Newline_At, True, Name);
      end case;
   end Newline_Execute;


   procedure Newline_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class)
   is
      pragma Unreferenced (Context);
      Command : constant String := To_String (Name);
   begin
      case Commands.Newline (Command) is
         when Commands.Set_Newline_Command_Encoding =>
            Param.Newline := Commands.To_Newline_Encoding (Command);
         when Commands.Set_Newline_Separator =>
            Separator_Execute (Param.Newline_At, True, Name, Arguments);
      end case;
   end Newline_Execute;


   procedure Quoted_Execute
     (Param : in out Parameters;
      Context : in Meaningless_Type;
      Name : in Atom)
   is
      pragma Unreferenced (Context);
      Command : constant String := To_String (Name);
   begin
      case Commands.Quoted_String (Command) is
         when Commands.Set_Quoted_Option =>
            Param.Quoted := Commands.To_Quoted_Option (Command);
         when Commands.Set_Quoted_Escape =>
            Param.Quoted_Escape := Commands.To_Quoted_Escape (Command);
            Update_Casing (Param.Hex_Casing, Name);
      end case;
   end Quoted_Execute;


   procedure Separator_Execute
     (State : in out Entity_Separator;
      Value : in Boolean;
      Name : in Atom) is
   begin
      case Commands.Separator (To_String (Name)) is
         when Commands.All_Separators =>
            State := (others => (others => Value));
         when Commands.No_Separators =>
            State := (others => (others => not Value));

         when Commands.Invert_Separators =>
            null;  --  Error, actually

         when Commands.Open_Open =>
            State (Opening, Opening) := Value;
         when Commands.Open_Atom =>
            State (Opening, Atom_Data) := Value;
         when Commands.Open_Close =>
            State (Opening, Closing) := Value;

         when Commands.Atom_Open =>
            State (Atom_Data, Opening) := Value;
         when Commands.Atom_Atom =>
            State (Atom_Data, Atom_Data) := Value;
         when Commands.Atom_Close =>
            State (Atom_Data, Closing) := Value;

         when Commands.Close_Open =>
            State (Closing, Opening) := Value;
         when Commands.Close_Atom =>
            State (Closing, Atom_Data) := Value;
         when Commands.Close_Close =>
            State (Closing, Closing) := Value;
      end case;
   end Separator_Execute;


   procedure Separator_Execute
     (State : in out Entity_Separator;
      Value : in Boolean;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class) is
   begin
      case Commands.Separator (To_String (Name)) is
         when Commands.Invert_Separators =>
            Separator_Interpreter (Arguments, State, not Value);

         when Commands.All_Separators
           | Commands.No_Separators
           | Commands.Open_Open
           | Commands.Open_Atom
           | Commands.Open_Close
           | Commands.Atom_Open
           | Commands.Atom_Atom
           | Commands.Atom_Close
           | Commands.Close_Open
           | Commands.Close_Atom
           | Commands.Close_Close
         =>
            Separator_Execute (State, Value, Name);
      end case;
   end Separator_Execute;



   procedure Main_Interpreter is new Interpreter_Loop
     (Parameters, Meaningless_Type, Main_Execute, Main_Execute);

   procedure Newline_Interpreter is new Interpreter_Loop
     (Parameters, Meaningless_Type, Newline_Execute, Newline_Execute);

   procedure Quoted_Interpreter is new Interpreter_Loop
     (Parameters, Meaningless_Type,
      Dispatch_Without_Argument => Quoted_Execute);

   procedure Interpreter is new Interpreter_Loop
     (Entity_Separator, Boolean, Separator_Execute, Separator_Execute);



   procedure Newline_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      Param : in out Parameters) is
   begin
      Newline_Interpreter (Expression, Param, Meaningless_Value);
   end Newline_Interpreter;

   procedure Quoted_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      Param : in out Parameters) is
   begin
      Quoted_Interpreter (Expression, Param, Meaningless_Value);
   end Quoted_Interpreter;

   procedure Separator_Interpreter
     (Expression : in out Lockable.Descriptor'Class;
      State : in out Entity_Separator;
      Context : in Boolean)
     renames Interpreter;



   ------------------------------
   -- Local Helper Subprograms --
   ------------------------------

   procedure Read_Screen_Offset
     (Expression : in Lockable.Descriptor'Class;
      Value : in out Screen_Offset;
      Has_Value : out Boolean)
   is
      Result : Screen_Offset := 0;
   begin
      Has_Value := False;

292
293
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
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
396
397
398
399
400
401
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
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
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
601
602
603
604
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
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
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
811
812
813
814
815
816
817
818
         when Verbatim    => Output.Append_Atom (To_Atom ("verbatim"));
      end case;
   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"),
                          Set_Token'(Value => No_Token));
      Result.Add_Command (To_Atom ("standard-token"),
                          Set_Token'(Value => Standard_Token));
      Result.Add_Command (To_Atom ("token"),
                          Set_Token'(Value => Standard_Token));

      Result.Add_Command (To_Atom ("no-quoted"),
                          Set_Quoted'(Value => No_Quoted));
      Result.Add_Command (To_Atom ("no-quoted-string"),
                          Set_Quoted'(Value => No_Quoted));
      Result.Add_Command (To_Atom ("quoted-when-shorter"),
                          Set_Quoted'(Value => When_Shorter));
      Result.Add_Command (To_Atom ("quoted-string-when-shorter"),
                          Set_Quoted'(Value => When_Shorter));
      Result.Add_Command (To_Atom ("single-line-quoted"),
                          Set_Quoted'(Value => Single_Line));
      Result.Add_Command (To_Atom ("single-line-quoted-string"),
                          Set_Quoted'(Value => Single_Line));

      Result.Add_Command (To_Atom ("base64"),
                          Set_Fallback'(Value => Base64));
      Result.Add_Command (To_Atom ("base-64"),
                          Set_Fallback'(Value => Base64));
      Result.Add_Command (To_Atom ("lower-hex"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("lower-hexa"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("hex"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("hexa"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("hexadecimal"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("upper-hex"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("upper-hexa"),
                          Set_Fallback'(Value => Hexadecimal));
      Result.Add_Command (To_Atom ("verbatim"),
                          Set_Fallback'(Value => Verbatim));

      Add_Char_Encoding_Commands (Result);
      Add_Hex_Casing_Commands (Result);
      Add_Newline_Encoding_Commands (Result);
      return Result;
   end Config_Interpreter;


   procedure Add_Char_Encoding_Commands
     (Interpreter : in out Interpreters.Interpreter) is
   begin
      Interpreter.Add_Command (To_Atom ("utf-8"),
                               Set_Char_Encoding'(Value => UTF_8));
      Interpreter.Add_Command (To_Atom ("UTF-8"),
                               Set_Char_Encoding'(Value => UTF_8));
      Interpreter.Add_Command (To_Atom ("utf8"),
                               Set_Char_Encoding'(Value => UTF_8));
      Interpreter.Add_Command (To_Atom ("UTF8"),
                               Set_Char_Encoding'(Value => UTF_8));
      Interpreter.Add_Command (To_Atom ("ascii"),
                               Set_Char_Encoding'(Value => ASCII));
      Interpreter.Add_Command (To_Atom ("ASCII"),
                               Set_Char_Encoding'(Value => ASCII));
      Interpreter.Add_Command (To_Atom ("latin-1"),
                               Set_Char_Encoding'(Value => Latin));
      Interpreter.Add_Command (To_Atom ("latin"),
                               Set_Char_Encoding'(Value => Latin));
      Interpreter.Add_Command (To_Atom ("iso-8859-1"),
                               Set_Char_Encoding'(Value => Latin));
      Interpreter.Add_Command (To_Atom ("ISO-8859-1"),
                               Set_Char_Encoding'(Value => Latin));
   end Add_Char_Encoding_Commands;


   procedure Add_Hex_Casing_Commands
     (Interpreter : in out Interpreters.Interpreter) is
   begin
      Interpreter.Add_Command (To_Atom ("upper"),
                               Set_Hex_Casing'(Value => Encodings.Upper));
      Interpreter.Add_Command (To_Atom ("upper-case"),
                               Set_Hex_Casing'(Value => Encodings.Upper));
      Interpreter.Add_Command (To_Atom ("lower"),
                               Set_Hex_Casing'(Value => Encodings.Lower));
      Interpreter.Add_Command (To_Atom ("lower-case"),
                               Set_Hex_Casing'(Value => Encodings.Lower));
   end Add_Hex_Casing_Commands;


   procedure Add_Quoted_Commands
     (Interpreter : in out Interpreters.Interpreter) is
   begin
      Interpreter.Add_Command (To_Atom ("never"),
                               Set_Quoted'(Value => No_Quoted));
      Interpreter.Add_Command (To_Atom ("single-line"),
                               Set_Quoted'(Value => Single_Line));
      Interpreter.Add_Command (To_Atom ("when-shorter"),
                               Set_Quoted'(Value => When_Shorter));
   end Add_Quoted_Commands;


   procedure Add_Quoted_Escape_Commands
     (Interpreter : in out Interpreters.Interpreter) is
   begin
      Interpreter.Add_Command (To_Atom ("octal"),
                               Set_Quoted_Escape'(Value => Octal_Escape));
      Interpreter.Add_Command (To_Atom ("hex"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("hexa"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("hexadecimal"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("lower-hex"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("lower-hexa"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("upper-hex"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Interpreter.Add_Command (To_Atom ("upper-hexa"),
                               Set_Quoted_Escape'(Value => Hex_Escape));
      Add_Hex_Casing_Commands (Interpreter);
   end Add_Quoted_Escape_Commands;


   procedure Add_Newline_Encoding_Commands
     (Interpreter : in out Interpreters.Interpreter) is
   begin
      Interpreter.Add_Command (To_Atom ("cr"),
                               Set_Newline_Encoding'(Value => CR));
      Interpreter.Add_Command (To_Atom ("CR"),
                               Set_Newline_Encoding'(Value => CR));
      Interpreter.Add_Command (To_Atom ("lf"),
                               Set_Newline_Encoding'(Value => LF));
      Interpreter.Add_Command (To_Atom ("LF"),
                               Set_Newline_Encoding'(Value => LF));
      Interpreter.Add_Command (To_Atom ("CRLF"),
                               Set_Newline_Encoding'(Value => CR_LF));
      Interpreter.Add_Command (To_Atom ("CR-LF"),
                               Set_Newline_Encoding'(Value => CR_LF));
      Interpreter.Add_Command (To_Atom ("crlf"),
                               Set_Newline_Encoding'(Value => CR_LF));
      Interpreter.Add_Command (To_Atom ("cr-lf"),
                               Set_Newline_Encoding'(Value => CR_LF));
      Interpreter.Add_Command (To_Atom ("lf-cr"),
                               Set_Newline_Encoding'(Value => LF_CR));
      Interpreter.Add_Command (To_Atom ("lfcr"),
                               Set_Newline_Encoding'(Value => LF_CR));
      Interpreter.Add_Command (To_Atom ("LF-CR"),
                               Set_Newline_Encoding'(Value => LF_CR));
      Interpreter.Add_Command (To_Atom ("LFCR"),
                               Set_Newline_Encoding'(Value => LF_CR));
   end Add_Newline_Encoding_Commands;


   procedure Add_Separator_Commands
     (Interpreter : in out Interpreters.Interpreter;
      Value : in Boolean;
      Newline : in Boolean) is
   begin
      for Before in Entity loop
         for After in Entity loop
            Interpreter.Add_Command
              (To_Atom (Before, After),
               Set_Separator'(Before, After, Value, Newline));
         end loop;
      end loop;

      Interpreter.Add_Command
        (To_Atom ("all"),
         Set_All_Separators'(Value, Newline));
      Interpreter.Add_Command
        (To_Atom ("none"),
         Set_All_Separators'(not Value, Newline));
      Interpreter.Add_Command
        (To_Atom ("not"),
         Set_All_Separators'(not Value, Newline));
   end Add_Separator_Commands;



   -------------------------
   -- 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;
   begin
      Cmd.Next (Event);
      Read_Screen_Offset (Cmd, State.Indentation, Has_Value);

      if Has_Value and State.Indentation /= 0 then
         Cmd.Next (Event);
         if Event = Events.Add_Atom then
            declare
               Keyword : constant String := To_String (Cmd.Current_Atom);
            begin
               if Keyword = "tab" or Keyword = "tabs" then
                  State.Indent := Tabs;
               elsif Keyword = "space" or Keyword = "spaces" then
                  State.Indent := Spaces;
               elsif Keyword = "tabbed-space" or Keyword = "tabbed-spaces" then
                  State.Indent := Tabs_And_Spaces;
               end if;
            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
      Cmd.Next (Event);
      if Event /= Events.Add_Atom then
         return;
      end if;

      declare
         Token : constant String := To_String (Cmd.Current_Atom);
      begin
         if Token = "standard" then
            State.Token := Standard_Token;
         elsif Token = "extended" then
            State.Token := Extended_Token;
         elsif Token = "never" or Token = "none" or Token = "no" then
            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;







<
<
<
<
<
<
<
<
<
<
<


|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

643
644
645
646
647
648
649











650
651
652
653
654























































































































































































































































































































































































































































































































655
         when Verbatim    => Output.Append_Atom (To_Atom ("verbatim"));
      end case;
   end Print;


   procedure Update
     (Param : in out Parameters;











      Expression : in out Lockable.Descriptor'Class) is
   begin
      Main_Interpreter (Expression, Param, Meaningless_Value);
   end Update;
























































































































































































































































































































































































































































































































end Natools.S_Expressions.Printers.Pretty.Config;