|
|
@ -20,21 +20,24 @@ int yyerror(void* scanner, void* lvalp, char* str){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void EMSCRIPTEN_KEEPALIVE webdice(char* str){ |
|
|
|
void EMSCRIPTEN_KEEPALIVE webdice(char* str){ |
|
|
|
union expression* root; |
|
|
|
union expression* root = NULL; |
|
|
|
struct expression_result result; |
|
|
|
struct expression_result result; |
|
|
|
int length; |
|
|
|
int length; |
|
|
|
|
|
|
|
char* in_block; |
|
|
|
char* out_block; |
|
|
|
char* out_block; |
|
|
|
|
|
|
|
|
|
|
|
console_print("A"); |
|
|
|
yydebug = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
in_block = (char*) malloc((2 + strlen(str)) * sizeof(char)); |
|
|
|
|
|
|
|
sprintf(in_block,"%s\n",str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yyscan_t scanner; |
|
|
|
yyscan_t scanner; |
|
|
|
console_print("B"); |
|
|
|
|
|
|
|
yylex_init(&scanner); |
|
|
|
yylex_init(&scanner); |
|
|
|
console_print("C"); |
|
|
|
yy_scan_string (in_block, scanner); |
|
|
|
yy_scan_string (str, scanner); |
|
|
|
|
|
|
|
console_print("D"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(yyparse((void*) scanner, &root) == 0){ |
|
|
|
yyparse((void*) scanner, &root); |
|
|
|
|
|
|
|
if(root != NULL){ |
|
|
|
result = resolve(root); |
|
|
|
result = resolve(root); |
|
|
|
length = strlen(result.text) + 4 * ceill(log10l(result.max)) + 100; |
|
|
|
length = strlen(result.text) + 4 * ceill(log10l(result.max)) + 100; |
|
|
|
out_block = (char*) malloc(length * sizeof(char)); |
|
|
|
out_block = (char*) malloc(length * sizeof(char)); |
|
|
@ -46,5 +49,6 @@ void EMSCRIPTEN_KEEPALIVE webdice(char* str){ |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
output_print("<p>Error!</p>"); |
|
|
|
output_print("<p>Error!</p>"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
free(in_block); |
|
|
|
yylex_destroy(scanner); |
|
|
|
yylex_destroy(scanner); |
|
|
|
} |
|
|
|
} |
|
|
|