[Plib-cvs] plib/src/psl pslCodeGen.cxx,1.23,1.24 pslCompiler.cxx,1.21,1.22 pslCompiler.h,1.23,1.24 p
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-09-15 00:03:00
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv7115/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslExpression.cxx pslLocal.h Log Message: Added the AstroPong demo. Fixed up a couple of bugs in PSL. Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- pslCodeGen.cxx 14 Sep 2002 15:47:33 -0000 1.23 +++ pslCodeGen.cxx 15 Sep 2002 00:02:51 -0000 1.24 @@ -27,7 +27,10 @@ void pslCompiler::pushCodeByte ( pslOpcode op ) { - code [ next_code++ ] = op ; + if ( next_code >= MAX_CODE - 1 ) + error ( "Program too big!" ) ; + else + code [ next_code++ ] = op ; } Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- pslCompiler.cxx 14 Sep 2002 06:12:32 -0000 1.21 +++ pslCompiler.cxx 15 Sep 2002 00:02:51 -0000 1.22 @@ -523,7 +523,6 @@ { ungetToken ( c ) ; ungetToken ( var ) ; - // pushFunctionCall ( var ) ; pushExpression () ; pushPop () ; return TRUE ; Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- pslCompiler.h 14 Sep 2002 06:12:32 -0000 1.23 +++ pslCompiler.h 15 Sep 2002 00:02:51 -0000 1.24 @@ -141,8 +141,9 @@ int pushBitwiseExpression () ; int pushMultExpression () ; int pushAddExpression () ; - int pushRelExpression () ; int pushShiftExpression () ; + int pushRelExpression () ; + int pushBoolExpression () ; int pushExpression () ; /* Statement-level parsers & code generators. */ Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- pslExpression.cxx 14 Sep 2002 20:52:42 -0000 1.13 +++ pslExpression.cxx 15 Sep 2002 00:02:51 -0000 1.14 @@ -43,7 +43,7 @@ if ( strcmp ( c, ")" ) != 0 ) { ungetToken ( c ) ; - return error ( "Missing ')' after expression (found '%s')", c ); + return error ( "Missing ')' (found '%s')", c ); } return TRUE ; @@ -331,9 +331,39 @@ } + +int pslCompiler::pushBoolExpression () +{ + if ( ! pushRelExpression () ) + return FALSE ; + + while ( TRUE ) + { + char c [ MAX_TOKEN ] ; + + getToken ( c ) ; + + if ( strcmp ( c, "&&" ) != 0 && + strcmp ( c, "||" ) != 0 ) + { + ungetToken ( c ) ; + return TRUE ; + } + + if ( ! pushRelExpression () ) + return FALSE ; + + if ( strcmp ( c, "&&" ) == 0 ) + pushAndAnd () ; + else + pushOrOr () ; + } +} + + int pslCompiler::pushExpression () { - return pushRelExpression () ; + return pushBoolExpression () ; } Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- pslLocal.h 10 Sep 2002 04:37:39 -0000 1.15 +++ pslLocal.h 15 Sep 2002 00:02:51 -0000 1.16 @@ -41,7 +41,7 @@ #define MAX_VARIABLE 256 #define MAX_LABEL 256 #define MAX_TOKEN 1024 -#define MAX_CODE 512 +#define MAX_CODE 65536 #define MAX_STACK 256 #define MAX_NESTING 32 #define MAX_UNGET 64 |