mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
s/operator/oper/
This commit is contained in:
parent
746054dd03
commit
427ef9ac56
6 changed files with 15 additions and 15 deletions
|
@ -163,7 +163,7 @@ inline size_t PSYC_getContentLength (PSYC_ParseState* s);
|
||||||
* @param value A pointer to a PSYC_Array. It will point to the
|
* @param value A pointer to a PSYC_Array. It will point to the
|
||||||
* value/body the variable/method and its length will be set accordingly
|
* value/body the variable/method and its length will be set accordingly
|
||||||
*/
|
*/
|
||||||
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* operator, PSYC_Array* name, PSYC_Array* value);
|
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List value parser.
|
* List value parser.
|
||||||
|
|
|
@ -42,7 +42,7 @@ inline void PSYC_initRenderState (PSYC_RenderState* state);
|
||||||
int PSYC_renderVar(PSYC_RenderState* render,
|
int PSYC_renderVar(PSYC_RenderState* render,
|
||||||
const char* name, size_t nlength,
|
const char* name, size_t nlength,
|
||||||
const char* value, size_t vlength,
|
const char* value, size_t vlength,
|
||||||
PSYC_RenderFlag flags, char operator);
|
PSYC_RenderFlag flags, char oper);
|
||||||
|
|
||||||
int PSYC_renderBody(PSYC_RenderState* render,
|
int PSYC_renderBody(PSYC_RenderState* render,
|
||||||
const char* method, size_t mlength,
|
const char* method, size_t mlength,
|
||||||
|
|
10
src/parser.c
10
src/parser.c
|
@ -154,9 +154,9 @@ inline PSYC_ParseRC PSYC_parseBinaryValue(PSYC_ParseState* state, PSYC_Array* va
|
||||||
* Parse simple or binary variable.
|
* Parse simple or binary variable.
|
||||||
* @return PSYC_PARSE_ERROR or PSYC_PARSE_SUCCESS
|
* @return PSYC_PARSE_ERROR or PSYC_PARSE_SUCCESS
|
||||||
*/
|
*/
|
||||||
inline PSYC_ParseRC PSYC_parseVar(PSYC_ParseState* state, char* operator, PSYC_Array* name, PSYC_Array* value)
|
inline PSYC_ParseRC PSYC_parseVar(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value)
|
||||||
{
|
{
|
||||||
*operator = *(state->buffer.ptr + state->cursor);
|
*oper = *(state->buffer.ptr + state->cursor);
|
||||||
ADVANCE_CURSOR_OR_RETURN(PSYC_PARSE_INSUFFICIENT);
|
ADVANCE_CURSOR_OR_RETURN(PSYC_PARSE_INSUFFICIENT);
|
||||||
|
|
||||||
if (PSYC_parseName(state, name) != PSYC_PARSE_SUCCESS)
|
if (PSYC_parseName(state, name) != PSYC_PARSE_SUCCESS)
|
||||||
|
@ -218,7 +218,7 @@ inline PSYC_ParseRC PSYC_parseVar(PSYC_ParseState* state, char* operator, PSYC_A
|
||||||
* Parse PSYC packets.
|
* Parse PSYC packets.
|
||||||
* Generalized line-based parser.
|
* Generalized line-based parser.
|
||||||
*/
|
*/
|
||||||
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* operator, PSYC_Array* name, PSYC_Array* value)
|
PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value)
|
||||||
{
|
{
|
||||||
int ret; // a return value
|
int ret; // a return value
|
||||||
size_t pos; // a cursor position
|
size_t pos; // a cursor position
|
||||||
|
@ -248,7 +248,7 @@ PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* operator, PSYC_Array* name
|
||||||
// so just test if the first char is a glyph.
|
// so just test if the first char is a glyph.
|
||||||
if (isGlyph(state->buffer.ptr[state->cursor])) // is the first char a glyph?
|
if (isGlyph(state->buffer.ptr[state->cursor])) // is the first char a glyph?
|
||||||
{ // it is a glyph, so a variable starts here
|
{ // it is a glyph, so a variable starts here
|
||||||
ret = PSYC_parseVar(state, operator, name, value);
|
ret = PSYC_parseVar(state, oper, name, value);
|
||||||
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ROUTING : ret;
|
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ROUTING : ret;
|
||||||
}
|
}
|
||||||
else // not a glyph
|
else // not a glyph
|
||||||
|
@ -310,7 +310,7 @@ PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* operator, PSYC_Array* name
|
||||||
if (isGlyph(state->buffer.ptr[state->cursor]))
|
if (isGlyph(state->buffer.ptr[state->cursor]))
|
||||||
{
|
{
|
||||||
pos = state->cursor;
|
pos = state->cursor;
|
||||||
ret = PSYC_parseVar(state, operator, name, value);
|
ret = PSYC_parseVar(state, oper, name, value);
|
||||||
state->contentParsed += state->cursor - pos;
|
state->contentParsed += state->cursor - pos;
|
||||||
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ENTITY : ret;
|
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ENTITY : ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ struct PSYC_Parser
|
||||||
void (*stateCallback)(struct PSYC_Parser* pstate,
|
void (*stateCallback)(struct PSYC_Parser* pstate,
|
||||||
const uint8_t *name, const unsigned int nlength,
|
const uint8_t *name, const unsigned int nlength,
|
||||||
const uint8_t *value, const unsigned int vlength,
|
const uint8_t *value, const unsigned int vlength,
|
||||||
enum PSYC_Operator operators, char inEntity);
|
enum PSYC_Operator oper, char inEntity);
|
||||||
|
|
||||||
/** @brief gets called after the routing-header was parsed
|
/** @brief gets called after the routing-header was parsed
|
||||||
*
|
*
|
||||||
|
@ -135,7 +135,7 @@ struct PSYC_Parser
|
||||||
void (*errorStateCallback)(struct PSYC_Parser* pstate,
|
void (*errorStateCallback)(struct PSYC_Parser* pstate,
|
||||||
const uint8_t *name, const unsigned int nlength,
|
const uint8_t *name, const unsigned int nlength,
|
||||||
const uint8_t *value, const unsigned int vlength,
|
const uint8_t *value, const unsigned int vlength,
|
||||||
enum PSYC_Operator operators);
|
enum PSYC_Operator oper);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
/*******************************************
|
||||||
|
|
|
@ -9,15 +9,15 @@ inline void PSYC_initRenderState (PSYC_RenderState* state)
|
||||||
PSYC_RenderRC PSYC_renderVar(PSYC_RenderState* state,
|
PSYC_RenderRC PSYC_renderVar(PSYC_RenderState* state,
|
||||||
const char* name, size_t nlength,
|
const char* name, size_t nlength,
|
||||||
const char* value, size_t vlength,
|
const char* value, size_t vlength,
|
||||||
const PSYC_RenderFlag flags, char operator)
|
const PSYC_RenderFlag flags, char oper)
|
||||||
{
|
{
|
||||||
size_t startc = state->cursor;
|
size_t startc = state->cursor;
|
||||||
|
|
||||||
unless (nlength) nlength = strlen(name);
|
unless (nlength) nlength = strlen(name);
|
||||||
// vlength 0 means an empty variable.. no cheating there
|
// vlength 0 means an empty variable.. no cheating there
|
||||||
unless (operator) operator = C_GLYPH_OPERATOR_SET;
|
unless (oper) oper = C_GLYPH_OPERATOR_SET;
|
||||||
|
|
||||||
state->buffer[state->cursor++] = operator;
|
state->buffer[state->cursor++] = oper;
|
||||||
strncpy(&state->buffer[state->cursor], name, nlength);
|
strncpy(&state->buffer[state->cursor], name, nlength);
|
||||||
state->cursor += nlength;
|
state->cursor += nlength;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int index, ret;
|
int index, ret;
|
||||||
char buffer[2048], operator;
|
char buffer[2048], oper;
|
||||||
PSYC_Array name, value, elem;
|
PSYC_Array name, value, elem;
|
||||||
PSYC_ParseState state;
|
PSYC_ParseState state;
|
||||||
PSYC_ParseListState listState;
|
PSYC_ParseListState listState;
|
||||||
|
@ -25,13 +25,13 @@ int main(int argc, char** argv)
|
||||||
PSYC_nextParseBuffer(&state, PSYC_createArray(buffer, index));
|
PSYC_nextParseBuffer(&state, PSYC_createArray(buffer, index));
|
||||||
|
|
||||||
// try parsing that now
|
// try parsing that now
|
||||||
while ((ret = PSYC_parse(&state, &operator, &name, &value)))
|
while ((ret = PSYC_parse(&state, &oper, &name, &value)))
|
||||||
{
|
{
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case PSYC_PARSE_ROUTING:
|
case PSYC_PARSE_ROUTING:
|
||||||
case PSYC_PARSE_ENTITY:
|
case PSYC_PARSE_ENTITY:
|
||||||
write(1, &operator, 1);
|
write(1, &oper, 1);
|
||||||
case PSYC_PARSE_BODY:
|
case PSYC_PARSE_BODY:
|
||||||
// printf("the string is '%.*s'\n", name);
|
// printf("the string is '%.*s'\n", name);
|
||||||
write(1, name.ptr, name.length);
|
write(1, name.ptr, name.length);
|
||||||
|
|
Loading…
Reference in a new issue