ROS 2 rclcpp + rcl - jazzy
jazzy
ROS 2 C++ Client Library with ROS Client Library
|
#include <stddef.h>
#include "rcl/allocator.h"
#include "rcl/lexer.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
Go to the source code of this file.
Classes | |
struct | rcl_lexer_lookahead2_s |
Track lexical analysis and allow looking ahead 2 lexemes. More... | |
Typedefs | |
typedef struct rcl_lexer_lookahead2_impl_s | rcl_lexer_lookahead2_impl_t |
typedef struct rcl_lexer_lookahead2_s | rcl_lexer_lookahead2_t |
Track lexical analysis and allow looking ahead 2 lexemes. | |
Functions | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_lexer_lookahead2_t | rcl_get_zero_initialized_lexer_lookahead2 (void) |
Get a zero initialized rcl_lexer_lookahead2_t instance. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_init (rcl_lexer_lookahead2_t *buffer, const char *text, rcl_allocator_t allocator) |
Initialize an rcl_lexer_lookahead2_t instance. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_fini (rcl_lexer_lookahead2_t *buffer) |
Finalize an instance of an rcl_lexer_lookahead2_t structure. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_peek (rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t *next_type) |
Look ahead at the next lexeme in the string. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_peek2 (rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t *next_type1, rcl_lexeme_t *next_type2) |
Look ahead at the next two lexemes in the string. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_accept (rcl_lexer_lookahead2_t *buffer, const char **lexeme_text, size_t *lexeme_text_length) |
Accept a lexeme and advance analysis. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_lexer_lookahead2_expect (rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t type, const char **lexeme_text, size_t *lexeme_text_length) |
Require the next lexeme to be a certain type and advance analysis. More... | |
RCL_PUBLIC RCL_WARN_UNUSED const char * | rcl_lexer_lookahead2_get_text (const rcl_lexer_lookahead2_t *buffer) |
Get the text at the point where it is currently being analyzed. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_lexer_lookahead2_t rcl_get_zero_initialized_lexer_lookahead2 | ( | void | ) |
Get a zero initialized rcl_lexer_lookahead2_t instance.
Attribute | Adherence |
---|---|
Allocates Memory | No |
Thread-Safe | Yes |
Uses Atomics | No |
Lock-Free | Yes |
Definition at line 37 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_accept | ( | rcl_lexer_lookahead2_t * | buffer, |
const char ** | lexeme_text, | ||
size_t * | lexeme_text_length | ||
) |
Accept a lexeme and advance analysis.
A token must have been peeked before it can be accepted.
Attribute | Adherence |
---|---|
Allocates Memory | Yes [1] |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[1] Only allocates if an argument is invalid or an error occurs.
[in] | buffer | the lookahead2 buffer being used to analyze a string. |
[out] | lexeme_text | pointer to where lexeme begins in string. |
[out] | lexeme_text_length | length of lexeme_text. |
Definition at line 172 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, RCL_LEXEME_EOF, rcl_lexer_lookahead2_get_text(), RCL_RET_ERROR, RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.
Referenced by rcl_lexer_lookahead2_expect().
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_expect | ( | rcl_lexer_lookahead2_t * | buffer, |
rcl_lexeme_t | type, | ||
const char ** | lexeme_text, | ||
size_t * | lexeme_text_length | ||
) |
Require the next lexeme to be a certain type and advance analysis.
This method is a shortcut to peeking and accepting a lexeme. It should be used by a parser when there is only one valid lexeme that could come next.
Attribute | Adherence |
---|---|
Allocates Memory | Yes [1] |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[1] Only allocates if an argument is invalid or an error occurs.
[in] | buffer | the lookahead2 buffer being used to analyze a string. |
[in] | type | the type the next lexeme must be. |
[out] | lexeme_text | pointer to where lexeme begins in string. |
[out] | lexeme_text_length | length of lexeme_text. |
Definition at line 222 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, RCL_LEXEME_EOF, RCL_LEXEME_NONE, rcl_lexer_lookahead2_accept(), rcl_lexer_lookahead2_peek(), RCL_RET_OK, and RCL_RET_WRONG_LEXEME.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_fini | ( | rcl_lexer_lookahead2_t * | buffer | ) |
Finalize an instance of an rcl_lexer_lookahead2_t structure.
Attribute | Adherence |
---|---|
Allocates Memory | Yes [1] |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[1] Only allocates if an argument is invalid.
[in] | buffer | The structure to be deallocated. |
Definition at line 80 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, RCL_CHECK_ALLOCATOR_WITH_MSG, RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.
RCL_PUBLIC RCL_WARN_UNUSED const char* rcl_lexer_lookahead2_get_text | ( | const rcl_lexer_lookahead2_t * | buffer | ) |
Get the text at the point where it is currently being analyzed.
Attribute | Adherence |
---|---|
Allocates Memory | No |
Thread-Safe | Yes |
Uses Atomics | No |
Lock-Free | Yes |
[in] | buffer | the lookahead2 buffer being used to analyze a string. |
NULL
if buffer is itself NULL
or zero initialized, or Definition at line 253 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl.
Referenced by rcl_lexer_lookahead2_accept(), and rcl_lexer_lookahead2_peek().
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_init | ( | rcl_lexer_lookahead2_t * | buffer, |
const char * | text, | ||
rcl_allocator_t | allocator | ||
) |
Initialize an rcl_lexer_lookahead2_t instance.
The lookahead2 buffer borrows a reference to the provided text. The text must not be freed before the buffer is finalized. The lookahead2 buffer only needs to be finalized if this function does not return RCL_RET_OK.
Attribute | Adherence |
---|---|
Allocates Memory | Yes |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[in] | buffer | A buffer that is zero initialized. |
[in] | text | The string to analyze. |
[in] | allocator | An allocator to use if an error occurs. |
Definition at line 46 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, RCL_CHECK_ALLOCATOR_WITH_MSG, RCL_LEXEME_NONE, RCL_RET_BAD_ALLOC, RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_peek | ( | rcl_lexer_lookahead2_t * | buffer, |
rcl_lexeme_t * | next_type | ||
) |
Look ahead at the next lexeme in the string.
Repeated calls to peek will return the same lexeme. A parser that deems the next lexeme as valid must accept it to advance lexing.
Attribute | Adherence |
---|---|
Allocates Memory | Yes [1] |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[1] Only allocates if an argument is invalid or an internal bug is detected.
[in] | buffer | the lookahead2 buffer being used to analyze a string. |
[out] | next_type | an output variable for the next lexeme in the string. |
Definition at line 95 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, rcl_lexer_analyze(), rcl_lexer_lookahead2_get_text(), RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.
Referenced by rcl_lexer_lookahead2_expect(), and rcl_lexer_lookahead2_peek2().
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_peek2 | ( | rcl_lexer_lookahead2_t * | buffer, |
rcl_lexeme_t * | next_type1, | ||
rcl_lexeme_t * | next_type2 | ||
) |
Look ahead at the next two lexemes in the string.
Repeated calls to peek2 will return the same two lexemes. A parser that deems the next two lexemes as valid must accept twice to advance lexing.
Attribute | Adherence |
---|---|
Allocates Memory | Yes [1] |
Thread-Safe | No |
Uses Atomics | No |
Lock-Free | Yes |
[1] Only allocates if an argument is invalid or an internal bug is detected.
[in] | buffer | the lookahead2 buffer being used to analyze a string. |
[out] | next_type1 | an output variable for the next lexeme in the string. |
[out] | next_type2 | an output variable for the lexeme after the next lexeme in the string. |
Definition at line 129 of file lexer_lookahead.c.
References rcl_lexer_lookahead2_s::impl, RCL_LEXEME_EOF, RCL_LEXEME_NONE, rcl_lexer_analyze(), rcl_lexer_lookahead2_peek(), RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.