slc comment start state machine
This commit is contained in:
parent
844a9165dd
commit
ceabdee697
32
engine/slc.h
32
engine/slc.h
@ -5,6 +5,9 @@
|
|||||||
#include<string.h> // memcpy, strlen..
|
#include<string.h> // memcpy, strlen..
|
||||||
#include<stddef.h> // NULL
|
#include<stddef.h> // NULL
|
||||||
|
|
||||||
|
/* Define this if you want to debug the engine doing its thing */
|
||||||
|
/* #define SLC_DEBUG */
|
||||||
|
|
||||||
/* 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 because of union types enable storage for it often, but you can override */
|
||||||
#ifndef SLOFFS_T
|
#ifndef SLOFFS_T
|
||||||
#define SLOFFS_T uint64_t
|
#define SLOFFS_T uint64_t
|
||||||
@ -268,11 +271,30 @@ static inline slc_state slc_comment_statechange_in(
|
|||||||
char c,
|
char c,
|
||||||
const char *singleline_comment,
|
const char *singleline_comment,
|
||||||
const char *multiline_comment_opener,
|
const char *multiline_comment_opener,
|
||||||
int singleline_comment_len,
|
|
||||||
int multiline_comment_len,
|
|
||||||
int *comment_i,
|
int *comment_i,
|
||||||
int *multiline_i){
|
int *multiline_i){
|
||||||
// FIXME: Implement
|
|
||||||
|
char s = singleline_comment[*comment_i];
|
||||||
|
char m = multiline_comment_opener[*multiline_i];
|
||||||
|
|
||||||
|
/* Check if we have finished processing */
|
||||||
|
if(s == 0) return SLC_COMMENT;
|
||||||
|
if(m == 0) return SLC_MULTILINE_COMMENT;
|
||||||
|
|
||||||
|
/* Single-line comment progress */
|
||||||
|
if(c == s) {
|
||||||
|
++(*comment_i);
|
||||||
|
} else {
|
||||||
|
*comment_i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Multi-line comment progress */
|
||||||
|
if(c == m) {
|
||||||
|
++(*multiline_i);
|
||||||
|
} else {
|
||||||
|
*multiline_i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return current_state;
|
return current_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,8 +373,6 @@ static inline void slc(
|
|||||||
const char *varprefix) {
|
const char *varprefix) {
|
||||||
|
|
||||||
slc_state state = SLC_START;
|
slc_state state = SLC_START;
|
||||||
int singleline_comment_len = strlen(singleline_comment);
|
|
||||||
int multiline_comment_opener_len = strlen(multiline_comment_opener);
|
|
||||||
|
|
||||||
// TODO: Count line numbers
|
// TODO: Count line numbers
|
||||||
// TODO: Handle/count indentation for better error messages
|
// TODO: Handle/count indentation for better error messages
|
||||||
@ -374,8 +394,6 @@ static inline void slc(
|
|||||||
c,
|
c,
|
||||||
singleline_comment,
|
singleline_comment,
|
||||||
multiline_comment_opener,
|
multiline_comment_opener,
|
||||||
singleline_comment_len,
|
|
||||||
multiline_comment_opener_len,
|
|
||||||
&comment_i,
|
&comment_i,
|
||||||
&multiline_i);
|
&multiline_i);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user