1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

compiles now. setting of expectedBytes and parsing of length is still missing

This commit is contained in:
Mathias L. Baumann 2011-04-16 11:30:26 +02:00
parent 453011001d
commit c688bab1f8
3 changed files with 26 additions and 28 deletions

View file

@ -1,15 +1,11 @@
#include <stdint.h>
#include <string.h>
enum
{
}
typedef struct
{
unsigned int length;
const uint8_t *ptr;
const uint8_t * ptr;
} PSYC_Array;
typedef struct
@ -23,7 +19,7 @@ typedef struct
} PSYC_State;
inline PSYC_Array (const uint8_t memory, unsigned int length)
inline PSYC_Array PSYC_CreateArray (uint8_t* const memory, unsigned int length)
{
PSYC_Array arr = {length, memory};
@ -41,11 +37,9 @@ inline void PSYC_nextBuffer (PSYC_State* state, PSYC_Array newBuf)
}
int PSYC_parse(PSYC_State* state,
PSYC_ConstArray name,
PSYC_ConstArray value,
uint8_t modifier,
unsigned long *expectedBytes);
inline int PSYC_parse(PSYC_State* state,
PSYC_Array* name, PSYC_Array* value,
uint8_t* modifier, unsigned long *expectedBytes);
inline unsigned int PSYC_getBodyLength (PSYC_State* state)

View file

@ -9,5 +9,5 @@ diet:
/opt/diet/bin/diet ar rcs libpsyc.a libpsyc.o
lib:
${CC} -static -c -Os parser.c -lc -o libpsyc.o -DDEBUG
${CC} -static -c -Os parser.c -lc -o libpsyc.o -DDEBUG -I../include
ar rcs libpsyc.a libpsyc.o

View file

@ -5,7 +5,7 @@
#include <stdio.h>
#endif
#include <psyc/parser.h>
/** @brief isGlyph
*
@ -44,22 +44,10 @@ inline char isAlphaNumeric(uint8_t c)
int PSYC_parse(PSYC_State* state,
PSYC_ConstArray name,
PSYC_ConstArray value,
uint8_t modifier,
unsigned long *expectedBytes)
{
}
/** @brief generalized linebased parser */
inline int PSYC_parse(
PSYC_State* state,
PSYC_Array* name, PSYC_Array* value
PSYC_Array* name, PSYC_Array* value,
uint8_t* modifier, unsigned long* expectedBytes)
{
/* first we test if we can access the first char */
@ -101,7 +89,16 @@ inline int PSYC_parse(
return -6; // report error
}else // it is a glyph, so a variable name starts here
{
*modifier = *state->buffer.ptr+state->cursor;
*modifier = *(state->buffer.ptr+state->cursor);
if (state->buffer.length <= ++(state->cursor))
{
state->cursor = startc; // rewind to start of line
return 1; // return insufficient
}
name->ptr = state->buffer.ptr + state->cursor;
name->length = 0;
}
}
@ -140,6 +137,14 @@ inline int PSYC_parse(
}
else
{
*modifier = *(state->buffer.ptr+state->cursor);
if (state->buffer.length <= ++(state->cursor))
{
state->cursor = startc; // rewind
return 1; // return insufficient
}
name->ptr = state->buffer.ptr+state->cursor;
name->length=1;
}
@ -177,7 +182,6 @@ inline int PSYC_parse(
break; // not valid? then stop the loop right here
++(name->length); // was a valid char, increase length
}
/* we now parsed the variable name successfully