Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

lslparse.c File Reference

#include "lclintMacros.nf"
#include "llbasic.h"
#include "lclscan.h"
#include "signature.h"
#include "signature2.h"
#include "scan.h"
#include "scanline.h"
#include "syntable.h"
#include "tokentable.h"
#include "lslinit.h"
#include "lslparse.h"
#include "llmain.h"

Go to the source code of this file.

Functions

int parseSignatures (cstring infile)
lslOp parseOpLine (char *fname, char *line)
lsymbol processTraitSortId (lsymbol sortid)
void callLSL ( char *specfile, char *text)
void readlsignatures (interfaceNode n)

Variables

lslOp g_importedlslOp = NULL
bool g_lslParsingTraits = FALSE


Function Documentation

void callLSL ( char * specfile,
char * text )
 

Definition at line 372 of file lslparse.c.

Referenced by importCTrait(), and readlsignatures().

00373 {
00374   /* specfile is the name of the LCL file that contains "uses"
00375      Create an intermediate file named
00376      specfile_<TEMP_LSL_SUFFIX>.<TEMP_LSL_IN_SUFFIX>.
00377      put text in the file, run lsl on it and direct
00378      output to specfile_<TEMP_LSL_SUFFIX>.<TEMP_LSL_OUT_SUFFIX>.
00379      specfile can be a full pathname.
00380      Note: LSL does not support traitnames that are pathnames, only
00381      symbols. 
00382      */
00383 
00384   char *infile, *outfile;
00385   char *tmp1, *tmp2;
00386   FILE *inptr;
00387 
00388   infile = cstring_toCharsSafe (fileName (fileTable_addltemp (context_fileTable ())));
00389   
00390   inptr = fopen (infile, "w");
00391   
00392   if (inptr == NULL)
00393     {
00394       /* fopen fails */
00395       llfatalerror (message ("Unable to write intermediate file: %s", 
00396                              cstring_fromChars (infile)));
00397     }
00398   
00399   tmp1 = removePath (infile);
00400   tmp2 = removeAnyExtension (tmp1);
00401 
00402   fprintf (inptr, "%s : trait\n", tmp2);
00403   sfree (tmp1);
00404   sfree (tmp2);
00405 
00406   fprintf (inptr, "%s", text);
00407   check (fclose (inptr) == 0);
00408 
00409   /* the default is to delete the input file */
00410 
00411   outfile = cstring_toCharsSafe (fileName (fileTable_addltemp (context_fileTable ())));
00412   invokeLSL (infile, outfile, context_getFlag (FLG_KEEP));
00413   sfree (text);
00414 }

lslOp parseOpLine ( char * fname,
char * line )
 

Definition at line 113 of file lslparse.c.

Referenced by o_fctInfo().

00114 {
00115   tsource *sourceFile;
00116   bool status;
00117 
00118   sourceFile = tsource_fromString (fname, line);
00119   
00120   if (check (tsource_open (sourceFile)))
00121     {
00122       LSLScanReset (sourceFile);
00123       LSLReportEolTokens (FALSE); /* 0 by default, lslParsingTraits = 0; */
00124       
00125       /*
00126       ** lsl parsing and importing .lcs files are expected to be mutually
00127       ** exclusive. 
00128       **
00129       ** lslparse sets importedlslOp
00130       */
00131       
00132       status = (lslparse () != 0);
00133       
00134       if (status)
00135         {
00136           lclplainfatalerror (message ("Error in parsing line: %s", 
00137                                        cstring_fromChars (line)));
00138         }
00139       
00140       (void) tsource_close (sourceFile);
00141     }
00142 
00143   tsource_free (sourceFile);
00144   
00145   llassert (g_importedlslOp != NULL);
00146   return (lslOp_copy (g_importedlslOp));
00147 }

int parseSignatures ( cstring infile )
 

Definition at line 55 of file lslparse.c.

Referenced by importCTrait().

00056 {
00057   char *cinfile = cstring_toCharsSafe (infile);
00058   tsource *sourceFile;
00059   ltoken *id = (ltoken *) dmalloc (sizeof (*id));
00060   int status = 0;
00061 
00062   /* parse traits */
00063   *id = LSLInsertToken (LST_SIMPLEID, lsymbol_fromChars (cinfile), 0, FALSE);
00064   ltoken_setFileName (*id, cinfile);
00065   ltoken_setLine (*id, 0);
00066   ltoken_setCol (*id, 0);
00067 
00068   sourceFile = tsource_create (cinfile, "", FALSE);
00069 
00070   if (!tsource_getPath (cstring_toCharsSafe (context_getLarchPath ()), sourceFile))
00071     {
00072       lclplainerror 
00073         (message ("LSL signature parsing: can't find file %s containing trait",
00074                   cstring_fromChars (tsource_fileName (sourceFile))));
00075       status = 1;
00076 
00077       sfree (id);
00078       tsource_free (sourceFile);
00079       return status;
00080     }
00081 
00082   if (!tsource_open (sourceFile))
00083     {
00084       lclplainerror 
00085         (cstring_makeLiteral ("LSL parsing: can't open file containing trait"));
00086       status = 2;
00087       sfree (id);
00088       tsource_free (sourceFile);
00089 
00090       return status;
00091     }
00092 
00093   lsldebug = 0;
00094   g_lslParsingTraits = TRUE;
00095   LSLScanReset (sourceFile);
00096   LSLReportEolTokens (FALSE);
00097 
00098   status = lslparse ();
00099 
00100   /* symtable_dump (symtab, stdout, TRUE); */
00101   g_lslParsingTraits = FALSE;
00102 
00103   (void) tsource_close (sourceFile);
00104   tsource_free (sourceFile);
00105 
00106   sfree (id);
00107 
00108   
00109   return status;
00110 }

lsymbol processTraitSortId ( lsymbol sortid )
 

Definition at line 150 of file lslparse.c.

00151 {
00152   lsymbol out = lsymbol_sortFromType (g_symtab, sortid);
00153   if (out == sortid)
00154     { /* may be a new sort */
00155       (void) sort_fromLsymbol (sortid);
00156     }
00157   return out;
00158 }

void readlsignatures ( interfaceNode n )
 

Definition at line 505 of file lslparse.c.

00506 {
00507   /* assume n->kind = usesKIND */
00508   char *content;
00509   
00510   content = cstring_toCharsSafe (printTraitRefList2 (n->content.uses));
00511   callLSL (cstring_toCharsSafe (g_currentSpec), content);
00512 }


Variable Documentation

lslOp g_importedlslOp = NULL
 

Definition at line 49 of file lslparse.c.

bool g_lslParsingTraits = FALSE
 

Definition at line 50 of file lslparse.c.


Generated at Fri Nov 3 18:58:03 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000