Skip to content
Snippets Groups Projects
Commit a020d116 authored by Sven M. Hallberg's avatar Sven M. Hallberg
Browse files

add a pprint function pointer to HTTEntry

parent b5a68a8e
No related branches found
No related tags found
No related merge requests found
......@@ -428,6 +428,7 @@ typedef struct HTTEntry_ {
const char* name;
HTokenType value;
void (*unamb_sub)(const HParsedToken *tok, struct result_buf *buf);
void (*pprint)(FILE* stream, const HParsedToken* tok, int indent, int delta);
} HTTEntry;
const HTTEntry* h_get_token_type_entry(HTokenType token_type);
......
......@@ -69,9 +69,11 @@ void h_pprint(FILE* stream, const HParsedToken* tok, int indent, int delta) {
break;
default:
if(tok->token_type >= TT_USER) {
const char *name = h_get_token_type_name(tok->token_type);
const HTTEntry *e = h_get_token_type_entry(tok->token_type);
int num = tok->token_type-TT_USER;
fprintf(stream, "%*sUSER:%s %d\n", indent, "", name, num);
fprintf(stream, "%*sUSER:%s %d\n", indent, "", e->name, num);
if (e->pprint)
e->pprint(stream, tok, indent + delta, delta);
} else {
assert_message(0, "Should not reach here.");
}
......
......@@ -60,6 +60,7 @@ HTokenType h_allocate_token_new(
new_entry->name = name;
new_entry->value = 0;
new_entry->unamb_sub = unamb_sub;
new_entry->pprint = NULL;
HTTEntry* probe = *(HTTEntry**)tsearch(new_entry, &tt_registry, compare_entries);
if (probe->value != 0) {
// Token type already exists...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment