rcl  master
C API providing common ROS client library functionality.
lexer_lookahead.h
Go to the documentation of this file.
1 // Copyright 2018 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCL__LEXER_LOOKAHEAD_H_
16 #define RCL__LEXER_LOOKAHEAD_H_
17 
18 #include <stddef.h>
19 
20 #include "rcl/allocator.h"
21 #include "rcl/lexer.h"
22 #include "rcl/macros.h"
23 #include "rcl/types.h"
24 #include "rcl/visibility_control.h"
25 
26 #if __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 // Forward declaration
32 struct rcl_lexer_lookahead2_impl_t;
33 
35 typedef struct rcl_lexer_lookahead2_t
36 {
37  struct rcl_lexer_lookahead2_impl_t * impl;
39 
41 
57 
59 
86  rcl_lexer_lookahead2_t * buffer,
87  const char * text,
88  rcl_allocator_t allocator);
89 
91 
110 rcl_ret_t
112  rcl_lexer_lookahead2_t * buffer);
113 
115 
137 rcl_ret_t
139  rcl_lexer_lookahead2_t * buffer,
140  rcl_lexeme_t * next_type);
141 
143 
166 rcl_ret_t
168  rcl_lexer_lookahead2_t * buffer,
169  rcl_lexeme_t * next_type1,
170  rcl_lexeme_t * next_type2);
171 
173 
196 rcl_ret_t
198  rcl_lexer_lookahead2_t * buffer,
199  const char ** lexeme_text,
200  size_t * lexeme_text_length);
201 
203 
229 rcl_ret_t
231  rcl_lexer_lookahead2_t * buffer,
232  rcl_lexeme_t type,
233  const char ** lexeme_text,
234  size_t * lexeme_text_length);
235 
237 
253 const char *
255  const rcl_lexer_lookahead2_t * buffer);
256 
257 #if __cplusplus
258 }
259 #endif
260 
261 #endif // RCL__LEXER_LOOKAHEAD_H_
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.
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.
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.
rmw_ret_t rcl_ret_t
Definition: types.h:20
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.
rcl_ret_t rcl_lexer_lookahead2_fini(rcl_lexer_lookahead2_t *buffer)
Finalize an instance of an rcl_lexer_lookahead2_t structure.
struct rcl_lexer_lookahead2_t rcl_lexer_lookahead2_t
Track lexical analysis and allow looking ahead 2 lexemes.
struct rcl_lexer_lookahead2_impl_t * impl
Definition: lexer_lookahead.h:37
#define RCL_WARN_UNUSED
Ignored return values of functions with this macro will emit a warning.
Definition: macros.h:25
rcl_lexer_lookahead2_t rcl_get_zero_initialized_lexer_lookahead2()
Get a zero initialized rcl_lexer_lookahead2_t instance.
#define RCL_PUBLIC
Definition: visibility_control.h:48
rcl_lexeme_t
Type of lexeme found by lexical analysis.
Definition: lexer.h:31
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.
Track lexical analysis and allow looking ahead 2 lexemes.
Definition: lexer_lookahead.h:35
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.