15 #include "rcl/error_handling.h"
197 #define LAST_STATE S31
199 #define T_TILDE_SLASH 32u
200 #define T_URL_SERVICE 33u
201 #define T_URL_TOPIC 34u
205 #define T_SEPARATOR 38u
216 #define T_FORWARD_SLASH 49u
217 #define T_WILD_ONE 50u
218 #define T_WILD_MULTI 51u
224 #define FIRST_TERMINAL T_TILDE_SLASH
225 #define LAST_TERMINAL T_NONE
228 #define END_TRANSITIONS {0, '\0', '\0'}
237 {T_FORWARD_SLASH,
'/',
'/'},
273 {T_TILDE_SLASH,
'/',
'/'},
443 {T_URL_TOPIC,
'/',
'/'},
524 {T_URL_SERVICE,
'/',
'/'},
533 {T_WILD_MULTI,
'*',
'*'},
542 {T_SEPARATOR,
'=',
'='},
548 static const rcl_lexeme_t g_terminals[LAST_TERMINAL + 1] = {
612 if (
'\0' == text[0u]) {
620 size_t next_state = S0;
625 if (next_state > LAST_STATE) {
627 RCL_SET_ERROR_MSG(
"Internal lexer bug: next state does not exist");
630 state = &(g_states[next_state]);
631 current_char = text[*length];
636 size_t transition_idx = 0u;
639 transition = &(state->
transitions[transition_idx]);
645 }
while (0u != transition->
to_state);
648 if (0u == next_state) {
653 if (0u == movement) {
654 if (
'\0' != current_char) {
660 if (movement - 1u > *length) {
662 RCL_SET_ERROR_MSG(
"Internal lexer bug: movement would read before start of string");
665 *length -= movement - 1u;
667 }
while (next_state < FIRST_TERMINAL);
669 if (FIRST_TERMINAL > next_state || next_state - FIRST_TERMINAL > LAST_TERMINAL) {
671 RCL_SET_ERROR_MSG(
"Internal lexer bug: terminal state does not exist");
674 *lexeme = g_terminals[next_state - FIRST_TERMINAL];
@ RCL_LEXEME_TOKEN
a name between slashes, must match (([a-zA-Z](_)?)|_)([0-9a-zA-Z](_)?)*
@ RCL_LEXEME_NONE
Indicates no valid lexeme was found (end of input not reached)
@ RCL_LEXEME_EOF
Indicates end of input has been reached.
@ RCL_LEXEME_URL_TOPIC
rostopic://
@ RCL_LEXEME_URL_SERVICE
rosservice://
@ RCL_LEXEME_TILDE_SLASH
~/
@ RCL_LEXEME_FORWARD_SLASH
/
@ RCL_LEXEME_NODE
__node or __name
@ RCL_LEXEME_WILD_MULTI
**
enum rcl_lexeme_e rcl_lexeme_t
Type of lexeme found by lexical analysis.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_analyze(const char *text, rcl_lexeme_t *lexeme, size_t *length)
Do lexical analysis on a string.
const unsigned char else_movement
Movement associated with taking else state.
const unsigned char else_state
Transition to this state if no other transition matches.
const rcl_lexer_transition_t transitions[12]
Transitions in the state machine (NULL value at end of array)
const unsigned char to_state
Index of a state to transition to.
const char range_end
End of a range of chars (inclusive) which activates this transition.
const char range_start
Start of a range of chars (inclusive) which activates this transition.
#define RCL_RET_OK
Success return code.
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
#define RCL_RET_ERROR
Unspecified error return code.
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.