diff --git a/Utils/Scripter/codegen.cpp b/Utils/Scripter/codegen.cpp new file mode 100644 index 000000000..48acb9f7c --- /dev/null +++ b/Utils/Scripter/codegen.cpp @@ -0,0 +1,281 @@ +/*========================================================================= + + codegen.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "codegen.h" + + +/* Std Lib + ------- */ + +#include + + +/* Data + ---- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +static FILE *s_fhOutput=NULL; + +CTreeNode *s_baseTreeNode=NULL; + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +extern int openOutputFile(char *_filename) +{ + int ret=1; + + if((s_fhOutput=fopen(_filename,"wb"))==NULL) + { + ret=0; + } + return ret; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +extern int closeOutputFile() +{ + fclose(s_fhOutput); + return 0; +} + + + + + + + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +CTreeNode::CTreeNode(NodeType _type) +{ + m_type=_type; + m_children[0]=NULL; + m_children[1]=NULL; + m_children[2]=NULL; + m_numChildren=0; +} +CTreeNode::CTreeNode(NodeType _type,CTreeNode *child1) +{ + m_type=_type; + m_children[0]=child1; + m_children[1]=NULL; + m_children[2]=NULL; + m_numChildren=1; +} +CTreeNode::CTreeNode(NodeType _type,CTreeNode *child1,CTreeNode *child2) +{ + m_type=_type; + m_children[0]=child1; + m_children[1]=child2; + m_children[2]=NULL; + m_numChildren=2; +} +CTreeNode::CTreeNode(NodeType _type,CTreeNode *child1,CTreeNode *child2,CTreeNode *child3) +{ + m_type=_type; + m_children[0]=child1; + m_children[1]=child2; + m_children[2]=child3; + m_numChildren=3; +} +CTreeNode::CTreeNode(NodeType _type,int _data) +{ + m_type=_type; + m_children[0]=NULL; + m_children[1]=NULL; + m_children[2]=NULL; + m_numChildren=0; + switch(_type) + { + case VARIABLE_EXPR: + m_variableIdx=_data; + break; + case VALUE_EXPR: + m_value=_data; + break; + default: + printf("ARSE\n"); + break; + } +} + + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CTreeNode::generateCode(int _write) +{ + int codeSize=0; + + switch(m_type) + { + case STMT_LIST: // list of statements [left-part, right-part] (left-part may be another list) + if(m_children[0])codeSize=m_children[0]->generateCode(_write); + if(m_children[1])codeSize=m_children[1]->generateCode(_write); + break; + + case EMPTY_STMT: // empty statement + break; + + case PRINT_STMT: // print [variable] + codeSize+=m_children[0]->generateCode(_write); + codeSize+=emit(OP_PRINT,_write); + break; + + case STOP_STMT: // stop + codeSize+=emit(OP_STOP,_write); + break; + + case PAUSE_STMT: // pause + codeSize+=emit(OP_PAUSE,_write); + break; + + case IF_STMT: // if [expression, ifcode] + codeSize+=m_children[0]->generateCode(_write); + codeSize+=emit(OP_PUSHVALUE,_write); + codeSize+=emit((signed short)m_children[1]->generateCode(false),_write); + codeSize+=emit(OP_JMPF,_write); + codeSize+=m_children[1]->generateCode(_write); + break; + + case IFELSE_STMT: // if [expression, ifcode, elsecode] + codeSize+=m_children[0]->generateCode(_write); + codeSize+=emit(OP_PUSHVALUE,_write); + codeSize+=emit((signed short)(m_children[1]->generateCode(false)+emit(OP_PUSHVALUE,false)+emit(0,false)+emit(OP_JMP,false)),_write); + codeSize+=emit(OP_JMPF,_write); + codeSize+=m_children[1]->generateCode(_write); + codeSize+=emit(OP_PUSHVALUE,_write); + codeSize+=emit((signed short)m_children[2]->generateCode(false),_write); + codeSize+=emit(OP_JMP,_write); + codeSize+=m_children[2]->generateCode(_write); + break; + + case ASSIGN_EXPR: // assign [ variable, number ] + codeSize+=m_children[1]->generateCode(_write); + codeSize+=emit(OP_PUSHVALUE,_write); + codeSize+=emit(m_children[0]->getVariableIdx(),_write); + codeSize+=emit(OP_ASSIGN,_write); + break; + + case EQUAL_EXPR: // == [variable, value] + codeSize+=m_children[0]->generateCode(_write); + codeSize+=m_children[1]->generateCode(_write); + codeSize+=emit(OP_IS_EQUAL_VALUE,_write); + break; + + case NOTEQUAL_EXPR: // != [variable, value] + codeSize+=m_children[0]->generateCode(_write); + codeSize+=m_children[1]->generateCode(_write); + codeSize+=emit(OP_IS_NOTEQUAL_VALUE,_write); + break; + + case VARIABLE_EXPR: // variable + case VALUE_EXPR: // value + if(m_numChildren) + codeSize+=emitValue(m_children[0],_write); + else + codeSize+=emitValue(this,_write); + break; + + case PLUS_EXPR: // + [value, value] + codeSize+=emitValue(m_children[0],_write); + codeSize+=emitValue(m_children[1],_write); + codeSize+=emit(OP_ADD,_write); + break; + + default: + printf("UNHANDLED CASE %d\n",m_type); + break; + } + + return codeSize; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CTreeNode::emit(unsigned short _data,int _write) +{ + if(_write) + { + fwrite(&_data,sizeof(unsigned short),1,s_fhOutput); + } + return 1; +} +int CTreeNode::emitValue(CTreeNode *_child,int _write) +{ + int codeSize; + + switch(_child->getType()) + { + case VARIABLE_EXPR: + codeSize=emit(OP_PUSHVARVALUE,_write)+emit(_child->getVariableIdx(),_write); + break; + case VALUE_EXPR: + codeSize=emit(OP_PUSHVALUE,_write)+emit(_child->getValue(),_write); + break; + default: + printf("INTERNAL ERROR IN emitValue() :(\n"); + codeSize=0; + break; + } + return codeSize; +} + + +/*=========================================================================== + end */ diff --git a/Utils/Scripter/codegen.h b/Utils/Scripter/codegen.h new file mode 100644 index 000000000..48a59a2ba --- /dev/null +++ b/Utils/Scripter/codegen.h @@ -0,0 +1,124 @@ +/*========================================================================= + + func.h + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __CODEGEN_H__ +#define __CODEGEN_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +typedef enum +{ + // Statements + STMT_LIST, // list of statements [left-part, right-part] (left-part may be another list) + EMPTY_STMT, // empty statement + PRINT_STMT, // print [variable] + STOP_STMT, // stop + PAUSE_STMT, // pause + IF_STMT, // if [expression, ifcode] + IFELSE_STMT, // if [expression, ifcode, elsecode] + + // Expressions + ASSIGN_EXPR, // assignment [variable, value] + EQUAL_EXPR, // == [variable, value] + NOTEQUAL_EXPR, // != [variable, value] + VARIABLE_EXPR, // variable + VALUE_EXPR, // value + PLUS_EXPR, // + [value, value] +}NodeType; + + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CTreeNode +{ +public: + CTreeNode(NodeType _type); + CTreeNode(NodeType _type,CTreeNode *child1); + CTreeNode(NodeType _type,CTreeNode *child1,CTreeNode *child2); + CTreeNode(NodeType _type,CTreeNode *child1,CTreeNode *child2,CTreeNode *child3); + CTreeNode(NodeType _type,int _data); + + int generateCode(int _write); + + int getVariableIdx() {return m_variableIdx;} + int getValue() {return m_value;} + int getType() {return m_type;} + +private: + + // Nothing else needs to know these so we may as well protect them + enum + { + // args stack data result + OP_NOP=0x1100, // + OP_STOP, // + OP_PAUSE, // + OP_PUSHVALUE, // value + OP_PUSHVARVALUE, // varidx + OP_JMP, // jump + OP_JMPF, // jump, value + OP_JMPT, // jump, value + OP_IS_EQUAL_VALUE, // value, value pushes result ( 0 or 1 ) to stack + OP_IS_NOTEQUAL_VALUE, // value, value pushes result ( 0 or 1 ) to stack + OP_ASSIGN, // varidx, value + OP_ADD, // value, value pushes result to stack + OP_PRINT, // value + }; + + enum{MAX_CHILD_NODES=3}; + + + int emit(unsigned short _data,int _write); + int emitValue(CTreeNode *_child,int _write); + + NodeType m_type; + CTreeNode *m_children[MAX_CHILD_NODES]; + int m_numChildren; + + signed short m_variableIdx; + signed short m_value; +}; + + +/*---------------------------------------------------------------------- + Globals + ------- */ + +extern CTreeNode *s_baseTreeNode; + + +/*---------------------------------------------------------------------- + Functions + --------- */ + +extern int openOutputFile(char *_filename); +extern int closeOutputFile(); + + +/*---------------------------------------------------------------------- */ + +#endif /* __CODEGEN_H__ */ + +/*=========================================================================== + end */ diff --git a/Utils/Scripter/lexer.l b/Utils/Scripter/lexer.l new file mode 100644 index 000000000..1336c5b91 --- /dev/null +++ b/Utils/Scripter/lexer.l @@ -0,0 +1,76 @@ +%{ +/**************************************************************************** +lexer.l +ParserWizard generated Lex file. + +Date: 07 December 2000 +****************************************************************************/ + +#include "parser.h" +#include "var.h" +#include + + +%} + +///////////////////////////////////////////////////////////////////////////// +// declarations section + +// lexical analyser name +%name mylexer + +// class definition +{ + // place any extra class members here +} + +// constructor +{ + // place any extra initialisation code here +} + +// place any declarations here + +%% + + +///////////////////////////////////////////////////////////////////////////// +// rules section + +%{ +// extract yylval for use later on in actions +YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr; +%} + +// place your Lex rules here + +^[ \t]*#.* {/*preprocess(yytext);*/} +//# {yyerror("# commands must be at start of line!");} +stop {return STOP;} +if {return IF;} +else {return ELSE;} +pause {return PAUSE;} +print {return PRINT;} += {return ASSIGN;} +== {return EQUAL;} +!= {return NOTEQUAL;} +\+ {return PLUS;} +; {return END_STMT;} +\( {return OPEN_PAR;} +\) {return CLOSE_PAR;} +\{ {return BEGIN_CS;} +\} {return END_CS;} +\$[a-zA-Z_][a-zA-Z_0-9]* {yylval.variableIdx=lookupVarName(yytext+1);return VARIABLE;} +\/\/.* {} +[0-9]+ {yylval.value=atoi(yytext);return VALUE;} +[ \t]+ {} +\n {/*s_linesProcessed++;*/} +. {printf("?\n");/*printf("line:%d\n",yylineno);printf("-%s-\n",yytext);yyerror("Unexpected character in source");*/} + + +%% + + +///////////////////////////////////////////////////////////////////////////// +// programs section + diff --git a/Utils/Scripter/parser.y b/Utils/Scripter/parser.y new file mode 100644 index 000000000..0bf880927 --- /dev/null +++ b/Utils/Scripter/parser.y @@ -0,0 +1,159 @@ +%{ +/**************************************************************************** +parser.y +ParserWizard generated YACC file. + +Date: 07 December 2000 +****************************************************************************/ + +#include "lexer.h" +#include "codegen.h" + + +%} + +///////////////////////////////////////////////////////////////////////////// +// declarations section + +// parser name +%name myparser + +// class definition +{ + // place any extra class members here +} + +// constructor +{ + // place any extra initialisation code here +} + +//// attribute type +//%include { +//#ifndef YYSTYPE +//#define YYSTYPE int +//#endif +//} + +%union { + int variableIdx; + signed short value; + class CTreeNode *treenode; +} + + + +// place any declarations here + +%token STOP +%token IF +%token ELSE +%token PAUSE +%token PRINT +%token ASSIGN +%token EQUAL +%token NOTEQUAL +%token PLUS +%token END_STMT +%token OPEN_PAR +%token CLOSE_PAR +%token BEGIN_CS +%token END_CS +%token VARIABLE +%token VALUE + +%type program statement_list statement +%type assign_expression +%type expression equal_expression notequal_expression +%type variable +%type value + +%% + + +///////////////////////////////////////////////////////////////////////////// +// rules section + +// place your YACC rules here (there must be at least one) + +program + :statement_list {s_baseTreeNode=$1;} + ; + +statement_list + :statement_list statement {$$=new CTreeNode(STMT_LIST,$1,$2);} + | {$$=new CTreeNode(EMPTY_STMT);} + ; + +statement + :END_STMT {$$=new CTreeNode(EMPTY_STMT);} + |STOP END_STMT {$$=new CTreeNode(STOP_STMT);} + |PAUSE END_STMT {$$=new CTreeNode(PAUSE_STMT);} + |PRINT OPEN_PAR value CLOSE_PAR END_STMT {$$=new CTreeNode(PRINT_STMT,$3);} + |assign_expression END_STMT {$$=$1;} + |IF OPEN_PAR expression CLOSE_PAR statement {$$=new CTreeNode(IF_STMT,$3,$5);} + |IF OPEN_PAR expression CLOSE_PAR statement ELSE statement {$$=new CTreeNode(IFELSE_STMT,$3,$5,$7);} + |BEGIN_CS statement_list END_CS {$$=new CTreeNode(STMT_LIST,$2);} + ; + + +assign_expression + :variable ASSIGN value {$$=new CTreeNode(ASSIGN_EXPR,$1,$3);} + ; + + +expression + :OPEN_PAR expression CLOSE_PAR {$$=$2;} + |equal_expression {$$=$1;} + |notequal_expression {$$=$1;} + ; + +equal_expression + :value EQUAL value {$$=new CTreeNode(EQUAL_EXPR,$1,$3);} + ; + +notequal_expression + :value NOTEQUAL value {$$=new CTreeNode(NOTEQUAL_EXPR,$1,$3);} + ; + + +variable + :VARIABLE {$$=new CTreeNode(VARIABLE_EXPR,$1);} // variable id + ; + +value + :VALUE {$$=new CTreeNode(VALUE_EXPR,$1);} + |VARIABLE {$$=new CTreeNode(VARIABLE_EXPR,$1);} // variable value + |value PLUS value {$$=new CTreeNode(PLUS_EXPR,$1,$3);} + ; + +%% + + +///////////////////////////////////////////////////////////////////////////// +// programs section + +int main(void) +{ + int n=1; + +openOutputFile("test.dat"); + mylexer lexer; + myparser parser; + if(parser.yycreate(&lexer)) + { + if(lexer.yycreate(&parser)) + { + n=parser.yyparse(); + } + } + +if(s_baseTreeNode) +{ + s_baseTreeNode->generateCode(true); +} +closeOutputFile(); + + return n; +} + diff --git a/Utils/Scripter/scripter.dsp b/Utils/Scripter/scripter.dsp new file mode 100644 index 000000000..b6cbdfc1c --- /dev/null +++ b/Utils/Scripter/scripter.dsp @@ -0,0 +1,143 @@ +# Microsoft Developer Studio Project File - Name="scripter" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=scripter - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "scripter.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "scripter.mak" CFG="scripter - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "scripter - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "scripter - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "scripter - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\Parser Generator\include" /D "NDEBUG" /D "NODEFAULTLIB" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 yl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\tools\scripter.exe" /libpath:"..\Parser Generator\lib\msdev" + +!ELSEIF "$(CFG)" == "scripter - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\Parser Generator\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "YYDEBUG" /YX /FD /GZ /c +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 yld.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\tools\scripter.exe" /pdbtype:sept /libpath:"..\Parser Generator\lib\msdev" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "scripter - Win32 Release" +# Name "scripter - Win32 Debug" +# Begin Group "Parser" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\lexer.l +# End Source File +# Begin Source File + +SOURCE=.\parser.y +# End Source File +# End Group +# Begin Group "Parser generated" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\lexer.cpp +# End Source File +# Begin Source File + +SOURCE=.\lexer.h +# End Source File +# Begin Source File + +SOURCE=.\parser.cpp +# End Source File +# Begin Source File + +SOURCE=.\parser.h +# End Source File +# Begin Source File + +SOURCE=.\parser.v +# End Source File +# End Group +# Begin Group "Code" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\codegen.cpp +# End Source File +# Begin Source File + +SOURCE=.\codegen.h +# End Source File +# Begin Source File + +SOURCE=.\var.cpp +# End Source File +# Begin Source File + +SOURCE=.\var.h +# End Source File +# End Group +# End Target +# End Project diff --git a/Utils/Scripter/scripter.pgp b/Utils/Scripter/scripter.pgp new file mode 100644 index 000000000..287ca5165 --- /dev/null +++ b/Utils/Scripter/scripter.pgp @@ -0,0 +1,45 @@ +[Project] +Directory=C:\spongebob\Utils\scripter +[FilesInProject] +File1=C:\spongebob\Utils\scripter\parser.y +File2=C:\spongebob\Utils\scripter\lexer.l +[AYACCOptions] +OptionDollar=1 +OptionS=0 +OptionCapitalT=cpp +OptionM= +OptionP= +OtherOptions= +OptionC=0 +OptionD=1 +OptionV=1 +OptionE= +OptionX= +OptionCapitalS=0 +OptionCapitalE=0 +OptionCapitalR= +OptionCapitalN=0 +OptionCapitalG=0 +OptionCapitalI=0 +OptionZ=0 +OptionL=0 +OptionF=0 +[ALexOptions] +OptionDollar=1 +OptionS=0 +OptionCapitalT=cpp +OptionM= +OptionU=0 +OptionR=0 +OtherOptions= +OptionC=0 +OptionI=1 +OptionE= +OptionX= +OptionD=0 +OptionCapitalS=0 +OptionCapitalE=0 +OptionCapitalR=0 +OptionZ=0 +OptionL=0 +OptionF=0 diff --git a/Utils/Scripter/var.cpp b/Utils/Scripter/var.cpp new file mode 100644 index 000000000..b61896817 --- /dev/null +++ b/Utils/Scripter/var.cpp @@ -0,0 +1,99 @@ +/*========================================================================= + + var.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "var.h" + + +/* Std Lib + ------- */ + +#include +#include + + +/* Data + ---- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +static char *s_globalVarNames[]= +{ + "lives", +}; +static int s_numGlobalVarNames=sizeof(s_globalVarNames)/sizeof(char *); + +static char *s_localVarNames[]= +{ + "tmp1", + "tmp2", + "tmp3", +}; +static int s_numLocalVarNames=sizeof(s_localVarNames)/sizeof(char *); + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +extern int lookupVarName(char *_name) +{ + int i,vnum; + + vnum=0; + + // Global vars + for(i=0;i