]> andersk Git - splint.git/blob - src/lslinit.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / lslinit.c
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 **         Massachusetts Institute of Technology
5 **
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
10 ** 
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ** General Public License for more details.
15 ** 
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
19 **
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
23 */
24 /*
25 ** lslinit.c
26 **
27 ** Processor for Larch Shared Language Init Files
28 */
29
30 # include "splintMacros.nf"
31 # include "basic.h"
32 # include "signature.h"
33 # include "signature2.h"
34 # include "scan.h"
35 # include "scanline.h"
36 # include "tokentable.h"
37 # include "syntable.h"
38 # include "lslinit.h"
39 # include "lclinit.h"
40 # include "lclscan.h"
41 # include "lclscanline.h"
42 # include "lclsyntable.h"
43 # include "lcltokentable.h"
44
45 /* needed to parse init files */
46 # include "shift.h"
47 #if TRACING == 1
48 /*@notfunction@*/
49 # define LTRACE(rule) printf ("Reducing: %s\n", rule)
50 #else
51 /*@notfunction@*/
52 # define LTRACE(rule)
53 #endif
54
55 static void LocalUserError (ltoken p_t, /*@temp@*/ char *p_msg)
56   /*@modifies *g_warningstream@*/;
57
58 static /*@only@*/ ltoken nextToken;
59
60 static /*@only@*/ /*@null@*/ inputStream s_initFile = inputStream_undefined;
61
62 static void InitFile (void) /*@modifies nextToken@*/ ;
63 static void InitLines (void) /*@modifies nextToken@*/ ;
64 static void InitLine (void) /*@modifies nextToken@*/ ;
65 static void Classification (void) /*@modifies nextToken@*/ ;
66 static void CharClass (void) /*@modifies nextToken@*/ ;
67
68 static void EndCommentChars (void) /*@modifies nextToken@*/ ;
69 static void IdChars (void) /*@modifies nextToken@*/ ;
70 static void OpChars (void) /*@modifies nextToken@*/ ;
71 static void ExtensionChar (void) /*@modifies nextToken@*/ ;
72 static void SingChars (void) /*@modifies nextToken@*/ ;
73 static void WhiteChars (void) /*@modifies nextToken@*/ ;
74 static void EndCommentChar (void) /*@modifies nextToken@*/ ;
75 static void IdChar (void) /*@modifies nextToken@*/ ;
76 static void OpChar (void) /*@modifies nextToken@*/ ;
77 static void SingChar (void) /*@modifies nextToken@*/ ;
78 static void WhiteChar (void) /*@modifies nextToken@*/ ;
79
80 static void TokenClass (void) /*@modifies nextToken@*/ ;
81 static void QuantifierSymToks (void) /*@modifies nextToken@*/ ;
82 static void LogicalOpToks (void) /*@modifies nextToken@*/ ;
83 static void EqOpToks (void) /*@modifies nextToken@*/ ;
84 static void EquationSymToks (void) /*@modifies nextToken@*/ ;
85 static void EqSepSymToks (void) /*@modifies nextToken@*/ ;
86 static void SelectSymToks (void) /*@modifies nextToken@*/ ;
87 static void OpenSymToks (void) /*@modifies nextToken@*/ ;
88 static void SepSymToks (void) /*@modifies nextToken@*/ ;
89 static void CloseSymToks (void) /*@modifies nextToken@*/ ;
90 static void SimpleIdToks (void) /*@modifies nextToken@*/ ;
91 static void MapSymToks (void) /*@modifies nextToken@*/ ;
92 static void MarkerSymToks (void) /*@modifies nextToken@*/ ;
93 static void CommentSymToks (void) /*@modifies nextToken@*/ ;
94 static void QuantifierSymTok (void) /*@modifies nextToken@*/ ;
95 static void LogicalOpTok (void) /*@modifies nextToken@*/ ;
96 static void EqOpTok (void) /*@modifies nextToken@*/ ;
97 static void EquationSymTok (void) /*@modifies nextToken@*/ ;
98 static void EqSepSymTok (void) /*@modifies nextToken@*/ ;
99 static void SelectSymTok (void) /*@modifies nextToken@*/ ;
100 static void OpenSymTok (void) /*@modifies nextToken@*/ ;
101 static void SepSymTok (void) /*@modifies nextToken@*/ ;
102 static void CloseSymTok (void) /*@modifies nextToken@*/ ;
103 static void SimpleIdTok (void) /*@modifies nextToken@*/ ;
104 static void MapSymTok (void) /*@modifies nextToken@*/ ;
105 static void MarkerSymTok (void) /*@modifies nextToken@*/ ;
106 static void CommentSymTok (void) /*@modifies nextToken@*/ ;
107 static void SynClass (void) /*@modifies nextToken@*/ ;
108 static void OldToken (void) /*@modifies nextToken@*/ ;
109 static void NewToken (void) /*@modifies nextToken@*/ ;
110 static void Token (void) /*@modifies nextToken@*/ ;
111
112 static void InitReduce (LSLInitRuleCode p_rule) /*@modifies nextToken@*/ ;
113 static void UpdateXCharKeywords (charCode) /*@modifies nextToken@*/ ;
114 static void ProcessExtensionChar (void) /*@modifies nextToken@*/ ;
115 static void ProcessEndCommentChar (void) /*@modifies nextToken@*/ ;
116 static void ProcessSingleChar (charCode p_code) /*@modifies nextToken@*/ ;
117 static void ProcessToken (ltokenCode p_code) /*@modifies nextToken@*/ ;
118 static void ProcessSynonym (void) /*@modifies nextToken@*/ ;
119
120 /* If TRUE character has been redefined as a singleChar. */
121 static bool defineSingleChar[LASTCHAR + 1];
122
123 static charCode currentExtensionChar;
124
125 /* LSL init file keyword tokens.  */
126
127 static /*@dependent@*/ ltoken endCommentCharToken;
128 static /*@dependent@*/ ltoken idCharToken;
129 static /*@dependent@*/ ltoken opCharToken;
130 static /*@dependent@*/ ltoken extensionCharToken;
131 static /*@dependent@*/ ltoken singleCharToken;
132 static /*@dependent@*/ ltoken whiteCharToken;
133 static /*@dependent@*/ ltoken quantifierSymToken;
134 static /*@dependent@*/ ltoken logicalOpToken;
135 static /*@dependent@*/ ltoken eqOpToken;
136 static /*@dependent@*/ ltoken equationSymToken;
137 static /*@dependent@*/ ltoken eqSepSymToken;
138 static /*@dependent@*/ ltoken selectSymToken;
139 static /*@dependent@*/ ltoken openSymToken;
140 static /*@dependent@*/ ltoken sepSymToken;
141 static /*@dependent@*/ ltoken closeSymToken;
142 static /*@dependent@*/ ltoken simpleIdToken;
143 static /*@dependent@*/ ltoken mapSymToken;
144 static /*@dependent@*/ ltoken markerSymToken;
145 static /*@dependent@*/ ltoken commentSymToken;
146 static /*@dependent@*/ ltoken synonymToken;
147
148 static bool
149 hasFirstChar (ltoken tok)
150 {
151   return (ltoken_isChar (tok)
152           && lscanCharClass (cstring_firstChar (ltoken_unparse (tok))) == SINGLECHAR);
153 }
154
155 void
156 lslinit_setInitFile (inputStream s)
157 {
158   llassert (inputStream_isUndefined (s_initFile));
159   s_initFile = s;
160 }
161
162 /*
163 **
164 **  Parsing functions for init file processing, in the same order as the
165 **  grammar file lslinit.cfg.  This is top-down order, as much as possible.
166 **
167 */
168
169 static void lslinit_processInitFile (void)
170 {
171   InitLines ();
172   InitReduce (INITFILE1);
173
174   if (ltoken_getCode (nextToken) != LEOFTOKEN)
175     {
176       LocalUserError (nextToken, "unexpected tokens after end-of-file");
177     }
178 }
179
180 static void
181 InitLines (void)
182 {
183   InitReduce (INITLINES1);
184
185   if (ltoken_getCode (nextToken) != LEOFTOKEN)
186     {
187       InitLine ();
188       InitReduce (INITLINES2);
189     }
190
191   while (ltoken_getCode (nextToken) != LEOFTOKEN)
192     {
193       InitLine ();
194       InitReduce (INITLINES3);
195     }
196
197 }
198
199 static void
200 InitLine (void)
201 {
202   if (ltoken_getCode (nextToken) == LST_EOL)
203     {
204      /* Nothing on line. */
205       InitReduce (INITLINE1);
206     }
207   else
208     {
209       Classification ();
210       InitReduce (INITLINE2);
211     }
212
213   if (ltoken_getCode (nextToken) != LST_EOL)
214     {
215       LocalUserError (nextToken, "Unexpected tokens on line");
216     }
217
218   ltoken_free (nextToken);
219   nextToken = LSLScanNextToken ();             
220 }
221
222 static void
223 Classification (void)
224 {
225   if (ltoken_getRawText (nextToken) == ltoken_getText (endCommentCharToken)
226       || ltoken_getRawText (nextToken) == ltoken_getText (idCharToken)
227       || ltoken_getRawText (nextToken) == ltoken_getText (opCharToken)
228       || ltoken_getRawText (nextToken) == ltoken_getText (extensionCharToken)
229       || ltoken_getRawText (nextToken) == ltoken_getText (singleCharToken)
230       || ltoken_getRawText (nextToken) == ltoken_getText (whiteCharToken))
231     {
232       CharClass ();
233       InitReduce (CLASSIFICATION1);
234     }
235   else if (ltoken_getRawText (nextToken) == ltoken_getText (quantifierSymToken)
236            || ltoken_getRawText (nextToken) == ltoken_getText (logicalOpToken)
237            || ltoken_getRawText (nextToken) == ltoken_getText (eqOpToken)
238            || ltoken_getRawText (nextToken) == ltoken_getText (equationSymToken)
239            || ltoken_getRawText (nextToken) == ltoken_getText (eqSepSymToken)
240            || ltoken_getRawText (nextToken) == ltoken_getText (selectSymToken)
241            || ltoken_getRawText (nextToken) == ltoken_getText (openSymToken)
242            || ltoken_getRawText (nextToken) == ltoken_getText (sepSymToken)
243            || ltoken_getRawText (nextToken) == ltoken_getText (closeSymToken)
244            || ltoken_getRawText (nextToken) == ltoken_getText (simpleIdToken)
245            || ltoken_getRawText (nextToken) == ltoken_getText (mapSymToken)
246            || ltoken_getRawText (nextToken) == ltoken_getText (markerSymToken)
247            || ltoken_getRawText (nextToken) == ltoken_getText (commentSymToken))
248     {
249       TokenClass ();
250       InitReduce (CLASSIFICATION2);
251     }
252   else if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken))
253     {
254       SynClass ();
255       InitReduce (CLASSIFICATION3);
256     }
257   else
258     {
259       LocalUserError (nextToken,
260                       "expected character, token, or synonym classification");
261     }
262 }
263
264 static void
265 CharClass (void)
266 {
267   ltoken charClassToken;
268
269   charClassToken = nextToken;
270
271   nextToken = LSLScanNextToken ();              /* Discard char class keyword. */
272
273   if (ltoken_getRawText (charClassToken) == ltoken_getText (endCommentCharToken))
274     {
275       EndCommentChars ();
276       InitReduce (CHARCLASS1);
277     }
278   else if (ltoken_getRawText (charClassToken) == ltoken_getText (idCharToken))
279     {
280       IdChars ();
281       InitReduce (CHARCLASS2);
282     }
283   else if (ltoken_getRawText (charClassToken) == ltoken_getText (opCharToken))
284     {
285       OpChars ();
286       InitReduce (CHARCLASS3);
287     }
288   else if (ltoken_getRawText (charClassToken)
289            == ltoken_getText (extensionCharToken))
290     {
291       ExtensionChar ();
292       InitReduce (CHARCLASS4);
293     }
294   else if (ltoken_getRawText (charClassToken) == ltoken_getText (singleCharToken))
295     {
296       SingChars ();
297       InitReduce (CHARCLASS5);
298     }
299   else if (ltoken_getRawText (charClassToken) == ltoken_getText (whiteCharToken))
300     {
301       WhiteChars ();
302       InitReduce (CHARCLASS6);
303     }
304   else
305     {
306       LocalUserError (nextToken, "expected character classification");
307     }
308
309   ltoken_free (charClassToken);
310 }
311
312 static void
313 EndCommentChars (void)
314 {
315   EndCommentChar ();
316   InitReduce (LRC_ENDCOMMENT1);
317
318   while (ltoken_getCode (nextToken) != LST_EOL)
319     {
320       EndCommentChar ();
321       InitReduce (LRC_ENDCOMMENT2);
322     }
323
324 }
325
326 static void
327 IdChars (void)
328 {
329   IdChar ();
330   InitReduce (IDCHARS1);
331
332   while (ltoken_getCode (nextToken) != LST_EOL)
333     {
334       IdChar ();
335       InitReduce (IDCHARS2);
336     }
337 }
338
339 static void
340 OpChars (void)
341 {
342   OpChar ();
343   InitReduce (OPCHARS1);
344
345   while (ltoken_getCode (nextToken) != LST_EOL)
346     {
347       OpChar ();
348       InitReduce (OPCHARS2);
349     }
350 }
351
352 static void
353 ExtensionChar (void)
354 {
355   if (ltoken_isChar (nextToken)
356       && lscanCharClass (cstring_firstChar (ltoken_unparse (nextToken))) == SINGLECHAR)
357     {
358       LSLGenShiftOnly (nextToken);
359       nextToken = LSLScanNextToken ();
360       InitReduce (LRC_EXTENSIONCHAR1);
361     }
362   else
363     {
364       LocalUserError (nextToken, "expected only one character");
365     }
366 }
367
368 static void
369 SingChars (void)
370 {
371   SingChar ();
372   InitReduce (SINGCHARS1);
373
374   while (ltoken_getCode (nextToken) != LST_EOL)
375     {
376       SingChar ();
377       InitReduce (SINGCHARS2);
378     }
379 }
380
381 static void
382 WhiteChars (void)
383 {
384   WhiteChar ();
385   InitReduce (WHITECHARS1);
386
387   while (ltoken_getCode (nextToken) != LST_EOL)
388     {
389       WhiteChar ();
390       InitReduce (WHITECHARS2);
391     }
392 }
393
394 static void
395 EndCommentChar (void)
396 {
397   if (ltoken_isChar (nextToken))
398     {
399       LSLGenShiftOnly (nextToken);
400       nextToken = LSLScanNextToken ();
401       InitReduce (LRC_ENDCOMMENTCHAR1);
402     }
403   else
404     {
405       LocalUserError (nextToken, "expected only one character");
406     }
407 }
408
409 static void
410 IdChar (void)
411 {
412   if (hasFirstChar (nextToken))
413     {
414       LSLGenShiftOnly (nextToken);
415       nextToken = LSLScanNextToken ();
416       InitReduce (IDCHAR1);
417     }
418   else
419     {
420       LocalUserError (nextToken, "character is already defined, cannot redefine");
421     }
422 }
423
424 static void
425 OpChar (void)
426 {
427   if (hasFirstChar (nextToken))
428     {
429       LSLGenShiftOnly (nextToken);
430       nextToken = LSLScanNextToken ();
431       InitReduce (OPCHAR1);
432     }
433   else
434     {
435       LocalUserError (nextToken, "character is already defined, cannot redefine");
436     }
437 }
438
439 static void
440 SingChar (void)
441 {
442   if (hasFirstChar (nextToken))
443     {
444       LSLGenShiftOnly (nextToken);
445       nextToken = LSLScanNextToken ();
446       InitReduce (SINGCHAR1);
447     }
448   else
449     {
450       LocalUserError (nextToken, "character is already defined, cannot redefine");
451     }
452 }
453
454 static void
455 WhiteChar (void)
456 {
457   if (hasFirstChar (nextToken))
458     {
459       LSLGenShiftOnly (nextToken);
460       nextToken = LSLScanNextToken ();
461       InitReduce (WHITECHAR1);
462     }
463   else
464     {
465       LocalUserError (nextToken, "character is already defined, cannot redefine");
466     }
467 }
468
469 static void
470 TokenClass (void)
471 {
472   ltoken tokenClassToken;
473
474   tokenClassToken = nextToken;
475
476   nextToken = LSLScanNextToken ();
477
478   if (ltoken_getRawText (tokenClassToken) == ltoken_getText (quantifierSymToken))
479     {
480       QuantifierSymToks ();
481       InitReduce (TOKENCLASS1);
482     }
483   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (logicalOpToken))
484     {
485       LogicalOpToks ();
486       InitReduce (TOKENCLASS2);
487     }
488   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqOpToken))
489     {
490       EqOpToks ();
491       InitReduce (TOKENCLASS3);
492     }
493   else if (ltoken_getRawText (tokenClassToken)
494            == ltoken_getText (equationSymToken))
495     {
496       EquationSymToks ();
497       InitReduce (TOKENCLASS4);
498     }
499   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqSepSymToken))
500     {
501       EqSepSymToks ();
502       InitReduce (TOKENCLASS5);
503     }
504   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (selectSymToken))
505     {
506       SelectSymToks ();
507       InitReduce (TOKENCLASS6);
508     }
509   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (openSymToken))
510     {
511       OpenSymToks ();
512       InitReduce (TOKENCLASS7);
513     }
514   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (sepSymToken))
515     {
516       SepSymToks ();
517       InitReduce (TOKENCLASS8);
518     }
519   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (closeSymToken))
520     {
521       CloseSymToks ();
522       InitReduce (TOKENCLASS9);
523     }
524   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (simpleIdToken))
525     {
526       SimpleIdToks ();
527       InitReduce (TOKENCLASS10);
528     }
529   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (mapSymToken))
530     {
531       MapSymToks ();
532       InitReduce (TOKENCLASS11);
533     }
534   else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (markerSymToken))
535     {
536       MarkerSymToks ();
537       InitReduce (TOKENCLASS12);
538     }
539   else if (ltoken_getRawText (tokenClassToken)
540            == ltoken_getText (commentSymToken))
541     {
542       CommentSymToks ();
543       InitReduce (TOKENCLASS13);
544     }
545   else
546     {
547       LocalUserError (nextToken, "expected token classification");
548     }
549
550   ltoken_free (tokenClassToken);
551 }
552
553 static void
554 QuantifierSymToks (void)
555 {
556   QuantifierSymTok ();
557   InitReduce (QUANTIFIERSYMTOKS1);
558
559   while (ltoken_getCode (nextToken) != LST_EOL)
560     {
561       QuantifierSymTok ();
562       InitReduce (QUANTIFIERSYMTOKS2);
563     }
564 }
565
566 static void
567 LogicalOpToks (void)
568 {
569   LogicalOpTok ();
570   InitReduce (LOGICALOPTOKS1);
571
572   while (ltoken_getCode (nextToken) != LST_EOL)
573     {
574       LogicalOpTok ();
575       InitReduce (LOGICALOPTOKS2);
576     }
577 }
578
579 static void
580 EqOpToks (void)
581 {
582   EqOpTok ();
583   InitReduce (LRC_EQOPTOKS1);
584
585   while (ltoken_getCode (nextToken) != LST_EOL)
586     {
587       EqOpTok ();
588       InitReduce (LRC_EQOPTOKS2);
589     }
590 }
591
592 static void
593 EquationSymToks (void)
594 {
595   EquationSymTok ();
596   InitReduce (LRC_EQUATIONSYMTOKS1);
597
598   while (ltoken_getCode (nextToken) != LST_EOL)
599     {
600       EquationSymTok ();
601       InitReduce (LRC_EQUATIONSYMTOKS2);
602     }
603 }
604
605 static void
606 EqSepSymToks (void)
607 {
608   EqSepSymTok ();
609   InitReduce (LRC_EQSEPSYMTOKS1);
610
611   while (ltoken_getCode (nextToken) != LST_EOL)
612     {
613       EqSepSymTok ();
614       InitReduce (LRC_EQSEPSYMTOKS2);
615     }
616 }
617
618 static void
619 SelectSymToks (void)
620 {
621   SelectSymTok ();
622   InitReduce (SELECTSYMTOKS1);
623
624   while (ltoken_getCode (nextToken) != LST_EOL)
625     {
626       SelectSymTok ();
627       InitReduce (SELECTSYMTOKS2);
628     }
629 }
630
631 static void
632 OpenSymToks (void)
633 {
634   OpenSymTok ();
635   InitReduce (OPENSYMTOKS1);
636
637   while (ltoken_getCode (nextToken) != LST_EOL)
638     {
639       OpenSymTok ();
640       InitReduce (OPENSYMTOKS2);
641     }
642 }
643
644 static void
645 SepSymToks (void)
646 {
647   SepSymTok ();
648   InitReduce (SEPSYMTOKS1);
649
650   while (ltoken_getCode (nextToken) != LST_EOL)
651     {
652       SepSymTok ();
653       InitReduce (SEPSYMTOKS2);
654     }
655 }
656
657 static void
658 CloseSymToks (void)
659 {
660   CloseSymTok ();
661   InitReduce (CLOSESYMTOKS1);
662
663   while (ltoken_getCode (nextToken) != LST_EOL)
664     {
665       CloseSymTok ();
666       InitReduce (CLOSESYMTOKS2);
667     }
668 }
669
670 static void
671 SimpleIdToks (void)
672 {
673   SimpleIdTok ();
674   InitReduce (SIMPLEIDTOKS1);
675
676   while (ltoken_getCode (nextToken) != LST_EOL)
677     {
678       SimpleIdTok ();
679       InitReduce (SIMPLEIDTOKS2);
680     }
681 }
682
683 static void
684 MapSymToks (void)
685 {
686   MapSymTok ();
687   InitReduce (MAPSYMTOKS1);
688
689   while (ltoken_getCode (nextToken) != LST_EOL)
690     {
691       MapSymTok ();
692       InitReduce (MAPSYMTOKS2);
693     }
694 }
695
696 static void
697 MarkerSymToks (void)
698 {
699   MarkerSymTok ();
700   InitReduce (MARKERSYMTOKS1);
701
702   while (ltoken_getCode (nextToken) != LST_EOL)
703     {
704       MarkerSymTok ();
705       InitReduce (MARKERSYMTOKS2);
706     }
707 }
708
709 static void
710 CommentSymToks (void)
711 {
712   CommentSymTok ();
713   InitReduce (COMMENTSYMTOKS1);
714
715   while (ltoken_getCode (nextToken) != LST_EOL)
716     {
717       CommentSymTok ();
718       InitReduce (COMMENTSYMTOKS2);
719     }
720 }
721
722 static void
723 QuantifierSymTok (void)
724 {
725   Token ();
726   InitReduce (QUANTIFIERSYMTOK1);
727 }
728
729 static void
730 LogicalOpTok (void)
731 {
732   Token ();
733   InitReduce (LOGICALOPTOK1);
734 }
735
736 static void
737 EqOpTok (void)
738 {
739   Token ();
740   InitReduce (LRC_EQOPTOK1);
741 }
742
743 static void
744 EquationSymTok (void)
745 {
746  /* ### EquationSymTok (); ### */
747   Token ();
748   InitReduce (LRC_EQUATIONSYMTOK1);
749 }
750
751 static void
752 EqSepSymTok (void)
753 {
754   Token ();
755   InitReduce (LRC_EQSEPSYMTOK1);
756
757 }
758
759 static void
760 SelectSymTok (void)
761 {
762   Token ();
763   InitReduce (SELECTSYMTOK1);
764 }
765
766 static void
767 OpenSymTok (void)
768 {
769   Token ();
770   InitReduce (OPENSYMTOK1);
771 }
772
773 static void
774 SepSymTok (void)
775 {
776   Token ();
777   InitReduce (SEPSYMTOK1);
778 }
779
780 static void
781 CloseSymTok (void)
782 {
783   Token ();
784   InitReduce (CLOSESYMTOK1);
785 }
786
787 static void
788 SimpleIdTok (void)
789 {
790   Token ();
791   InitReduce (SIMPLEIDTOK1);
792 }
793
794 static void
795 MapSymTok (void)
796 {
797   Token ();
798   InitReduce (MAPSYMTOK1);
799 }
800
801 static void
802 MarkerSymTok (void)
803 {
804   Token ();
805   InitReduce (MARKERSYMTOK1);
806
807 }
808
809 static void
810 CommentSymTok (void)
811 {
812   Token ();
813   InitReduce (COMMENTSYMTOK1);
814 }
815
816
817 static void
818 SynClass (void)
819 {
820   if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken))
821     {
822       ltoken_free (nextToken);
823       nextToken = LSLScanNextToken ();
824
825       OldToken ();
826       NewToken ();
827
828       InitReduce (SYNCLASS1);
829     }
830   else
831     {
832       LocalUserError (nextToken, "expected synonym classification");
833     }
834
835 }
836
837 static void
838 OldToken (void)
839 {
840   Token ();
841   InitReduce (OLDTOKEN1);
842
843 }
844
845 static void
846 NewToken (void)
847 {
848   Token ();
849   InitReduce (NEWTOKEN1);
850
851 }
852
853 static void
854 Token (void)
855 {
856   if (ltoken_getCode (nextToken) == LST_EOL
857       || ltoken_getCode (nextToken) == LEOFTOKEN)
858     {
859       LocalUserError (nextToken, "unexpected end-of-line or end-of-file");
860     }
861   else
862     {
863       LSLGenShiftOnly (nextToken);
864       nextToken = LSLScanNextToken ();
865     }
866 }
867
868 /*
869 ** Init File Processing Routines, these routines use the shift-reduce sequence
870 ** produced by the init file parser and update the necessary tables for the
871 ** scanner.
872 **
873 ** The same shift stack is used that LSL parser uses.  A different reduce
874 ** procedure is used because the init file grammar is different from the LSL
875 ** grammar.
876 **
877 */
878
879 static void
880 InitReduce (LSLInitRuleCode rule)
881 {
882   switch (rule)
883     {
884       case INITFILE1:
885       LTRACE ("INITFILE1");
886       break;
887
888     case INITLINES1:
889       LTRACE ("INITLINES1");
890       break;
891
892     case INITLINES2:
893       LTRACE ("INITLINES2");
894       break;
895
896     case INITLINES3:
897       LTRACE ("INITLINES3");
898       break;
899
900     case INITLINE1:
901       LTRACE ("INITLINE1");
902       break;
903
904     case INITLINE2:
905       LTRACE ("INITLINE2");
906       break;
907
908     case CLASSIFICATION1:
909       LTRACE ("CLASSIFICATION1");
910       break;
911
912     case CLASSIFICATION2:
913       LTRACE ("CLASSIFICATION2");
914       break;
915
916     case CLASSIFICATION3:
917       LTRACE ("CLASSIFICATION3");
918       break;
919
920     case CHARCLASS1:
921       LTRACE ("CHARCLASS1");
922       break;
923
924     case CHARCLASS2:
925       LTRACE ("CHARCLASS2");
926       break;
927
928     case CHARCLASS3:
929       LTRACE ("CHARCLASS3");
930       break;
931
932     case CHARCLASS4:
933       LTRACE ("CHARCLASS4");
934       break;
935
936     case CHARCLASS5:
937       LTRACE ("CHARCLASS5");
938       break;
939
940     case CHARCLASS6:
941       LTRACE ("CHARCLASS6");
942       break;
943
944     case LRC_ENDCOMMENT1:
945       LTRACE ("LRC_ENDCOMMENT1");
946       break;
947
948     case LRC_ENDCOMMENT2:
949       LTRACE ("LRC_ENDCOMMENT2");
950       break;
951
952     case IDCHARS1:
953       LTRACE ("IDCHARS1");
954       break;
955
956     case IDCHARS2:
957       LTRACE ("IDCHARS2");
958       break;
959
960     case OPCHARS1:
961       LTRACE ("OPCHARS1");
962       break;
963
964     case OPCHARS2:
965       LTRACE ("OPCHARS2");
966       break;
967
968     case LRC_EXTENSIONCHAR1:
969       LTRACE ("LRC_EXTENSIONCHAR1");
970       ProcessExtensionChar ();
971       break;
972
973     case SINGCHARS1:
974       LTRACE ("SINGCHARS1");
975       break;
976
977     case SINGCHARS2:
978       LTRACE ("SINGCHARS2");
979       break;
980
981     case WHITECHARS1:
982       LTRACE ("WHITECHARS1");
983       break;
984
985     case WHITECHARS2:
986       LTRACE ("WHITECHARS2");
987       break;
988
989     case LRC_ENDCOMMENTCHAR1:
990       LTRACE ("LRC_ENDCOMMENTCHAR1");
991       ProcessEndCommentChar ();
992       break;
993
994     case IDCHAR1:
995       LTRACE ("IDCHAR1");
996       ProcessSingleChar (IDCHAR);
997       break;
998
999     case OPCHAR1:
1000       LTRACE ("OPCHAR1");
1001       ProcessSingleChar (OPCHAR);
1002       break;
1003
1004     case SINGCHAR1:
1005       LTRACE ("SINGCHAR1");
1006       ProcessSingleChar (SINGLECHAR);
1007       break;
1008
1009     case WHITECHAR1:
1010       LTRACE ("CHAR1");
1011       ProcessSingleChar (WHITECHAR);
1012       break;
1013
1014     case TOKENCLASS1:
1015       LTRACE ("TOKENCLASS1");
1016       break;
1017
1018     case TOKENCLASS2:
1019       LTRACE ("TOKENCLASS2");
1020       break;
1021
1022     case TOKENCLASS3:
1023       LTRACE ("TOKENCLASS3");
1024       break;
1025
1026     case TOKENCLASS4:
1027       LTRACE ("TOKENCLASS4");
1028       break;
1029
1030     case TOKENCLASS5:
1031       LTRACE ("TOKENCLASS5");
1032       break;
1033
1034     case TOKENCLASS6:
1035       LTRACE ("TOKENCLASS6");
1036       break;
1037
1038     case TOKENCLASS7:
1039       LTRACE ("TOKENCLASS7");
1040       break;
1041
1042     case TOKENCLASS8:
1043       LTRACE ("TOKENCLASS8");
1044       break;
1045
1046     case TOKENCLASS9:
1047       LTRACE ("TOKENCLASS9");
1048       break;
1049
1050     case TOKENCLASS10:
1051       LTRACE ("TOKENCLASS10");
1052       break;
1053
1054     case TOKENCLASS11:
1055       LTRACE ("TOKENCLASS11");
1056       break;
1057
1058     case TOKENCLASS12:
1059       LTRACE ("TOKENCLASS12");
1060       break;
1061
1062     case TOKENCLASS13:
1063       LTRACE ("TOKENCLASS13");
1064       break;
1065
1066     case QUANTIFIERSYMTOKS1:
1067       LTRACE ("QUALIFERSYMTOKS1");
1068       break;
1069
1070     case QUANTIFIERSYMTOKS2:
1071       LTRACE ("QUANTIFIERSYMTOKS2");
1072       break;
1073
1074     case LOGICALOPTOKS1:
1075       LTRACE ("LOGICALOPTOKS1");
1076       break;
1077
1078     case LOGICALOPTOKS2:
1079       LTRACE ("LOGICALOPTOKS2");
1080       break;
1081
1082     case LRC_EQOPTOKS1:
1083       LTRACE ("LRC_EQOPTOKS1");
1084       break;
1085
1086     case LRC_EQOPTOKS2:
1087       LTRACE ("LRC_EQOPTOKS2");
1088       break;
1089
1090     case LRC_EQUATIONSYMTOKS1:
1091       LTRACE ("LRC_EQUATIONSYMTOKS1");
1092       break;
1093
1094     case LRC_EQUATIONSYMTOKS2:
1095       LTRACE ("LRC_EQUATIONSYMTOKS2");
1096       break;
1097
1098     case LRC_EQSEPSYMTOKS1:
1099       LTRACE ("LRC_EQSEPSYMTOKS1");
1100       break;
1101
1102     case LRC_EQSEPSYMTOKS2:
1103       LTRACE ("LRC_EQSEPSYMTOKS2");
1104       break;
1105
1106     case SELECTSYMTOKS1:
1107       LTRACE ("SELECTSYMTOKS1");
1108       break;
1109
1110     case SELECTSYMTOKS2:
1111       LTRACE ("SELECTSYMTOKS2");
1112       break;
1113
1114     case OPENSYMTOKS1:
1115       LTRACE ("OPENSYMTOKS1");
1116       break;
1117
1118     case OPENSYMTOKS2:
1119       LTRACE ("OPENSYMTOKS2");
1120       break;
1121
1122     case SEPSYMTOKS1:
1123       LTRACE ("SEPSYMTOKS1");
1124       break;
1125
1126     case SEPSYMTOKS2:
1127       LTRACE ("SEPSYMTOKS2");
1128       break;
1129
1130     case CLOSESYMTOKS1:
1131       LTRACE ("CLOSESYMTOKS1");
1132       break;
1133
1134     case CLOSESYMTOKS2:
1135       LTRACE ("CLOSESYMTOKS2");
1136       break;
1137
1138     case SIMPLEIDTOKS1:
1139       LTRACE ("SIMPLEIDTOKS1");
1140       break;
1141
1142     case SIMPLEIDTOKS2:
1143       LTRACE ("SIMPLEIDTOKS2");
1144       break;
1145
1146     case MAPSYMTOKS1:
1147       LTRACE ("MAPSYMTOKS1");
1148       break;
1149
1150     case MAPSYMTOKS2:
1151       LTRACE ("MAPSYMTOKS2");
1152       break;
1153
1154     case MARKERSYMTOKS1:
1155       LTRACE ("MARKERSYMTOKS1");
1156       break;
1157
1158     case MARKERSYMTOKS2:
1159       LTRACE ("MARKERSYMTOKS2");
1160       break;
1161
1162     case COMMENTSYMTOKS1:
1163       LTRACE ("COMMENTSYMTOKS1");
1164       break;
1165
1166     case COMMENTSYMTOKS2:
1167       LTRACE ("COMMENTSYMTOKS2");
1168       break;
1169
1170     case QUANTIFIERSYMTOK1:
1171       LTRACE ("QUANTIFERSYMTOK1");
1172       ProcessToken (LST_QUANTIFIERSYM);
1173       break;
1174
1175     case LOGICALOPTOK1:
1176       LTRACE ("LOGICALOPTOK1");
1177       ProcessToken (LST_LOGICALOP);
1178       break;
1179
1180     case LRC_EQOPTOK1:
1181       LTRACE ("LRC_EQOPTOK1");
1182       ProcessToken (LST_EQOP);
1183       break;
1184
1185     case LRC_EQUATIONSYMTOK1:
1186       LTRACE ("LRC_EQUATIONSYMTOK1");
1187       ProcessToken (LST_EQUATIONSYM);
1188       break;
1189
1190     case LRC_EQSEPSYMTOK1:
1191       LTRACE ("LRC_EQSEPSYMTOK1");
1192       ProcessToken (LST_EQSEPSYM);
1193       break;
1194
1195     case SELECTSYMTOK1:
1196       LTRACE ("SELECTSYMTOK1");
1197       ProcessToken (LST_SELECTSYM);
1198       break;
1199
1200     case OPENSYMTOK1:
1201       LTRACE ("OPENSYMTOK1");
1202       ProcessToken (LST_OPENSYM);
1203       break;
1204
1205     case SEPSYMTOK1:
1206       LTRACE ("SEPSYMTOK1");
1207       ProcessToken (LST_SEPSYM);
1208       break;
1209
1210     case CLOSESYMTOK1:
1211       LTRACE ("CLOSESYMTOK1");
1212       ProcessToken (LST_CLOSESYM);
1213       break;
1214
1215     case SIMPLEIDTOK1:
1216       LTRACE ("SIMPLEIDTOK1");
1217       ProcessToken (LST_SIMPLEID);
1218       break;
1219
1220     case MAPSYMTOK1:
1221       LTRACE ("MAPSYMTOK1");
1222       ProcessToken (LST_MAPSYM);
1223       break;
1224
1225     case MARKERSYMTOK1:
1226       LTRACE ("MARKERSYMTOK1");
1227       ProcessToken (LST_MARKERSYM);
1228       break;
1229
1230     case COMMENTSYMTOK1:
1231       LTRACE ("COMMENTSYMTOK1");
1232       ProcessToken (LST_COMMENTSYM);
1233       break;
1234
1235     case SYNCLASS1:
1236       LTRACE ("SYNCLASS1");
1237       ProcessSynonym ();
1238       break;
1239
1240     case OLDTOKEN1:
1241       LTRACE ("OLDTOKEN1");
1242       break;
1243
1244     case NEWTOKEN1:
1245       LTRACE ("NEWTOKEN1");
1246       break;
1247
1248     default:
1249       llcontbuglit ("InitReduce: bad switch");
1250       break;
1251
1252     }                           /* end switch       */
1253 }                               /* end InitReduce () */
1254
1255
1256
1257 /* Reset the first character of the predefined extensionChar keywords when  */
1258 /* the extensionChar changes.  e.g. "extensionChar @" changes "forall" to   */
1259 /* "@forall".                                                               */
1260
1261 static void
1262 UpdateXCharKeywords (charCode xCharCode)
1263 {
1264   char xChar = (char) xCharCode;
1265   char *str;
1266
1267   str = ltoken_getTextChars (ltoken_forall);
1268   *str = xChar;
1269
1270   str = ltoken_getTextChars (ltoken_and);
1271   *str = xChar;
1272
1273   str = ltoken_getTextChars (ltoken_or);
1274   *str = xChar;
1275
1276   str = ltoken_getTextChars (ltoken_implies);
1277   *str = xChar;
1278
1279   str = ltoken_getTextChars (ltoken_eq);
1280   *str = xChar;
1281
1282   str = ltoken_getTextChars (ltoken_neq);
1283   *str = xChar;
1284
1285   str = ltoken_getTextChars (ltoken_equals);
1286   *str = xChar;
1287
1288   str = ltoken_getTextChars (ltoken_eqsep);
1289   *str = xChar;
1290
1291   str = ltoken_getTextChars (ltoken_select);
1292   *str = xChar;
1293
1294   str = ltoken_getTextChars (ltoken_open);
1295   *str = xChar;
1296
1297   str = ltoken_getTextChars (ltoken_sep);
1298   *str = xChar;
1299
1300   str = ltoken_getTextChars (ltoken_close);
1301   *str = xChar;
1302
1303   str = ltoken_getTextChars (ltoken_id);
1304   *str = xChar;
1305
1306   str = ltoken_getTextChars (ltoken_arrow);
1307   *str = xChar;
1308
1309   str = ltoken_getTextChars (ltoken_marker);
1310   *str = xChar;
1311
1312   str = ltoken_getTextChars (ltoken_comment);
1313   *str = xChar;
1314
1315 }
1316
1317 /* Different from ProcessCharClass because only allow one extension         */
1318 /* character. Therefore, the present extension character must be set to a   */
1319 /* singleChar.                                                              */
1320
1321 static void
1322 ProcessExtensionChar (void)
1323 {
1324   ltoken stackToken = LSLGenTopPopShiftStack ();
1325   char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1326
1327   if (!defineSingleChar[(int)firstChar]
1328       && lscanCharClass (firstChar) == SINGLECHAR)
1329     {
1330      /* Is a single character that has not been defined before.     */
1331      /* Can only have one extension char.  Release old one. */
1332       lsetCharClass (firstChar, CHC_EXTENSION);
1333       
1334       /* this is a (bogus) type bug! caught by splint */
1335       /* lsetCharClass (currentExtensionChar, SINGLECHAR); */
1336
1337       lsetCharClass ((char) currentExtensionChar, SINGLECHAR);
1338
1339       currentExtensionChar = (charCode) firstChar;
1340       UpdateXCharKeywords (currentExtensionChar);
1341     }
1342   else
1343     {
1344      /* Already redefined.  Don't allow to be redefined. */
1345       LocalUserError (stackToken, "character is already defined, cannot redefine");
1346     }
1347   ltoken_free (stackToken);
1348 }
1349
1350 /* Different from ProcessSingleChar because allow any characters to be      */
1351 /* endCommentChar and also set a different part of the scanner structure.   */
1352
1353 static void
1354 ProcessEndCommentChar (void)
1355 {
1356   ltoken stackToken = LSLGenTopPopShiftStack ();
1357   char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1358
1359   if (LSLIsEndComment (firstChar))
1360     {
1361       LocalUserError (stackToken,
1362                     "already defined as a endCommentChar, cannot redefine");
1363     }
1364   else
1365     {
1366       lsetEndCommentChar (firstChar, TRUE);
1367     }
1368   ltoken_free (stackToken);
1369 }
1370
1371 static void
1372 ProcessSingleChar (charCode code)
1373 {
1374   ltoken stackToken = LSLGenTopPopShiftStack ();
1375   char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1376
1377   if (!defineSingleChar[(int)firstChar]
1378       && lscanCharClass (firstChar) == SINGLECHAR)
1379     {
1380       /* Is a single character that has not been defined before.            */
1381       /* It's OK to redefine once. */
1382       lsetCharClass (firstChar, code);
1383       /* OK to mark as a defined singleChar even if not.  Only check        */
1384       /* defineSingleChar[] if defining a singleChar.                       */
1385       defineSingleChar[(int)firstChar] = TRUE;
1386     }
1387   else
1388     {
1389       LocalUserError (stackToken, "character is already defined, cannot redefine");
1390     }
1391   ltoken_free (stackToken);
1392 }
1393
1394 static void
1395 ProcessToken (ltokenCode code)
1396 {
1397   ltoken stackToken, temp;
1398   lsymbol sym;
1399
1400   stackToken = LSLGenTopPopShiftStack ();
1401   sym = ltoken_getText (stackToken);
1402
1403   if (LSLIsSyn (sym))
1404     {
1405       LocalUserError (stackToken,
1406                       "already defined as a synonym, cannot redefine");
1407     }
1408
1409   /* Get the token from the token table, so can check if the token    */
1410   /* was updated by a previous token.                               */
1411   temp = LSLGetToken (sym);
1412   
1413   if (ltoken_isStateDefined (temp))
1414     {
1415       if ((code == LST_OPENSYM && sym == lsymbol_fromChars ("[")) ||
1416           (code == LST_CLOSESYM && sym == lsymbol_fromChars ("]")))
1417         {
1418           /* ignore "openSym [" and "closeSym ]" TokenClass */
1419           ltoken_free (stackToken);
1420           return;
1421         }
1422       else
1423         {
1424           LocalUserError (stackToken, "already defined, cannot redefine");
1425           PrintToken (temp);
1426         }
1427     }
1428   
1429   LSLUpdateToken (code, ltoken_getText (stackToken), TRUE);
1430   ltoken_free (stackToken);
1431 }
1432
1433
1434 static void
1435 ProcessSynonym (void)
1436 {
1437   ltoken newtok;
1438   ltoken oldtok;
1439
1440   newtok = LSLGenTopPopShiftStack ();
1441   oldtok = LSLGenTopPopShiftStack ();
1442
1443   if (ltoken_wasSyn (newtok))
1444     {
1445      /* The token has a synonym.  This means that the synonym was in the */
1446      /* init file, so complain about redefining as a synonym again          */
1447       LocalUserError (newtok, "newtok already is a synonym, cannot redefine");
1448     }
1449
1450   if (ltoken_hasSyn (newtok))
1451     {
1452       /*
1453       ** newtok already has a synonym defined for it.  Do not allow         
1454       ** synonyms to be chained.                                            
1455       */
1456
1457       LocalUserError (newtok,
1458                       "newtok already has a synonym, cannot chain synonyms");
1459     }
1460
1461   if (ltoken_isStateDefined (newtok))
1462     {
1463       LocalUserError (newtok, "newtok already defined, cannot redefine");
1464     }
1465
1466   LSLAddSyn (ltoken_getText (newtok), ltoken_getText (oldtok));
1467   ltoken_free (oldtok);
1468   ltoken_free (newtok);
1469 }
1470
1471
1472 /*
1473  * Utilities, in alphabetical order
1474  */
1475
1476 static void
1477 LocalUserError (ltoken t, /*@temp@*/ char *msg)
1478 {
1479   lldiagmsg (message ("%s %s in the LSL init file:", 
1480                       ltoken_unparse (t), cstring_fromChars (msg)));
1481
1482   ltoken_free (nextToken);
1483   nextToken = LSLScanNextToken ();             
1484
1485   while (ltoken_getCode (nextToken) != LST_EOL)
1486     {
1487       ltoken_free (nextToken);
1488       nextToken = LSLScanNextToken ();
1489     }
1490 }
1491
1492 /*
1493 **  Required initialization and cleanup routines
1494 */
1495
1496 static /*@exposed@*/ ltoken insertSimpleToken (char *text) 
1497   /*@modifies internalState@*/
1498 {
1499   return (LSLInsertToken (LST_SIMPLEID, lsymbol_fromChars (text), 0, FALSE));
1500 }
1501
1502 static void
1503 lslinit_initProcessInitFile (void)
1504 {
1505   int i;
1506
1507   LSLGenInit (TRUE);            /* parsing LSLinit not LCLinit */
1508
1509   /*
1510   ** Insert the init file keywords into the token table as undefined        
1511   ** SIMPLEIDs.  They are defined as simpleIds since they must be treated 
1512   ** that way if they do not appear as the first token on a line, and       
1513   ** they must be treated that way for the actual LSL parsing. Save the   
1514   ** tokens so can recognize as init file keywords when necessary.       
1515   */
1516
1517   endCommentCharToken = insertSimpleToken ("endCommentChar");
1518   idCharToken = insertSimpleToken ("idChar");                        
1519   opCharToken = insertSimpleToken ("opChar");                        
1520   extensionCharToken = insertSimpleToken ("extensionChar");    
1521   singleCharToken = insertSimpleToken ("singleChar");   
1522   whiteCharToken = insertSimpleToken ("whiteChar");
1523
1524   quantifierSymToken = insertSimpleToken ("quantifierSym");
1525   logicalOpToken = insertSimpleToken ("logicalOp");
1526   eqOpToken = insertSimpleToken ("eqOp");                          
1527   equationSymToken = insertSimpleToken ("equationSym");
1528   eqSepSymToken = insertSimpleToken ("eqSepSym");                              
1529   selectSymToken = insertSimpleToken ("selectSym");
1530   openSymToken = insertSimpleToken ("openSym");                       
1531   sepSymToken = insertSimpleToken ("sepSym");                        
1532   closeSymToken = insertSimpleToken ("closeSym");                              
1533   simpleIdToken = insertSimpleToken ("simpleId");                              
1534   mapSymToken = insertSimpleToken ("mapSym");                        
1535   markerSymToken = insertSimpleToken ("markerSym");
1536   commentSymToken = insertSimpleToken ("commentSym"); 
1537   synonymToken = insertSimpleToken ("synonym");                       
1538
1539   for (i = 0; i <= LASTCHAR; i++)
1540     {
1541       defineSingleChar[i] = FALSE;
1542     }
1543   
1544   /*
1545   ** Record the current extension character so can redefine back to         
1546   ** singleChar if a new extension character is redefined.                  
1547   */
1548
1549   currentExtensionChar = (charCode) CHAREXTENDER;
1550
1551   LSLReportEolTokens (TRUE);
1552   ltoken_free (nextToken);
1553   nextToken = LSLScanNextToken ();             
1554 }
1555
1556 void lslinit_process (void)
1557   /*@globals undef g_symtab; @*/
1558   /*@modifies g_symtab, internalState, fileSystem; @*/
1559 {
1560   /*
1561   ** Open init file provided by user, or use the default LCL init file 
1562   */
1563   
1564   cstring larchpath = context_getLarchPath ();
1565   inputStream initstream = inputStream_undefined;
1566
1567   setCodePoint ();
1568
1569   if (inputStream_isUndefined (s_initFile))
1570     {
1571       s_initFile = inputStream_create (cstring_makeLiteral (INITFILENAME), 
1572                                        cstring_makeLiteralTemp (LCLINIT_SUFFIX),
1573                                        FALSE);
1574       
1575       if (!inputStream_getPath (larchpath, s_initFile))
1576         {
1577           lldiagmsg (message ("Continuing without LCL init file: %s",
1578                               inputStream_fileName (s_initFile)));
1579         }
1580       else 
1581         {
1582           if (!inputStream_open (s_initFile))
1583             {
1584               lldiagmsg (message ("Continuing without LCL init file: %s",
1585                                   inputStream_fileName (s_initFile)));
1586             }
1587         }
1588     }
1589   else 
1590     {
1591       if (!inputStream_open (s_initFile))
1592         {
1593           lldiagmsg (message ("Continuing without LCL init file: %s",
1594                               inputStream_fileName (s_initFile)));
1595         }
1596     }
1597
1598   /* Initialize checker */
1599
1600   lsymbol_initMod ();
1601   LCLSynTableInit ();
1602
1603   setCodePoint ();
1604
1605   LCLSynTableReset ();
1606   LCLTokenTableInit ();
1607
1608   setCodePoint ();
1609
1610   LCLScanLineInit ();
1611   setCodePoint ();
1612   LCLScanLineReset ();
1613   setCodePoint ();
1614   LCLScanInit ();
1615
1616   setCodePoint ();
1617
1618   /* need this to initialize LCL checker */
1619
1620   llassert (inputStream_isDefined (s_initFile));      
1621   if (inputStream_isOpen (s_initFile))
1622     {
1623       setCodePoint ();
1624
1625       LCLScanReset (s_initFile);
1626       lclinit_initMod ();
1627       lclinit_reset ();
1628
1629       setCodePoint ();
1630       lclinit_process ();
1631       lclinit_cleanup ();
1632
1633       setCodePoint ();
1634       check (inputStream_close (s_initFile));
1635     }
1636   
1637   /* Initialize LSL init files, for parsing LSL signatures from LSL */
1638   
1639   initstream = inputStream_create (cstring_makeLiteral ("lslinit.lsi"), 
1640                                     cstring_makeLiteralTemp (".lsi"),
1641                                     FALSE);
1642   
1643   if (!inputStream_getPath (larchpath, initstream))
1644     {
1645       lldiagmsg (message ("Continuing without LSL init file: %s",
1646                           inputStream_fileName (initstream)));
1647     }
1648   else 
1649     {
1650       if (!inputStream_open (initstream))
1651         {
1652           lldiagmsg (message ("Continuing without LSL init file: %s",
1653                               inputStream_fileName (initstream)));
1654         }
1655     }
1656       
1657   setCodePoint ();
1658   lsynTableInit ();
1659   lsynTableReset ();
1660
1661   setCodePoint ();
1662   ltokenTableInit ();
1663
1664   setCodePoint ();
1665   lscanLineInit ();
1666   lscanLineReset ();
1667   LSLScanInit ();
1668
1669   if (inputStream_isOpen (initstream))
1670     {
1671       setCodePoint ();
1672       LSLScanReset (initstream);
1673       lslinit_initProcessInitFile ();
1674       lslinit_processInitFile ();
1675       check (inputStream_close (initstream));
1676     }
1677       
1678   inputStream_free (initstream);
1679   
1680   if (lclHadError ())
1681     {
1682       lclplainerror 
1683         (cstring_makeLiteral ("LSL init file error.  Attempting to continue."));
1684     }
1685   
1686   setCodePoint ();
1687   g_symtab = symtable_new ();
1688   
1689   /* 
1690   ** sort_init must come after symtab has been initialized 
1691   */
1692   sort_init ();
1693   abstract_init ();
1694   setCodePoint ();
1695   
1696   /* 
1697   ** Equivalent to importing old spec_csupport.lcl
1698   ** define immutable LCL type "bool" and bool constants TRUE and FALSE
1699   ** and initialized them to be equal to LSL's "true" and "false".
1700   **
1701   ** Reads in CTrait.syms (derived from CTrait.lsl) on LARCH_PATH.
1702   */
1703       
1704   LCLBuiltins (); 
1705   LCLReportEolTokens (FALSE);
1706 }
This page took 0.163151 seconds and 5 git commands to generate.