Skip to content

Commit

Permalink
Allow forward slashes within a parameter name rule in argument parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Mar 23, 2022
1 parent d5baf85 commit c2e6c0c
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions rcl/src/rcl/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,45 @@ _rcl_parse_resource_match(
return RCL_RET_OK;
}

RCL_LOCAL
rcl_ret_t
_rcl_parse_param_name_token(rcl_lexer_lookahead2_t * lex_lookahead)
{
rcl_ret_t ret;
rcl_lexeme_t lexeme;

// Check arguments sanity
assert(NULL != lex_lookahead);

ret = rcl_lexer_lookahead2_peek(lex_lookahead, &lexeme);
if (RCL_RET_OK != ret) {
return ret;
}
if (RCL_LEXEME_TOKEN != lexeme && RCL_LEXEME_FORWARD_SLASH != lexeme) {
if (RCL_LEXEME_WILD_ONE == lexeme) {
RCL_SET_ERROR_MSG("Wildcard '*' is not implemented");
return RCL_RET_ERROR;
} else if (RCL_LEXEME_WILD_MULTI == lexeme) {
RCL_SET_ERROR_MSG("Wildcard '**' is not implemented");
return RCL_RET_ERROR;
} else {
RCL_SET_ERROR_MSG("Expecting token or wildcard");
return RCL_RET_WRONG_LEXEME;
}
}
do {
ret = rcl_lexer_lookahead2_accept(lex_lookahead, NULL, NULL);
if (RCL_RET_OK != ret) {
return ret;
}
ret = rcl_lexer_lookahead2_peek(lex_lookahead, &lexeme);
if (RCL_RET_OK != ret) {
return ret;
}
} while (RCL_LEXEME_TOKEN == lexeme || RCL_LEXEME_FORWARD_SLASH == lexeme);
return RCL_RET_OK;
}

/// Parse a parameter name in a parameter override rule (ex: `foo.bar`)
/**
* \sa _rcl_parse_param_rule()
Expand Down Expand Up @@ -1277,7 +1316,7 @@ _rcl_parse_param_name(
}

// token ( '.' token )*
ret = _rcl_parse_resource_match_token(lex_lookahead);
ret = _rcl_parse_param_name_token(lex_lookahead);
if (RCL_RET_OK != ret) {
return ret;
}
Expand All @@ -1290,7 +1329,7 @@ _rcl_parse_param_name(
if (RCL_RET_WRONG_LEXEME == ret) {
return RCL_RET_INVALID_REMAP_RULE;
}
ret = _rcl_parse_resource_match_token(lex_lookahead);
ret = _rcl_parse_param_name_token(lex_lookahead);
if (RCL_RET_OK != ret) {
return ret;
}
Expand Down

0 comments on commit c2e6c0c

Please sign in to comment.