Moved OS dependent constants from constants.h to osd.h
[splint-patched.git] / src / lslinit.c
blobf2c4bfd53b771fd9a3704a9f0d3fec9346183ef4
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
5 **
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
15 **
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
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
25 ** lslinit.c
27 ** Processor for Larch Shared Language Init Files
30 # include "splintMacros.nf"
31 # include "basic.h"
33 # include "lslgrammar.h"
34 # include "lslscan.h"
35 # include "lslscanline.h"
36 # include "lsltokentable.h"
37 # include "lslsyntable.h"
38 # include "lslinit.h"
40 # include "lclinit.h"
41 # include "lclscan.h"
42 # include "lclscanline.h"
43 # include "lclsyntable.h"
44 # include "lcltokentable.h"
46 /* needed to parse init files */
47 # include "shift.h"
49 #define TRACING 0
50 #if TRACING == 1
51 /*@notfunction@*/
52 # define LTRACE(rule) printf ("Reducing: %s\n", rule)
53 #else
54 /*@notfunction@*/
55 # define LTRACE(rule)
56 #endif
58 static void LocalUserError (ltoken p_t, /*@temp@*/ char *p_msg)
59 /*@modifies *g_warningstream@*/;
61 static /*@only@*/ ltoken nextToken;
63 static /*@only@*/ /*@null@*/ inputStream s_initFile = inputStream_undefined;
65 static void InitFile (void) /*@modifies nextToken@*/ ;
66 static void InitLines (void) /*@modifies nextToken@*/ ;
67 static void InitLine (void) /*@modifies nextToken@*/ ;
68 static void Classification (void) /*@modifies nextToken@*/ ;
69 static void CharClass (void) /*@modifies nextToken@*/ ;
71 static void EndCommentChars (void) /*@modifies nextToken@*/ ;
72 static void IdChars (void) /*@modifies nextToken@*/ ;
73 static void OpChars (void) /*@modifies nextToken@*/ ;
74 static void ExtensionChar (void) /*@modifies nextToken@*/ ;
75 static void SingChars (void) /*@modifies nextToken@*/ ;
76 static void WhiteChars (void) /*@modifies nextToken@*/ ;
77 static void EndCommentChar (void) /*@modifies nextToken@*/ ;
78 static void IdChar (void) /*@modifies nextToken@*/ ;
79 static void OpChar (void) /*@modifies nextToken@*/ ;
80 static void SingChar (void) /*@modifies nextToken@*/ ;
81 static void WhiteChar (void) /*@modifies nextToken@*/ ;
83 static void TokenClass (void) /*@modifies nextToken@*/ ;
84 static void QuantifierSymToks (void) /*@modifies nextToken@*/ ;
85 static void LogicalOpToks (void) /*@modifies nextToken@*/ ;
86 static void EqOpToks (void) /*@modifies nextToken@*/ ;
87 static void EquationSymToks (void) /*@modifies nextToken@*/ ;
88 static void EqSepSymToks (void) /*@modifies nextToken@*/ ;
89 static void SelectSymToks (void) /*@modifies nextToken@*/ ;
90 static void OpenSymToks (void) /*@modifies nextToken@*/ ;
91 static void SepSymToks (void) /*@modifies nextToken@*/ ;
92 static void CloseSymToks (void) /*@modifies nextToken@*/ ;
93 static void SimpleIdToks (void) /*@modifies nextToken@*/ ;
94 static void MapSymToks (void) /*@modifies nextToken@*/ ;
95 static void MarkerSymToks (void) /*@modifies nextToken@*/ ;
96 static void CommentSymToks (void) /*@modifies nextToken@*/ ;
97 static void QuantifierSymTok (void) /*@modifies nextToken@*/ ;
98 static void LogicalOpTok (void) /*@modifies nextToken@*/ ;
99 static void EqOpTok (void) /*@modifies nextToken@*/ ;
100 static void EquationSymTok (void) /*@modifies nextToken@*/ ;
101 static void EqSepSymTok (void) /*@modifies nextToken@*/ ;
102 static void SelectSymTok (void) /*@modifies nextToken@*/ ;
103 static void OpenSymTok (void) /*@modifies nextToken@*/ ;
104 static void SepSymTok (void) /*@modifies nextToken@*/ ;
105 static void CloseSymTok (void) /*@modifies nextToken@*/ ;
106 static void SimpleIdTok (void) /*@modifies nextToken@*/ ;
107 static void MapSymTok (void) /*@modifies nextToken@*/ ;
108 static void MarkerSymTok (void) /*@modifies nextToken@*/ ;
109 static void CommentSymTok (void) /*@modifies nextToken@*/ ;
110 static void SynClass (void) /*@modifies nextToken@*/ ;
111 static void OldToken (void) /*@modifies nextToken@*/ ;
112 static void NewToken (void) /*@modifies nextToken@*/ ;
113 static void Token (void) /*@modifies nextToken@*/ ;
115 static void InitReduce (LSLInitRuleCode p_rule) /*@modifies nextToken@*/ ;
116 static void UpdateXCharKeywords (charCode) /*@modifies nextToken@*/ ;
117 static void ProcessExtensionChar (void) /*@modifies nextToken@*/ ;
118 static void ProcessEndCommentChar (void) /*@modifies nextToken@*/ ;
119 static void ProcessSingleChar (charCode p_code) /*@modifies nextToken@*/ ;
120 static void ProcessToken (ltokenCode p_code) /*@modifies nextToken@*/ ;
121 static void ProcessSynonym (void) /*@modifies nextToken@*/ ;
123 /* If TRUE character has been redefined as a singleChar. */
124 static bool defineSingleChar[LASTCHAR + 1];
126 static charCode currentExtensionChar;
128 /* LSL init file keyword tokens. */
130 static /*@dependent@*/ ltoken endCommentCharToken;
131 static /*@dependent@*/ ltoken idCharToken;
132 static /*@dependent@*/ ltoken opCharToken;
133 static /*@dependent@*/ ltoken extensionCharToken;
134 static /*@dependent@*/ ltoken singleCharToken;
135 static /*@dependent@*/ ltoken whiteCharToken;
136 static /*@dependent@*/ ltoken quantifierSymToken;
137 static /*@dependent@*/ ltoken logicalOpToken;
138 static /*@dependent@*/ ltoken eqOpToken;
139 static /*@dependent@*/ ltoken equationSymToken;
140 static /*@dependent@*/ ltoken eqSepSymToken;
141 static /*@dependent@*/ ltoken selectSymToken;
142 static /*@dependent@*/ ltoken openSymToken;
143 static /*@dependent@*/ ltoken sepSymToken;
144 static /*@dependent@*/ ltoken closeSymToken;
145 static /*@dependent@*/ ltoken simpleIdToken;
146 static /*@dependent@*/ ltoken mapSymToken;
147 static /*@dependent@*/ ltoken markerSymToken;
148 static /*@dependent@*/ ltoken commentSymToken;
149 static /*@dependent@*/ ltoken synonymToken;
151 static bool
152 hasFirstChar (ltoken tok)
154 return (ltoken_isChar (tok)
155 && lscanCharClass (cstring_firstChar (ltoken_unparse (tok))) == SINGLECHAR);
158 void
159 lslinit_setInitFile (inputStream s)
161 llassert (inputStream_isUndefined (s_initFile));
162 s_initFile = s;
167 ** Parsing functions for init file processing, in the same order as the
168 ** grammar file lslinit.cfg. This is top-down order, as much as possible.
172 static void lslinit_processInitFile (void)
174 InitLines ();
175 InitReduce (INITFILE1);
177 if (ltoken_getCode (nextToken) != LEOFTOKEN)
179 LocalUserError (nextToken, "unexpected tokens after end-of-file");
183 static void
184 InitLines (void)
186 InitReduce (INITLINES1);
188 if (ltoken_getCode (nextToken) != LEOFTOKEN)
190 InitLine ();
191 InitReduce (INITLINES2);
194 while (ltoken_getCode (nextToken) != LEOFTOKEN)
196 InitLine ();
197 InitReduce (INITLINES3);
202 static void
203 InitLine (void)
205 if (ltoken_getCode (nextToken) == LST_EOL)
207 /* Nothing on line. */
208 InitReduce (INITLINE1);
210 else
212 Classification ();
213 InitReduce (INITLINE2);
216 if (ltoken_getCode (nextToken) != LST_EOL)
218 LocalUserError (nextToken, "Unexpected tokens on line");
221 ltoken_free (nextToken);
222 nextToken = LSLScanNextToken ();
225 static void
226 Classification (void)
228 if (ltoken_getRawText (nextToken) == ltoken_getText (endCommentCharToken)
229 || ltoken_getRawText (nextToken) == ltoken_getText (idCharToken)
230 || ltoken_getRawText (nextToken) == ltoken_getText (opCharToken)
231 || ltoken_getRawText (nextToken) == ltoken_getText (extensionCharToken)
232 || ltoken_getRawText (nextToken) == ltoken_getText (singleCharToken)
233 || ltoken_getRawText (nextToken) == ltoken_getText (whiteCharToken))
235 CharClass ();
236 InitReduce (CLASSIFICATION1);
238 else if (ltoken_getRawText (nextToken) == ltoken_getText (quantifierSymToken)
239 || ltoken_getRawText (nextToken) == ltoken_getText (logicalOpToken)
240 || ltoken_getRawText (nextToken) == ltoken_getText (eqOpToken)
241 || ltoken_getRawText (nextToken) == ltoken_getText (equationSymToken)
242 || ltoken_getRawText (nextToken) == ltoken_getText (eqSepSymToken)
243 || ltoken_getRawText (nextToken) == ltoken_getText (selectSymToken)
244 || ltoken_getRawText (nextToken) == ltoken_getText (openSymToken)
245 || ltoken_getRawText (nextToken) == ltoken_getText (sepSymToken)
246 || ltoken_getRawText (nextToken) == ltoken_getText (closeSymToken)
247 || ltoken_getRawText (nextToken) == ltoken_getText (simpleIdToken)
248 || ltoken_getRawText (nextToken) == ltoken_getText (mapSymToken)
249 || ltoken_getRawText (nextToken) == ltoken_getText (markerSymToken)
250 || ltoken_getRawText (nextToken) == ltoken_getText (commentSymToken))
252 TokenClass ();
253 InitReduce (CLASSIFICATION2);
255 else if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken))
257 SynClass ();
258 InitReduce (CLASSIFICATION3);
260 else
262 LocalUserError (nextToken,
263 "expected character, token, or synonym classification");
267 static void
268 CharClass (void)
270 ltoken charClassToken;
272 charClassToken = nextToken;
274 nextToken = LSLScanNextToken (); /* Discard char class keyword. */
276 if (ltoken_getRawText (charClassToken) == ltoken_getText (endCommentCharToken))
278 EndCommentChars ();
279 InitReduce (CHARCLASS1);
281 else if (ltoken_getRawText (charClassToken) == ltoken_getText (idCharToken))
283 IdChars ();
284 InitReduce (CHARCLASS2);
286 else if (ltoken_getRawText (charClassToken) == ltoken_getText (opCharToken))
288 OpChars ();
289 InitReduce (CHARCLASS3);
291 else if (ltoken_getRawText (charClassToken)
292 == ltoken_getText (extensionCharToken))
294 ExtensionChar ();
295 InitReduce (CHARCLASS4);
297 else if (ltoken_getRawText (charClassToken) == ltoken_getText (singleCharToken))
299 SingChars ();
300 InitReduce (CHARCLASS5);
302 else if (ltoken_getRawText (charClassToken) == ltoken_getText (whiteCharToken))
304 WhiteChars ();
305 InitReduce (CHARCLASS6);
307 else
309 LocalUserError (nextToken, "expected character classification");
312 ltoken_free (charClassToken);
315 static void
316 EndCommentChars (void)
318 EndCommentChar ();
319 InitReduce (LRC_ENDCOMMENT1);
321 while (ltoken_getCode (nextToken) != LST_EOL)
323 EndCommentChar ();
324 InitReduce (LRC_ENDCOMMENT2);
329 static void
330 IdChars (void)
332 IdChar ();
333 InitReduce (IDCHARS1);
335 while (ltoken_getCode (nextToken) != LST_EOL)
337 IdChar ();
338 InitReduce (IDCHARS2);
342 static void
343 OpChars (void)
345 OpChar ();
346 InitReduce (OPCHARS1);
348 while (ltoken_getCode (nextToken) != LST_EOL)
350 OpChar ();
351 InitReduce (OPCHARS2);
355 static void
356 ExtensionChar (void)
358 if (ltoken_isChar (nextToken)
359 && lscanCharClass (cstring_firstChar (ltoken_unparse (nextToken))) == SINGLECHAR)
361 LSLGenShiftOnly (nextToken);
362 nextToken = LSLScanNextToken ();
363 InitReduce (LRC_EXTENSIONCHAR1);
365 else
367 LocalUserError (nextToken, "expected only one character");
371 static void
372 SingChars (void)
374 SingChar ();
375 InitReduce (SINGCHARS1);
377 while (ltoken_getCode (nextToken) != LST_EOL)
379 SingChar ();
380 InitReduce (SINGCHARS2);
384 static void
385 WhiteChars (void)
387 WhiteChar ();
388 InitReduce (WHITECHARS1);
390 while (ltoken_getCode (nextToken) != LST_EOL)
392 WhiteChar ();
393 InitReduce (WHITECHARS2);
397 static void
398 EndCommentChar (void)
400 if (ltoken_isChar (nextToken))
402 LSLGenShiftOnly (nextToken);
403 nextToken = LSLScanNextToken ();
404 InitReduce (LRC_ENDCOMMENTCHAR1);
406 else
408 LocalUserError (nextToken, "expected only one character");
412 static void
413 IdChar (void)
415 if (hasFirstChar (nextToken))
417 LSLGenShiftOnly (nextToken);
418 nextToken = LSLScanNextToken ();
419 InitReduce (IDCHAR1);
421 else
423 LocalUserError (nextToken, "character is already defined, cannot redefine");
427 static void
428 OpChar (void)
430 if (hasFirstChar (nextToken))
432 LSLGenShiftOnly (nextToken);
433 nextToken = LSLScanNextToken ();
434 InitReduce (OPCHAR1);
436 else
438 LocalUserError (nextToken, "character is already defined, cannot redefine");
442 static void
443 SingChar (void)
445 if (hasFirstChar (nextToken))
447 LSLGenShiftOnly (nextToken);
448 nextToken = LSLScanNextToken ();
449 InitReduce (SINGCHAR1);
451 else
453 LocalUserError (nextToken, "character is already defined, cannot redefine");
457 static void
458 WhiteChar (void)
460 if (hasFirstChar (nextToken))
462 LSLGenShiftOnly (nextToken);
463 nextToken = LSLScanNextToken ();
464 InitReduce (WHITECHAR1);
466 else
468 LocalUserError (nextToken, "character is already defined, cannot redefine");
472 static void
473 TokenClass (void)
475 ltoken tokenClassToken;
477 tokenClassToken = nextToken;
479 nextToken = LSLScanNextToken ();
481 if (ltoken_getRawText (tokenClassToken) == ltoken_getText (quantifierSymToken))
483 QuantifierSymToks ();
484 InitReduce (TOKENCLASS1);
486 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (logicalOpToken))
488 LogicalOpToks ();
489 InitReduce (TOKENCLASS2);
491 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqOpToken))
493 EqOpToks ();
494 InitReduce (TOKENCLASS3);
496 else if (ltoken_getRawText (tokenClassToken)
497 == ltoken_getText (equationSymToken))
499 EquationSymToks ();
500 InitReduce (TOKENCLASS4);
502 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqSepSymToken))
504 EqSepSymToks ();
505 InitReduce (TOKENCLASS5);
507 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (selectSymToken))
509 SelectSymToks ();
510 InitReduce (TOKENCLASS6);
512 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (openSymToken))
514 OpenSymToks ();
515 InitReduce (TOKENCLASS7);
517 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (sepSymToken))
519 SepSymToks ();
520 InitReduce (TOKENCLASS8);
522 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (closeSymToken))
524 CloseSymToks ();
525 InitReduce (TOKENCLASS9);
527 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (simpleIdToken))
529 SimpleIdToks ();
530 InitReduce (TOKENCLASS10);
532 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (mapSymToken))
534 MapSymToks ();
535 InitReduce (TOKENCLASS11);
537 else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (markerSymToken))
539 MarkerSymToks ();
540 InitReduce (TOKENCLASS12);
542 else if (ltoken_getRawText (tokenClassToken)
543 == ltoken_getText (commentSymToken))
545 CommentSymToks ();
546 InitReduce (TOKENCLASS13);
548 else
550 LocalUserError (nextToken, "expected token classification");
553 ltoken_free (tokenClassToken);
556 static void
557 QuantifierSymToks (void)
559 QuantifierSymTok ();
560 InitReduce (QUANTIFIERSYMTOKS1);
562 while (ltoken_getCode (nextToken) != LST_EOL)
564 QuantifierSymTok ();
565 InitReduce (QUANTIFIERSYMTOKS2);
569 static void
570 LogicalOpToks (void)
572 LogicalOpTok ();
573 InitReduce (LOGICALOPTOKS1);
575 while (ltoken_getCode (nextToken) != LST_EOL)
577 LogicalOpTok ();
578 InitReduce (LOGICALOPTOKS2);
582 static void
583 EqOpToks (void)
585 EqOpTok ();
586 InitReduce (LRC_EQOPTOKS1);
588 while (ltoken_getCode (nextToken) != LST_EOL)
590 EqOpTok ();
591 InitReduce (LRC_EQOPTOKS2);
595 static void
596 EquationSymToks (void)
598 EquationSymTok ();
599 InitReduce (LRC_EQUATIONSYMTOKS1);
601 while (ltoken_getCode (nextToken) != LST_EOL)
603 EquationSymTok ();
604 InitReduce (LRC_EQUATIONSYMTOKS2);
608 static void
609 EqSepSymToks (void)
611 EqSepSymTok ();
612 InitReduce (LRC_EQSEPSYMTOKS1);
614 while (ltoken_getCode (nextToken) != LST_EOL)
616 EqSepSymTok ();
617 InitReduce (LRC_EQSEPSYMTOKS2);
621 static void
622 SelectSymToks (void)
624 SelectSymTok ();
625 InitReduce (SELECTSYMTOKS1);
627 while (ltoken_getCode (nextToken) != LST_EOL)
629 SelectSymTok ();
630 InitReduce (SELECTSYMTOKS2);
634 static void
635 OpenSymToks (void)
637 OpenSymTok ();
638 InitReduce (OPENSYMTOKS1);
640 while (ltoken_getCode (nextToken) != LST_EOL)
642 OpenSymTok ();
643 InitReduce (OPENSYMTOKS2);
647 static void
648 SepSymToks (void)
650 SepSymTok ();
651 InitReduce (SEPSYMTOKS1);
653 while (ltoken_getCode (nextToken) != LST_EOL)
655 SepSymTok ();
656 InitReduce (SEPSYMTOKS2);
660 static void
661 CloseSymToks (void)
663 CloseSymTok ();
664 InitReduce (CLOSESYMTOKS1);
666 while (ltoken_getCode (nextToken) != LST_EOL)
668 CloseSymTok ();
669 InitReduce (CLOSESYMTOKS2);
673 static void
674 SimpleIdToks (void)
676 SimpleIdTok ();
677 InitReduce (SIMPLEIDTOKS1);
679 while (ltoken_getCode (nextToken) != LST_EOL)
681 SimpleIdTok ();
682 InitReduce (SIMPLEIDTOKS2);
686 static void
687 MapSymToks (void)
689 MapSymTok ();
690 InitReduce (MAPSYMTOKS1);
692 while (ltoken_getCode (nextToken) != LST_EOL)
694 MapSymTok ();
695 InitReduce (MAPSYMTOKS2);
699 static void
700 MarkerSymToks (void)
702 MarkerSymTok ();
703 InitReduce (MARKERSYMTOKS1);
705 while (ltoken_getCode (nextToken) != LST_EOL)
707 MarkerSymTok ();
708 InitReduce (MARKERSYMTOKS2);
712 static void
713 CommentSymToks (void)
715 CommentSymTok ();
716 InitReduce (COMMENTSYMTOKS1);
718 while (ltoken_getCode (nextToken) != LST_EOL)
720 CommentSymTok ();
721 InitReduce (COMMENTSYMTOKS2);
725 static void
726 QuantifierSymTok (void)
728 Token ();
729 InitReduce (QUANTIFIERSYMTOK1);
732 static void
733 LogicalOpTok (void)
735 Token ();
736 InitReduce (LOGICALOPTOK1);
739 static void
740 EqOpTok (void)
742 Token ();
743 InitReduce (LRC_EQOPTOK1);
746 static void
747 EquationSymTok (void)
749 /* ### EquationSymTok (); ### */
750 Token ();
751 InitReduce (LRC_EQUATIONSYMTOK1);
754 static void
755 EqSepSymTok (void)
757 Token ();
758 InitReduce (LRC_EQSEPSYMTOK1);
762 static void
763 SelectSymTok (void)
765 Token ();
766 InitReduce (SELECTSYMTOK1);
769 static void
770 OpenSymTok (void)
772 Token ();
773 InitReduce (OPENSYMTOK1);
776 static void
777 SepSymTok (void)
779 Token ();
780 InitReduce (SEPSYMTOK1);
783 static void
784 CloseSymTok (void)
786 Token ();
787 InitReduce (CLOSESYMTOK1);
790 static void
791 SimpleIdTok (void)
793 Token ();
794 InitReduce (SIMPLEIDTOK1);
797 static void
798 MapSymTok (void)
800 Token ();
801 InitReduce (MAPSYMTOK1);
804 static void
805 MarkerSymTok (void)
807 Token ();
808 InitReduce (MARKERSYMTOK1);
812 static void
813 CommentSymTok (void)
815 Token ();
816 InitReduce (COMMENTSYMTOK1);
820 static void
821 SynClass (void)
823 if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken))
825 ltoken_free (nextToken);
826 nextToken = LSLScanNextToken ();
828 OldToken ();
829 NewToken ();
831 InitReduce (SYNCLASS1);
833 else
835 LocalUserError (nextToken, "expected synonym classification");
840 static void
841 OldToken (void)
843 Token ();
844 InitReduce (OLDTOKEN1);
848 static void
849 NewToken (void)
851 Token ();
852 InitReduce (NEWTOKEN1);
856 static void
857 Token (void)
859 if (ltoken_getCode (nextToken) == LST_EOL
860 || ltoken_getCode (nextToken) == LEOFTOKEN)
862 LocalUserError (nextToken, "unexpected end-of-line or end-of-file");
864 else
866 LSLGenShiftOnly (nextToken);
867 nextToken = LSLScanNextToken ();
872 ** Init File Processing Routines, these routines use the shift-reduce sequence
873 ** produced by the init file parser and update the necessary tables for the
874 ** scanner.
876 ** The same shift stack is used that LSL parser uses. A different reduce
877 ** procedure is used because the init file grammar is different from the LSL
878 ** grammar.
882 static void
883 InitReduce (LSLInitRuleCode rule)
885 switch (rule)
887 case INITFILE1:
888 LTRACE ("INITFILE1");
889 break;
891 case INITLINES1:
892 LTRACE ("INITLINES1");
893 break;
895 case INITLINES2:
896 LTRACE ("INITLINES2");
897 break;
899 case INITLINES3:
900 LTRACE ("INITLINES3");
901 break;
903 case INITLINE1:
904 LTRACE ("INITLINE1");
905 break;
907 case INITLINE2:
908 LTRACE ("INITLINE2");
909 break;
911 case CLASSIFICATION1:
912 LTRACE ("CLASSIFICATION1");
913 break;
915 case CLASSIFICATION2:
916 LTRACE ("CLASSIFICATION2");
917 break;
919 case CLASSIFICATION3:
920 LTRACE ("CLASSIFICATION3");
921 break;
923 case CHARCLASS1:
924 LTRACE ("CHARCLASS1");
925 break;
927 case CHARCLASS2:
928 LTRACE ("CHARCLASS2");
929 break;
931 case CHARCLASS3:
932 LTRACE ("CHARCLASS3");
933 break;
935 case CHARCLASS4:
936 LTRACE ("CHARCLASS4");
937 break;
939 case CHARCLASS5:
940 LTRACE ("CHARCLASS5");
941 break;
943 case CHARCLASS6:
944 LTRACE ("CHARCLASS6");
945 break;
947 case LRC_ENDCOMMENT1:
948 LTRACE ("LRC_ENDCOMMENT1");
949 break;
951 case LRC_ENDCOMMENT2:
952 LTRACE ("LRC_ENDCOMMENT2");
953 break;
955 case IDCHARS1:
956 LTRACE ("IDCHARS1");
957 break;
959 case IDCHARS2:
960 LTRACE ("IDCHARS2");
961 break;
963 case OPCHARS1:
964 LTRACE ("OPCHARS1");
965 break;
967 case OPCHARS2:
968 LTRACE ("OPCHARS2");
969 break;
971 case LRC_EXTENSIONCHAR1:
972 LTRACE ("LRC_EXTENSIONCHAR1");
973 ProcessExtensionChar ();
974 break;
976 case SINGCHARS1:
977 LTRACE ("SINGCHARS1");
978 break;
980 case SINGCHARS2:
981 LTRACE ("SINGCHARS2");
982 break;
984 case WHITECHARS1:
985 LTRACE ("WHITECHARS1");
986 break;
988 case WHITECHARS2:
989 LTRACE ("WHITECHARS2");
990 break;
992 case LRC_ENDCOMMENTCHAR1:
993 LTRACE ("LRC_ENDCOMMENTCHAR1");
994 ProcessEndCommentChar ();
995 break;
997 case IDCHAR1:
998 LTRACE ("IDCHAR1");
999 ProcessSingleChar (IDCHAR);
1000 break;
1002 case OPCHAR1:
1003 LTRACE ("OPCHAR1");
1004 ProcessSingleChar (OPCHAR);
1005 break;
1007 case SINGCHAR1:
1008 LTRACE ("SINGCHAR1");
1009 ProcessSingleChar (SINGLECHAR);
1010 break;
1012 case WHITECHAR1:
1013 LTRACE ("CHAR1");
1014 ProcessSingleChar (WHITECHAR);
1015 break;
1017 case TOKENCLASS1:
1018 LTRACE ("TOKENCLASS1");
1019 break;
1021 case TOKENCLASS2:
1022 LTRACE ("TOKENCLASS2");
1023 break;
1025 case TOKENCLASS3:
1026 LTRACE ("TOKENCLASS3");
1027 break;
1029 case TOKENCLASS4:
1030 LTRACE ("TOKENCLASS4");
1031 break;
1033 case TOKENCLASS5:
1034 LTRACE ("TOKENCLASS5");
1035 break;
1037 case TOKENCLASS6:
1038 LTRACE ("TOKENCLASS6");
1039 break;
1041 case TOKENCLASS7:
1042 LTRACE ("TOKENCLASS7");
1043 break;
1045 case TOKENCLASS8:
1046 LTRACE ("TOKENCLASS8");
1047 break;
1049 case TOKENCLASS9:
1050 LTRACE ("TOKENCLASS9");
1051 break;
1053 case TOKENCLASS10:
1054 LTRACE ("TOKENCLASS10");
1055 break;
1057 case TOKENCLASS11:
1058 LTRACE ("TOKENCLASS11");
1059 break;
1061 case TOKENCLASS12:
1062 LTRACE ("TOKENCLASS12");
1063 break;
1065 case TOKENCLASS13:
1066 LTRACE ("TOKENCLASS13");
1067 break;
1069 case QUANTIFIERSYMTOKS1:
1070 LTRACE ("QUALIFERSYMTOKS1");
1071 break;
1073 case QUANTIFIERSYMTOKS2:
1074 LTRACE ("QUANTIFIERSYMTOKS2");
1075 break;
1077 case LOGICALOPTOKS1:
1078 LTRACE ("LOGICALOPTOKS1");
1079 break;
1081 case LOGICALOPTOKS2:
1082 LTRACE ("LOGICALOPTOKS2");
1083 break;
1085 case LRC_EQOPTOKS1:
1086 LTRACE ("LRC_EQOPTOKS1");
1087 break;
1089 case LRC_EQOPTOKS2:
1090 LTRACE ("LRC_EQOPTOKS2");
1091 break;
1093 case LRC_EQUATIONSYMTOKS1:
1094 LTRACE ("LRC_EQUATIONSYMTOKS1");
1095 break;
1097 case LRC_EQUATIONSYMTOKS2:
1098 LTRACE ("LRC_EQUATIONSYMTOKS2");
1099 break;
1101 case LRC_EQSEPSYMTOKS1:
1102 LTRACE ("LRC_EQSEPSYMTOKS1");
1103 break;
1105 case LRC_EQSEPSYMTOKS2:
1106 LTRACE ("LRC_EQSEPSYMTOKS2");
1107 break;
1109 case SELECTSYMTOKS1:
1110 LTRACE ("SELECTSYMTOKS1");
1111 break;
1113 case SELECTSYMTOKS2:
1114 LTRACE ("SELECTSYMTOKS2");
1115 break;
1117 case OPENSYMTOKS1:
1118 LTRACE ("OPENSYMTOKS1");
1119 break;
1121 case OPENSYMTOKS2:
1122 LTRACE ("OPENSYMTOKS2");
1123 break;
1125 case SEPSYMTOKS1:
1126 LTRACE ("SEPSYMTOKS1");
1127 break;
1129 case SEPSYMTOKS2:
1130 LTRACE ("SEPSYMTOKS2");
1131 break;
1133 case CLOSESYMTOKS1:
1134 LTRACE ("CLOSESYMTOKS1");
1135 break;
1137 case CLOSESYMTOKS2:
1138 LTRACE ("CLOSESYMTOKS2");
1139 break;
1141 case SIMPLEIDTOKS1:
1142 LTRACE ("SIMPLEIDTOKS1");
1143 break;
1145 case SIMPLEIDTOKS2:
1146 LTRACE ("SIMPLEIDTOKS2");
1147 break;
1149 case MAPSYMTOKS1:
1150 LTRACE ("MAPSYMTOKS1");
1151 break;
1153 case MAPSYMTOKS2:
1154 LTRACE ("MAPSYMTOKS2");
1155 break;
1157 case MARKERSYMTOKS1:
1158 LTRACE ("MARKERSYMTOKS1");
1159 break;
1161 case MARKERSYMTOKS2:
1162 LTRACE ("MARKERSYMTOKS2");
1163 break;
1165 case COMMENTSYMTOKS1:
1166 LTRACE ("COMMENTSYMTOKS1");
1167 break;
1169 case COMMENTSYMTOKS2:
1170 LTRACE ("COMMENTSYMTOKS2");
1171 break;
1173 case QUANTIFIERSYMTOK1:
1174 LTRACE ("QUANTIFERSYMTOK1");
1175 ProcessToken (LST_QUANTIFIERSYM);
1176 break;
1178 case LOGICALOPTOK1:
1179 LTRACE ("LOGICALOPTOK1");
1180 ProcessToken (LST_LOGICALOP);
1181 break;
1183 case LRC_EQOPTOK1:
1184 LTRACE ("LRC_EQOPTOK1");
1185 ProcessToken (LST_EQOP);
1186 break;
1188 case LRC_EQUATIONSYMTOK1:
1189 LTRACE ("LRC_EQUATIONSYMTOK1");
1190 ProcessToken (LST_EQUATIONSYM);
1191 break;
1193 case LRC_EQSEPSYMTOK1:
1194 LTRACE ("LRC_EQSEPSYMTOK1");
1195 ProcessToken (LST_EQSEPSYM);
1196 break;
1198 case SELECTSYMTOK1:
1199 LTRACE ("SELECTSYMTOK1");
1200 ProcessToken (LST_SELECTSYM);
1201 break;
1203 case OPENSYMTOK1:
1204 LTRACE ("OPENSYMTOK1");
1205 ProcessToken (LST_OPENSYM);
1206 break;
1208 case SEPSYMTOK1:
1209 LTRACE ("SEPSYMTOK1");
1210 ProcessToken (LST_SEPSYM);
1211 break;
1213 case CLOSESYMTOK1:
1214 LTRACE ("CLOSESYMTOK1");
1215 ProcessToken (LST_CLOSESYM);
1216 break;
1218 case SIMPLEIDTOK1:
1219 LTRACE ("SIMPLEIDTOK1");
1220 ProcessToken (LST_SIMPLEID);
1221 break;
1223 case MAPSYMTOK1:
1224 LTRACE ("MAPSYMTOK1");
1225 ProcessToken (LST_MAPSYM);
1226 break;
1228 case MARKERSYMTOK1:
1229 LTRACE ("MARKERSYMTOK1");
1230 ProcessToken (LST_MARKERSYM);
1231 break;
1233 case COMMENTSYMTOK1:
1234 LTRACE ("COMMENTSYMTOK1");
1235 ProcessToken (LST_COMMENTSYM);
1236 break;
1238 case SYNCLASS1:
1239 LTRACE ("SYNCLASS1");
1240 ProcessSynonym ();
1241 break;
1243 case OLDTOKEN1:
1244 LTRACE ("OLDTOKEN1");
1245 break;
1247 case NEWTOKEN1:
1248 LTRACE ("NEWTOKEN1");
1249 break;
1251 default:
1252 llcontbuglit ("InitReduce: bad switch");
1253 break;
1255 } /* end switch */
1256 } /* end InitReduce () */
1260 /* Reset the first character of the predefined extensionChar keywords when */
1261 /* the extensionChar changes. e.g. "extensionChar @" changes "forall" to */
1262 /* "@forall". */
1264 static void
1265 UpdateXCharKeywords (charCode xCharCode)
1267 char xChar = (char) xCharCode;
1268 char *str;
1270 str = ltoken_getTextChars (ltoken_forall);
1271 *str = xChar;
1273 str = ltoken_getTextChars (ltoken_and);
1274 *str = xChar;
1276 str = ltoken_getTextChars (ltoken_or);
1277 *str = xChar;
1279 str = ltoken_getTextChars (ltoken_implies);
1280 *str = xChar;
1282 str = ltoken_getTextChars (ltoken_eq);
1283 *str = xChar;
1285 str = ltoken_getTextChars (ltoken_neq);
1286 *str = xChar;
1288 str = ltoken_getTextChars (ltoken_equals);
1289 *str = xChar;
1291 str = ltoken_getTextChars (ltoken_eqsep);
1292 *str = xChar;
1294 str = ltoken_getTextChars (ltoken_select);
1295 *str = xChar;
1297 str = ltoken_getTextChars (ltoken_open);
1298 *str = xChar;
1300 str = ltoken_getTextChars (ltoken_sep);
1301 *str = xChar;
1303 str = ltoken_getTextChars (ltoken_close);
1304 *str = xChar;
1306 str = ltoken_getTextChars (ltoken_id);
1307 *str = xChar;
1309 str = ltoken_getTextChars (ltoken_arrow);
1310 *str = xChar;
1312 str = ltoken_getTextChars (ltoken_marker);
1313 *str = xChar;
1315 str = ltoken_getTextChars (ltoken_comment);
1316 *str = xChar;
1320 /* Different from ProcessCharClass because only allow one extension */
1321 /* character. Therefore, the present extension character must be set to a */
1322 /* singleChar. */
1324 static void
1325 ProcessExtensionChar (void)
1327 ltoken stackToken = LSLGenTopPopShiftStack ();
1328 char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1330 if (!defineSingleChar[(int)firstChar]
1331 && lscanCharClass (firstChar) == SINGLECHAR)
1333 /* Is a single character that has not been defined before. */
1334 /* Can only have one extension char. Release old one. */
1335 lsetCharClass (firstChar, CHC_EXTENSION);
1337 /* this is a (bogus) type bug! caught by splint */
1338 /* lsetCharClass (currentExtensionChar, SINGLECHAR); */
1340 lsetCharClass ((char) currentExtensionChar, SINGLECHAR);
1342 currentExtensionChar = (charCode) firstChar;
1343 UpdateXCharKeywords (currentExtensionChar);
1345 else
1347 /* Already redefined. Don't allow to be redefined. */
1348 LocalUserError (stackToken, "character is already defined, cannot redefine");
1350 ltoken_free (stackToken);
1353 /* Different from ProcessSingleChar because allow any characters to be */
1354 /* endCommentChar and also set a different part of the scanner structure. */
1356 static void
1357 ProcessEndCommentChar (void)
1359 ltoken stackToken = LSLGenTopPopShiftStack ();
1360 char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1362 if (LSLIsEndComment (firstChar))
1364 LocalUserError (stackToken,
1365 "already defined as a endCommentChar, cannot redefine");
1367 else
1369 lsetEndCommentChar (firstChar, TRUE);
1371 ltoken_free (stackToken);
1374 static void
1375 ProcessSingleChar (charCode code)
1377 ltoken stackToken = LSLGenTopPopShiftStack ();
1378 char firstChar = cstring_firstChar (ltoken_unparse (stackToken));
1380 if (!defineSingleChar[(int)firstChar]
1381 && lscanCharClass (firstChar) == SINGLECHAR)
1383 /* Is a single character that has not been defined before. */
1384 /* It's OK to redefine once. */
1385 lsetCharClass (firstChar, code);
1386 /* OK to mark as a defined singleChar even if not. Only check */
1387 /* defineSingleChar[] if defining a singleChar. */
1388 defineSingleChar[(int)firstChar] = TRUE;
1390 else
1392 LocalUserError (stackToken, "character is already defined, cannot redefine");
1394 ltoken_free (stackToken);
1397 static void
1398 PrintToken (ltoken tok)
1400 char *codStr;
1402 switch (ltoken_getCode (tok))
1404 case NOTTOKEN: codStr = "*** NOTTOKEN ***"; break;
1405 case LST_QUANTIFIERSYM: codStr = "QUANTIFIERSYM"; break;
1406 case LST_LOGICALOP: codStr = "LOGICALOP: "; break;
1407 case LST_SELECTSYM: codStr = "LST_SELECTSYM"; break;
1408 case LST_OPENSYM: codStr = "LST_OPENSYM"; break;
1409 case LST_SEPSYM: codStr = "SEPSYM"; break;
1410 case LST_CLOSESYM: codStr = "LST_CLOSESYM"; break;
1411 case LST_SIMPLEID: codStr = "LST_SIMPLEID"; break;
1412 case LST_MAPSYM: codStr = "MAPSYM"; break;
1413 case LST_MARKERSYM: codStr = "LST_MARKERSYM"; break;
1414 case LST_COMMENTSYM: codStr = "COMMENTSYM"; break;
1415 case LST_SIMPLEOP: codStr = "SIMPLEOP"; break;
1416 case LST_COLON: codStr = "LST_COLON"; break;
1417 case LST_COMMA: codStr = "COMMA"; break;
1418 case LST_LBRACKET: codStr = "LST_LBRACKET"; break;
1419 case LST_LPAR: codStr = "LST_LPAR"; break;
1420 case LST_RBRACKET: codStr = "LST_RBRACKET"; break;
1421 case LST_RPAR: codStr = "LST_RPAR"; break;
1422 case LST_EQOP: codStr = "LST_EQOP"; break;
1423 case LST_WHITESPACE: codStr = "WHITESPACE,"; break;
1424 case LST_EOL: codStr = "LST_EOL"; break;
1425 case LST_elseTOKEN: codStr = "elseTOKEN"; break;
1426 case LST_ifTOKEN: codStr = "ifTOKEN"; break;
1427 case LST_thenTOKEN: codStr = "thenTOKEN"; break;
1428 case LST_BADTOKEN: codStr = "*** BADTOKEN ***"; break;
1429 case LEOFTOKEN: /* can't reach LEOFTOKEN easily */
1430 codStr = "LEOFTOKEN"; break;
1431 default:
1432 codStr = "*** invalid token code ***";
1433 break;
1434 } /* end switch */
1436 /* only used for debugging */
1437 printf ("%u:%u: Token Code (%u): %s",
1438 ltoken_getLine (tok), ltoken_getCol (tok),
1439 ltoken_getCode (tok), codStr);
1440 if (ltoken_getRawText (tok) != 0)
1442 printf (", Token String (%lu): %s\n",
1443 ltoken_getRawText (tok), ltoken_getRawTextChars (tok));
1445 else printf ("\n");
1448 static void
1449 ProcessToken (ltokenCode code)
1451 ltoken stackToken, temp;
1452 lsymbol sym;
1454 stackToken = LSLGenTopPopShiftStack ();
1455 sym = ltoken_getText (stackToken);
1457 if (LSLIsSyn (sym))
1459 LocalUserError (stackToken,
1460 "already defined as a synonym, cannot redefine");
1463 /* Get the token from the token table, so can check if the token */
1464 /* was updated by a previous token. */
1465 temp = LSLGetToken (sym);
1467 if (ltoken_isStateDefined (temp))
1469 if ((code == LST_OPENSYM && sym == lsymbol_fromChars ("[")) ||
1470 (code == LST_CLOSESYM && sym == lsymbol_fromChars ("]")))
1472 /* ignore "openSym [" and "closeSym ]" TokenClass */
1473 ltoken_free (stackToken);
1474 return;
1476 else
1478 LocalUserError (stackToken, "already defined, cannot redefine");
1479 PrintToken (temp);
1483 LSLUpdateToken (code, ltoken_getText (stackToken), TRUE);
1484 ltoken_free (stackToken);
1488 static void
1489 ProcessSynonym (void)
1491 ltoken newtok;
1492 ltoken oldtok;
1494 newtok = LSLGenTopPopShiftStack ();
1495 oldtok = LSLGenTopPopShiftStack ();
1497 if (ltoken_wasSyn (newtok))
1499 /* The token has a synonym. This means that the synonym was in the */
1500 /* init file, so complain about redefining as a synonym again */
1501 LocalUserError (newtok, "newtok already is a synonym, cannot redefine");
1504 if (ltoken_hasSyn (newtok))
1507 ** newtok already has a synonym defined for it. Do not allow
1508 ** synonyms to be chained.
1511 LocalUserError (newtok,
1512 "newtok already has a synonym, cannot chain synonyms");
1515 if (ltoken_isStateDefined (newtok))
1517 LocalUserError (newtok, "newtok already defined, cannot redefine");
1520 LSLAddSyn (ltoken_getText (newtok), ltoken_getText (oldtok));
1521 ltoken_free (oldtok);
1522 ltoken_free (newtok);
1527 * Utilities, in alphabetical order
1530 static void
1531 LocalUserError (ltoken t, /*@temp@*/ char *msg)
1533 lldiagmsg (message ("%s %s in the LSL init file:",
1534 ltoken_unparse (t), cstring_fromChars (msg)));
1536 ltoken_free (nextToken);
1537 nextToken = LSLScanNextToken ();
1539 while (ltoken_getCode (nextToken) != LST_EOL)
1541 ltoken_free (nextToken);
1542 nextToken = LSLScanNextToken ();
1547 ** Required initialization and cleanup routines
1550 static /*@exposed@*/ ltoken insertSimpleToken (char *text)
1551 /*@modifies internalState@*/
1553 return (LSLInsertToken (LST_SIMPLEID, lsymbol_fromChars (text), 0, FALSE));
1556 static void
1557 lslinit_initProcessInitFile (void)
1559 int i;
1561 LSLGenInit (TRUE); /* parsing LSLinit not LCLinit */
1564 ** Insert the init file keywords into the token table as undefined
1565 ** SIMPLEIDs. They are defined as simpleIds since they must be treated
1566 ** that way if they do not appear as the first token on a line, and
1567 ** they must be treated that way for the actual LSL parsing. Save the
1568 ** tokens so can recognize as init file keywords when necessary.
1571 endCommentCharToken = insertSimpleToken ("endCommentChar");
1572 idCharToken = insertSimpleToken ("idChar");
1573 opCharToken = insertSimpleToken ("opChar");
1574 extensionCharToken = insertSimpleToken ("extensionChar");
1575 singleCharToken = insertSimpleToken ("singleChar");
1576 whiteCharToken = insertSimpleToken ("whiteChar");
1578 quantifierSymToken = insertSimpleToken ("quantifierSym");
1579 logicalOpToken = insertSimpleToken ("logicalOp");
1580 eqOpToken = insertSimpleToken ("eqOp");
1581 equationSymToken = insertSimpleToken ("equationSym");
1582 eqSepSymToken = insertSimpleToken ("eqSepSym");
1583 selectSymToken = insertSimpleToken ("selectSym");
1584 openSymToken = insertSimpleToken ("openSym");
1585 sepSymToken = insertSimpleToken ("sepSym");
1586 closeSymToken = insertSimpleToken ("closeSym");
1587 simpleIdToken = insertSimpleToken ("simpleId");
1588 mapSymToken = insertSimpleToken ("mapSym");
1589 markerSymToken = insertSimpleToken ("markerSym");
1590 commentSymToken = insertSimpleToken ("commentSym");
1591 synonymToken = insertSimpleToken ("synonym");
1593 for (i = 0; i <= LASTCHAR; i++)
1595 defineSingleChar[i] = FALSE;
1599 ** Record the current extension character so can redefine back to
1600 ** singleChar if a new extension character is redefined.
1603 currentExtensionChar = (charCode) CHAREXTENDER;
1605 LSLReportEolTokens (TRUE);
1606 ltoken_free (nextToken);
1607 nextToken = LSLScanNextToken ();
1610 void lslinit_process (void)
1611 /*@globals undef g_symtab; @*/
1612 /*@modifies g_symtab, internalState, fileSystem; @*/
1615 ** Open init file provided by user, or use the default LCL init file
1618 cstring larchpath = context_getLarchPath ();
1619 inputStream initstream = inputStream_undefined;
1621 setCodePoint ();
1623 if (inputStream_isUndefined (s_initFile))
1625 s_initFile = inputStream_create (cstring_makeLiteral (INITFILENAME),
1626 cstring_makeLiteralTemp (LCLINIT_SUFFIX),
1627 FALSE);
1629 if (!inputStream_getPath (larchpath, s_initFile))
1631 lldiagmsg (message ("Continuing without LCL init file: %s",
1632 inputStream_fileName (s_initFile)));
1634 else
1636 if (!inputStream_open (s_initFile))
1638 lldiagmsg (message ("Continuing without LCL init file: %s",
1639 inputStream_fileName (s_initFile)));
1643 else
1645 if (!inputStream_open (s_initFile))
1647 lldiagmsg (message ("Continuing without LCL init file: %s",
1648 inputStream_fileName (s_initFile)));
1652 /* Initialize checker */
1654 lsymbol_initMod ();
1655 LCLSynTableInit ();
1657 setCodePoint ();
1659 LCLSynTableReset ();
1660 LCLTokenTableInit ();
1662 setCodePoint ();
1664 LCLScanLineInit ();
1665 setCodePoint ();
1666 LCLScanLineReset ();
1667 setCodePoint ();
1668 LCLScanInit ();
1670 setCodePoint ();
1672 /* need this to initialize LCL checker */
1674 llassert (inputStream_isDefined (s_initFile));
1675 if (inputStream_isOpen (s_initFile))
1677 setCodePoint ();
1679 LCLScanReset (s_initFile);
1680 lclinit_initMod ();
1681 lclinit_reset ();
1683 setCodePoint ();
1684 lclinit_process ();
1685 lclinit_cleanup ();
1687 setCodePoint ();
1688 check (inputStream_close (s_initFile));
1691 /* Initialize LSL init files, for parsing LSL signatures from LSL */
1693 initstream = inputStream_create (cstring_makeLiteral ("lslinit.lsi"),
1694 cstring_makeLiteralTemp (".lsi"),
1695 FALSE);
1697 if (!inputStream_getPath (larchpath, initstream))
1699 lldiagmsg (message ("Continuing without LSL init file: %s",
1700 inputStream_fileName (initstream)));
1702 else
1704 if (!inputStream_open (initstream))
1706 lldiagmsg (message ("Continuing without LSL init file: %s",
1707 inputStream_fileName (initstream)));
1711 setCodePoint ();
1712 lsynTableInit ();
1713 lsynTableReset ();
1715 setCodePoint ();
1716 ltokenTableInit ();
1718 setCodePoint ();
1719 lscanLineInit ();
1720 lscanLineReset ();
1721 LSLScanInit ();
1723 if (inputStream_isOpen (initstream))
1725 setCodePoint ();
1726 LSLScanReset (initstream);
1727 lslinit_initProcessInitFile ();
1728 lslinit_processInitFile ();
1729 check (inputStream_close (initstream));
1732 inputStream_free (initstream);
1734 if (lclHadError ())
1736 lclplainerror
1737 (cstring_makeLiteral ("LSL init file error. Attempting to continue."));
1740 setCodePoint ();
1741 g_symtab = symtable_new ();
1744 ** sort_init must come after symtab has been initialized
1746 sort_init ();
1747 abstract_init ();
1748 setCodePoint ();
1751 ** Equivalent to importing old spec_csupport.lcl
1752 ** define immutable LCL type "bool" and bool constants TRUE and FALSE
1753 ** and initialized them to be equal to LSL's "true" and "false".
1755 ** Reads in CTrait.syms (derived from CTrait.lsl) on LARCH_PATH.
1758 LCLBuiltins ();
1759 LCLReportEolTokens (FALSE);