From 32cc498a2eb0b189cc90918dc28f8933b2f55278 Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 25 Mar 2014 18:27:50 +0800 Subject: location trackdown --- ast.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ast.c') diff --git a/ast.c b/ast.c index 0ca0271..e65f2c2 100644 --- a/ast.c +++ b/ast.c @@ -365,11 +365,13 @@ char *cnode_debug_type_repr(CNode *ast) { assert(type); } if (aptr == abuff) - sprintf(buffer, "%s", type); + sprintf(buffer, "%s(%d,%d)", type, + ast->loc.row, ast->loc.col); else { *aptr = '\0'; - sprintf(buffer, "%s:%s", type, abuff); + sprintf(buffer, "%s:%s(%d,%d)", type, abuff, + ast->loc.row, ast->loc.col); } return buffer; } @@ -407,3 +409,10 @@ void cnode_debug_print(CNode *ast, int fancy) { cnode_debug_print_plain(ast); puts(""); } + + +CNode *cnode_add_loc(CNode *node, YYLTYPE loc) { + node->loc.row = loc.first_line; + node->loc.col = loc.first_column; + return node; +} -- cgit v1.2.3-70-g09d2