expr: Also print position on variables and constants
This commit is contained in:
parent
fd24623c27
commit
4908386435
1 changed files with 21 additions and 2 deletions
23
src/expr.c
23
src/expr.c
|
|
@ -552,6 +552,25 @@ print_body(struct apfl_expr_body *body, unsigned indent, FILE *f)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_constant_with_pos(struct apfl_expr_const constant, struct apfl_position pos, unsigned indent, FILE *f)
|
||||
{
|
||||
switch (constant.type) {
|
||||
case APFL_EXPR_CONST_NIL:
|
||||
print_indented(indent, f, "Const (nil) @ " POSFMT "\n", POSARGS(pos));
|
||||
break;
|
||||
case APFL_EXPR_CONST_BOOLEAN:
|
||||
print_indented(indent, f, "Const (%s) @ " POSFMT "\n", constant.boolean ? "true" : "false", POSARGS(pos));
|
||||
break;
|
||||
case APFL_EXPR_CONST_STRING:
|
||||
print_indented(indent, f, "Const (" APFL_STR_FMT ") @ " POSFMT "\n", APFL_STR_FMT_ARGS(constant.string), POSARGS(pos));
|
||||
break;
|
||||
case APFL_EXPR_CONST_NUMBER:
|
||||
print_indented(indent, f, "Const (%f) @ " POSFMT "\n", constant.number, POSARGS(pos));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_constant(struct apfl_expr_const constant, unsigned indent, FILE *f)
|
||||
{
|
||||
|
|
@ -703,10 +722,10 @@ print_expr(struct apfl_expr *expr, unsigned indent, FILE *f)
|
|||
print_expr(expr->at.rhs, indent+2, f);
|
||||
break;
|
||||
case APFL_EXPR_CONSTANT:
|
||||
print_constant(expr->constant, indent, f);
|
||||
print_constant_with_pos(expr->constant, expr->position, indent, f);
|
||||
break;
|
||||
case APFL_EXPR_VAR:
|
||||
print_indented(indent, f, "Var (" APFL_STR_FMT ")\n", APFL_STR_FMT_ARGS(expr->var));
|
||||
print_indented(indent, f, "Var (" APFL_STR_FMT ") @ " POSFMT "\n", APFL_STR_FMT_ARGS(expr->var), POSARGS(expr->position));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue