# include "tokentable.h"
# include "syntable.h"
# include "lslinit.h"
-# include "lclinit.h"
/* needed to parse init files */
# include "shift.h"
static /*@only@*/ ltoken nextToken;
-static /*@only@*/ /*@null@*/ inputStream s_initFile = inputStream_undefined;
-
static void InitFile (void) /*@modifies nextToken@*/ ;
static void InitLines (void) /*@modifies nextToken@*/ ;
static void InitLine (void) /*@modifies nextToken@*/ ;
}
void
-lslinit_setInitFile (inputStream s)
+LSLProcessInitFile (void)
{
- llassert (inputStream_isUndefined (s_initFile));
- s_initFile = s;
+ InitFile ();
}
/*
**
*/
-static void lslinit_processInitFile (void)
+static void
+InitFile (void)
{
InitLines ();
InitReduce (INITFILE1);
return (LSLInsertToken (LST_SIMPLEID, lsymbol_fromChars (text), 0, FALSE));
}
-static void
-lslinit_initProcessInitFile (void)
+void
+LSLProcessInitFileInit (void)
{
int i;
nextToken = LSLScanNextToken ();
}
-void lslinit_process (void)
- /*@globals undef g_symtab; @*/
- /*@modifies g_symtab, internalState, fileSystem; @*/
-{
- /*
- ** Open init file provided by user, or use the default LCL init file
- */
-
- cstring larchpath = context_getLarchPath ();
- inputStream initstream = inputStream_undefined;
-
- setCodePoint ();
-
- if (inputStream_isUndefined (s_initFile))
- {
- s_initFile = inputStream_create (cstring_makeLiteral (INITFILENAME),
- cstring_makeLiteralTemp (LCLINIT_SUFFIX),
- FALSE);
-
- if (!inputStream_getPath (larchpath, s_initFile))
- {
- lldiagmsg (message ("Continuing without LCL init file: %s",
- inputStream_fileName (s_initFile)));
- }
- else
- {
- if (!inputStream_open (s_initFile))
- {
- lldiagmsg (message ("Continuing without LCL init file: %s",
- inputStream_fileName (s_initFile)));
- }
- }
- }
- else
- {
- if (!inputStream_open (s_initFile))
- {
- lldiagmsg (message ("Continuing without LCL init file: %s",
- inputStream_fileName (s_initFile)));
- }
- }
-
- /* Initialize checker */
-
- lsymbol_initMod ();
- LCLSynTableInit ();
-
- setCodePoint ();
-
- LCLSynTableReset ();
- LCLTokenTableInit ();
-
- setCodePoint ();
-
- LCLScanLineInit ();
- setCodePoint ();
- LCLScanLineReset ();
- setCodePoint ();
- LCLScanInit ();
- setCodePoint ();
- /* need this to initialize LCL checker */
- llassert (inputStream_isDefined (s_initFile));
- if (inputStream_isOpen (s_initFile))
- {
- setCodePoint ();
-
- LCLScanReset (s_initFile);
- lclinit_initMod ();
- lclinit_reset ();
- setCodePoint ();
- lclinit_process ();
- lclinit_cleanup ();
-
- setCodePoint ();
- check (inputStream_close (s_initFile));
- }
-
- /* Initialize LSL init files, for parsing LSL signatures from LSL */
-
- initstream = inputStream_create (cstring_makeLiteral ("lslinit.lsi"),
- cstring_makeLiteralTemp (".lsi"),
- FALSE);
-
- if (!inputStream_getPath (larchpath, initstream))
- {
- lldiagmsg (message ("Continuing without LSL init file: %s",
- inputStream_fileName (initstream)));
- }
- else
- {
- if (!inputStream_open (initstream))
- {
- lldiagmsg (message ("Continuing without LSL init file: %s",
- inputStream_fileName (initstream)));
- }
- }
-
- setCodePoint ();
- lsynTableInit ();
- lsynTableReset ();
- setCodePoint ();
- ltokenTableInit ();
- setCodePoint ();
- lscanLineInit ();
- lscanLineReset ();
- LSLScanInit ();
- if (inputStream_isOpen (initstream))
- {
- setCodePoint ();
- LSLScanReset (initstream);
- lslinit_initProcessInitFile ();
- lslinit_processInitFile ();
- check (inputStream_close (initstream));
- }
-
- inputStream_free (initstream);
-
- if (lclHadError ())
- {
- lclplainerror
- (cstring_makeLiteral ("LSL init file error. Attempting to continue."));
- }
-
- setCodePoint ();
- g_symtab = symtable_new ();
-
- /*
- ** sort_init must come after symtab has been initialized
- */
- sort_init ();
- abstract_init ();
- setCodePoint ();
-
- /*
- ** Equivalent to importing old spec_csupport.lcl
- ** define immutable LCL type "bool" and bool constants TRUE and FALSE
- ** and initialized them to be equal to LSL's "true" and "false".
- **
- ** Reads in CTrait.syms (derived from CTrait.lsl) on LARCH_PATH.
- */
-
- LCLBuiltins ();
- LCLReportEolTokens (FALSE);
-}