Lely core libraries
2.2.5
|
This header file is part of the utilities library; it contains the lexer function declarations. More...
Go to the source code of this file.
Functions | |
int | isbreak (int c) |
Returns 1 if c is a line break character, and 0 otherwise. | |
int | isodigit (int c) |
Returns 1 if c is an octal digit, and 0 otherwise. | |
int | ctoo (int c) |
Returns the octal digit corresponding to the character c. More... | |
int | ctox (int c) |
Returns the hexadecimal digit corresponding to the character c. More... | |
size_t | lex_char (int c, const char *begin, const char *end, struct floc *at) |
Lexes the specified character from a memory buffer. More... | |
size_t | lex_ctype (int(*ctype)(int), const char *begin, const char *end, struct floc *at) |
Greedily lexes a sequence of characters of the specified class from a memory buffer. More... | |
size_t | lex_break (const char *begin, const char *end, struct floc *at) |
Lexes a single line break from a memory buffer. More... | |
size_t | lex_utf8 (const char *begin, const char *end, struct floc *at, char32_t *pc32) |
Lexes a UTF-8 encoded Unicode character from a memory buffer. More... | |
size_t | lex_c99_id (const char *begin, const char *end, struct floc *at, char *s, size_t *pn) |
Lexes a C99 identifier from a memory buffer. More... | |
size_t | lex_c99_esc (const char *begin, const char *end, struct floc *at, char32_t *pc32) |
Lexes a C99 character escape sequence from a memory buffer if the buffer begins with '\', and a UTF-8 encoded Unicode character if not. More... | |
size_t | lex_c99_str (const char *begin, const char *end, struct floc *at, char *s, size_t *pn) |
Lexes a UTF-8 encoded Unicode string from a memory buffer. More... | |
size_t | lex_c99_pp_num (const char *begin, const char *end, struct floc *at) |
Lexes a C99 preprocessing number from a memory buffer. More... | |
size_t | lex_c99_long (const char *begin, const char *end, struct floc *at, long *pl) |
Lexes a C99 long from a memory buffer. More... | |
size_t | lex_c99_ulong (const char *begin, const char *end, struct floc *at, unsigned long *pul) |
Lexes a C99 unsigned long from a memory buffer. More... | |
size_t | lex_c99_llong (const char *begin, const char *end, struct floc *at, long long *pll) |
Lexes a C99 long long from a memory buffer. More... | |
size_t | lex_c99_ullong (const char *begin, const char *end, struct floc *at, unsigned long long *pul) |
Lexes a C99 unsigned long long from a memory buffer. More... | |
size_t | lex_c99_flt (const char *begin, const char *end, struct floc *at, float *pf) |
Lexes a C99 float from a memory buffer. More... | |
size_t | lex_c99_dbl (const char *begin, const char *end, struct floc *at, double *pd) |
Lexes a C99 double from a memory buffer. More... | |
size_t | lex_c99_ldbl (const char *begin, const char *end, struct floc *at, long double *pld) |
Lexes a C99 long double from a memory buffer. More... | |
size_t | lex_c99_i8 (const char *begin, const char *end, struct floc *at, int_least8_t *pi8) |
Lexes a C99 int_least8_t from a memory buffer. More... | |
size_t | lex_c99_i16 (const char *begin, const char *end, struct floc *at, int_least16_t *pi16) |
Lexes a C99 int_least16_t from a memory buffer. More... | |
size_t | lex_c99_i32 (const char *begin, const char *end, struct floc *at, int_least32_t *pi32) |
Lexes a C99 int_least32_t from a memory buffer. More... | |
size_t | lex_c99_i64 (const char *begin, const char *end, struct floc *at, int_least64_t *pi64) |
Lexes a C99 int_least64_t from a memory buffer. More... | |
size_t | lex_c99_u8 (const char *begin, const char *end, struct floc *at, uint_least8_t *pu8) |
Lexes a C99 uint_least8_t from a memory buffer. More... | |
size_t | lex_c99_u16 (const char *begin, const char *end, struct floc *at, uint_least16_t *pu16) |
Lexes a C99 uint_least16_t from a memory buffer. More... | |
size_t | lex_c99_u32 (const char *begin, const char *end, struct floc *at, uint_least32_t *pu32) |
Lexes a C99 uint_least32_t from a memory buffer. More... | |
size_t | lex_c99_u64 (const char *begin, const char *end, struct floc *at, uint_least64_t *pu64) |
Lexes a C99 uint_least64_t from a memory buffer. More... | |
size_t | lex_line_comment (const char *delim, const char *begin, const char *end, struct floc *at) |
Lexes a single line-comment (excluding the line break) starting with the specified delimiter from a memory buffer. More... | |
size_t | lex_hex (const char *begin, const char *end, struct floc *at, void *ptr, size_t *pn) |
Lexes and decodes the hexadecimal representation of binary data from a memory buffer. More... | |
size_t | lex_base64 (const char *begin, const char *end, struct floc *at, void *ptr, size_t *pn) |
Lexes and decodes the Base64 representation of binary data from a memory buffer. More... | |
This header file is part of the utilities library; it contains the lexer function declarations.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file lex.h.
|
inline |
|
inline |
size_t lex_char | ( | int | c, |
const char * | begin, | ||
const char * | end, | ||
struct floc * | at | ||
) |
Lexes the specified character from a memory buffer.
c | the character to match. |
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
size_t lex_ctype | ( | int(*)(int) | ctype, |
const char * | begin, | ||
const char * | end, | ||
struct floc * | at | ||
) |
Greedily lexes a sequence of characters of the specified class from a memory buffer.
ctype | a pointer to a function returning a non-zero value if its argument is part of the character class. |
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
size_t lex_break | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at | ||
) |
Lexes a single line break from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
size_t lex_utf8 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
char32_t * | pc32 | ||
) |
Lexes a UTF-8 encoded Unicode character from a memory buffer.
Illegal Unicode code points are replaced with the replacement character (U+FFFD).
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pc32 | the address at which to store the Unicode character. On success, if pc32 is not NULL, *pc32 contains the UTF-32 encoded character. On error, *pc32 is left untouched. |
begin < end
).size_t lex_c99_id | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
char * | s, | ||
size_t * | pn | ||
) |
Lexes a C99 identifier from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
s | the address at which to store the identifier (can be NULL). |
pn | the address of a value containing the size (in bytes) of the buffer at s. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at s been sufficiently large. |
size_t lex_c99_esc | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
char32_t * | pc32 | ||
) |
Lexes a C99 character escape sequence from a memory buffer if the buffer begins with '\', and a UTF-8 encoded Unicode character if not.
If the escape sequence is invalid, the initial '\' is returned as is.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pc32 | the address at which to store the converted escape sequence or Unicode character. On success, if pc32 is not NULL, *pc32 contains the UTF-32 encoded character. On error, *pc32 is left untouched. |
begin < end
).size_t lex_c99_str | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
char * | s, | ||
size_t * | pn | ||
) |
Lexes a UTF-8 encoded Unicode string from a memory buffer.
The string MAY contain C99 character escape sequences. Strings are terminated by a null byte, an unescaped double-quote or a newline character.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
s | the address at which to store the string (can be NULL). |
pn | the address of a value containing the size (in bytes) of the buffer at s. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at s been sufficiently large. |
size_t lex_c99_pp_num | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at | ||
) |
Lexes a C99 preprocessing number from a memory buffer.
Note that this does not necessarily correspond to a valid integer or floating-point constant.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
size_t lex_c99_long | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
long * | pl | ||
) |
Lexes a C99 long
from a memory buffer.
The actual conversion is performed by strtol ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pl | the address at which to store the value. On success, if pl is not NULL, * pl contains the lexed value. On error, * pl is left untouched. On underflow/overflow, * pl contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_ulong | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
unsigned long * | pul | ||
) |
Lexes a C99 unsigned long
from a memory buffer.
The actual conversion is performed by strtoul ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pul | the address at which to store the value. On success, if pul is not NULL, * pul contains the lexed value. On error, * pul is left untouched. On underflow/overflow, * pul contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_llong | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
long long * | pll | ||
) |
Lexes a C99 long long
from a memory buffer.
The actual conversion is performed by strtoll ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pll | the address at which to store the value. On success, if pll is not NULL, * pll contains the lexed value. On error, * pll is left untouched. On underflow/overflow, * pll contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_ullong | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
unsigned long long * | pul | ||
) |
Lexes a C99 unsigned long long
from a memory buffer.
The actual conversion is performed by strtoull ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pul | the address at which to store the value. On success, if pul is not NULL, * pul contains the lexed value. On error, * pul is left untouched. On underflow/overflow, * pul contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_flt | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
float * | pf | ||
) |
Lexes a C99 float
from a memory buffer.
The actual conversion is performed by strtof ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pf | the address at which to store the value. On success, if pf is not NULL, * pf contains the lexed value. On error, * pf is left untouched. On underflow/overflow, * pf contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_dbl | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
double * | pd | ||
) |
Lexes a C99 double
from a memory buffer.
The actual conversion is performed by strtod ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pd | the address at which to store the value. On success, if pd is not NULL, * pd contains the lexed value. On error, * pd is left untouched. On underflow/overflow, * pd contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_ldbl | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
long double * | pld | ||
) |
Lexes a C99 long double
from a memory buffer.
The actual conversion is performed by strtold ()
.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pld | the address at which to store the value. On success, if pld is not NULL, * pld contains the lexed value. On error, * pld is left untouched. On underflow/overflow, * pld contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_i8 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
int_least8_t * | pi8 | ||
) |
Lexes a C99 int_least8_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pi8 | the address at which to store the value. On success, if pi8 is not NULL, * pi8 contains the lexed value. On error, * pi8 is left untouched. On underflow/overflow, * pi8 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_i16 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
int_least16_t * | pi16 | ||
) |
Lexes a C99 int_least16_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pi16 | the address at which to store the value. On success, if pi16 is not NULL, * pi16 contains the lexed value. On error, * pi16 is left untouched. On underflow/overflow, * pi16 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_i32 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
int_least32_t * | pi32 | ||
) |
Lexes a C99 int_least32_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pi32 | the address at which to store the value. On success, if pi32 is not NULL, * pi32 contains the lexed value. On error, * pi32 is left untouched. On underflow/overflow, * pi32 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_i64 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
int_least64_t * | pi64 | ||
) |
Lexes a C99 int_least64_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pi64 | the address at which to store the value. On success, if pi64 is not NULL, * pi64 contains the lexed value. On error, * pi64 is left untouched. On underflow/overflow, * pi64 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_u8 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
uint_least8_t * | pu8 | ||
) |
Lexes a C99 uint_least8_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pu8 | the address at which to store the value. On success, if pu8 is not NULL, * pu8 contains the lexed value. On error, * pu8 is left untouched. On underflow/overflow, * pu8 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_u16 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
uint_least16_t * | pu16 | ||
) |
Lexes a C99 uint_least16_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pu16 | the address at which to store the value. On success, if pu16 is not NULL, * pu16 contains the lexed value. On error, * pu16 is left untouched. On underflow/overflow, * pu16 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_u32 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
uint_least32_t * | pu32 | ||
) |
Lexes a C99 uint_least32_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pu32 | the address at which to store the value. On success, if pu32 is not NULL, * pu32 contains the lexed value. On error, * pu32 is left untouched. On underflow/overflow, * pu32 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_c99_u64 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
uint_least64_t * | pu64 | ||
) |
Lexes a C99 uint_least64_t
from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
pu64 | the address at which to store the value. On success, if pu64 is not NULL, * pu64 contains the lexed value. On error, * pu64 is left untouched. On underflow/overflow, * pu64 contains the minimum/maximum value and get_errnum() returns ERRNUM_RANGE. |
size_t lex_line_comment | ( | const char * | delim, |
const char * | begin, | ||
const char * | end, | ||
struct floc * | at | ||
) |
Lexes a single line-comment (excluding the line break) starting with the specified delimiter from a memory buffer.
delim | a pointer to the delimiter indicating the start of a comment (can be NULL or pointing to the empty string to lex a line unconditionally). |
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
size_t lex_hex | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
void * | ptr, | ||
size_t * | pn | ||
) |
Lexes and decodes the hexadecimal representation of binary data from a memory buffer.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
ptr | the address at which to store the decoded binary data (can be NULL). |
pn | the address of a value containing the size of the buffer at *ptr. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at ptr been sufficiently large. |
size_t lex_base64 | ( | const char * | begin, |
const char * | end, | ||
struct floc * | at, | ||
void * | ptr, | ||
size_t * | pn | ||
) |
Lexes and decodes the Base64 representation of binary data from a memory buffer.
This function implements the MIME variant of Base64 as specified in RFC 2045. Since this variant instructs implementations to ignore invalid characters, this function will lex the entire input.
begin | a pointer to the start of the buffer. |
end | a pointer to the end of the buffer (can be NULL if the buffer is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL , *at points to one past the last character lexed. On error, *at is left untouched. |
ptr | the address at which to store the decoded binary data (can be NULL). |
pn | the address of a value containing the size of the buffer at *ptr. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at ptr been sufficiently large. |