|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The tokens of esc_json_lex.c and the functions esc_json.c reads them with. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | tok_t |
| One JSON token, with its byte range and its links. More... | |
| struct | lex_t |
| State of one lexer run over a JSON text. More... | |
Enumerations | |
| enum | ttype_t { T_OBJ , T_ARR , T_STR , T_NUM , T_TRUE , T_FALSE , T_NULL } |
| Type of one JSON token. | |
| enum | lex_why_t { LEX_SYNTAX = 0 , LEX_DUP , LEX_NUL , LEX_SURROGATE , LEX_UTF8 , LEX_MEMBERS } |
| Why the text was refused, beyond its not being JSON. More... | |
Functions | |
| bool | esc_json_lex_all (lex_t *l) |
Cut lexer l's text into tokens. | |
| const char * | esc_json_lex_why_text (lex_why_t why) |
| Why the lexer refused, as the text after "%s near byte". | |
| unsigned | esc_json_decode_unit (const char *s, uint32_t *i, uint8_t out[4]) |
The UTF-8 bytes of the character at s[*i], into out; *i moves past it. | |
| bool | esc_json_text_is (const char *s, const tok_t *a, const char *lit) |
Whether a string token's text decodes to the plain lit. | |
The tokens of esc_json_lex.c and the functions esc_json.c reads them with.
Private to shared/esc/: no other file includes it.
SPDX-License-Identifier: MIT
| enum lex_why_t |
| unsigned esc_json_decode_unit | ( | const char * | s, |
| uint32_t * | i, | ||
| uint8_t | out[4] ) |
The UTF-8 bytes of the character at s[*i], into out; *i moves past it.
Only for text esc_json_lex_all() accepted. Returns the byte count, 1 to 4.
| s | The text. |
| i | Position of the character; moves past it. |
| out | Receives the UTF-8 bytes. |
| bool esc_json_lex_all | ( | lex_t * | l | ) |
Cut lexer l's text into tokens.
With l->tok NULL it only counts them into l->n; with l->tok set to l->cap tokens it stores them and refuses a key an object already had. False on a refusal, with l->pos and l->why saying where and why.
| l | The lexer state. |
| const char * esc_json_lex_why_text | ( | lex_why_t | why | ) |
Why the lexer refused, as the text after "%s near byte".
| why | The refusal reason. |
| bool esc_json_text_is | ( | const char * | s, |
| const tok_t * | a, | ||
| const char * | lit ) |
Whether a string token's text decodes to the plain lit.
| s | The text. |
| a | The string token. |
| lit | The literal to compare with. |
lit.