Compare commits
3 Commits
ea2745da22
...
844a9165dd
Author | SHA1 | Date | |
---|---|---|---|
|
844a9165dd | ||
|
b8e631188d | ||
|
07c2c39143 |
38
engine/slc.h
38
engine/slc.h
@ -5,11 +5,16 @@
|
||||
#include<string.h> // memcpy, strlen..
|
||||
#include<stddef.h> // NULL
|
||||
|
||||
// Session offset type - defaults to 64 bit, but you can override
|
||||
/* Session offset type - defaults to 64 bit because of union types enable storage for it often, but you can override */
|
||||
#ifndef SLOFFS_T
|
||||
#define SLOFFS_T uint64_t
|
||||
#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 {
|
||||
SLOFFS_T offset;
|
||||
void *ptr;
|
||||
@ -234,9 +239,9 @@ typedef union iores iores;
|
||||
typedef iores (*ioconn)(SLC_IO_OP op, const char *param);
|
||||
|
||||
/**
|
||||
* Function-abstraction for reading the source code byte-by-byte.
|
||||
* Function-abstraction for reading the source code char-by-char.
|
||||
*/
|
||||
typedef uint8_t (*coderead)();
|
||||
typedef char (*coderead)();
|
||||
|
||||
enum slc_state : uint32_t {
|
||||
/** Before things */
|
||||
@ -274,7 +279,8 @@ static inline slc_state slc_comment_statechange_in(
|
||||
static inline slc_state slc_def_name_statechange(
|
||||
slc_state current_state,
|
||||
char c,
|
||||
const char *prefix) {
|
||||
const char *prefix,
|
||||
int *prefix_i) {
|
||||
// FIXME: Implement
|
||||
return current_state;
|
||||
}
|
||||
@ -282,7 +288,8 @@ static inline slc_state slc_def_name_statechange(
|
||||
static inline slc_state slc_word_name_statechange(
|
||||
slc_state current_state,
|
||||
char c,
|
||||
const char *prefix) {
|
||||
int *wordname_i,
|
||||
const char *wordname) {
|
||||
// FIXME: Implement
|
||||
return current_state;
|
||||
}
|
||||
@ -352,8 +359,11 @@ static inline void slc(
|
||||
|
||||
int comment_i = 0;
|
||||
int multiline_i = 0;
|
||||
int prefix_i = 0;
|
||||
int wordname_i = 0;
|
||||
char wordname[SL_MAX_WORD_NAME];
|
||||
|
||||
uint8_t c = 0;
|
||||
char c = 0;
|
||||
while(((c = code_src()) != 0)) {
|
||||
process_char:
|
||||
switch(state) {
|
||||
@ -368,23 +378,27 @@ static inline void slc(
|
||||
multiline_comment_opener_len,
|
||||
&comment_i,
|
||||
&multiline_i);
|
||||
|
||||
/* state -> def_name */
|
||||
if(state == SLC_START) {
|
||||
state = slc_def_name_statechange(
|
||||
state,
|
||||
c,
|
||||
prefix);
|
||||
} else goto process_char; // new state might need 'c' too
|
||||
prefix,
|
||||
&prefix_i);
|
||||
} else goto process_char; /* new state might need 'c' too */
|
||||
|
||||
/* state -> word_name */
|
||||
if(state == SLC_START) {
|
||||
state = slc_word_name_statechange(
|
||||
state,
|
||||
c,
|
||||
prefix);
|
||||
if(state != SLC_START) goto process_char; // new state might need 'c' too
|
||||
} else goto process_char; // new state might need 'c' too
|
||||
&wordname_i,
|
||||
wordname);
|
||||
if(state != SLC_START) 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;
|
||||
case SLC_COMMENT:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user