\section{aversive\_\-10-03-12/modules/ihm/parse/parse.h File Reference}
\label{parse_8h}\index{aversive\_\-10-03-12/modules/ihm/parse/parse.h@{aversive\_\-10-03-12/modules/ihm/parse/parse.h}}
{\tt \#include $<$aversive/pgmspace.h$>$}\par
{\tt \#include $<$aversive/types.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf token\_\-hdr}
\item 
struct {\bf token\_\-hdr\_\-pgm}
\item 
struct {\bf token\_\-ops}
\item 
struct {\bf inst}
\item 
struct {\bf inst\_\-pgm}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf offsetof}(type, field)~((size\_\-t) \&( ((type $\ast$)0) $\rightarrow$ field) )
\item 
\#define {\bf PARSE\_\-SUCCESS}~0
\item 
\#define {\bf PARSE\_\-AMBIGUOUS}~-1
\item 
\#define {\bf PARSE\_\-NOMATCH}~-2
\item 
\#define {\bf PARSE\_\-BAD\_\-ARGS}~-3
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef struct {\bf token\_\-hdr} {\bf parse\_\-token\_\-hdr\_\-t}
\item 
typedef struct {\bf token\_\-hdr\_\-pgm} {\bf parse\_\-pgm\_\-token\_\-hdr\_\-t}
\item 
typedef struct {\bf inst} {\bf parse\_\-inst\_\-t}
\item 
typedef struct {\bf inst\_\-pgm} {\bf parse\_\-pgm\_\-inst\_\-t}
\item 
typedef {\bf parse\_\-pgm\_\-inst\_\-t} $\ast$ {\bf parse\_\-ctx\_\-t}
\item 
typedef {\bf PROGMEM} {\bf parse\_\-ctx\_\-t} {\bf parse\_\-pgm\_\-ctx\_\-t}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int8\_\-t {\bf parse} ({\bf parse\_\-pgm\_\-ctx\_\-t} ctx[$\,$], const char $\ast$buf)
\item 
int8\_\-t {\bf complete} ({\bf parse\_\-pgm\_\-ctx\_\-t} ctx[$\,$], const char $\ast$buf, int16\_\-t $\ast$state, char $\ast$dst, uint8\_\-t size)
\item 
int {\bf isendoftoken} (char c)
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
struct {\bf token\_\-hdr\_\-pgm} {\bf PROGMEM}
\end{CompactItemize}


\subsection{Define Documentation}
\index{parse.h@{parse.h}!offsetof@{offsetof}}
\index{offsetof@{offsetof}!parse.h@{parse.h}}
\subsubsection[offsetof]{\setlength{\rightskip}{0pt plus 5cm}\#define offsetof(type, \/  field)~((size\_\-t) \&( ((type $\ast$)0) $\rightarrow$ field) )}\label{parse_8h_353187251a6359e206c4472fe66895ce}




Definition at line 31 of file parse.h.\index{parse.h@{parse.h}!PARSE\_\-AMBIGUOUS@{PARSE\_\-AMBIGUOUS}}
\index{PARSE\_\-AMBIGUOUS@{PARSE\_\-AMBIGUOUS}!parse.h@{parse.h}}
\subsubsection[PARSE\_\-AMBIGUOUS]{\setlength{\rightskip}{0pt plus 5cm}\#define PARSE\_\-AMBIGUOUS~-1}\label{parse_8h_052b5b15e6d9d3e59a6593e94b1b05b2}




Definition at line 35 of file parse.h.

Referenced by parse().\index{parse.h@{parse.h}!PARSE\_\-BAD\_\-ARGS@{PARSE\_\-BAD\_\-ARGS}}
\index{PARSE\_\-BAD\_\-ARGS@{PARSE\_\-BAD\_\-ARGS}!parse.h@{parse.h}}
\subsubsection[PARSE\_\-BAD\_\-ARGS]{\setlength{\rightskip}{0pt plus 5cm}\#define PARSE\_\-BAD\_\-ARGS~-3}\label{parse_8h_84d0414e3a9cbd23724434ec8b9cc4e6}




Definition at line 37 of file parse.h.

Referenced by parse().\index{parse.h@{parse.h}!PARSE\_\-NOMATCH@{PARSE\_\-NOMATCH}}
\index{PARSE\_\-NOMATCH@{PARSE\_\-NOMATCH}!parse.h@{parse.h}}
\subsubsection[PARSE\_\-NOMATCH]{\setlength{\rightskip}{0pt plus 5cm}\#define PARSE\_\-NOMATCH~-2}\label{parse_8h_f8efe22bf9e35dcb24db8833c07d4f1f}




Definition at line 36 of file parse.h.

Referenced by parse().\index{parse.h@{parse.h}!PARSE\_\-SUCCESS@{PARSE\_\-SUCCESS}}
\index{PARSE\_\-SUCCESS@{PARSE\_\-SUCCESS}!parse.h@{parse.h}}
\subsubsection[PARSE\_\-SUCCESS]{\setlength{\rightskip}{0pt plus 5cm}\#define PARSE\_\-SUCCESS~0}\label{parse_8h_bcde3a4e302861db03acdfe7fb0b1dad}




Definition at line 34 of file parse.h.

\subsection{Typedef Documentation}
\index{parse.h@{parse.h}!parse\_\-ctx\_\-t@{parse\_\-ctx\_\-t}}
\index{parse\_\-ctx\_\-t@{parse\_\-ctx\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-ctx\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef {\bf parse\_\-pgm\_\-inst\_\-t}$\ast$ {\bf parse\_\-ctx\_\-t}}\label{parse_8h_d2e15bf936c278618476c487134e0a38}


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

Definition at line 112 of file parse.h.\index{parse.h@{parse.h}!parse\_\-inst\_\-t@{parse\_\-inst\_\-t}}
\index{parse\_\-inst\_\-t@{parse\_\-inst\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-inst\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf inst} {\bf parse\_\-inst\_\-t}}\label{parse_8h_ef05032049541ebb29e67f3d724d2414}




Definition at line 97 of file parse.h.\index{parse.h@{parse.h}!parse\_\-pgm\_\-ctx\_\-t@{parse\_\-pgm\_\-ctx\_\-t}}
\index{parse\_\-pgm\_\-ctx\_\-t@{parse\_\-pgm\_\-ctx\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-pgm\_\-ctx\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef {\bf PROGMEM} {\bf parse\_\-ctx\_\-t} {\bf parse\_\-pgm\_\-ctx\_\-t}}\label{parse_8h_07975b1edd0923228f2eaa26cec6768a}




Definition at line 113 of file parse.h.\index{parse.h@{parse.h}!parse\_\-pgm\_\-inst\_\-t@{parse\_\-pgm\_\-inst\_\-t}}
\index{parse\_\-pgm\_\-inst\_\-t@{parse\_\-pgm\_\-inst\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-pgm\_\-inst\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf inst\_\-pgm} {\bf parse\_\-pgm\_\-inst\_\-t}}\label{parse_8h_ecde232312d1dc6e0e0dae1f2d4970c3}




Definition at line 105 of file parse.h.\index{parse.h@{parse.h}!parse\_\-pgm\_\-token\_\-hdr\_\-t@{parse\_\-pgm\_\-token\_\-hdr\_\-t}}
\index{parse\_\-pgm\_\-token\_\-hdr\_\-t@{parse\_\-pgm\_\-token\_\-hdr\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-pgm\_\-token\_\-hdr\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf token\_\-hdr\_\-pgm} {\bf parse\_\-pgm\_\-token\_\-hdr\_\-t}}\label{parse_8h_6eee7061edace749b72305962eacb46d}




Definition at line 53 of file parse.h.\index{parse.h@{parse.h}!parse\_\-token\_\-hdr\_\-t@{parse\_\-token\_\-hdr\_\-t}}
\index{parse\_\-token\_\-hdr\_\-t@{parse\_\-token\_\-hdr\_\-t}!parse.h@{parse.h}}
\subsubsection[parse\_\-token\_\-hdr\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf token\_\-hdr} {\bf parse\_\-token\_\-hdr\_\-t}}\label{parse_8h_163372b16b9127743fdfa15adf3d64d2}




Definition at line 47 of file parse.h.

\subsection{Function Documentation}
\index{parse.h@{parse.h}!complete@{complete}}
\index{complete@{complete}!parse.h@{parse.h}}
\subsubsection[complete]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t complete ({\bf parse\_\-pgm\_\-ctx\_\-t} {\em ctx}[$\,$], \/  const char $\ast$ {\em buf}, \/  int16\_\-t $\ast$ {\em state}, \/  char $\ast$ {\em dst}, \/  uint8\_\-t {\em size})}\label{parse_8h_504efa998f81c60f6d2c832e730b2dd7}


\doxyref{complete()}{p.}{parse_8c_504efa998f81c60f6d2c832e730b2dd7} must be called with $\ast$state==0. It returns $<$ 0 on \doxyref{error}{p.}{structerror}.

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.\index{parse.h@{parse.h}!isendoftoken@{isendoftoken}}
\index{isendoftoken@{isendoftoken}!parse.h@{parse.h}}
\subsubsection[isendoftoken]{\setlength{\rightskip}{0pt plus 5cm}int isendoftoken (char {\em c})}\label{parse_8h_e686144463bf8def2e1ded352a1e5a81}




Definition at line 56 of file parse.c.

Referenced by parse\_\-num(), and parse\_\-string().\index{parse.h@{parse.h}!parse@{parse}}
\index{parse@{parse}!parse.h@{parse.h}}
\subsubsection[parse]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t parse ({\bf parse\_\-pgm\_\-ctx\_\-t} {\em ctx}[$\,$], \/  const char $\ast$ {\em buf})}\label{parse_8h_c63651ed290319d3835b6578ab5c2c48}


Try to parse a buffer according to the specified context. The argument buf must ends with \char`\"{}$\backslash$n$\backslash$0\char`\"{}. The function returns PARSE\_\-AMBIGUOUS, PARSE\_\-NOMATCH or PARSE\_\-BAD\_\-ARGS on \doxyref{error}{p.}{structerror}. 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.

\subsection{Variable Documentation}
\index{parse.h@{parse.h}!PROGMEM@{PROGMEM}}
\index{PROGMEM@{PROGMEM}!parse.h@{parse.h}}
\subsubsection[PROGMEM]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf inst\_\-pgm} {\bf PROGMEM}}\label{parse_8h_5ac35a7ca6e36a35e02a484cee11756c}


