aversive_10-03-12/modules/ihm/parse/parse.h File Reference

#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_tparse_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 Documentation

#define offsetof ( type,
field   )     ((size_t) &( ((type *)0)->field) )

Definition at line 31 of file parse.h.

#define PARSE_AMBIGUOUS   -1

Definition at line 35 of file parse.h.

Referenced by parse().

#define PARSE_BAD_ARGS   -3

Definition at line 37 of file parse.h.

Referenced by parse().

#define PARSE_NOMATCH   -2

Definition at line 36 of file parse.h.

Referenced by parse().

#define PARSE_SUCCESS   0

Definition at line 34 of file parse.h.


Typedef Documentation

A context is identified by its name, and contains a list of instruction

Definition at line 112 of file parse.h.

typedef struct inst parse_inst_t

Definition at line 97 of file parse.h.

Definition at line 113 of file parse.h.

typedef struct inst_pgm parse_pgm_inst_t

Definition at line 105 of file parse.h.

Definition at line 53 of file parse.h.

typedef struct token_hdr parse_token_hdr_t

Definition at line 47 of file parse.h.


Function Documentation

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  ) 

Definition at line 56 of file parse.c.

Referenced by parse_num(), and parse_string().

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.


Variable Documentation

struct inst_pgm PROGMEM


Generated on Fri Mar 12 06:32:07 2010 for AVR by  doxygen 1.5.6