From b3c7c4633cdd0dedf3e329251fc7a6728bc041b5 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 22 Jun 2016 00:49:24 +0200 Subject: template-parser: added some ast debug --- src/template-parser.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/template-parser.c') diff --git a/src/template-parser.c b/src/template-parser.c index 525f5f5..1582c17 100644 --- a/src/template-parser.c +++ b/src/template-parser.c @@ -11,6 +11,7 @@ #endif /* HAVE_CONFIG_H */ #include +#include #include #include "template-parser.h" @@ -634,3 +635,67 @@ blogc_template_free_stmts(sb_slist_t *stmts) } sb_slist_free(stmts); } + + +static const char* +get_operator(blogc_template_stmt_operator_t op) +{ + if (op & BLOGC_TEMPLATE_OP_NEQ) + return "!="; + if (op & BLOGC_TEMPLATE_OP_EQ) { + if (op & BLOGC_TEMPLATE_OP_LT) + return "<="; + else if (op & BLOGC_TEMPLATE_OP_GT) + return ">="; + return "=="; + } + if (op & BLOGC_TEMPLATE_OP_LT) + return "<"; + else if (op & BLOGC_TEMPLATE_OP_GT) + return ">"; + return ""; +} + + +void +blogc_template_debug(sb_slist_t *stmts) +{ + for (sb_slist_t *tmp = stmts; tmp != NULL; tmp = tmp->next) { + blogc_template_stmt_t *data = tmp->data; + fprintf(stderr, "DEBUG: