diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-09 15:12:53 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-09 15:12:53 +0300 |
commit | ca151e4c71e359ab26d192092528938b82cffd18 (patch) | |
tree | a0bf0a93865ac333cce4e1c7f440e9515e672114 /src | |
parent | 2614146e13e93c69a26907ef25fca89f5b84545e (diff) | |
download | grecs-ca151e4c71e359ab26d192092528938b82cffd18.tar.gz grecs-ca151e4c71e359ab26d192092528938b82cffd18.tar.bz2 |
Allow for statements without values, for compatibility with bind.
* src/format.c (grecs_format_value): Return immediately if val is NULL.
* src/grecs-gram.y: Accept statements without values and arrays as
block tags.
* src/tree.c (grecs_process_ident): Bail out if a value is required, but
not given.
Diffstat (limited to 'src')
-rw-r--r-- | src/format.c | 4 | ||||
-rw-r--r-- | src/grecs-gram.y | 18 | ||||
-rw-r--r-- | src/tree.c | 7 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/format.c b/src/format.c index 9b6b6af..b4a4340 100644 --- a/src/format.c +++ b/src/format.c @@ -217,7 +217,9 @@ grecs_format_value(struct grecs_value *val, int flags, FILE *fp) struct grecs_list_entry *ep; size_t clen; int need_quote; - + + if (!val) + return; switch (val->type) { case GRECS_TYPE_STRING: clen = wordsplit_c_quoted_length(val->v.string, diff --git a/src/grecs-gram.y b/src/grecs-gram.y index a805702..8d0adbf 100644 --- a/src/grecs-gram.y +++ b/src/grecs-gram.y @@ -44,8 +44,8 @@ int grecs_default_port = 0; %token <string> IDENT STRING QSTRING MSTRING %type <string> string slist %type <list> slist0 -%type <svalue> value tag -%type <pvalue> vallist +%type <svalue> value +%type <pvalue> vallist tag %type <list> values list vlist %type <node> stmt simple block %type <node_list> stmtlist @@ -82,6 +82,13 @@ simple : IDENT vallist ';' $$->ident = $1; $$->v.value = $2; } + | IDENT ';' + { + $$ = grecs_node_create(grecs_node_stmt, + &grecs_current_locus); + $$->ident = $1; + $$->v.value = NULL; + } ; block : IDENT tag '{' stmtlist '}' opt_sc @@ -89,17 +96,16 @@ block : IDENT tag '{' stmtlist '}' opt_sc $$ = grecs_node_create(grecs_node_block, &grecs_current_locus); $$->ident = $1; - $$->v.value = grecs_value_ptr_from_static(&$2); + $$->v.value = $2; grecs_node_bind($$, $4.head, 1); } ; tag : /* empty */ { - $$.type = GRECS_TYPE_STRING; - $$.v.string = NULL; + $$ = NULL; } - | value + | vallist ; vallist : vlist @@ -669,7 +669,12 @@ grecs_process_ident(struct grecs_keyword *kwp, grecs_value_t *value, target, value, &kwp->callback_data); - else if (value->type == GRECS_TYPE_ARRAY) { + else if (GRECS_TYPE(kwp->type) == grecs_type_void) + return; + else if (!value) { + grecs_error(locus, 0, "%s has no value", kwp->ident); + return; + } else if (value->type == GRECS_TYPE_ARRAY) { grecs_error(locus, 0, _("too many arguments to `%s'; missing semicolon?"), kwp->ident); |