int main(int argc, char *argv[]) { // Declare a pointer to the input file FILE *inFile; // Declare a pointer to the root file name char *rootName; // Declare pointers to the head and tail of the symbol table DEF_NODE *head, *tail; // Set head and tail to NULL head = tail = NULL; // Initialize the errorIndex to 0 errorIndex = 0; // Find the root file name and set it rootName = (char *)findRootFileName(argv[IN_FILE]); // Try to open the input file for reading if((inFile = fopen(argv[IN_FILE], "r")) == NULL) { // Print error message if file could not be opened fprintf(stderr, "Could not open file: %s\n", argv[IN_FILE]); // Fatal error, exit program exit(1); } // Initialize all the opcodes initOpcodes(); // Do the first pass and build the symbol table passOne(inFile, &head, &tail); // Rewind the input file so it is ready for the second pass rewind(inFile); // Do the second pass and check for errors passTwo(inFile, &head, &tail); // If there were errors in the input file... if(errorIndex > 0) { // Make an error file writeErrFile(inFile, rootName); } // There were no errors in the input file else { // Write the symbol table file printST(head, rootName); // Write the object code file writeObjFile(rootName); } // Try to close the input file if(fclose(inFile) == EOF) { // If file could not be closed, print error fprintf(stderr, "Could not close file: %s\n", argv[IN_FILE]); // Fatal error, exit program exit(1); } // Program finished without errors, return 0 return 0; }
SC_DLLEXPORT_C bool compileLibrary() { //printf("->compileLibrary\n"); shutdownLibrary(); pthread_mutex_lock (&gLangMutex); gNumCompiledFiles = 0; compiledOK = false; // FIXME: the library config should have been initialized earlier! if (!gLibraryConfig) SC_LanguageConfig::readDefaultLibraryConfig(); compileStartTime = elapsedTime(); totalByteCodes = 0; #ifdef NDEBUG postfl("compiling class library...\n"); #else postfl("compiling class library (debug build)...\n"); #endif bool res = passOne(); if (res) { postfl("\tpass 1 done\n"); if (!compileErrors) { buildDepTree(); traverseFullDepTree(); traverseFullDepTree2(); flushPostBuf(); if (!compileErrors && gShowWarnings) { SymbolTable* symbolTable = gMainVMGlobals->symbolTable; symbolTable->CheckSymbols(); } } pyr_pool_compile->FreeAll(); flushPostBuf(); compileSucceeded(); } else { compiledOK = false; } pthread_mutex_unlock (&gLangMutex); //printf("<-compileLibrary\n"); return compiledOK; }
SC_DLLEXPORT_C bool compileLibrary(bool standalone) { //printf("->compileLibrary\n"); shutdownLibrary(); gLangMutex.lock(); gNumCompiledFiles = 0; compiledOK = false; SC_LanguageConfig::readLibraryConfig(standalone); compileStartTime = elapsedRealTime(); totalByteCodes = 0; #ifdef NDEBUG postfl("compiling class library...\n"); #else postfl("compiling class library (debug build)...\n"); #endif bool res = passOne(); if (res) { postfl("\tpass 1 done\n"); if (!compileErrors) { buildDepTree(); traverseFullDepTree(); traverseFullDepTree2(); flushPostBuf(); if (!compileErrors && gShowWarnings) { SymbolTable* symbolTable = gMainVMGlobals->symbolTable; symbolTable->CheckSymbols(); } } pyr_pool_compile->FreeAll(); flushPostBuf(); compileSucceeded(); } else { compiledOK = false; } gLangMutex.unlock(); //printf("<-compileLibrary\n"); return compiledOK; }
main(int argc, char**argv) { lookahead = yylex(); stringArray = arraylist_create(objEquals); intArray = arraylist_create(objEquals); finalString = arraylist_create(objEquals); finalInt = arraylist_create(objEquals); p1Int = arraylist_create(objEquals); p1Str = arraylist_create(objEquals); p2Int = arraylist_create(objEquals); p2Str = arraylist_create(objEquals); prodList(); if(lookahead!=0){ printf("error"); return 0; } int r,c;//=arraylist_size(arraylist_get(finalString,0)); int i,j; //counters //printf("\nTHIS IS THE SIZE %d\n", s); r=arraylist_size(finalString);//r is row for (i=0;i<r;i++){ c=arraylist_size(arraylist_get(finalString,i)); for(j=0;j<c;j++){ char *str=arraylist_get(arraylist_get(finalString,i),j); int *num=arraylist_get(arraylist_get(finalInt,i),j); //printf("%s",str); if (arraylist_get(arraylist_get(finalInt,i),(j+1))==GOES) printf("\n%s ",str); else if (num==GOES) printf("%s\t\t",str); else if (num==OR) printf("\n\t%s\t",str); else if (num==7) printf(""); else printf("%s ",str); } } printf("\n"); passOne(); }
int main (int argc, char *argv[]) { if((argc > 2) || (argc <= 1)) { printf("Syntax: ssasm <inputFileName>\n"); return 0; } writeOpcodeSheet(); printf("\n**********************************************************************************\n"); printf("\t\tSIC machine assembler by Suhas H and Sumukha TV\n\n"); passOne(argv[1]); checkError(argv[1]); // check if there are any errors in the source code length = LOCCTR - startAddr; if(flag == 0) // perform pass two only if no errors are found passTwo(argv[1]); else printf("\nAssembler Terminated!\n"); printf("\n**********************************************************************************\n\n"); return 0; }