#include <aversive/pgmspace.h>
#include <aversive/types.h>
Go to the source code of this file.
Data Structures | |
struct | token_hdr |
struct | token_hdr_pgm |
struct | token_ops |
struct | inst |
struct | inst_pgm |
Defines | |
#define | offsetof(type, field) ((size_t) &( ((type *)0)->field) ) |
#define | PARSE_SUCCESS 0 |
#define | PARSE_AMBIGUOUS -1 |
#define | PARSE_NOMATCH -2 |
#define | PARSE_BAD_ARGS -3 |
Typedefs | |
typedef struct token_hdr | parse_token_hdr_t |
typedef struct token_hdr_pgm | parse_pgm_token_hdr_t |
typedef struct inst | parse_inst_t |
typedef struct inst_pgm | parse_pgm_inst_t |
typedef parse_pgm_inst_t * | parse_ctx_t |
typedef PROGMEM parse_ctx_t | parse_pgm_ctx_t |
Functions | |
int8_t | parse (parse_pgm_ctx_t ctx[], const char *buf) |
int8_t | complete (parse_pgm_ctx_t ctx[], const char *buf, int16_t *state, char *dst, uint8_t size) |
int | isendoftoken (char c) |
Variables | |
struct token_hdr_pgm | PROGMEM |
#define offsetof | ( | type, | |||
field | ) | ((size_t) &( ((type *)0)->field) ) |
typedef parse_pgm_inst_t* parse_ctx_t |
typedef struct inst parse_inst_t |
typedef PROGMEM parse_ctx_t parse_pgm_ctx_t |
typedef struct inst_pgm parse_pgm_inst_t |
typedef struct token_hdr_pgm parse_pgm_token_hdr_t |
typedef struct token_hdr parse_token_hdr_t |
int8_t complete | ( | parse_pgm_ctx_t | ctx[], | |
const char * | buf, | |||
int16_t * | state, | |||
char * | dst, | |||
uint8_t | size | |||
) |
complete() must be called with *state==0. It returns < 0 on error.
Else it returns: 2 on completion (one possible choice). In this case, the chars are appended in dst buffer. 1 if there is several possible choices. In this case, you must call the function again, keeping the value of state intact. 0 when the iteration is finished. The dst is not valid for this last call.
The returned dst buf ends with .
Definition at line 259 of file parse.c.
References token_ops::complete_get_elt, token_ops::complete_get_nb, debug_printf, token_ops::get_help, inst_pgm::help_str, parse_symbols::l, token_hdr::ops, and inst_pgm::tokens.
int isendoftoken | ( | char | c | ) |
int8_t parse | ( | parse_pgm_ctx_t | ctx[], | |
const char * | buf | |||
) |
Try to parse a buffer according to the specified context. The argument buf must ends with "\n\0". The function returns PARSE_AMBIGUOUS, PARSE_NOMATCH or PARSE_BAD_ARGS on error. Else it calls the associated function (defined in the context) and returns 0 (PARSE_SUCCESS).
Definition at line 152 of file parse.c.
References inst_pgm::data, debug_printf, parse_symbols::f, inst_pgm::f, PARSE_AMBIGUOUS, PARSE_BAD_ARGS, and PARSE_NOMATCH.