17 #include "rcl/error_handling.h"
200 #define LAST_STATE S31
202 #define T_TILDE_SLASH 32u
203 #define T_URL_SERVICE 33u
204 #define T_URL_TOPIC 34u
208 #define T_SEPARATOR 38u
219 #define T_FORWARD_SLASH 49u
220 #define T_WILD_ONE 50u
221 #define T_WILD_MULTI 51u
227 #define FIRST_TERMINAL T_TILDE_SLASH
228 #define LAST_TERMINAL T_NONE
231 #define END_TRANSITIONS {0, '\0', '\0'}
240 {T_FORWARD_SLASH,
'/',
'/'},
276 {T_TILDE_SLASH,
'/',
'/'},
446 {T_URL_TOPIC,
'/',
'/'},
527 {T_URL_SERVICE,
'/',
'/'},
536 {T_WILD_MULTI,
'*',
'*'},
545 {T_SEPARATOR,
'=',
'='},
551 static const rcl_lexeme_t g_terminals[LAST_TERMINAL + 1] = {
615 if (
'\0' == text[0u]) {
623 size_t next_state = S0;
628 if (next_state > LAST_STATE) {
630 RCL_SET_ERROR_MSG(
"Internal lexer bug: next state does not exist");
633 state = &(g_states[next_state]);
634 current_char = text[*length];
639 size_t transition_idx = 0u;
642 transition = &(state->
transitions[transition_idx]);
648 }
while (0u != transition->
to_state);
651 if (0u == next_state) {
656 if (0u == movement) {
657 if (
'\0' != current_char) {
663 if (movement - 1u > *length) {
665 RCL_SET_ERROR_MSG(
"Internal lexer bug: movement would read before start of string");
668 *length -= movement - 1u;
670 }
while (next_state < FIRST_TERMINAL);
672 if (FIRST_TERMINAL > next_state || next_state - FIRST_TERMINAL > LAST_TERMINAL) {
674 RCL_SET_ERROR_MSG(
"Internal lexer bug: terminal state does not exist");
677 *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.