Compare commits

..

No commits in common. "844a9165ddadd47c8838da0f898c3b6fae41f3c7" and "ea2745da22c0e45fa9572cdf93ff1015c93f014b" have entirely different histories.

2 changed files with 14 additions and 28 deletions

View File

@ -5,16 +5,11 @@
#include<string.h> // memcpy, strlen.. #include<string.h> // memcpy, strlen..
#include<stddef.h> // NULL #include<stddef.h> // NULL
/* Session offset type - defaults to 64 bit because of union types enable storage for it often, but you can override */ // Session offset type - defaults to 64 bit, but you can override
#ifndef SLOFFS_T #ifndef SLOFFS_T
#define SLOFFS_T uint64_t #define SLOFFS_T uint64_t
#endif #endif
/* Maximum length of words - defaults but you can override */
#ifndef SL_MAX_WORD_NAME
#define SL_MAX_WORD_NAME 255
#endif
union word_body { union word_body {
SLOFFS_T offset; SLOFFS_T offset;
void *ptr; void *ptr;
@ -239,9 +234,9 @@ typedef union iores iores;
typedef iores (*ioconn)(SLC_IO_OP op, const char *param); typedef iores (*ioconn)(SLC_IO_OP op, const char *param);
/** /**
* Function-abstraction for reading the source code char-by-char. * Function-abstraction for reading the source code byte-by-byte.
*/ */
typedef char (*coderead)(); typedef uint8_t (*coderead)();
enum slc_state : uint32_t { enum slc_state : uint32_t {
/** Before things */ /** Before things */
@ -279,8 +274,7 @@ static inline slc_state slc_comment_statechange_in(
static inline slc_state slc_def_name_statechange( static inline slc_state slc_def_name_statechange(
slc_state current_state, slc_state current_state,
char c, char c,
const char *prefix, const char *prefix) {
int *prefix_i) {
// FIXME: Implement // FIXME: Implement
return current_state; return current_state;
} }
@ -288,8 +282,7 @@ static inline slc_state slc_def_name_statechange(
static inline slc_state slc_word_name_statechange( static inline slc_state slc_word_name_statechange(
slc_state current_state, slc_state current_state,
char c, char c,
int *wordname_i, const char *prefix) {
const char *wordname) {
// FIXME: Implement // FIXME: Implement
return current_state; return current_state;
} }
@ -359,11 +352,8 @@ static inline void slc(
int comment_i = 0; int comment_i = 0;
int multiline_i = 0; int multiline_i = 0;
int prefix_i = 0;
int wordname_i = 0;
char wordname[SL_MAX_WORD_NAME];
char c = 0; uint8_t c = 0;
while(((c = code_src()) != 0)) { while(((c = code_src()) != 0)) {
process_char: process_char:
switch(state) { switch(state) {
@ -378,27 +368,23 @@ static inline void slc(
multiline_comment_opener_len, multiline_comment_opener_len,
&comment_i, &comment_i,
&multiline_i); &multiline_i);
/* state -> def_name */ /* state -> def_name */
if(state == SLC_START) { if(state == SLC_START) {
state = slc_def_name_statechange( state = slc_def_name_statechange(
state, state,
c, c,
prefix, prefix);
&prefix_i); } else goto process_char; // new state might need 'c' too
} else goto process_char; /* new state might need 'c' too */
/* state -> word_name */ /* state -> word_name */
if(state == SLC_START) { if(state == SLC_START) {
state = slc_word_name_statechange( state = slc_word_name_statechange(
state, state,
c, c,
&wordname_i, prefix);
wordname); if(state != SLC_START) goto process_char; // new state might need 'c' too
if(state != SLC_START) goto process_char; /* new state might need 'c' too */ } else goto process_char; // new state might need 'c' too
} else goto process_char; /* new state might need 'c' too */
/* Step to read next character */ // Step to read next character
break; break;
case SLC_COMMENT: case SLC_COMMENT:
break; break;

View File

@ -1,4 +1,4 @@
debug: debug:
gcc -Wall -g hamt.c main.c -o main gcc -g hamt.c main.c -o main
release: release:
gcc -Wall -O2 hamt.c main.c -o main gcc -O2 hamt.c main.c -o main