aboutsummaryrefslogtreecommitdiff
path: root/src/git-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/git-parser.c')
-rw-r--r--src/git-parser.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/git-parser.c b/src/git-parser.c
index d1c7600..aae2884 100644
--- a/src/git-parser.c
+++ b/src/git-parser.c
@@ -21,11 +21,11 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
-#include <grecs.h>
+#include <argot.h>
static FILE *infile;
static int input_char;
-static struct grecs_txtacc *acc;
+static struct argot_txtacc *acc;
#define TOK_EOF 0
#define TOK_EQ '='
@@ -39,8 +39,8 @@ struct token {
char *buf;
char chbuf[2];
int putback;
- struct grecs_list *path;
- grecs_locus_t loc;
+ struct argot_list *path;
+ argot_locus_t loc;
unsigned prev_col;
} tok;
@@ -55,12 +55,12 @@ rawinput()
return input_char = 0;
input_char = fgetc(infile);
if (input_char == '\n') {
- tok.prev_col = grecs_current_locus_point.col;
- grecs_locus_point_advance_line(grecs_current_locus_point);
+ tok.prev_col = argot_current_locus_point.col;
+ argot_locus_point_advance_line(argot_current_locus_point);
} else if (input_char < 0)
input_char = 0;
else
- grecs_current_locus_point.col++;
+ argot_current_locus_point.col++;
return input_char;
}
@@ -81,10 +81,10 @@ unput()
if (!input_char)
return;
if (input_char == '\n') {
- grecs_current_locus_point.line--;
- grecs_current_locus_point.col = tok.prev_col;
+ argot_current_locus_point.line--;
+ argot_current_locus_point.col = tok.prev_col;
} else
- grecs_current_locus_point.col--;
+ argot_current_locus_point.col--;
ungetc(input_char, infile);
}
@@ -100,7 +100,7 @@ static void
collect_unquoted()
{
do
- grecs_txtacc_grow_char(acc, input_char);
+ argot_txtacc_grow_char(acc, input_char);
while (input() &&
!(ISSPACE(input_char) || input_char == ']'));
@@ -110,7 +110,7 @@ static void
collect_subsection_name()
{
do
- grecs_txtacc_grow_char(acc, input_char);
+ argot_txtacc_grow_char(acc, input_char);
while (input() &&
(isalnum(input_char) || input_char == '_' ||
input_char == '-'));
@@ -122,7 +122,7 @@ collect_substring()
while (rawinput()) {
if (input_char == '\\') {
if (!input()) {
- grecs_error(&tok.loc, 0,
+ argot_error(&tok.loc, 0,
"unexpected EOF in string");
break;
}
@@ -138,12 +138,12 @@ collect_substring()
}
} else if (input_char == '"')
break;
- grecs_txtacc_grow_char(acc, input_char);
+ argot_txtacc_grow_char(acc, input_char);
}
}
#define endpoint(t,adj) do { \
- (t).loc.end = grecs_current_locus_point; \
+ (t).loc.end = argot_current_locus_point; \
if (adj) { \
if (input_char == '\n') \
(t).loc.end.col = (t).prev_col; \
@@ -159,9 +159,9 @@ gettoken(void)
tok.putback = 0;
if (putback) {
if (putback == '\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++;
return;
}
@@ -170,7 +170,7 @@ gettoken(void)
while (input() && ISSPACE(input_char))
;
- tok.loc.beg = grecs_current_locus_point;
+ tok.loc.beg = argot_current_locus_point;
if (input_char <= 0) {
tok.type = TOK_EOF;
@@ -182,7 +182,7 @@ gettoken(void)
int dot_delimited = -1;
tok.type = TOK_SECTION;
- grecs_list_clear(tok.path);
+ argot_list_clear(tok.path);
input();
for (;;) {
char *p;
@@ -199,7 +199,7 @@ gettoken(void)
if (input_char == TOK_EOF) {
endpoint(tok, 0);
- grecs_error(&tok.loc, 0,
+ argot_error(&tok.loc, 0,
"unexpected EOF in section header");
tok.type = TOK_ERR;
return;
@@ -208,7 +208,7 @@ gettoken(void)
break;
if (input_char == '\n') {
endpoint(tok, 1);
- grecs_error(&tok.loc, 0,
+ argot_error(&tok.loc, 0,
"unexpect newline in in section header");
tok.type = TOK_ERR;
return;
@@ -227,20 +227,20 @@ gettoken(void)
else if (dot_delimited == 1) {
if (input_char != '.' && input_char != ']') {
endpoint(tok, 1);
- grecs_error(&tok.loc, 0,
+ argot_error(&tok.loc, 0,
"unexpected character in section header");
tok.type = TOK_ERR;
return;
}
}
- grecs_txtacc_grow_char(acc, 0);
- p = grecs_txtacc_finish(acc, 0);
- grecs_list_append(tok.path, p);
+ argot_txtacc_grow_char(acc, 0);
+ p = argot_txtacc_finish(acc, 0);
+ argot_list_append(tok.path, p);
}
endpoint(tok, 1);
- if (grecs_list_size(tok.path) == 0) {
- grecs_error(&tok.loc, 0, "empty section header");
+ if (argot_list_size(tok.path) == 0) {
+ argot_error(&tok.loc, 0, "empty section header");
tok.type = TOK_ERR;
return;
}
@@ -252,11 +252,11 @@ gettoken(void)
if (ISINITIAL(input_char)) {
tok.type = TOK_KEYWORD;
do
- grecs_txtacc_grow_char(acc, input_char);
+ argot_txtacc_grow_char(acc, input_char);
while (input() && ISIDENT(input_char));
unput();
- grecs_txtacc_grow_char(acc, 0);
- tok.buf = grecs_txtacc_finish(acc, 0);
+ argot_txtacc_grow_char(acc, 0);
+ tok.buf = argot_txtacc_finish(acc, 0);
endpoint(tok, 0);
return;
}
@@ -293,42 +293,42 @@ collect_value()
input_char = '\b';
}
}
- grecs_txtacc_grow_char(acc, input_char);
+ argot_txtacc_grow_char(acc, input_char);
} while (input() && input_char != '\n');
}
-static struct grecs_value *
+static struct argot_value *
getvalue()
{
int len;
- struct grecs_value *val = grecs_malloc(sizeof(*val));
+ struct argot_value *val = argot_malloc(sizeof(*val));
while (input() && ISSPACE(input_char) && input_char != '\n')
;
- val->locus.beg = grecs_current_locus_point;
+ val->locus.beg = argot_current_locus_point;
if (input_char != '\n')
collect_value();
- val->locus.end = grecs_current_locus_point;
+ val->locus.end = argot_current_locus_point;
val->locus.end.line--;
val->locus.end.col = tok.prev_col;
- grecs_txtacc_grow_char(acc, 0);
+ argot_txtacc_grow_char(acc, 0);
tok.type = TOK_VALUE;
- tok.buf = grecs_txtacc_finish(acc, 1);
+ tok.buf = argot_txtacc_finish(acc, 1);
len = strlen(tok.buf);
while (len > 0 && ISSPACE(tok.buf[len-1]))
tok.buf[--len] = 0;
- val->type = GRECS_TYPE_STRING;
+ val->type = ARGOT_TYPE_STRING;
val->v.string = tok.buf;
return val;
}
static int
-read_statement(struct grecs_node *parent)
+read_statement(struct argot_node *parent)
{
- struct grecs_node *node;
+ struct argot_node *node;
gettoken();
if (tok.type == TOK_EOF || tok.type == TOK_SECTION) {
@@ -336,54 +336,54 @@ read_statement(struct grecs_node *parent)
return 0;
}
if (tok.type != TOK_KEYWORD) {
- grecs_error(&tok.loc, 0, "syntax error");
+ argot_error(&tok.loc, 0, "syntax error");
error_recovery();
return 1;
}
- node = grecs_node_create(grecs_node_stmt, &tok.loc);
- node->ident = grecs_strdup(tok.buf);
+ node = argot_node_create(argot_node_stmt, &tok.loc);
+ node->ident = argot_strdup(tok.buf);
node->idloc = tok.loc;
gettoken();
if (tok.type == TOK_EOF) {
- grecs_error(&tok.loc, 0, "unexpected EOF");
- grecs_node_free(node);
+ argot_error(&tok.loc, 0, "unexpected EOF");
+ argot_node_free(node);
return 0;
}
if (tok.type != TOK_EQ) {
- grecs_error(&tok.loc, 0,
+ argot_error(&tok.loc, 0,
"expected `=', but found `%s'", tok.buf);
error_recovery();
- grecs_node_free(node);
+ argot_node_free(node);
return 1;
}
node->v.value = getvalue();
node->locus.end = node->v.value->locus.end;
- grecs_node_bind(parent, node, 1);
+ argot_node_bind(parent, node, 1);
return 1;
}
static void
-read_statement_list(struct grecs_node *parent)
+read_statement_list(struct argot_node *parent)
{
while (read_statement(parent))
;
}
-struct grecs_node *
-create_subsection_node(struct grecs_node *root)
+struct argot_node *
+create_subsection_node(struct argot_node *root)
{
- struct grecs_list_entry *ep;
- struct grecs_node *p;
+ struct argot_list_entry *ep;
+ struct argot_node *p;
for (ep = tok.path->head; ep; ep = ep->next) {
char *ident = ep->data;
- p = grecs_find_node(root, ident);
+ p = argot_find_node(root, ident);
if (!p) {
- p = grecs_node_create(grecs_node_block, &tok.loc);
- p->ident = grecs_strdup(ident);
- grecs_node_bind(root, p, 1);
+ p = argot_node_create(argot_node_block, &tok.loc);
+ p->ident = argot_strdup(ident);
+ argot_node_bind(root, p, 1);
}
root = p;
}
@@ -391,50 +391,50 @@ create_subsection_node(struct grecs_node *root)
}
static int
-read_section(struct grecs_node *parent)
+read_section(struct argot_node *parent)
{
gettoken();
if (tok.type == TOK_EOF)
return 0;
else if (tok.type == TOK_SECTION) {
- struct grecs_node *node = create_subsection_node(parent);
+ struct argot_node *node = create_subsection_node(parent);
read_statement_list(node);
} else if (tok.type == TOK_KEYWORD) {
read_statement(parent);
} else {
- grecs_error(&tok.loc, 0, "syntax error");
+ argot_error(&tok.loc, 0, "syntax error");
error_recovery();
}
return 1;
}
/* FIXME: traceflags not used */
-struct grecs_node *
-grecs_git_parser(const char *name, int traceflags)
+struct argot_node *
+argot_git_parser(const char *name, int traceflags)
{
- struct grecs_node *root;
+ struct argot_node *root;
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;
+ argot_current_locus_point.file = argot_install_text(name);
+ argot_current_locus_point.line = 1;
+ argot_current_locus_point.col = 0;
- acc = grecs_txtacc_create();
- tok.path = grecs_list_create();
- root = grecs_node_create(grecs_node_root, &tok.loc);
+ acc = argot_txtacc_create();
+ tok.path = argot_list_create();
+ root = argot_node_create(argot_node_root, &tok.loc);
while (read_section(root))
;
- root->locus.end = grecs_current_locus_point;
+ root->locus.end = argot_current_locus_point;
fclose(infile);
- grecs_txtacc_free(acc);
- grecs_list_free(tok.path);
- if (grecs_error_count) {
- grecs_tree_free(root);
+ argot_txtacc_free(acc);
+ argot_list_free(tok.path);
+ if (argot_error_count) {
+ argot_tree_free(root);
root = NULL;
}
return root;

Return to:

Send suggestions and report system problems to the System administrator.