use Size for linenum
parent
f124126b32
commit
b3e31c1d25
|
@ -12,7 +12,7 @@ ostd::ConstCharRange GenState::get_str() {
|
||||||
ostd::Size nl;
|
ostd::Size nl;
|
||||||
ostd::ConstCharRange beg = source;
|
ostd::ConstCharRange beg = source;
|
||||||
source = util::parse_string(cs, source, nl);
|
source = util::parse_string(cs, source, nl);
|
||||||
current_line += int(nl) - 1;
|
current_line += nl - 1;
|
||||||
ostd::ConstCharRange ret = ostd::slice_until(beg, source);
|
ostd::ConstCharRange ret = ostd::slice_until(beg, source);
|
||||||
return ret.slice(1, ret.size() - 1);
|
return ret.slice(1, ret.size() - 1);
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ static inline int cs_ret_code(int type, int def = 0) {
|
||||||
static void compilestatements(
|
static void compilestatements(
|
||||||
GenState &gs, int rettype, int brak = '\0', int prevargs = 0
|
GenState &gs, int rettype, int brak = '\0', int prevargs = 0
|
||||||
);
|
);
|
||||||
static inline ostd::Pair<ostd::ConstCharRange, int> compileblock(
|
static inline ostd::Pair<ostd::ConstCharRange, ostd::Size> compileblock(
|
||||||
GenState &gs, ostd::ConstCharRange p, int line,
|
GenState &gs, ostd::ConstCharRange p, ostd::Size line,
|
||||||
int rettype = CsRetNull, int brak = '\0'
|
int rettype = CsRetNull, int brak = '\0'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -171,16 +171,16 @@ static inline void compileblock(GenState &gs) {
|
||||||
gs.code.push(CsCodeEmpty);
|
gs.code.push(CsCodeEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ostd::Pair<ostd::ConstCharRange, int> compileblock(
|
static inline ostd::Pair<ostd::ConstCharRange, ostd::Size> compileblock(
|
||||||
GenState &gs, ostd::ConstCharRange p, int line, int rettype, int brak
|
GenState &gs, ostd::ConstCharRange p, ostd::Size line, int rettype, int brak
|
||||||
) {
|
) {
|
||||||
ostd::Size start = gs.code.size();
|
ostd::Size start = gs.code.size();
|
||||||
gs.code.push(CsCodeBlock);
|
gs.code.push(CsCodeBlock);
|
||||||
gs.code.push(CsCodeOffset | ((start + 2) << 8));
|
gs.code.push(CsCodeOffset | ((start + 2) << 8));
|
||||||
int retline = line;
|
ostd::Size retline = line;
|
||||||
if (p) {
|
if (p) {
|
||||||
ostd::ConstCharRange op = gs.source;
|
ostd::ConstCharRange op = gs.source;
|
||||||
int oldline = gs.current_line;
|
ostd::Size oldline = gs.current_line;
|
||||||
gs.source = p;
|
gs.source = p;
|
||||||
gs.current_line = line;
|
gs.current_line = line;
|
||||||
compilestatements(gs, CsValAny, brak);
|
compilestatements(gs, CsValAny, brak);
|
||||||
|
@ -583,7 +583,7 @@ done:
|
||||||
|
|
||||||
static void compileblockmain(GenState &gs, int wordtype, int prevargs) {
|
static void compileblockmain(GenState &gs, int wordtype, int prevargs) {
|
||||||
char const *start = gs.source.data();
|
char const *start = gs.source.data();
|
||||||
int curline = gs.current_line;
|
ostd::Size curline = gs.current_line;
|
||||||
int concs = 0;
|
int concs = 0;
|
||||||
for (int brak = 1; brak;) {
|
for (int brak = 1; brak;) {
|
||||||
switch (gs.skip_until("@\"/[]")) {
|
switch (gs.skip_until("@\"/[]")) {
|
||||||
|
@ -759,7 +759,7 @@ static bool compilearg(
|
||||||
gs.get_str();
|
gs.get_str();
|
||||||
break;
|
break;
|
||||||
case CsValCond: {
|
case CsValCond: {
|
||||||
int line = gs.current_line;
|
ostd::Size line = gs.current_line;
|
||||||
auto s = gs.get_str_dup();
|
auto s = gs.get_str_dup();
|
||||||
if (!s.empty()) {
|
if (!s.empty()) {
|
||||||
compileblock(gs, s, line);
|
compileblock(gs, s, line);
|
||||||
|
@ -787,7 +787,7 @@ static bool compilearg(
|
||||||
compileunescapestr(gs, true);
|
compileunescapestr(gs, true);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
int line = gs.current_line;
|
ostd::Size line = gs.current_line;
|
||||||
auto s = gs.get_str_dup();
|
auto s = gs.get_str_dup();
|
||||||
gs.gen_value(wordtype, s, line);
|
gs.gen_value(wordtype, s, line);
|
||||||
break;
|
break;
|
||||||
|
@ -842,7 +842,7 @@ static bool compilearg(
|
||||||
return !gs.get_word().empty();
|
return !gs.get_word().empty();
|
||||||
}
|
}
|
||||||
case CsValCond: {
|
case CsValCond: {
|
||||||
int line = gs.current_line;
|
ostd::Size line = gs.current_line;
|
||||||
auto s = gs.get_word();
|
auto s = gs.get_word();
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -851,7 +851,7 @@ static bool compilearg(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case CsValCode: {
|
case CsValCode: {
|
||||||
int line = gs.current_line;
|
ostd::Size line = gs.current_line;
|
||||||
auto s = gs.get_word();
|
auto s = gs.get_word();
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -867,7 +867,7 @@ static bool compilearg(
|
||||||
return !w.empty();
|
return !w.empty();
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
int line = gs.current_line;
|
ostd::Size line = gs.current_line;
|
||||||
auto s = gs.get_word();
|
auto s = gs.get_word();
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1252,7 +1252,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
gs.skip_comments();
|
gs.skip_comments();
|
||||||
idname.clear();
|
idname.clear();
|
||||||
int curline = gs.current_line;
|
ostd::Size curline = gs.current_line;
|
||||||
bool more = compilearg(gs, CsValWord, prevargs, &idname);
|
bool more = compilearg(gs, CsValWord, prevargs, &idname);
|
||||||
if (!more) {
|
if (!more) {
|
||||||
goto endstatement;
|
goto endstatement;
|
||||||
|
|
|
@ -149,7 +149,7 @@ struct GenState {
|
||||||
bool parsing = true;
|
bool parsing = true;
|
||||||
CsVector<ostd::Uint32> code;
|
CsVector<ostd::Uint32> code;
|
||||||
ostd::ConstCharRange source;
|
ostd::ConstCharRange source;
|
||||||
int current_line;
|
ostd::Size current_line;
|
||||||
ostd::ConstCharRange src_name;
|
ostd::ConstCharRange src_name;
|
||||||
|
|
||||||
GenState() = delete;
|
GenState() = delete;
|
||||||
|
|
Loading…
Reference in New Issue