static void execute_smt (void) { Bool cont = TRUE; EVENT *event; struct_ggcode_call_error *ggcode_call_error; char *ptr; SCRIPT_HANDLE *script_handle; SCRIPT_LINE *script_line; static char buffer [LINE_MAX + 1]; while (cont) { while (cont && (myqueue-> cur_events == 0)) cont = smt_exec_step (); if (myqueue-> cur_events) { event = event_accept (myqueue, NULL); coprintf ("Received event: %s", event-> name); if (streq (event-> name, GGCODE_CALL_ERROR) || streq (event-> name, GGCODE_CALL_MESSAGE)) { get_ggcode_call_error (event-> body, & ggcode_call_error); ptr = strtok (ggcode_call_error-> error_text, "\n"); while (ptr) { coprintf ("(%s %u): %s", ggcode_call_error-> error_name, ggcode_call_error-> error_line, ptr); ptr = strtok (NULL, "\n"); } free_ggcode_call_error (& ggcode_call_error); } else if (streq (event-> name, GGCODE_CALL_OK)) { script_handle = result. value. i; coprintf ("<script links=\"%lu\" path=\"%s\" name=\"%s\" timestamp=\"%lu\" >", script_handle-> links, script_handle-> path, script_handle-> name, script_handle-> timestamp); script_line = (SCRIPT_LINE *) script_handle-> line_head. next; while (script_line != (SCRIPT_LINE *) & script_handle-> line_head) { snprintf (buffer, LINE_MAX, " <line links=\"%u\" number=\"%u\" type=\"%s\" ", script_line-> links, script_line-> line, node_type_string (script_line-> node-> type)); if (script_line-> loop_start) strcat (buffer, strprintf ("loop_start=\"%u\" ", script_line-> loop_start-> line)); if (script_line-> block_end) strcat (buffer, strprintf ("block_end=\"%u\" ", script_line-> block_end-> line)); strcat (buffer, ">"); coprintf ("%s", buffer); script_line = script_line-> next; } coprintf ("</script>"); script_handle_link (script_handle); script_handle_destroy (script_handle); } event_destroy (event); } } }
static void print_node_as_graphviz(const struct ast_node *node) { switch (node->type) { case NODE_IDENT: printf("\"(%p)\\n%s\\n%s\"", node, node_type_string(node->type), node->ident); break; case NODE_STR: printf("\"(%p)\\n%s\\n\\\"%s\\\"\"", node, node_type_string(node->type), node->sValue); break; case NODE_INT: printf("\"(%p)\\n%s\\n%ld\"", node, node_type_string(node->type), node->iValue); break; case NODE_REAL: printf("\"(%p)\\n%s\\n%f\"", node, node_type_string(node->type), node->fValue); break; case NODE_BOOL: if (node->bValue) { printf("\"(%p)\\n%s\\nTrue\"", node, node_type_string(node->type)); } else { printf("\"(%p)\\n%s\\nFalse\"", node, node_type_string(node->type)); } break; case NODE_RELOP: { printf("\"(%p)\\n%s\\n", node, node_type_string(node->type)); switch (node->token) { case LT : printf("<") ; break ; case LEQ : printf("<=") ; break ; case GT : printf(">") ; break ; case GEQ : printf(">=") ; break ; case EQ : printf("=") ; break ; case NEQ : printf("<>") ; break ; default: fprintf(stderr, "\n\nunknown token in RELOP\n"); exit(EXIT_FAILURE); } printf("\""); break; } case NODE_ADDOP: { printf("\"(%p)\\n%s\\n", node, node_type_string(node->type)); switch (node->token) { case PLUS : printf("+") ; break ; case MINUS : printf("-") ; break ; case OR : printf("OR") ; break ; default: fprintf(stderr, "\n\nunknown token in ADDOP\n"); exit(EXIT_FAILURE); } printf("\""); break; } case NODE_MULOP: { printf("\"(%p)\\n%s\\n", node, node_type_string(node->type)); switch (node->token) { case ASTR : printf("*") ; break ; case SLASH : printf("/") ; break ; case DIV : printf("DIV") ; break ; case MOD : printf("MOD") ; break ; case AND : printf("AND") ; break ; default: fprintf(stderr, "\n\nunknown token in MULOP\n"); exit(EXIT_FAILURE); } printf("\""); break; } default: printf("\"(%p)\\n%s\"", node, node_type_string(node->type)); break; } }