Browse Source

[config] expect exactly one comma between list entries

- the parser didn't require a comma before, and accepted multiple ones
- comma at end of list still optional

Change-Id: I4bb07ceed9aaceb43a14f7eeb5d364d6718e7acc
master
Stefan Bühler 4 years ago
parent
commit
130f14a3ea
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      src/main/config_parser.rl

+ 12
- 3
src/main/config_parser.rl View File

@@ -1244,7 +1244,10 @@ static gboolean p_value_list(gint *key_value_nesting, liValue **result, gboolean
if (NULL == pre_value) {
NEXT(token);
if (end == token) break;
if (TK_COMMA == token) continue;
if (TK_COMMA == token) {
parse_error(ctx, error, "unexpected ',', expected value or list end");
goto error;
}
REMEMBER(token);

if (!p_value(&sub_kv_nesting, &value, TK_ERROR, ctx, error)) goto error;
@@ -1258,7 +1261,7 @@ static gboolean p_value_list(gint *key_value_nesting, liValue **result, gboolean
if (!key_value_list && TK_ASSOCICATE == token) {
key_value_list = TRUE;
if (li_value_list_len(list) > 0) {
parse_error(ctx, error, "unexpected '=>'");
parse_error(ctx, error, "unexpected '=>', not a key-value list");
goto error;
}
}
@@ -1278,11 +1281,17 @@ static gboolean p_value_list(gint *key_value_nesting, liValue **result, gboolean
li_value_list_append(pair, value);
li_value_list_append(list, pair);
value = key = NULL;
NEXT(token);
} else {
REMEMBER(token);
li_value_list_append(list, value);
value = NULL;
}

if (end == token) break;
if (TK_COMMA != token) {
parse_error(ctx, error, "expected ',' or list end");
goto error;
}
}

if (key_value_list) *key_value_nesting = 0;


Loading…
Cancel
Save