File: pprgstmt.w

package info (click to toggle)
3dldf 2.0.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,508 kB
  • ctags: 7
  • sloc: makefile: 892; sh: 117; cpp: 5
file content (1185 lines) | stat: -rw-r--r-- 29,273 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
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
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
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
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
903
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
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
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
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
@q pprgstmt.w @>
@q Created by Laurence Finston Tue Sep  7 12:24:12 CEST 2004 @>
     
@q * (0) Copyright and License.@>

@q This file is part of GNU 3DLDF, a package for three-dimensional drawing. @>
@q Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @>
@q 2011, 2012, 2013 The Free Software Foundation @>

@q GNU 3DLDF is free software; you can redistribute it and/or modify @>
@q it under the terms of the GNU General Public License as published by @>
@q the Free Software Foundation; either version 3 of the License, or @>
@q (at your option) any later version. @>

@q GNU 3DLDF is distributed in the hope that it will be useful, @>
@q but WITHOUT ANY WARRANTY; without even the implied warranty of @>
@q MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the @>
@q GNU General Public License for more details. @>

@q You should have received a copy of the GNU General Public License @>
@q along with GNU 3DLDF; if not, write to the Free Software @>
@q Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA @>

@q GNU 3DLDF is a GNU package.  @>
@q It is part of the GNU Project of the  @>
@q Free Software Foundation @>
@q and is published under the GNU General Public License. @>
@q See the website http://www.gnu.org @>
@q for more information.   @>
@q GNU 3DLDF is available for downloading from @>
@q http://www.gnu.org/software/3dldf/LDF.html. @>

@q (``@@'' stands for a single at-sign in the following paragraph.) @>

@q Please send bug reports to Laurence.Finston@@gmx.de @>
@q The mailing list help-3dldf@@gnu.org is available for people to @>
@q ask other users for help.  @>
@q The mailing list info-3dldf@@gnu.org is for sending @>
@q announcements to users. To subscribe to these mailing lists, send an @>
@q email with ``subscribe <email-address>'' as the subject.  @>

@q The author can be contacted at: @>

@q Laurence D. Finston                 @> 
@q c/o Free Software Foundation, Inc.  @>
@q 51 Franklin St, Fifth Floor         @> 
@q Boston, MA  02110-1301              @>
@q USA                                 @>

@q Laurence.Finston@@gmx.de (@@ stands for a single ``at'' sign.)@>



@q ** (2) Common declarations for rules.@>
@*1 Common declarations for rules.
It would be nice to declare the variables in this section as local variables
within |yyparse()|, but I don't know of any way to do that.
\initials{LDF 2004.04.16.}


I also wanted |out_stream_metapost| to be a plain |ostream| rather than an
|ostream*|, but I couldn't get this to work.  I believe it will only be needed
for debugging purposes, because real output should be performed by
|beginfig()|, |endfig()|, |Picture::output()|, and other functions.
\initials{LDF 2004.04.16.}

@q *** (3) LOG.@>

\LOG
\initials{LDF 2004.04.16.}  
Added this section.

\initials{LDF 2004.04.22.}
Added |int status| and |using namespace Scan_Parse|.

\initials{LDF 2004.06.30.}
Added |string rule_name_string|.

\initials{LDF 2004.07.03.}
Added |Thread_Info_Type* thread_info|.

\initials{LDF 2004.07.05.}
Added |stringstream cerr_strm|.

\initials{LDF 2004.07.19.}
@:??@> ?? For some reason, |Thread_Info_Type::get_thread_info()| doesn't seem to
work here.  I've now put a pointer to |Thread_Info_Type| onto |Scanner_Type|
instead.  I think this is better anyway, but I would like to know why the other
way didn't work.  It seems as if |yyparse()| is not in the scope of the
thread-specific data, but this shouldn't be the case.

\initials{LDF 2004.07.21.}
Now declaring and initializing |string thread_name| for use in error and 
help messages and debugging output. 

\initials{LDF 2004.07.21.}
Now declaring and initializing |bool stop_value|.

\initials{LDF 2004.09.09.}
@:BUG FIX@> BUG FIX: 
Now testing |HAVE_PTHREAD_H|, |scanner_node->run_state.multithread_input|, 
and |scanner_node->run_state.multithread_output| when setting |thread_name|.

\initials{LDF 2004.09.12.}
Added |stringstream location_strm|.

\initials{LDF 2004.09.13.}
@:KLUDGE@> KLUDGE: 
Now setting |stop_value| to |false| if 
|scanner_node->in->type == Io_Struct::STDIN_TYPE|.  The problem is that the 
``\<RETURNS>'' typed by the user are read by |sub_yylex()|, which can cause
old input characters that haven't been processed yet to be overwritten.

\initials{LDF 2004.09.13.}
If the user is typing input in line-by-line, then we don't really need to stop.
However, I'd prefer to find a better solution.  Perhaps the input characters
should be read into a buffer.  

\initials{LDF 2004.09.22.}
Removed |string rule_name_string|.

\initials{LDF 2004.10.09.}
Added |bool warning_stop_value|.
\ENDLOG 

@q **** (4) End of LOG.@>

@q *** (3) Code.@> 

@<Common declarations for rules@>=

   Scanner_Node scanner_node = static_cast<Scanner_Node>(parameter);

   ostream* out_stream_metapost
      = scanner_node->out[Run_State::METAPOST]->stream_ptr;


   bool error_stop_value = (      scanner_node->run_state.error_stop_mode
                         == Run_State::STOPPING
                      && scanner_node->in->type != Io_Struct::STDIN_TYPE)
                      
                      ? true : false;

   bool warning_stop_value = (      scanner_node->run_state.warning_stop_mode
                         == Run_State::STOPPING
                      && scanner_node->in->type != Io_Struct::STDIN_TYPE)
                      
                      ? true : false;



   Id_Map_Entry_Node entry;

   int status;

   using namespace Scan_Parse;

   stringstream cerr_strm;

   stringstream location_strm;

@q *** (3).@> 
@
\LOG
@:BUG FIX@> BUG FIX:  Now checking 
that |scanner_node != 0 && scanner_node->thread_info != static_cast<Thread_Info_Type*>(0)| before 
setting |thread_name = scanner_node->thread_info->name|.
\ENDLOG 

@<Common declarations for rules@>=

   string thread_name;

#ifdef HAVE_PTHREAD_H  
   if (   scanner_node != static_cast<Scanner_Node>(0) 
       && scanner_node->thread_info != static_cast<Thread_Info_Type*>(0)
       && (   scanner_node->run_state.multithread_input 
           || scanner_node->run_state.multithread_output))      

      thread_name = scanner_node->thread_info->name;

#else /* |HAVE_PTHREAD_H| is undefined.  */@; 

   if (0)  /* Dummy conditional.  */
      ;

#endif /* |HAVE_PTHREAD_H| is undefined.  */@; 

   else  /* Threads not available or not using them.  */

      thread_name = "";

@q *** (3).@> 
@
@<Common declarations for rules@>=

#if DEBUG_COMPILE
   bool DEBUG = false;
#endif /* |DEBUG_COMPILE|  */@; 


@q ** (2) program.  Start symbol.  @>
@q ** (2) program: statement_list END  @>
@*1 \program> \statement list> \.{END}.
\initials{LDF Undated.}

\syntax{program: statement_list END}

\LOG
\initials{LDF 2004.07.09.}
Added |Thread_Info_Type* t| and |pthread_t tid| for debugging.

\initials{LDF 2004.07.16.}
No longer closing the input and output streams.  
This wasn't thread-safe.  They are now closed in the destructors.

\initials{LDF 2004.07.21.}
Now using |Scan_Parse::log_message()|.

\initials{LDF 2004.09.13.}
Added code for handling unmatched |begingroup| commands in the input.  The
excess |Id_Map_Nodes| are deleted.
\ENDLOG 

@f program non_terminal_symbol

@q *** (3) Definition.  @>

@<Define rules@>=

@=program: statement_list END@>
{

 @<Common declarations for rules@>@;

#if DEBUG_COMPILE
 DEBUG = false; /* |true| */ @; 
 if (DEBUG)
   {
     cerr_strm << thread_name << "*** Parser: "
               << "`program --> statement_list END'.";
      
     log_message(cerr_strm);
     cerr_message(cerr_strm); 
     cerr_strm.str("");
   }
#endif /* |DEBUG_COMPILE|  */

@q **** (4) Delete all of the |Input_Struct| pointers on |scanner_node| @>
@q **** (4) if we're using single-threaded input and inclusion.@>

@ Delete all of the |Input_Struct| pointers on |scanner_node|
if we're using single-threaded input and inclusion.
\initials{LDF 2004.09.30.}

\LOG
\initials{LDF 2004.09.30.}
Added this section.
\ENDLOG

@<Define rules@>=


  if (   scanner_node->in->up != static_cast<Input_Struct*>(0)
      && !(   scanner_node->run_state.multithread_input
           || scanner_node->run_state.multithread_include))
      
    {
      Input_Struct* up = scanner_node->in->up;

      while (up != static_cast<Input_Struct*>(0))
        {
          delete scanner_node->in;
          scanner_node->in = up;
          up = scanner_node->in->up;
        }




      delete scanner_node->in;
      scanner_node->in = 0;
    }

@q **** (4) Remove excess |Id_Map_Nodes|.  @>
@ Remove excess |Id_Map_Nodes|.  They will only exist if there were 
unmatched |begingroup| commands in the input.
\initials{LDF 2004.09.13.}

\LOG
\initials{LDF 2004.09.13.}
Added this section.
\ENDLOG 

@<Define rules@>=

  if (scanner_node->group_ctr > 0)
    {

      cerr_strm << thread_name << "WARNING! In `yyparse()',"
                << endl << " rule `program --> statement_list END':"
                << endl 
                << scanner_node->group_ctr 
                << " unmatched `begingroup' commands."
                << endl << "Deleting excess `Id_Map_Nodes' and "
                << "continuing.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm, error_stop_value); 
      cerr_strm.str("");
      
    } /* |if (scanner_node->group_ctr > 0)|  */


 Id_Map_Node id_map_node = 0; 

 while (scanner_node->group_ctr > 0)
   {
     id_map_node = scanner_node->id_map_node;
     scanner_node->id_map_node = id_map_node->up;
     id_map_node->up = 0;
     delete id_map_node;
     id_map_node = 0;
     scanner_node->group_ctr--;

   } /* |while (scanner_node->group_ctr > 0)|  */

@q **** (4) Exit |yyparse()| with return value 0.@>

@ Exit |yyparse()| with return value 0.
\initials{LDF 2004.09.13.}

@<Define rules@>=

#if DEBUG_COMPILE
   if (DEBUG)
     {
       cerr_strm << thread_name << "In `yyparse()',"
                << endl << " rule `program --> statement_list END':"
                << endl << "`yyparse()' returning 0.";

       log_message(cerr_strm);
       cerr_message(cerr_strm);
       cerr_strm.str("");
     }
#endif /* |DEBUG_COMPILE|  */@; 

@q #define DEBUG_COMPILE 0 @>

  return 0;

};

@q ** (2) Statements.   @>
@*1 Statements.

@q *** (3) statement_list.   @>
@ \statement\_list>.  


@f statement_list non_terminal_symbol

@q **** (4) statement_list --> /* Empty  */.@>   
@*3 \statement\_list> $\longrightarrow$ \.{EMPTY}. 
\initials{LDF 2004.10.25.}

\syntax{statement_list: /* EMPTY */}

@<Define rules@>=
@=statement_list: /* EMPTY */@>@/
;

@q **** (4) statement_list --> statement_list statement.@>   
@*3 \statement\_list> $\longrightarrow$ \statement\_list>
\statement>.
\initials{LDF 2004.10.25.}

@<Define rules@>=
@=statement_list: statement_list  statement@>
{



#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true| */ @;   
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: statement_list --> statement_list "
                << "statement.";

      log_message(cerr_strm); 
      cerr_message(cerr_strm); 
      cerr_strm.str(""); 
      
    }
#endif /* |DEBUG_COMPILE|  */

};

@q *** (3) statement.@>
@*2 \statement>.  

|SEMI_COLON| appears at the end of each of the token lists in all of the rules
for |statement|.  This makes it possible to use {\it left recursion\/}%
%
\fnote{``Any kind of sequence can be defined using either left recursion or
right recursion, but you should always use left recursion, because it
can parse a sequence of any number of elements with bounded stack
space.''
Donnelly, Charles, and Richard Stallman. 
{\it Bison.  The YACC-compatible Parser Generator}, p.~28.}
%
in the
non-empty rule for |statement_list|.
This differs from Metafont's grammar, where the semi-colon is part of the 
$\langle {\rm statement\ list}\rangle$ rule, which uses right recursion.
%
\fnote{Knuth, {\it The METAFONTbook}, p.~217.}
%
$$\langle {\rm statement\ list}\rangle \longrightarrow \langle{\rm empty}
\rangle\ \vert\ \langle{\rm statement}\rangle {\ \tt ;\ }
\langle {\rm statement\ list} \rangle$$

@f statement non_terminal_symbol
@<Define rules@>= 

@q **** (4) statement --> SEMI_COLON.  @>
@ \statement> $\longrightarrow$ \.{SEMI\_COLON}.
This rule makes extra semi-colons valid input.
\initials{LDF 2004.04.23.}

\LOG
\initials{LDF 2004.04.23.}  
Added this rule.   
\ENDLOG 

@<Define rules@>=
@=statement: SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true| */ @; 
  if (DEBUG) 
    {
      cerr_strm << thread_name 
                << "*** Parser: statement --> SEMI_COLON.";

      log_message(cerr_strm); 
      cerr_message(cerr_strm); 
      cerr_strm.str(""); 
    }
#endif /* |DEBUG_COMPILE|  */

};


@q **** (4) statement --> END_INPUT.@>
@*3  \statement> $\longrightarrow$ \.{END\_INPUT}.

\LOG
\initials{LDF 2004.10.01.}
Added this rule.
\ENDLOG

@q ***** (5) Definition.@> 

@
@<Define rules@>=
  
@=statement: END_INPUT@>@/

{

  @<Common declarations for rules@>@; 

#if DEBUG_COMPILE
  DEBUG = false; /* |true| */ @; 
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> END_INPUT'.";

      log_message(cerr_strm); 
      cerr_message(cerr_strm); 
      cerr_strm.str(""); 
    }
#endif /* |DEBUG_COMPILE|  */@;


  Int_Void_Ptr_Bool end_ivp(END, 0, false);


@q ****** (6) Using multithreaded input and/or multithreaded inclusion.@>   

@ Using multithreaded input and/or multithreaded inclusion.
\initials{LDF 2004.10.01.}

@<Define rules@>=

  if (   scanner_node->run_state.multithread_input 
      || scanner_node->run_state.multithread_include)

    {

#if DEBUG_COMPILE
      if (DEBUG)
        {
          cerr_strm << thread_name 
                    << "WARNING! In `yyparse()', rule `statement --> "
                    << "END_INPUT':"
                    << endl 
                    << "`end_input' shouldn't be used when "
                    << "multithreaded input and/or inclusion"
                    << endl
                    << "is enabled. Will treat `end_input' as "
                    << "though it were `end' and continue.";
                
          log_message(cerr_strm); 
          cerr_message(cerr_strm, error_stop_value); 
          cerr_strm.str("");           
        }
#endif /* |DEBUG_COMPILE|  */@; 
 
      scanner_node->rescan_stack.push(end_ivp);

    } /* |if (   scanner_node->run_state.multithread_input 
              || scanner_node->run_state.multithread_include)|  */
    

@q ****** (6) Using single-threaded input and inclusion.@>   

@ Using single-threaded input and inclusion.
\initials{LDF 2004.10.01.}

@<Define rules@>=

  
  else /* |!(   scanner_node->run_state.multithread_input 
             || scanner_node->run_state.multithread_include)|  */
    {

      
@q ******* (7) |scanner_node->in->up != 0|.       @> 
@q ******* (7) Will call |scanner_node->pop_in()|.@> 

@ |scanner_node->in->up != 0|.  Will call |scanner_node->pop_in()|. 
\initials{LDF 2004.10.01.}

@<Define rules@>=
   
  if (scanner_node->in->up)
    {

#if DEBUG_COMPILE
      if (DEBUG)
        {
          cerr_strm << thread_name 
                    << "In `yyparse()', rule `statement --> "
                    << "END_INPUT':"
                    << endl 
                    << "Using single-threaded input and inclusion "
                    << "and `scanner_node->in->up' != 0."
                    << endl 
                    << "Calling `scanner_node->pop_in()'.";
          
          log_message(cerr_strm); 
          cerr_message(cerr_strm); 
          cerr_strm.str("");           
        }
#endif /* |DEBUG_COMPILE|  */@; 


      status = scanner_node->pop_in();


@q ******** (8) Error handling:  |scanner_node->pop_in()| failed.@> 

@ Error handling:  |scanner_node->pop_in()| failed.
\initials{LDF 2004.10.01.}

@<Define rules@>=

  if (status != 0)
    {

      cerr_strm << thread_name 
                << "ERROR! In `yyparse()', rule `statement --> "
                << "END_INPUT':"
                << endl 
                << "`scanner_node->pop_in()' failed. "
                << "Will treat `end_input' as though it were `end' "
                << "and try to continue.";

      log_message(cerr_strm);
      cerr_message(cerr_strm, error_stop_value);
      cerr_strm.str("");
      
      scanner_node->rescan_stack.push(end_ivp);

    }  /* |if (status != 0)|  */


@q ******** (8) |scanner_node->pop_in()| succeeded.@> 
@ |scanner_node->pop_in()| succeeded.
\initials{LDF 2004.10.01.}

@<Define rules@>=

   else /* |status == 0|  */
      {
#if DEBUG_COMPILE
          if (DEBUG) 
             {

                 cerr_strm << thread_name 
                           << "In `yyparse()', rule `statement --> "
                           << "END_INPUT':"
                           << endl 
                           << "`scanner_node->pop_in()' succeeded.";


                 log_message(cerr_strm);
                 cerr_message(cerr_strm);
                 cerr_strm.str("");
      
             }      
#endif /* |DEBUG_COMPILE|  */@; 

    scanner_node->set_first_call_yylex(true);

  } /* |else| (|status == 0|)  */

@q ******** (8).@> 


    } /* |if (scanner_node->in->up)|  */
  
  

@q ******* (7) |scanner_node->in->up == 0|.       @> 
@q ******* (7) Will push |END| onto |scanner_node->rescan_stack|.@> 

@ |scanner_node->in->up == 0|. 
Will push |END| onto |scanner_node->rescan_stack|. 
\initials{LDF 2004.10.01.}

@<Define rules@>=

  else  /* |scanner_node->in->up == 0|  */
    {

#if DEBUG_COMPILE
      if (DEBUG)
        {
          cerr_strm << thread_name 
                    << "In `yyparse()', rule `statement --> "
                    << "END_INPUT':"
                    << endl 
                    << "`scanner_node->in->up' == 0. "
                    << "Will treat `end_input' as though it were `end'.";

          log_message(cerr_strm);
          cerr_message(cerr_strm);
          cerr_strm.str("");


        }
#endif /* |DEBUG_COMPILE|  */@; 
 
      
      scanner_node->rescan_stack.push(end_ivp);

    }  /* |else| (|scanner_node->in->up == 0|)  */



@q ******* (7) End of single-threaded input and inclusion case.@> 

@ End of single-threaded input and inclusion case.
\initials{LDF 2004.10.01.}

@<Define rules@>=

    }    /* |else| (|!(   scanner_node->run_state.multithread_input 
                       || scanner_node->run_state.multithread_include)|)  */

@q ****** (6) Exit rule.@>   

@ Exit rule.
\initials{LDF 2004.10.01.}

@<Define rules@>=

};

@q **** (4) statement --> equation SEMI_COLON.  @>

@ \statement> $\longrightarrow$ \equation>  \.{SEMI\_COLON}.
\initials{LDF Undated.}

\LOG
\initials{LDF 2005.12.09.}
Now including this rule in |@<Garbage@>|.
\ENDLOG


@<Garbage@>=
@=statement:  equation SEMI_COLON@>
;

@q **** (4) statement --> declaration SEMI_COLON.@>
@*3 \statement> $\longrightarrow$ \declaration> \.{SEMI\_COLON}.
\initials{LDF 2004.10.01.}

\LOG
\initials{LDF 2004.10.01.}
Made debugging output thread-safe.
\ENDLOG 

@<Define rules@>=

@=statement:  declaration SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> declaration SEMI_COLON'.";

      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");

    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> assignment SEMI_COLON.  @>
@*3 \statement> $\longrightarrow$ \assignment> \.{SEMI\_COLON}.
\initials{LDF 2004.10.01.}

\LOG
\initials{LDF 2004.10.01.}
Made debugging output thread-safe.
\ENDLOG 


@<Define rules@>=


@=statement:  assignment SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> assignment SEMI_COLON'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> operation_assignment SEMI_COLON.@>
@*3 \statement> $\longrightarrow$ \operation assignment> 
\.{SEMI\_COLON}.
\initials{LDF 2004.11.05.}

\LOG
\initials{LDF 2004.11.05.}
Added this rule.
\ENDLOG

@<Define rules@>=

@=statement: operation_assignment SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> "
                << "operation_assignment SEMI_COLON'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> macro_definition.@>
@*3 \statement> $\longrightarrow$ \macro definition>.
\initials{LDF 2004.12.29.}

\LOG
\initials{LDF 2004.12.29.}
Added this rule.
\ENDLOG

@<Define rules@>=

@=statement: macro_definition@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG)
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> "
                << "macro_definition'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};



@q **** (4) statement --> command SEMI_COLON.  @>
@ \statement> $\longrightarrow$ \command>  \.{SEMI\_COLON}.


\LOG
\initials{LDF 2004.06.02.}  
Added this rule.

\initials{LDF 2004.10.01.}
Made debugging output thread-safe.
\ENDLOG 

@<Define rules@>=

@=statement: command SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG) 
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> command SEMI_COLON'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");

    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> conditional@>
@ \statement> $\longrightarrow$ \conditional>.

\LOG
\initials{LDF 2004.09.10.}  
Added this rule.
\ENDLOG 

@<Define rules@>=

@=statement: conditional@>@/
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG) 
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> conditional'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> loop@>
@ \statement> $\longrightarrow$ \loop>.

\LOG
\initials{LDF 2004.09.12.}  
Added this rule.
\ENDLOG 

@<Define rules@>=

@=statement: loop@>@/
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG) 
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> loop'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> macro_call@>
@ \statement> $\longrightarrow$ \macro call>.

\LOG
\initials{LDF 2004.12.22.}
Added this rule.

\initials{LDF 2004.12.29.}
Changed |defun_call| to |macro_call|.
\ENDLOG 

@<Define rules@>=

@=statement: macro_call@>@/
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG) 
    {
      cerr_strm << thread_name 
                << "*** Parser: `statement --> macro_call'.";
      
      log_message(cerr_strm);
      cerr_message(cerr_strm);
      cerr_strm.str("");
    }
#endif /* |DEBUG_COMPILE|  */

};

@q **** (4) statement --> let_statement SEMI_COLON.@>

@*3 \statement> $\longrightarrow$ \let statement>  \.{SEMI\_COLON}.
\initials{LDF 2005.01.25.}

\LOG
\initials{LDF 2005.01.25.}
Added this rule.
\ENDLOG

@<Define rules@>=
@=statement:  let_statement SEMI_COLON@>
{

#if DEBUG_COMPILE 
  @<Common declarations for rules@>@;
#endif

#if DEBUG_COMPILE
  DEBUG = false; /* |true|  */
  if (DEBUG)
     {
         cerr_strm << thread_name 
                   << "*** Parser:  `statement --> let_statement SEMI_COLON'.";

         log_message(cerr_strm);
         cerr_message(cerr_strm);
         cerr_strm.str("");
     }
#endif /* |DEBUG_COMPILE|  */

};

@q ** (2) let_statement --> LET symbolic_token equate_or_assign.@> 

@*1 \let statement> $\longrightarrow$ \.{LET} \equate or assign>. 
\initials{LDF 2005.01.25.}

\LOG
\initials{LDF 2005.01.25.}
Added this rule.

\initials{LDF 2005.01.26.}
Changed the second \symbolic token> to \string expression>.

\initials{LDF 2005.01.26.}
Changing the way this rule works.  Previously, it simply 
added a synonym.  I want it to copy the |Id_Map_Entry_Node| 
referenced by the \string expression> to one referenced by the
\symbolic token>.  If the \symbolic token> already references 
an |Id_Map_Entry_Node|, the latter must first be destroyed.

\initials{LDF 2005.01.26.}
Now calling |Scan_Parse::let_func()|.

\initials{LDF 2005.01.26.}
Removed \string expression> from the rule.  The |string| is now collected
in |Scan_Parse::let_func()|.
\ENDLOG

@q *** (3) Definition.@> 

@<Define rules@>= 
@=let_statement: LET symbolic_token equate_or_assign@>
{

   @<Common declarations for rules@>@; 

#if DEBUG_COMPILE
   DEBUG = false; /* |true|  */
   if (DEBUG) 
      {
          cerr_strm << thread_name 
                    << "*** Parser:  `let_statement --> "
                    << "symbolic_token equate_or_assign'.";

          log_message(cerr_strm);
          cerr_message(cerr_strm);
          cerr_strm.str("");
      }
#endif /* |DEBUG_COMPILE|  */

   string s = @=$2@>;

   try
      {
         status = let_func(scanner_node, s);
      }   

@q ***** (5) Error handling:  |Scan_Parse::let_func()| failed, @>   
@q ***** (5) throwing |bad_alloc|.                             @>   
@ Error handling:  |Scan_Parse::let_func()| failed, 
throwing |bad_alloc|.                                
\initials{LDF 2005.01.26.}

\LOG
\initials{LDF 2005.01.26.}
Added this section.
\ENDLOG

@<Define rules@>=

           catch (bad_alloc)
              {
                  cerr_strm << thread_name << "In `yyparse()', rule "
                            << "`let_statement --> "
                            << "symbolic_token equate_or_assign':"
                            << endl << "`Scan_Parse::let_func()' failed, throwing "
                            << "`bad_alloc'.  Rethrowing.";

                  log_message(cerr_strm);
                  cerr_message(cerr_strm, error_stop_value);
                  cerr_strm.str("");

                  throw;

              }  /* |catch (bad_alloc)|  */



@q ***** (5) Error handling:  |Scan_Parse::let_func()| failed, @>   
@q ***** (5) returning a non-zero value                        @>   

@ Error handling:  |Scan_Parse::let_func()| failed, 
returning a non-zero value.
\initials{LDF 2005.01.26.}

\LOG
\initials{LDF 2005.01.26.}
Added this section.
\ENDLOG

@<Define rules@>=

             if (status != 0)
                {
                    cerr_strm << thread_name << "In `yyparse()', rule "
                              << "`let_statement --> "
                              << "symbolic_token equate_or_assign':"
                              << endl << "`Scan_Parse::let_func()' failed, returning "
                              << status << "."  << endl << "Will try to continue.";

                    log_message(cerr_strm);
                    cerr_message(cerr_strm, error_stop_value);
                    cerr_strm.str("");

                }  /* |if (status != 0)|  */
@q ***** (5).@> 

#if DEBUG_COMPILE

            else if (DEBUG) /* |status == 0|  */
               {
                   cerr_strm << thread_name << "In `yyparse()', rule "
                             << "`let_statement --> "
                             << "symbolic_token equate_or_assign':"
                             << endl << "`Scan_Parse::let_func()' succeeded.";

                   log_message(cerr_strm);
                   cerr_message(cerr_strm, error_stop_value);
                   cerr_strm.str(""); 

               }  /* |else if (DEBUG) | (|status == 0|)  */

#endif /* |DEBUG_COMPILE|  */@; 
 
 
@q **** (4) @>   

};

  
@q * Emacs-Lisp code for use in indirect buffers when using the          @>
@q   GNU Emacs editor.  The local variable list is not evaluated when an @>
@q   indirect buffer is visited, so it's necessary to evaluate the       @>
@q   following s-expression in order to use the facilities normally      @>
@q   accessed via the local variables list.                              @>
@q   \initials{LDF 2004.02.12}.                                          @>
@q   (progn (cweb-mode) (outline-minor-mode t) (setq fill-column 80))    @>



@q Local Variables: @>
@q mode:CWEB  @>
@q eval:(outline-minor-mode t)  @>
@q abbrev-file-name:"~/.abbrev_defs" @>
@q eval:(read-abbrev-file)  @>
@q fill-column:80 @>
@q run-cweave-on-file:"3DLDFprg.web"  @>
@q End: @>