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