Exemple #1
0
Int32 parse(Pointer prog,Int32 size)
{
	break_num=0;
	setlocal_num=0;
	return_num=0;
	in_class=FALSE;
	in_method=FALSE;
	cur_scope=SYM_PUBLIC;
	local_num=0;
	global_num=0;
	base_class=NULL;
	super_class=NULL;
	new_class=NULL;
	compile_error=FALSE;
	ScnInit(prog,size);
	if( Token==tERROR || Token==tEOF )
    {
        compileError("EOF detected");
    }
    else
    {
        compile_error=FALSE;
	    SymInit();
    	Program();
        SymFree();
    }

    return compile_error;
}
Exemple #2
0
extern void AsmInit( void ) {
//***************************

    SymInit();
    InsInit();
    DirInit();
    ObjInit();
}
/**
 * Push a new symbol table on the stack when entering a new scope region
 *
 * @param stack a stack of symbol tables
 * @return a new symbol table 
 */
SymTable beginScope(SymtabStack stack) {
	SymTable symtab = SymInit(SYMTABLE_SIZE);

	SymInitField(symtab,SYMTAB_OFFSET_FIELD,(Generic)-1,NULL);
	SymInitField(symtab,SYMTAB_REGISTER_INDEX_FIELD,(Generic)-1,NULL);

	int intIndex = SymIndex(symtab,SYMTAB_INTEGER_TYPE_STRING);
    int errorIndex = SymIndex(symtab,SYMTAB_ERROR_TYPE_STRING);
    int voidIndex = SymIndex(symtab,SYMTAB_VOID_TYPE_STRING);

    SymPutFieldByIndex(symtab,intIndex,SYMTAB_SIZE_FIELD,(Generic)INTEGER_SIZE);
    SymPutFieldByIndex(symtab,errorIndex,SYMTAB_SIZE_FIELD,(Generic)0);
    SymPutFieldByIndex(symtab,voidIndex,SYMTAB_SIZE_FIELD,(Generic)0);

    SymPutFieldByIndex(symtab,intIndex,SYMTAB_BASIC_TYPE_FIELD,(Generic)INTEGER_TYPE);
    SymPutFieldByIndex(symtab,errorIndex,SYMTAB_BASIC_TYPE_FIELD,(Generic)ERROR_TYPE);
    SymPutFieldByIndex(symtab,voidIndex,SYMTAB_BASIC_TYPE_FIELD,(Generic)VOID_TYPE);

	dlinkPush(dlinkNodeAlloc((Generic)symtab),stack);
	int *size = (int*)dlinkListAtom(stack);
	(*size)++;

	return symtab;
}
Exemple #4
0
int main( int argc, char **argv )
//*******************************
{
    static char *fname;

#ifndef __WATCOMC__
    _argv = argv;
    _argc = argc;
#endif
    MemInit();
    if( !AsMsgInit() ) {
        return( EXIT_FAILURE );
    }
    if( argc == 1 ) {
        Banner();
        Usage();
    } else if( OptionsInit( --argc, ++argv ) ) {
        Banner();
        if( _IsOption( PRINT_HELP ) ) {
            Usage();
            *argv = NULL;
        } else if( !*argv ) {
            AsOutMessage( stderr, AS_MSG_ERROR );
            AsOutMessage( stderr, NO_FILENAME_SPECIFIED );
            fputc( '\n', stderr );
        }
        while( *argv ) {
            fname = MakeAsmFilename( *argv );
            if( PP_Init( fname, PPFLAG_ASM_COMMENT | PPFLAG_EMIT_LINE, NULL ) != 0 ) {
                AsOutMessage( stderr, UNABLE_TO_OPEN, fname );
                fputc( '\n', stderr );
            } else {
                OptionsPPDefine();
                SymInit();
                InsInit();
                DirInit();
                if( ObjInit( fname ) ) {
                    if( setjmp( AsmParse ) == 0 ) {
                        ErrorCountsReset();
                        DoReport = TRUE;
                        if( !yyparse() ) {
                            CurrLineno--;    // This is the total # of lines
                            ObjRelocsFini(); // Must be done before ErrorReport
                            // and other finis
                        } else {
                            DoReport = FALSE;
                        }
                    } else { // AbortParse() was invoked
                        DoReport = FALSE;
                    }
                    ErrorReport();
                    AsLexerFini();
                    ObjFini();
                }
                DirFini();
                InsFini();
                SymFini();
            }
            PP_Fini();
            ++argv;
        }
    }
    OptionsFini();
    AsMsgFini();
    MemFini();
    return( ExitStatus );
}
Exemple #5
0
void initSymbolTable(void) {
    symTab = SymInit(symTabCmp);
    if (symTab == NULL) {
        outOfMemory();
    }
}