fixed line numbering for double lines; faster turning off for defname; start state setter macro for safer code to not forget things
This commit is contained in:
parent
2b2cc47d7a
commit
c74ed39ef1
27
engine/slc.h
27
engine/slc.h
@ -355,6 +355,8 @@ static inline slc_state slc_def_name_statechange(
|
||||
if(c == ':') {
|
||||
*prefix_i = 0; /* XXX: restarts scan */
|
||||
return SLC_WORD_NAME;
|
||||
} else {
|
||||
*prefix_i = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,6 +378,14 @@ static inline slc_state slc_word_statechange(
|
||||
return current_state;
|
||||
}
|
||||
|
||||
#define SLC_SET_START_STATE \
|
||||
comment_i = 0; \
|
||||
multiline_i = 0; \
|
||||
prefix_i = 0; \
|
||||
wordname_i = 0; \
|
||||
wordname[0] = 0; \
|
||||
state = SLC_START;
|
||||
|
||||
/**
|
||||
* This function runs the main slc engine over a snippet of code.
|
||||
*
|
||||
@ -438,21 +448,23 @@ static inline void slc(
|
||||
char is_indenting = 1;
|
||||
int indent = 0;
|
||||
|
||||
slc_state state = SLC_START;
|
||||
|
||||
int comment_i = 0;
|
||||
int multiline_i = 0;
|
||||
int prefix_i = 0;
|
||||
int wordname_i = 0;
|
||||
slc_state state;
|
||||
int comment_i;
|
||||
int multiline_i;
|
||||
int prefix_i;
|
||||
int wordname_i;
|
||||
char wordname[SL_MAX_WORD_NAME + 1];
|
||||
|
||||
SLC_SET_START_STATE
|
||||
|
||||
char prevc = 0;
|
||||
char c = 0;
|
||||
while(((c = code_src()) != 0)) {
|
||||
/* Handle lines and columns, parts of indenting */
|
||||
if(endsline(c)) {
|
||||
/* Handles \n, \r, \r\n and \n\r this way and counts empty lines properly */
|
||||
if((prevc != c) || !last_is_endl) {
|
||||
/* De-Morgan (!a || b) == (a => b) so (last_is_endl => (prevc == c)) */
|
||||
if(!last_is_endl || (prevc == c)) {
|
||||
++line;
|
||||
col = 0;
|
||||
/* Indent part */
|
||||
@ -515,6 +527,7 @@ static inline void slc(
|
||||
&multiline_i);
|
||||
break;
|
||||
case SLC_DEF_NAME:
|
||||
// TODO
|
||||
break;
|
||||
case SLC_DEF_VAR:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user