// ICARUS: IBIze Interpreter // // -- jweier #include //For getch() #include //For _findXXX #include "Tokenizer.h" #include "BlockStream.h" #include "Interpreter.h" #define IBIZE_VERSION 1.6f #define SCRIPT_EXTENSION ".ICR" CInterpreter Interpreter; CTokenizer Tokenizer; CBlockStream BlockStream; /* ------------------------- NULL_Error ------------------------- */ void NULL_Error( LPCSTR *error_msg ) { } /* ------------------------- InterpretFile ------------------------- */ // note different return type now, rather than true/false bool it returns CBlock# +1 of the bad command (if any), // else 0 for all ok. Also returns -ve block numbers to indicate last block that was ok if an error occured between // blocks (eg unexpected float at command identifier position) // int InterpretFile( char *filename ) { printf("Parsing '%s'...\n\n", filename); //Create a block stream if ( BlockStream.Create( filename ) == false ) { printf("ERROR: Unable to create file \"%s\"!\n", filename ); return 1; } //Create the Interpreted Block Instruction file // // (if error, return) // int iErrorBlock = Interpreter.Interpret( &Tokenizer, &BlockStream, filename ); if (iErrorBlock!=0) { return iErrorBlock; } BlockStream.Free(); return iErrorBlock; //true; } /* ------------------------- main ------------------------- */ int main(int argc, char* argv[]) { struct _finddata_t fileinfo; bool error_pause = false; char *filename, error_msg[MAX_STRING_LENGTH], newfilename[MAX_FILENAME_LENGTH]; int handle; //Init the tokenizer and pass the symbols we require Tokenizer.Create( 0 ); Tokenizer.SetSymbols( (keywordArray_t *) Interpreter.GetSymbols() ); Tokenizer.SetErrorProc( (void (__cdecl *)(const char *)) NULL_Error ); //Init the block streaming class BlockStream.Init(); //No script arguments, print the banner if (argc < 2) { printf("\n\nIBIze v%1.2f -- jweier\n", IBIZE_VERSION ); printf("ICARUS v%1.2f\n", ICARUS_VERSION ); printf("Copyright (c) 1999, Raven Software\n"); printf("------------------------------\n"); printf("\nIBIze [script1.txt] [script2.txt] [script3.txt] ...\n\n"); return 0; } int iErrorBlock = 0; //Interpret all files passed on the command line for (int i=1; i