diff options
-rw-r--r-- | src/Make.am | 2 | ||||
-rw-r--r-- | src/bind-gram.y | 68 | ||||
-rw-r--r-- | src/bind-lex.l | 58 | ||||
-rw-r--r-- | src/diag.c | 18 | ||||
-rw-r--r-- | src/format.c | 59 | ||||
-rw-r--r-- | src/git-parser.c | 93 | ||||
-rw-r--r-- | src/grecs-gram.y | 43 | ||||
-rw-r--r-- | src/grecs-lex.l | 102 | ||||
-rw-r--r-- | src/grecs-locus.h | 56 | ||||
-rw-r--r-- | src/grecs.h | 45 | ||||
-rw-r--r-- | src/join.c | 27 | ||||
-rw-r--r-- | src/lookup.c | 54 | ||||
-rw-r--r-- | src/meta1-gram.y | 37 | ||||
-rw-r--r-- | src/meta1-lex.l | 27 | ||||
-rw-r--r-- | src/parser.c | 5 | ||||
-rw-r--r-- | src/path-parser.c | 172 | ||||
-rw-r--r-- | src/preproc.c | 22 | ||||
-rw-r--r-- | src/tree.c | 45 | ||||
-rw-r--r-- | tests/Makefile.am | 9 | ||||
-rw-r--r-- | tests/format01.at | 28 | ||||
-rw-r--r-- | tests/gcf1.conf | 12 | ||||
-rw-r--r-- | tests/gcffmt.c | 14 | ||||
-rw-r--r-- | tests/gcfpeek.c | 20 | ||||
-rw-r--r-- | tests/join.at | 16 | ||||
-rw-r--r-- | tests/locus-bind.at | 40 | ||||
-rw-r--r-- | tests/locus-git.at | 61 | ||||
-rw-r--r-- | tests/locus-meta1.at | 37 | ||||
-rw-r--r-- | tests/locus00.at | 30 | ||||
-rw-r--r-- | tests/locus01.at | 34 | ||||
-rw-r--r-- | tests/locus02.at | 32 | ||||
-rw-r--r-- | tests/path-locus.at | 92 | ||||
-rw-r--r-- | tests/set.at | 2 | ||||
-rw-r--r-- | tests/testsuite.at | 22 |
33 files changed, 1034 insertions, 348 deletions
diff --git a/src/Make.am b/src/Make.am index bc70edc..286bf4c 100644 --- a/src/Make.am +++ b/src/Make.am | |||
@@ -59,7 +59,7 @@ GRECS_SRC = \ | |||
59 | $(GRECS_PARSER_GIT)\ | 59 | $(GRECS_PARSER_GIT)\ |
60 | $(GRECS_PARSER_META1) | 60 | $(GRECS_PARSER_META1) |
61 | 61 | ||
62 | noinst_HEADERS = | 62 | noinst_HEADERS = grecs-locus.h |
63 | 63 | ||
64 | EXTRA_DIST=\ | 64 | EXTRA_DIST=\ |
65 | grecs-gram.h\ | 65 | grecs-gram.h\ |
diff --git a/src/bind-gram.y b/src/bind-gram.y index c751ae1..e353a54 100644 --- a/src/bind-gram.y +++ b/src/bind-gram.y | |||
@@ -19,7 +19,8 @@ | |||
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <grecs.h> | 21 | #include <grecs.h> |
22 | #include <grecs-gram.h> | 22 | #include <grecs-locus.h> |
23 | #include <bind-gram.h> | ||
23 | #include <stdlib.h> | 24 | #include <stdlib.h> |
24 | #include <stdarg.h> | 25 | #include <stdarg.h> |
25 | #include <string.h> | 26 | #include <string.h> |
@@ -30,17 +31,16 @@ int yyerror(char *s); | |||
30 | 31 | ||
31 | static struct grecs_node *parse_tree; | 32 | static struct grecs_node *parse_tree; |
32 | extern int yy_flex_debug; | 33 | extern int yy_flex_debug; |
33 | extern int grecs_bind_new_source(const char *name); | 34 | extern int grecs_bind_new_source(const char *name, grecs_locus_t *loc); |
34 | extern void grecs_bind_close_sources(void); | 35 | extern void grecs_bind_close_sources(void); |
35 | 36 | ||
36 | static struct grecs_value *stmtlist_to_value(struct grecs_node *node); | 37 | static struct grecs_value *stmtlist_to_value(struct grecs_node *node); |
37 | %} | 38 | %} |
38 | 39 | ||
40 | %error-verbose | ||
41 | %locations | ||
42 | |||
39 | %union { | 43 | %union { |
40 | struct { | ||
41 | grecs_locus_t locus; | ||
42 | char *string; | ||
43 | } ident; | ||
44 | char *string; | 44 | char *string; |
45 | grecs_value_t svalue, *pvalue; | 45 | grecs_value_t svalue, *pvalue; |
46 | struct grecs_list *list; | 46 | struct grecs_list *list; |
@@ -49,8 +49,7 @@ static struct grecs_value *stmtlist_to_value(struct grecs_node *node); | |||
49 | struct { struct grecs_node *head, *tail; } node_list; | 49 | struct { struct grecs_node *head, *tail; } node_list; |
50 | } | 50 | } |
51 | 51 | ||
52 | %token <ident> BIND_IDENT BIND_CONTROLS | 52 | %token <string> BIND_STRING BIND_IDENT BIND_CONTROLS |
53 | %token <string> BIND_STRING | ||
54 | %type <string> string | 53 | %type <string> string |
55 | %type <svalue> value ctlsub | 54 | %type <svalue> value ctlsub |
56 | %type <pvalue> vallist tag | 55 | %type <pvalue> vallist tag |
@@ -62,8 +61,7 @@ static struct grecs_value *stmtlist_to_value(struct grecs_node *node); | |||
62 | 61 | ||
63 | input : maybe_stmtlist | 62 | input : maybe_stmtlist |
64 | { | 63 | { |
65 | parse_tree = grecs_node_create(grecs_node_root, | 64 | parse_tree = grecs_node_create(grecs_node_root, &@1); |
66 | &grecs_current_locus); | ||
67 | parse_tree->v.texttab = grecs_text_table(); | 65 | parse_tree->v.texttab = grecs_text_table(); |
68 | grecs_node_bind(parse_tree, $1, 1); | 66 | grecs_node_bind(parse_tree, $1, 1); |
69 | } | 67 | } |
@@ -102,38 +100,44 @@ stmt : simple | |||
102 | 100 | ||
103 | simple : BIND_IDENT vallist ';' | 101 | simple : BIND_IDENT vallist ';' |
104 | { | 102 | { |
105 | if (strcmp($1.string, "include") == 0 && | 103 | if (strcmp($1, "include") == 0 && |
106 | $2->type == GRECS_TYPE_STRING) { | 104 | $2->type == GRECS_TYPE_STRING) { |
107 | grecs_bind_new_source($2->v.string); | 105 | grecs_bind_new_source($2->v.string, &@1); |
108 | $$ = NULL; | 106 | $$ = NULL; |
109 | } else { | 107 | } else { |
110 | $$ = grecs_node_create(grecs_node_stmt, &$1.locus); | 108 | $$ = grecs_node_create_points(grecs_node_stmt, |
111 | $$->ident = $1.string; | 109 | @1.beg, @2.end); |
110 | $$->ident = $1; | ||
111 | $$->idloc = @1; | ||
112 | $$->v.value = $2; | 112 | $$->v.value = $2; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | | string ';' | 115 | | string ';' |
116 | { | 116 | { |
117 | $$ = grecs_node_create(grecs_node_stmt, | 117 | $$ = grecs_node_create(grecs_node_stmt, &@1); |
118 | &grecs_current_locus); | ||
119 | $$->ident = $1; | 118 | $$->ident = $1; |
119 | $$->idloc = @1; | ||
120 | $$->v.value = NULL; | 120 | $$->v.value = NULL; |
121 | } | 121 | } |
122 | | '!' string ';' | 122 | | '!' string ';' |
123 | { | 123 | { |
124 | $$ = grecs_node_create(grecs_node_stmt, | 124 | $$ = grecs_node_create_points(grecs_node_stmt, |
125 | &grecs_current_locus); | 125 | @1.beg, @2.end); |
126 | $$->ident = grecs_strdup("!"); | 126 | $$->ident = grecs_strdup("!"); |
127 | $$->v.value = grecs_malloc(sizeof($$->v.value[0])); | 127 | $$->idloc = @1; |
128 | $$->v.value->type = GRECS_TYPE_STRING; | 128 | $$->v.value = grecs_malloc(sizeof($$->v.value[0])); |
129 | $$->v.value->v.string = $2; | 129 | $$->v.value->type = GRECS_TYPE_STRING; |
130 | $$->v.value->locus = @2; | ||
131 | $$->v.value->v.string = $2; | ||
130 | } | 132 | } |
131 | ; | 133 | ; |
132 | 134 | ||
133 | block : BIND_IDENT tag '{' maybe_stmtlist '}' ';' | 135 | block : BIND_IDENT tag '{' maybe_stmtlist '}' ';' |
134 | { | 136 | { |
135 | $$ = grecs_node_create(grecs_node_block, &$1.locus); | 137 | $$ = grecs_node_create_points(grecs_node_block, |
136 | $$->ident = $1.string; | 138 | @1.beg, @5.end); |
139 | $$->ident = $1; | ||
140 | $$->idloc = @1; | ||
137 | $$->v.value = $2; | 141 | $$->v.value = $2; |
138 | grecs_node_bind($$, $4, 1); | 142 | grecs_node_bind($$, $4, 1); |
139 | } | 143 | } |
@@ -151,8 +155,10 @@ block : BIND_IDENT tag '{' maybe_stmtlist '}' ';' | |||
151 | (127.0.0.1, 127.0.0.2), keys, (rndc-key)) | 155 | (127.0.0.1, 127.0.0.2), keys, (rndc-key)) |
152 | */ | 156 | */ |
153 | { | 157 | { |
154 | $$ = grecs_node_create(grecs_node_stmt, &$1.locus); | 158 | $$ = grecs_node_create_points(grecs_node_stmt, |
155 | $$->ident = $1.string; | 159 | @1.beg, @4.end); |
160 | $$->ident = $1; | ||
161 | $$->idloc = @1; | ||
156 | $$->v.value = grecs_value_ptr_from_static(&$3); | 162 | $$->v.value = grecs_value_ptr_from_static(&$3); |
157 | } | 163 | } |
158 | ; | 164 | ; |
@@ -176,6 +182,7 @@ vallist : vlist | |||
176 | 182 | ||
177 | $$ = grecs_malloc(sizeof($$[0])); | 183 | $$ = grecs_malloc(sizeof($$[0])); |
178 | $$->type = GRECS_TYPE_ARRAY; | 184 | $$->type = GRECS_TYPE_ARRAY; |
185 | $$->locus = @1; | ||
179 | $$->v.arg.c = n; | 186 | $$->v.arg.c = n; |
180 | $$->v.arg.v = grecs_calloc(n, | 187 | $$->v.arg.v = grecs_calloc(n, |
181 | sizeof($$->v.arg.v[0])); | 188 | sizeof($$->v.arg.v[0])); |
@@ -201,20 +208,19 @@ vlist : value | |||
201 | value : string | 208 | value : string |
202 | { | 209 | { |
203 | $$.type = GRECS_TYPE_STRING; | 210 | $$.type = GRECS_TYPE_STRING; |
211 | $$.locus = @1; | ||
204 | $$.v.string = $1; | 212 | $$.v.string = $1; |
205 | } | 213 | } |
206 | ; | 214 | ; |
207 | 215 | ||
208 | string : BIND_STRING | 216 | string : BIND_STRING |
209 | | BIND_IDENT | 217 | | BIND_IDENT |
210 | { | ||
211 | $$ = $1.string; | ||
212 | } | ||
213 | ; | 218 | ; |
214 | 219 | ||
215 | ctlsub : ctllist ';' | 220 | ctlsub : ctllist ';' |
216 | { | 221 | { |
217 | $$.type = GRECS_TYPE_LIST; | 222 |