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