Exemple #1
0
int main(int argc, char* argv[]){

    //Inicializace MMU
    mmuInit();

    if(argc != 2){
        fprintf(stderr, "Invalid arguments\n");
        return ERROR_COMPILATOR;
    }

    if(!(gFileHandler = mmuFopen(argv[1], "r"))){
        fprintf(stderr, "Cannot open input file\n");
        return ERROR_COMPILATOR;
    }

    initToken(&gToken);
    E_CODE err = ERROR_OK;

    tSymbolTable table;
    symbolTableInit(&table);

    err = parser(&table);

    if (err == ERROR_OK)
      err = interpret(&table);

    mmuFclose(gFileHandler);

    //mmuDump();

    mmuGlobalFree();

    return err;
}
Exemple #2
0
int main (int argc, char *argv[])
{
  if (argc != 3) {
    printf("Really? Even in test?\n");
    return 1;
  }

  mmuInit();
  tString text = strCreate(argv[1]);
  tString search = strCreate(argv[2]);

  printf("Text: %s\n"
         "Text len: %u\n", text.data, text.len);
  printf("Hledany string: %s\n"
         "Hledany len: %u\n", search.data, search.len);
  int position = kmpSearch(text, search);
  printf("Pozice je: %d\n", position);

  strFree(&text);
  strFree(&search);

  mmuGlobalFree();

  return 0;
}
Exemple #3
0
int main(int argc, char* argv[]){

    //Inicializace MMU
    mmuInit(); 
    
    if(argc != 2){
        fprintf(stderr, "Invalid arguments\n");
        return ERROR_COMPILATOR;
    }
    
    if(!(gFileHandler = mmuFopen(argv[1], "r"))){
        fprintf(stderr, "Cannot open input file\n");
        return ERROR_COMPILATOR;
    }

    initToken(&gToken);
    E_CODE err=ERROR_OK;
    tString func=strCreate("function");
    tString x = strCreate("x");x=x;
    tSymbolTable table;
    symbolTableInit(&table);
    err=symbolTableInsertFunction(&table,func);
    table.currentFunc=symbolTableSearchFunction(&table,func);
    if(table.currentFunc==NULL)printf("funkce nenalezena");
    functionInsertSymbol(table.currentFunc,x);

    tSymbol *result=NULL;
   // if(getToken()==LEX_L_BRACKET)printf("leva zavorka\n");


    //if(getToken()==LEX_R_BRACKET)printf("prava zavorka\n");

    if(getToken()==LEX_ID)printf("tady je ID\n");
    if(getToken()==LEX_ASSIGN)printf("tady je =\n");
    if(getToken()==LEX_STRING)printf("cislo\n");
    printf("string je:%s\n",gToken.data.data);
if(getToken()==LEX_ADDITION)printf("plus");
    if(getToken()==LEX_STRING)printf("cislo\n");
    if(getToken()==LEX_EOL)printf("konec radku\n");
    tKeyword kw=getToken();kw=kw;
    err=prsExpression(&table,kw,&result);

    printf("err je : %d\n",err);
    if(result==NULL)printf("chyba: vysledek je null\n");

    mmuFclose(gFileHandler);
    
    mmuDump();
    
    mmuGlobalFree();
}
Exemple #4
0
int main (int argc, char *argv[])
{
  if (argc != 2) {
    printf("Really? Even in test?\n");
    return 1;
  }

  mmuInit();
  tString text = strCreate(argv[1]);

  printf("Text: %s\n"
         "Text len: %u\n", text.data, text.len);
  quicksort(&text.data, 0, text.len-1);
  printf("Pozice je: %s\n", text.data);

  strFree(&text);

  mmuGlobalFree();

  return 0;
}
Exemple #5
0
void gameboyInit(Gameboy *gameboy, Cartridge *cartridge)
{
	CPU *cpu = malloc(sizeof(CPU));
	cpuInit(cpu);

	MMU *mmu = malloc(sizeof(MMU));
	mmuInit(mmu, cartridge);

	Timer *timer = malloc(sizeof(Timer));
	timerInit(timer);

	Display *display = malloc(sizeof(Display));
	displayInit(display);

	Joypad *joypad = malloc(sizeof(Joypad));
	inputInit(joypad);

	gameboy->cpu = cpu;
	gameboy->mmu = mmu;
	gameboy->timer = timer;
	gameboy->display = display;
	gameboy->joypad = joypad;
}
Exemple #6
0
int mmuTestInit(
    void
    )
{
    static SYMBOL symTableMmuTest[] =
    {
        {NULL, "_mmuGlobalMapTest", mmuGlobalMapTest, 0, N_TEXT | N_EXT}
    };

    int i;

    if (mmuInit() != OK)
    {
        fprintf(stderr, "Error - Unable to initialize mmu.\n");
        return ERROR;
    }

    for (i = 0; i < NELEMENTS(symTableMmuTest); i++)
    {
        symTableAdd(sysSymTable, &symTableMmuTest[i]);
    }

    return i;
}
Exemple #7
0
int main()
{
    tBTree *T;
    tBTNode N;

    mmuInit();
    T=mmuMalloc(sizeof(tBTree));
    btInit(T);
    tString str,str1,str2,str3;
    void *nic=NULL;
    str=strCreate("ahoj");
    str1=strCreate("nazdar");
    str2=strCreate("valhala");
    str3=strCreate("abcd");
    if(strCmp(&str1,&str1)!=0)printf("chyba strCmp");
    //printf("%s\n",str.data);
    BTInsert(T,&str,nic);
    BTInsert(T,&str1,nic);
    BTInsert(T,&str2,nic);
    BTInsert(T,&str3,nic);
    printf("%d\n",T->root->height);
    printf("%s\n",T->root->left->key->data);
    printf("%s\n",T->root->right->key->data);
    printf("%s\n",T->root->right->right->key->data);
    printf("%s\n",T->root->key->data);
    N=btFind(T,&str1);
    //BTInsert(T,&str2,nic);
    if(N!=NULL)printf("%s\n",N->key->data);
    else printf("nic se nenaslo\n");
    if(T->root->left==NULL && T->root->right==NULL) printf("chyba\n");
    int cmp=strCmp(&str1,&str);
    printf("%d\n",cmp);
    //btFree(T);
    mmuGlobalFree();
    return 0;
}
Exemple #8
0
int main(){
mmuInit();
tSymbolTable T;
symbolTableInit(&T);
tString str=strCreate("funkce");
symbolTableInsertFunction(&T,str);
tFunction *F=symbolTableSearchFunction(&T,str);
if(F==NULL)printf("chyba:nic se nenaslo"); else printf("OK:nalezena fce: %s\n",F->name.data);
if(symbolTableInsertFunction(&T,str)==ERROR_INS_EXIST) printf("OK:dvojita definice uspesne rozpoznana\n");
tString str2=strCreate("promenna");
functionInsertSymbol(F,str2);
tSymbol *S=functionSearchSymbol(F,str2);
if(S==NULL)printf("chyba:nic se nenaslo"); else printf("OK:nalezena promenna: %s\n",S->key.data);
if(F->symbols.lastAdded->data==S) printf("OK:posledni pridana promenna je rozpoznana\n");
    else printf("chyba: posledni pridana promenna se nerovna\n");
printf("OK: pristup k posledni pridane promenne:%s\n",((tSymbol*)(F->symbols.lastAdded->data))->key.data);
if(S==getLastSymbol(F))printf("OK:test fce getLastSymbol\n");else printf("chyba:fce getLastSymbol\n");
S=functionSearchSymbol(F,str);
if(S==NULL)printf("OK:nic se nenaslo\n"); else printf("chyba:nalezena promenna: %s\n",S->key.data);
S=functionInsertConstant(F,str,LEX_STRING); if(S==NULL) printf("chyba insert constant");
if (S==getLastConstant(F)) printf("getLastConstant je OK");
printf("posledni konstanta je:%s\n ",S->data->data.sData.data);
mmuGlobalFree();
}