[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v6 20/23] libxlu: record line and column number when parsing values
Originally only setting has line number recorded. Since we're moving to more sophisticated API, record line number and column number for individual value. They are useful for error reporting. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxlu_cfg.c | 10 ++++++++-- tools/libxl/libxlu_cfg_i.h | 5 +++-- tools/libxl/libxlu_cfg_y.c | 32 ++++++++++++++++++-------------- tools/libxl/libxlu_cfg_y.y | 10 +++++++--- tools/libxl/libxlu_internal.h | 1 + 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 611f5ec..b921a13 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -311,7 +311,8 @@ const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry) { } -XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom) +XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom, + int line, int column) { XLU_ConfigValue *value = NULL; @@ -321,6 +322,8 @@ XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom) if (!value) goto xe; value->type = XLU_STRING; value->u.string = atom; + value->line = line; + value->column = column; return value; @@ -333,7 +336,8 @@ XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom) } XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, - XLU_ConfigValue *val) + XLU_ConfigValue *val, + int line, int column) { XLU_ConfigValue *value = NULL; XLU_ConfigValue **values = NULL; @@ -350,6 +354,8 @@ XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, value->u.list.nvalues = 1; value->u.list.avalues = 1; value->u.list.values = values; + value->line = line; + value->column = column; return value; diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libxl/libxlu_cfg_i.h index 11dc33f..fa46460 100644 --- a/tools/libxl/libxlu_cfg_i.h +++ b/tools/libxl/libxlu_cfg_i.h @@ -26,9 +26,10 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set); void xlu__cfg_set_store(CfgParseContext*, char *name, XLU_ConfigValue *val, int lineno); XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, - char *atom); + char *atom, int line, int column); XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, - XLU_ConfigValue *val); + XLU_ConfigValue *val, + int line, int column); void xlu__cfg_list_append(CfgParseContext *ctx, XLU_ConfigValue *list, XLU_ConfigValue *val); diff --git a/tools/libxl/libxlu_cfg_y.c b/tools/libxl/libxlu_cfg_y.c index b05e48b..ec4d95d 100644 --- a/tools/libxl/libxlu_cfg_y.c +++ b/tools/libxl/libxlu_cfg_y.c @@ -452,8 +452,8 @@ static const yytype_int8 yyrhs[] = static const yytype_uint8 yyrline[] = { 0, 47, 47, 48, 50, 51, 53, 54, 55, 57, - 59, 60, 62, 63, 65, 66, 68, 69, 70, 72, - 73, 75, 77 + 59, 60, 62, 65, 67, 68, 70, 71, 72, 74, + 77, 79, 81 }; #endif @@ -1515,69 +1515,73 @@ yyreduce: /* Line 1806 of yacc.c */ #line 62 "libxlu_cfg_y.y" - { (yyval.value)= xlu__cfg_string_mk(ctx,(yyvsp[(1) - (1)].string)); } + { (yyval.value)= xlu__cfg_string_mk(ctx,(yyvsp[(1) - (1)].string), + (yylsp[(1) - (1)]).first_line, + (yylsp[(1) - (1)]).first_column); } break; case 13: /* Line 1806 of yacc.c */ -#line 63 "libxlu_cfg_y.y" +#line 65 "libxlu_cfg_y.y" { (yyval.value)= (yyvsp[(3) - (4)].value); } break; case 14: /* Line 1806 of yacc.c */ -#line 65 "libxlu_cfg_y.y" +#line 67 "libxlu_cfg_y.y" { (yyval.string)= (yyvsp[(1) - (1)].string); } break; case 15: /* Line 1806 of yacc.c */ -#line 66 "libxlu_cfg_y.y" +#line 68 "libxlu_cfg_y.y" { (yyval.string)= (yyvsp[(1) - (1)].string); } break; case 16: /* Line 1806 of yacc.c */ -#line 68 "libxlu_cfg_y.y" - { (yyval.value)= xlu__cfg_list_mk(ctx,NULL); } +#line 70 "libxlu_cfg_y.y" + { (yyval.value)= xlu__cfg_list_mk(ctx,NULL,0,0); } break; case 17: /* Line 1806 of yacc.c */ -#line 69 "libxlu_cfg_y.y" +#line 71 "libxlu_cfg_y.y" { (yyval.value)= (yyvsp[(1) - (1)].value); } break; case 18: /* Line 1806 of yacc.c */ -#line 70 "libxlu_cfg_y.y" +#line 72 "libxlu_cfg_y.y" { (yyval.value)= (yyvsp[(1) - (3)].value); } break; case 19: /* Line 1806 of yacc.c */ -#line 72 "libxlu_cfg_y.y" - { (yyval.value)= xlu__cfg_list_mk(ctx,(yyvsp[(1) - (2)].value)); } +#line 74 "libxlu_cfg_y.y" + { (yyval.value)= xlu__cfg_list_mk(ctx,(yyvsp[(1) - (2)].value), + (yylsp[(1) - (2)]).first_line, + (yylsp[(1) - (2)]).first_column); } break; case 20: /* Line 1806 of yacc.c */ -#line 73 "libxlu_cfg_y.y" +#line 77 "libxlu_cfg_y.y" { xlu__cfg_list_append(ctx,(yyvsp[(1) - (5)].value),(yyvsp[(4) - (5)].value)); (yyval.value)= (yyvsp[(1) - (5)].value); } break; /* Line 1806 of yacc.c */ -#line 1581 "libxlu_cfg_y.c" +#line 1585 "libxlu_cfg_y.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/tools/libxl/libxlu_cfg_y.y b/tools/libxl/libxlu_cfg_y.y index 4a5ca3a..4ebf0b3 100644 --- a/tools/libxl/libxlu_cfg_y.y +++ b/tools/libxl/libxlu_cfg_y.y @@ -59,17 +59,21 @@ assignment: IDENT '=' value { xlu__cfg_set_store(ctx,$1,$3,@3.first_line); } endstmt: NEWLINE | ';' -value: atom { $$= xlu__cfg_string_mk(ctx,$1); } +value: atom { $$= xlu__cfg_string_mk(ctx,$1, + @1.first_line, + @1.first_column); } | '[' nlok valuelist ']' { $$= $3; } atom: STRING { $$= $1; } | NUMBER { $$= $1; } -valuelist: /* empty */ { $$= xlu__cfg_list_mk(ctx,NULL); } +valuelist: /* empty */ { $$= xlu__cfg_list_mk(ctx,NULL,0,0); } | values { $$= $1; } | values ',' nlok { $$= $1; } -values: value nlok { $$= xlu__cfg_list_mk(ctx,$1); } +values: value nlok { $$= xlu__cfg_list_mk(ctx,$1, + @1.first_line, + @1.first_column); } | values ',' nlok value nlok { xlu__cfg_list_append(ctx,$1,$4); $$= $1; } nlok: diff --git a/tools/libxl/libxlu_internal.h b/tools/libxl/libxlu_internal.h index 092a17a..73fd85f 100644 --- a/tools/libxl/libxlu_internal.h +++ b/tools/libxl/libxlu_internal.h @@ -44,6 +44,7 @@ struct XLU_ConfigValue { char *string; XLU_ConfigList list; } u; + int line, column; }; typedef struct XLU_ConfigSetting { /* transparent */ -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |