aboutsummaryrefslogtreecommitdiff
path: root/src/meta1gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/meta1gram.y')
-rw-r--r--src/meta1gram.y47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/meta1gram.y b/src/meta1gram.y
index 6256448..deaf382 100644
--- a/src/meta1gram.y
+++ b/src/meta1gram.y
@@ -1,9 +1,9 @@
%{
/* MeTA1 configuration parser for GNU Pies.
- Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
GNU Pies 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, or (at your option)
any later version.
@@ -17,14 +17,16 @@
/* This file implements a grammar for parsing MeTA1 main configuration file,
and a set of functions for converting its statements into Pies
configuration statements. */
#include "pies.h"
+#include "grecs-locus.h"
#include "meta1lex.h"
-
+#include "meta1gram.h"
+
#define META1_QUEUE_DIR() \
(meta1_queue_dir ? meta1_queue_dir : "/var/spool/meta1")
enum meta1_stmt_type
{
meta1_simple,
@@ -48,13 +50,13 @@ struct meta1_stmt *
meta1_stmt_create (enum meta1_stmt_type type, const char *ident)
{
struct meta1_stmt *p = xmalloc (sizeof (*p));
p->next = NULL;
p->type = type;
p->ident = ident;
- p->locus = meta1_locus;
+ p->locus = meta1lloc;
return p;
}
static struct meta1_stmt *
_reverse (struct meta1_stmt *list, struct meta1_stmt **root)
{
@@ -81,15 +83,18 @@ reverse (struct meta1_stmt *in)
return root;
}
static void meta1_translate (struct meta1_stmt *);
%}
+%error-verbose
+%locations
+
%union {
char *string;
- gl_list_t list;
+ struct grecs_list *list;
grecs_value_t *value;
struct meta1_stmt *stmt;
}
%token <string> META1_IDENT META1_STRING META1_NUMBER
%type <list> slist values list
@@ -165,35 +170,31 @@ value : string
}
;
string : META1_IDENT
| slist
{
- const void *p;
- gl_list_iterator_t itr = gl_list_iterator ($1);
-
+ struct grecs_list_entry *ep;
meta1_line_begin ();
- while (gl_list_iterator_next (&itr, &p, NULL))
- meta1_line_add (p, strlen (p));
- gl_list_iterator_free (&itr);
+ for (ep = $1->head; ep; ep = ep->next)
+ {
+ const char *p = ep->data;
+ meta1_line_add (p, strlen (p));
+ }
$$ = meta1_line_finish ();
}
;
slist : META1_STRING
{
- $$ = gl_list_create_empty (&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- true);
- gl_list_add_last ($$, $1);
+ $$ = grecs_list_create ();
+ grecs_list_append ($$, $1);
}
| slist META1_STRING
{
- gl_list_add_last ($1, $2);
+ grecs_list_append ($1, $2);
$$ = $1;
}
;
list : '{' values '}'
{
@@ -204,35 +205,31 @@ list : '{' values '}'
$$ = $2;
}
;
values : value
{
- $$ = gl_list_create_empty (&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- true);
- gl_list_add_last ($$, $1);
+ $$ = grecs_list_create ();
+ grecs_list_append ($$, $1);
}
| values ',' value
{
- gl_list_add_last ($1, $3);
+ grecs_list_append ($1, $3);
$$ = $1;
}
;
opt_sc : /* empty */
| ';'
;
%%
int
yyerror (char *s)
{
- meta1_parse_error ("%s", s);
+ grecs_error (&yylloc, 0, "%s", s);
return 0;
}
void
meta1_parser_set_debug ()
{

Return to:

Send suggestions and report system problems to the System administrator.