aboutsummaryrefslogtreecommitdiff
path: root/src/dhcpd-gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhcpd-gram.y')
-rw-r--r--src/dhcpd-gram.y160
1 files changed, 80 insertions, 80 deletions
diff --git a/src/dhcpd-gram.y b/src/dhcpd-gram.y
index 11dd1b2..ec285c4 100644
--- a/src/dhcpd-gram.y
+++ b/src/dhcpd-gram.y
@@ -1,5 +1,5 @@
1%{ 1%{
2/* grecs - Gray's Extensible Configuration System 2/* argot - Gray's Extensible Configuration System
3 Copyright (C) 2007-2016 Sergey Poznyakoff 3 Copyright (C) 2007-2016 Sergey Poznyakoff
4 4
5 Grecs is free software; you can redistribute it and/or modify it 5 Grecs is free software; you can redistribute it and/or modify it
@@ -18,7 +18,7 @@
18#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
19# include <config.h> 19# include <config.h>
20#endif 20#endif
21#include <grecs.h> 21#include <argot.h>
22#include <dhcpd-gram.h> 22#include <dhcpd-gram.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdarg.h> 24#include <stdarg.h>
@@ -28,21 +28,21 @@
28int yylex(void); 28int yylex(void);
29int yyerror(char const *s); 29int yyerror(char const *s);
30 30
31static struct grecs_node *parse_tree; 31static struct argot_node *parse_tree;
32extern int yy_flex_debug; 32extern int yy_flex_debug;
33extern int grecs_dhcpd_new_source(const char *name, grecs_locus_t *loc); 33extern int argot_dhcpd_new_source(const char *name, argot_locus_t *loc);
34extern void grecs_dhcpd_close_sources(void); 34extern void argot_dhcpd_close_sources(void);
35 35
36extern void grecs_dhcpd_begin_bool(void); 36extern void argot_dhcpd_begin_bool(void);
37extern void grecs_dhcpd_begin_expr(void); 37extern void argot_dhcpd_begin_expr(void);
38 38
39/* NOTE: STRING must be allocated */ 39/* NOTE: STRING must be allocated */
40static grecs_value_t * 40static argot_value_t *
41make_string_value(char *string) 41make_string_value(char *string)
42{ 42{
43 grecs_value_t *val; 43 argot_value_t *val;
44 val = grecs_malloc(sizeof(val[0])); 44 val = argot_malloc(sizeof(val[0]));
45 val->type = GRECS_TYPE_STRING; 45 val->type = ARGOT_TYPE_STRING;
46 val->v.string = string; 46 val->v.string = string;
47 return val; 47 return val;
48} 48}
@@ -54,11 +54,11 @@ make_string_value(char *string)
54 54
55%union { 55%union {
56 char *string; 56 char *string;
57 grecs_value_t svalue, *pvalue; 57 argot_value_t svalue, *pvalue;
58 struct grecs_list *list; 58 struct argot_list *list;
59 struct grecs_node *node; 59 struct argot_node *node;
60 grecs_locus_t locus; 60 argot_locus_t locus;
61 struct { struct grecs_node *head, *tail; } node_list; 61 struct { struct argot_node *head, *tail; } node_list;
62} 62}
63 63
64%token <string> DHCPD_IF DHCPD_ELSIF DHCPD_EXPR 64%token <string> DHCPD_IF DHCPD_ELSIF DHCPD_EXPR
@@ -76,9 +76,9 @@ make_string_value(char *string)
76 76
77input : maybe_stmtlist 77input : maybe_stmtlist
78 { 78 {
79 parse_tree = grecs_node_create(grecs_node_root, &@1); 79 parse_tree = argot_node_create(argot_node_root, &@1);
80 parse_tree->v.texttab = grecs_text_table(); 80 parse_tree->v.texttab = argot_text_table();
81 grecs_node_bind(parse_tree, $1, 1); 81 argot_node_bind(parse_tree, $1, 1);
82 } 82 }
83 ; 83 ;
84 84
@@ -103,7 +103,7 @@ stmtlist: stmt
103 if (!$1.head) 103 if (!$1.head)
104 $1.head = $1.tail = $2; 104 $1.head = $1.tail = $2;
105 else 105 else
106 grecs_node_bind($1.tail, $2, 0); 106 argot_node_bind($1.tail, $2, 0);
107 } 107 }
108 $$ = $1; 108 $$ = $1;
109 } 109 }
@@ -117,20 +117,20 @@ stmt : simple
117simple : DHCPD_IDENT vallist ';' 117simple : DHCPD_IDENT vallist ';'
118 { 118 {
119 if (strcmp($1, "include") == 0 && 119 if (strcmp($1, "include") == 0 &&
120 $2->type == GRECS_TYPE_STRING) { 120 $2->type == ARGOT_TYPE_STRING) {
121 grecs_dhcpd_new_source($2->v.string, &@1); 121 argot_dhcpd_new_source($2->v.string, &@1);
122 $$ = NULL; 122 $$ = NULL;
123 } else { 123 } else {
124 $$ = grecs_node_create_points(grecs_node_stmt, 124 $$ = argot_node_create_points(argot_node_stmt,
125 @1.beg, @2.end); 125 @1.beg, @2.end);
126 $$->ident = $1; 126 $$->ident = $1;
127 $$->idloc = @1; 127 $$->idloc = @1;
128 $$->v.value = $2; 128 $$->v.value = $2;
129 } 129 }
130 } 130 }
131 | DHCPD_IDENT '=' { grecs_dhcpd_begin_expr(); } DHCPD_EXPR ';' 131 | DHCPD_IDENT '=' { argot_dhcpd_begin_expr(); } DHCPD_EXPR ';'
132 { 132 {
133 $$ = grecs_node_create_points(grecs_node_stmt, 133 $$ = argot_node_create_points(argot_node_stmt,
134 @1.beg, @5.end); 134 @1.beg, @5.end);
135 $$->ident = $1; 135 $$->ident = $1;
136 $$->idloc = @1; 136 $$->idloc = @1;
@@ -138,7 +138,7 @@ simple : DHCPD_IDENT vallist ';'
138 } 138 }
139 | string ';' 139 | string ';'
140 { 140 {
141 $$ = grecs_node_create(grecs_node_stmt, &@1); 141 $$ = argot_node_create(argot_node_stmt, &@1);
142 $$->ident = $1; 142 $$->ident = $1;
143 $$->idloc = @1; 143 $$->idloc = @1;
144 $$->v.value = NULL; 144 $$->v.value = NULL;
@@ -147,12 +147,12 @@ simple : DHCPD_IDENT vallist ';'
147 147
148block : DHCPD_IDENT tag '{' maybe_stmtlist '}' opt_semi 148block : DHCPD_IDENT tag '{' maybe_stmtlist '}' opt_semi
149 { 149 {
150 $$ = grecs_node_create_points(grecs_node_block, 150 $$ = argot_node_create_points(argot_node_block,
151 @1.beg, @5.end); 151 @1.beg, @5.end);
152 $$->ident = $1; 152 $$->ident = $1;
153 $$->idloc = @1; 153 $$->idloc = @1;
154 $$->v.value = $2; 154 $$->v.value = $2;
155 grecs_node_bind($$, $4, 1); 155 argot_node_bind($$, $4, 1);
156 } 156 }
157 ; 157 ;
158 158
@@ -171,46 +171,46 @@ vallist : vlist
171 { 171 {
172 size_t n; 172 size_t n;
173 173
174 if ((n = grecs_list_size($1)) == 1) { 174 if ((n = argot_list_size($1)) == 1) {
175 $$ = grecs_list_index($1, 0); 175 $$ = argot_list_index($1, 0);
176 } else { 176 } else {
177 size_t i; 177 size_t i;
178 struct grecs_list_entry *ep; 178 struct argot_list_entry *ep;
179 179
180 $$ = grecs_malloc(sizeof($$[0])); 180 $$ = argot_malloc(sizeof($$[0]));
181 $$->type = GRECS_TYPE_ARRAY; 181 $$->type = ARGOT_TYPE_ARRAY;
182 $$->locus = @1; 182 $$->locus = @1;
183 $$->v.arg.c = n; 183 $$->v.arg.c = n;
184 $$->v.arg.v = grecs_calloc(n, 184 $$->v.arg.v = argot_calloc(n,
185 sizeof($$->v.arg.v[0])); 185 sizeof($$->v.arg.v[0]));
186 for (i = 0, ep = $1->head; ep; i++, ep = ep->next) 186 for (i = 0, ep = $1->head; ep; i++, ep = ep->next)
187 $$->v.arg.v[i] = ep->data; 187 $$->v.arg.v[i] = ep->data;
188 } 188 }
189 $1->free_entry = NULL; 189 $1->free_entry = NULL;
190 grecs_list_free($1); 190 argot_list_free($1);
191 } 191 }
192 ; 192 ;
193 193
194vlist : value 194vlist : value
195 { 195 {
196 $$ = grecs_value_list_create(); 196 $$ = argot_value_list_create();
197 grecs_list_append($$, grecs_value_ptr_from_static(&$1)); 197 argot_list_append($$, argot_value_ptr_from_static(&$1));
198 } 198 }
199 | vlist value 199 | vlist value
200 { 200 {
201 grecs_list_append($1, grecs_value_ptr_from_static(&$2)); 201 argot_list_append($1, argot_value_ptr_from_static(&$2));
202 } 202 }
203 ; 203 ;
204 204
205value : string 205value : string
206 { 206 {
207 $$.type = GRECS_TYPE_STRING; 207 $$.type = ARGOT_TYPE_STRING;
208 $$.locus = @1; 208 $$.locus = @1;
209 $$.v.string = $1; 209 $$.v.string = $1;
210 } 210 }
211 | strlist 211 | strlist
212 { 212 {
213 $$.type = GRECS_TYPE_LIST;