diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-26 15:18:29 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-26 21:23:42 +0300 |
commit | 440771ca0056eb20396e24f03d349a75ee1c9d22 (patch) | |
tree | 3ec58a85e96d21a855ad3dcefaa8adc51039fc38 /src/grecs-locus.h | |
parent | 4c1959a4848c30206de3be4b16bdf04b650daae8 (diff) | |
download | grecs-440771ca0056eb20396e24f03d349a75ee1c9d22.tar.gz grecs-440771ca0056eb20396e24f03d349a75ee1c9d22.tar.bz2 |
Keep track of columns in the node and value locations. Improve error diagnostics.
* src/grecs.h (grecs_locus_point): New struct.
(grecs_locus_point_advance_line): New macro.
(grecs_locus_t): Redesign.
(grecs_value) <locus>: New member.
(grecs_node) <idloc>: New member.
(grecs_print_diag_fun): Change signature.
(grecs_warning,grecs_error): Change signature.
(grecs_parse_line_directive)
(grecs_parse_line_directive_cpp)
(grecs_string_convert): Change signature.
(grecs_current_locus): Remove.
(grecs_current_locus_point): New extern.
* src/grecs-locus.h: New file.
* src/Make.am (noinst_HEADERS): Add grecs-locus.h.
* src/join.c (reset_locus): Rewrite.
* src/lookup.c: Initialize new members of grecs_value and grecs_node.
(split_cfg_path): Return wrdse error code.
(grecs_node_from_path_locus): Take two grecs_locus_t arguments.
Make sure all created nodes have their locus members
properly initialized.
* src/parser.c (grecs_parse): Initialize grecs_current_locus_point.
* src/tree.c (grecs_node_create_points): New function.
(string_to_bool,string_to_host,string_to_sockaddr)
(grecs_string_convert): Change signatures. Be more precise in
what locus to report.
* src/diag.c (default_print_diag): Use YY_LOCATION_PRINT to
output locus.
(grecs_print_diag_fun): Change signature.
(grecs_warning,grecs_error): Change signature.
* src/format.c (grecs_format_locus): Rewrite.
(grecs_format_node): Be more precise in what locus is being
output.
* src/bind-gram.y: Keep track of locations. Turn on error-verbose mode.
* src/grecs-gram.y: Likewise.
* src/meta1-gram.y: Likewise.
* src/bind-lex.l: Keep track of locations.
* src/git-parser.c: Likewise.
* src/grecs-lex.l: Likewise.
* src/meta1-lex.l: Likewise.
* src/path-parser.c: Likewise.
* src/preproc.c: Likewise.
* tests/gcf1.conf: Untabify.
* tests/format01.at: Reflect changes in the output.
* tests/join.at: Likewise.
* tests/set.at: Likewise.
* tests/locus-bind.at: New testcase.
* tests/locus-git.at: New testcase.
* tests/locus-meta1.at: New testcase.
* tests/locus00.at: New testcase.
* tests/locus01.at: New testcase.
* tests/locus02.at: New testcase.
* tests/path-locus.at: New testcase.
Diffstat (limited to 'src/grecs-locus.h')
-rw-r--r-- | src/grecs-locus.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/grecs-locus.h b/src/grecs-locus.h new file mode 100644 index 0000000..e23add2 --- /dev/null +++ b/src/grecs-locus.h @@ -0,0 +1,56 @@ +/* grecs - Gray's Extensible Configuration System + Copyright (C) 2007-2011 Sergey Poznyakoff + + Grecs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + Grecs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Grecs. If not, see <http://www.gnu.org/licenses/>. */ + +#define YYLTYPE grecs_locus_t + +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) { \ + (Current).beg = YYRHSLOC(Rhs, 1).beg; \ + (Current).end = YYRHSLOC(Rhs, N).end; \ + } else { \ + (Current).beg = YYRHSLOC(Rhs, 0).end; \ + (Current).end = (Current).beg; \ + } \ + } while (0) + +#define YY_LOCATION_PRINT(File, Loc) do { \ + if ((Loc).beg.col == 0) \ + fprintf(File, "%s:%u", \ + (Loc).beg.file, \ + (Loc).beg.line); \ + else if (strcmp((Loc).beg.file, (Loc).end.file)) \ + fprintf(File, "%s:%u.%u-%s:%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.file, \ + (Loc).end.line, (Loc).end.col); \ + else if ((Loc).beg.line != (Loc).end.line) \ + fprintf(File, "%s:%u.%u-%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.line, (Loc).end.col); \ + else if ((Loc).beg.col != (Loc).end.col) \ + fprintf(File, "%s:%u.%u-%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.col); \ + else \ + fprintf(File, "%s:%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line); \ + } while (0) + |