ROS 2 rclcpp + rcl - rolling  rolling-a919a6e5
ROS 2 C++ Client Library with ROS Client Library
Typedefs | Enumerations | Functions
lexer.h File Reference
#include <stddef.h>
#include "rcl/allocator.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
Include dependency graph for lexer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum rcl_lexeme_e rcl_lexeme_t
 Type of lexeme found by lexical analysis.
 

Enumerations

enum  rcl_lexeme_e {
  RCL_LEXEME_NONE = 0 , RCL_LEXEME_EOF = 1 , RCL_LEXEME_TILDE_SLASH = 2 , RCL_LEXEME_URL_SERVICE = 3 ,
  RCL_LEXEME_URL_TOPIC = 4 , RCL_LEXEME_COLON = 5 , RCL_LEXEME_NODE = 6 , RCL_LEXEME_NS = 7 ,
  RCL_LEXEME_SEPARATOR = 8 , RCL_LEXEME_BR1 = 9 , RCL_LEXEME_BR2 = 10 , RCL_LEXEME_BR3 = 11 ,
  RCL_LEXEME_BR4 = 12 , RCL_LEXEME_BR5 = 13 , RCL_LEXEME_BR6 = 14 , RCL_LEXEME_BR7 = 15 ,
  RCL_LEXEME_BR8 = 16 , RCL_LEXEME_BR9 = 17 , RCL_LEXEME_TOKEN = 18 , RCL_LEXEME_FORWARD_SLASH = 19 ,
  RCL_LEXEME_WILD_ONE = 20 , RCL_LEXEME_WILD_MULTI = 21 , RCL_LEXEME_DOT = 22
}
 Type of lexeme found by lexical analysis. More...
 

Functions

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. More...
 

Enumeration Type Documentation

◆ rcl_lexeme_e

Type of lexeme found by lexical analysis.

Enumerator
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_TILDE_SLASH 

~/

RCL_LEXEME_URL_SERVICE 

rosservice://

RCL_LEXEME_URL_TOPIC 

rostopic://

RCL_LEXEME_COLON 

:

RCL_LEXEME_NODE 

__node or __name

RCL_LEXEME_NS 

__ns

RCL_LEXEME_SEPARATOR 

:=

RCL_LEXEME_BR1 

\1

RCL_LEXEME_BR2 

\2

RCL_LEXEME_BR3 

\3

RCL_LEXEME_BR4 

\4

RCL_LEXEME_BR5 

\5

RCL_LEXEME_BR6 

\6

RCL_LEXEME_BR7 

\7

RCL_LEXEME_BR8 

\8

RCL_LEXEME_BR9 

\9

RCL_LEXEME_TOKEN 

a name between slashes, must match (([a-zA-Z](_)?)|_)([0-9a-zA-Z](_)?)*

RCL_LEXEME_FORWARD_SLASH 

/

RCL_LEXEME_WILD_ONE 
RCL_LEXEME_WILD_MULTI 

**

RCL_LEXEME_DOT 

.

Definition at line 33 of file lexer.h.

Function Documentation

◆ rcl_lexer_analyze()

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.

This function analyzes a string to see if it starts with a valid lexeme. If the string does not begin with a valid lexeme then lexeme will be RCL_LEXEME_NONE, and the length will be set to include the character that made it impossible. It will never be longer than the length of the string. If the first character is '\0' then lexeme will be RCL_LEXEME_EOF.


Attribute Adherence
Allocates Memory No
Thread-Safe Yes
Uses Atomics No
Lock-Free Yes
Parameters
[in]textThe string to analyze.
[out]lexemeThe type of lexeme found in the string.
[out]lengthThe length of text in the string that constitutes the found lexeme.
Returns
RCL_RET_OK if analysis is successful regardless whether a valid lexeme is found, or
RCL_RET_INVALID_ARGUMENT if any function arguments are invalid, or
RCL_RET_ERROR if an internal bug is detected.

Definition at line 598 of file lexer.c.

References rcl_lexer_state_s::else_movement, rcl_lexer_state_s::else_state, rcl_lexer_transition_s::range_end, rcl_lexer_transition_s::range_start, RCL_LEXEME_EOF, RCL_RET_ERROR, RCL_RET_INVALID_ARGUMENT, RCL_RET_OK, rcl_lexer_transition_s::to_state, and rcl_lexer_state_s::transitions.

Referenced by rcl_lexer_lookahead2_peek(), and rcl_lexer_lookahead2_peek2().

Here is the caller graph for this function: