diff --git a/sk4/kod.txt b/sk4/kod.txt index 6df31d6..79e3bae 100644 --- a/sk4/kod.txt +++ b/sk4/kod.txt @@ -1,7 +1,15 @@ TUK -INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK KUK -DEK DEK KUK -DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK KUK -KUK -DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK KUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +INK INK INK PUK +INK INK INK INK INK INK INK INK INK INK INK PUK +BREK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +GLEK +DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK 102 +INK INK INK PUK 105 +INK INK INK INK INK INK INK INK INK PUK 114 +DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK 97 FUK \ No newline at end of file diff --git a/sk4/program.c b/sk4/program.c index 221733e..fcb748b 100644 --- a/sk4/program.c +++ b/sk4/program.c @@ -13,18 +13,20 @@ TUK, FUK char dtape[30000] = {0};//hlava dh inst ptape[30000] = {0};//hlava ph -size_t loops[2][15000] = {{0},{0}}; +size_t validRP[15000]={0}; + +inst* loops[2][15000] = {{0},{0}};//adresy zatvoriek size_t loopscount=0; char* dhead = dtape; inst* phead = ptape; -void run_tukafuk(const char* code) {// +void run_tukafuk(const char* code) { char current_char; bool running = false; size_t i; //bolo pozadovane zistit, kdd su skoky a teda som ich ulozil //(tie adresy skokov) - for (i = 0; code[i] != 0; i++) { + for (i = 0; code[i] != 0; i++){ current_char = code[i]; size_t j; size_t loop; @@ -97,8 +99,9 @@ void run_tukafuk(const char* code) {// break; case ']': for(size_t k=0;k - ++ptr; - } else if (current_char == 'DEK') {//< - --ptr; - } else if (current_char == 'BREK') {// + - ++*ptr; - } else if (current_char == 'GLEK') {// - - --*ptr; - } else if (current_char == 'PUK' ) {// . - putchar(*ptr); - } else if (current_char == 'KUK') {// , - *ptr = getchar(); - } else if (current_char == '[') {//start loop - continue; - } else if (current_char == ']' && *ptr) {stop loop - loop = 1; - while (loop > 0) { - current_char = input[--i]; - if (current_char == '[') { - loop--; - } else if (current_char == ']') { - loop++; - } - */ } + phead = ptape; + for (i = 0; i<30000; i++){ + if(running){ + switch(*phead){ + case INK: + (*dhead)++; + break; + case DEK: + (*dhead)--; + //printf("->%c\n",*dhead); + break; + case BREK: + dhead++; + break; + case GLEK: + dhead--; + break; + case PUK: + //printf("Puk\n"); + putchar(*dhead); + //printf("\nPukEnd\n"); + break; + case KUK: + printf("Zadaj vstup: \n"); + *dhead=getchar(); + //printf("Kukol %c\n",*dhead); + break; + case FUK: + running=false; + break; + case LP: + if(*dhead==0){ + for(int j=0;j