[Plib-cvs] plib/src/psl psl.h,1.24,1.25 pslCompiler.cxx,1.28,1.29 pslCompiler.h,1.32,1.33 pslFileIO.
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2003-01-06 05:10:16
|
Update of /cvsroot/plib/plib/src/psl In directory sc8-pr-cvs1:/tmp/cvs-serv11734/plib/src/psl Modified Files: psl.h pslCompiler.cxx pslCompiler.h pslFileIO.cxx pslFileIO.h pslProgram.cxx Log Message: Added ability to compile from string variables. Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- psl.h 27 Sep 2002 21:19:59 -0000 1.24 +++ psl.h 6 Jan 2003 05:10:13 -0000 1.25 @@ -322,6 +322,7 @@ void dump () const ; int compile ( const char *fname ) ; + int compile ( const char *memptr, const char *fname ) ; int compile ( FILE *fd ) ; void reset () ; pslResult step () ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- pslCompiler.cxx 27 Sep 2002 15:45:06 -0000 1.28 +++ pslCompiler.cxx 6 Jan 2003 05:10:13 -0000 1.29 @@ -45,16 +45,34 @@ } -int pslCompiler::compile ( FILE *fd, const char *fname ) +int pslCompiler::compile ( const char *memptr, const char *fname ) { - const char *dump_env = getenv ( "PSL_DUMP" ) ; + init () ; + + _pslPushDefaultFile ( memptr, (fname == NULL) ? progName : fname ) ; + genProgram () ; + _pslPopDefaultFile () ; + + return cleanup () ; +} + +int pslCompiler::compile ( FILE *fd, const char *fname ) +{ init () ; _pslPushDefaultFile ( fd, (fname == NULL) ? progName : fname ) ; genProgram () ; _pslPopDefaultFile () ; + return cleanup () ; +} + + +int pslCompiler::cleanup () +{ + const char *dump_env = getenv ( "PSL_DUMP" ) ; + if ( num_errors != 0 || num_warnings != 0 ) fprintf ( stderr, "PSL: '%s' Compiled with %d Warnings, %d Fatal Errors\n", progName, num_warnings, num_errors ) ; Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- pslCompiler.h 30 Oct 2002 12:32:58 -0000 1.32 +++ pslCompiler.h 6 Jan 2003 05:10:13 -0000 1.33 @@ -236,6 +236,8 @@ void addFwdRef ( const char *s, pslAddress where ) ; void checkUnresolvedSymbols () ; + int cleanup () ; /* Report errors, etc after a compile */ + void pushLocality () { if ( locality_sp >= MAX_NESTING-1 ) @@ -388,6 +390,7 @@ void dump () const ; int compile ( const char *fname ) ; int compile ( FILE *fd, const char *fname = NULL ) ; + int compile ( const char *memptr, const char *prog_name ) ; } ; Index: pslFileIO.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslFileIO.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslFileIO.cxx 9 Nov 2002 21:43:58 -0000 1.7 +++ pslFileIO.cxx 6 Jan 2003 05:10:13 -0000 1.8 @@ -31,6 +31,7 @@ class pslFile { FILE *fd ; + const char *memptr ; char *fname ; int ungetStack [ MAX_UNGET_CHAR ] ; @@ -38,14 +39,9 @@ int line_no ; [...67 lines suppressed...] + + if ( c == '\0' ) + { + memptr = NULL ; + c = -1 ; + } + } + else + c = -1 ; if ( c == '\n' ) line_no++ ; @@ -117,6 +151,7 @@ void _pslPopDefaultFile () { delete defaultFileStack [ fileStackPointer - 1 ] ; } void _pslPushDefaultFile ( FILE *fd, const char *fname ) { new pslFile ( fd, fname ) ; } +void _pslPushDefaultFile ( const char *memptr, const char *fname ) { new pslFile ( memptr, fname ) ; } void _pslPushDefaultFile ( const char *fname ) { Index: pslFileIO.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslFileIO.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pslFileIO.h 15 Sep 2002 14:32:53 -0000 1.3 +++ pslFileIO.h 6 Jan 2003 05:10:14 -0000 1.4 @@ -26,6 +26,7 @@ void _pslPopDefaultFile () ; void _pslPushDefaultFile ( FILE *fd, const char *fname ) ; +void _pslPushDefaultFile ( const char *memptr, const char *fname ) ; void _pslPushDefaultFile ( const char *fname ) ; void _pslUnGetChar ( int c ) ; Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslProgram.cxx 30 Oct 2002 12:32:59 -0000 1.16 +++ pslProgram.cxx 6 Jan 2003 05:10:14 -0000 1.17 @@ -101,6 +101,15 @@ +int pslProgram::compile ( const char *memptr, const char *fname ) +{ + if ( strcmp ( getProgName(), "PSLprogram" ) == 0 ) + setProgName ( fname ) ; + + return compiler -> compile ( memptr, fname ) ; +} + + int pslProgram::compile ( const char *fname ) { if ( strcmp ( getProgName(), "PSLprogram" ) == 0 ) |