diff options
Diffstat (limited to 'src/path-parser.c')
-rw-r--r-- | src/path-parser.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/path-parser.c b/src/path-parser.c index 825fafc..e43afb3 100644 --- a/src/path-parser.c +++ b/src/path-parser.c @@ -21,22 +21,22 @@ #include <string.h> #include <ctype.h> #include <errno.h> -#include <grecs.h> +#include <argot.h> static int next_char(FILE *infile) { int c = fgetc(infile); if (c == '\n') - grecs_locus_point_advance_line(grecs_current_locus_point); + argot_locus_point_advance_line(argot_current_locus_point); else { - grecs_current_locus_point.col++; + argot_current_locus_point.col++; if (c == '\\') { int nc = fgetc(infile); if (nc == '\n') { - grecs_locus_point_advance_line(grecs_current_locus_point); + argot_locus_point_advance_line(argot_current_locus_point); c = fgetc(infile); - grecs_current_locus_point.col++; + argot_current_locus_point.col++; } else ungetc(nc, infile); } @@ -44,14 +44,14 @@ next_char(FILE *infile) return c; } -struct grecs_node * -grecs_path_parser(const char *name, int traceflags) +struct argot_node * +argot_path_parser(const char *name, int traceflags) { - struct grecs_node *root, *subtree = NULL, *node; + struct argot_node *root, *subtree = NULL, *node; FILE *infile; - struct grecs_txtacc *acc = NULL; + struct argot_txtacc *acc = NULL; char *kw, *val; - grecs_locus_t kwloc, valloc, rootloc; + argot_locus_t kwloc, valloc, rootloc; int inquote; int lookahead; int err = 0; @@ -59,16 +59,16 @@ grecs_path_parser(const char *name, int traceflags) infile = fopen(name, "r"); if (!infile) { - grecs_error(NULL, errno, _("cannot open `%s'"), name); + argot_error(NULL, errno, _("cannot open `%s'"), name); return NULL; } - grecs_current_locus_point.file = grecs_install_text(name); - grecs_current_locus_point.line = 1; - grecs_current_locus_point.col = 0; - rootloc.beg = grecs_current_locus_point; + argot_current_locus_point.file = argot_install_text(name); + argot_current_locus_point.line = 1; + argot_current_locus_point.col = 0; + rootloc.beg = argot_current_locus_point; rootloc.beg.col++; - acc = grecs_txtacc_create(); + acc = argot_txtacc_create(); while ((lookahead = next_char(infile)) > 0) { while (1) { @@ -87,7 +87,7 @@ grecs_path_parser(const char *name, int traceflags) if (lookahead <= 0) break; - kwloc.beg = grecs_current_locus_point; + kwloc.beg = argot_current_locus_point; inquote = 0; for (; lookahead > 0 && lookahead != ':'; @@ -101,46 +101,46 @@ grecs_path_parser(const char *name, int traceflags) inquote = 0; } else if (lookahead == '\'' || lookahead == '"') inquote = lookahead; - grecs_txtacc_grow_char(acc, lookahead); + argot_txtacc_grow_char(acc, lookahead); } if (lookahead <= 0) { - grecs_error(&kwloc, 0, _("unexpected end of file")); + argot_error(&kwloc, 0, _("unexpected end of file")); err = 1; break; } - grecs_txtacc_grow_char(acc, 0); - kw = grecs_txtacc_finish(acc, 0); + argot_txtacc_grow_char(acc, 0); + kw = argot_txtacc_finish(acc, 0); - kwloc.end = grecs_current_locus_point; + kwloc.end = argot_current_locus_point; kwloc.end.col--; while ((lookahead = next_char(infile)) > 0 && (lookahead == ' ' || lookahead == '\t')); if (lookahead <= 0) { - grecs_error(&kwloc, 0, _("unexpected end of file")); + argot_error(&kwloc, 0, _("unexpected end of file")); err = 1; break; } - valloc.beg = grecs_current_locus_point; + valloc.beg = argot_current_locus_point; do { - grecs_txtacc_grow_char(acc, lookahead); - prev_col = grecs_current_locus_point.col; + argot_txtacc_grow_char(acc, lookahead); + prev_col = argot_current_locus_point.col; } while ((lookahead = next_char(infile)) > 0 && lookahead != '\n'); - valloc.end = grecs_current_locus_point; + valloc.end = argot_current_locus_point; valloc.end.line--; valloc.end.col = prev_col; - grecs_txtacc_grow_char(acc, 0); - val = grecs_txtacc_finish(acc, 0); + argot_txtacc_grow_char(acc, 0); + val = argot_txtacc_finish(acc, 0); - node = grecs_node_from_path_locus(kw, val, &kwloc, &valloc); + node = argot_node_from_path_locus(kw, val, &kwloc, &valloc); if (!node) { - grecs_error(&kwloc, 0, _("parse error")); + argot_error(&kwloc, 0, _("parse error")); err = 1; break; } @@ -150,23 +150,23 @@ grecs_path_parser(const char *name, int traceflags) if (!subtree) subtree = node; else - grecs_node_bind(subtree, node, 0); - grecs_txtacc_free_string(acc, kw); - grecs_txtacc_free_string(acc, val); + argot_node_bind(subtree, node, 0); + argot_txtacc_free_string(acc, kw); + argot_txtacc_free_string(acc, val); } fclose(infile); - grecs_txtacc_free(acc); + argot_txtacc_free(acc); if (err) { - grecs_tree_free(subtree); + argot_tree_free(subtree); root = NULL; } else { - rootloc.end = grecs_current_locus_point; - root = grecs_node_create(grecs_node_root, &rootloc); - root->v.texttab = grecs_text_table(); - grecs_node_bind(root, subtree, 1); - grecs_tree_reduce(root, NULL, 0); + rootloc.end = argot_current_locus_point; + root = argot_node_create(argot_node_root, &rootloc); + root->v.texttab = argot_text_table(); + argot_node_bind(root, subtree, 1); + argot_tree_reduce(root, NULL, 0); } return root; |