# HG changeset patch # User Mario de Sousa # Date 1499110035 -3600 # Node ID f9148870083589b9b7da54934df95181a1bd2be9 # Parent e483512edbeb05d20f669dc843df0437246ee80a Debugging helper class: print value of tokens in debugging output. diff -r e483512edbeb -r f91488700835 absyntax_utils/debug_ast.cc --- a/absyntax_utils/debug_ast.cc Tue May 09 21:46:44 2017 +0100 +++ b/absyntax_utils/debug_ast.cc Mon Jul 03 20:27:15 2017 +0100 @@ -120,13 +120,16 @@ void print_symbol_c::dump_symbol(symbol_c* symbol) { - fprintf(stderr, "(%s->%03d:%03d..%03d:%03d) \t%s\t", symbol->first_file, symbol->first_line, symbol->first_column, symbol->last_line, symbol->last_column, symbol->absyntax_cname()); - - fprintf(stderr, " datatype="); + fprintf(stderr, "(%s->%03d:%03d..%03d:%03d) \t%s", symbol->first_file, symbol->first_line, symbol->first_column, symbol->last_line, symbol->last_column, symbol->absyntax_cname()); + + if ((NULL != symbol->token) && (NULL != symbol->token->value)) + fprintf(stderr, "(%s)", symbol->token->value); + + fprintf(stderr, "\t datatype="); if (NULL == symbol->datatype) fprintf(stderr, "NULL\t\t"); else { - fprintf(stderr, "%s", symbol->datatype->absyntax_cname()); + fprintf(stderr, "%s", symbol->datatype->absyntax_cname()); } fprintf(stderr, "\t<-{"); if (symbol->candidate_datatypes.size() == 0) { @@ -153,26 +156,25 @@ dump_symbol(symbol); /* NOTE: std::map.size() returns a size_type, whose type is dependent on compiler/platform. To be portable, we need to do an explicit type cast. */ + fprintf(stderr, " prev_il_=%lu ", (unsigned long int)symbol->prev_il_instruction.size()); + if (symbol->prev_il_instruction.size() == 0) + fprintf(stderr, "(----)"); + else if (symbol->prev_il_instruction[0]->datatype == NULL) + fprintf(stderr, "(NULL)"); + else if (!get_datatype_info_c::is_type_valid(symbol->prev_il_instruction[0]->datatype)) + fprintf(stderr, "(****)"); + else + fprintf(stderr, "( )"); + fprintf(stderr, " next_il_=%lu ", (unsigned long int)symbol->next_il_instruction.size()); - fprintf(stderr, " prev_il_=%lu ", (unsigned long int)symbol->prev_il_instruction.size()); - - if (symbol->prev_il_instruction.size() == 0) - fprintf(stderr, "(----,"); - else if (symbol->prev_il_instruction[0]->datatype == NULL) - fprintf(stderr, "(NULL,"); - else if (!get_datatype_info_c::is_type_valid(symbol->prev_il_instruction[0]->datatype)) - fprintf(stderr, "(****,"); - else - fprintf(stderr, "( ,"); - if (symbol->next_il_instruction.size() == 0) - fprintf(stderr, "----)"); + fprintf(stderr, "(----)"); else if (symbol->next_il_instruction[0]->datatype == NULL) - fprintf(stderr, "NULL)"); + fprintf(stderr, "(NULL)"); else if (!get_datatype_info_c::is_type_valid(symbol->next_il_instruction[0]->datatype)) - fprintf(stderr, "****)"); + fprintf(stderr, "(****)"); else - fprintf(stderr, " )"); + fprintf(stderr, "( )"); fprintf(stderr, "\n");