diff --git a/src/hammer.h b/src/hammer.h index ad44fee910fcf42445e57e47ec8c1fe2d18d3724..5774b2dd7ed022d0297b3f22903c73ea6281490b 100644 --- a/src/hammer.h +++ b/src/hammer.h @@ -795,7 +795,8 @@ HTokenType h_allocate_token_type(const char* name); /// Allocate a new token type with an unambiguous print function. HTokenType h_allocate_token_new( const char* name, - void (*unamb_sub)(const HParsedToken *tok, struct result_buf *buf)); + void (*unamb_sub)(const HParsedToken *tok, struct result_buf *buf), + void (*pprint)(FILE* stream, const HParsedToken* tok, int indent, int delta)); /// Get the token type associated with name. Returns -1 if name is unkown HTokenType h_get_token_type_number(const char* name); diff --git a/src/registry.c b/src/registry.c index f0201c61eb804c46caf47bbe305d9c1f7c5d1680..5486fd7bdb8022c65a296205b0dfd562a20a0572 100644 --- a/src/registry.c +++ b/src/registry.c @@ -54,13 +54,14 @@ static void default_unamb_sub(const HParsedToken* tok, HTokenType h_allocate_token_new( const char* name, - void (*unamb_sub)(const HParsedToken *tok, struct result_buf *buf)) { + void (*unamb_sub)(const HParsedToken *tok, struct result_buf *buf), + void (*pprint)(FILE* stream, const HParsedToken* tok, int indent, int delta)) { HTTEntry* new_entry = h_alloc(&system_allocator, sizeof(*new_entry)); assert(new_entry != NULL); new_entry->name = name; new_entry->value = 0; - new_entry->unamb_sub = unamb_sub; - new_entry->pprint = NULL; + new_entry->unamb_sub = unamb_sub ? unamb_sub : default_unamb_sub; + new_entry->pprint = pprint; HTTEntry* probe = *(HTTEntry**)tsearch(new_entry, &tt_registry, compare_entries); if (probe->value != 0) { // Token type already exists... @@ -87,7 +88,7 @@ HTokenType h_allocate_token_new( } } HTokenType h_allocate_token_type(const char* name) { - return h_allocate_token_new(name, default_unamb_sub); + return h_allocate_token_new(name, NULL, NULL); } HTokenType h_get_token_type_number(const char* name) { HTTEntry e;