|
|
@ -57,35 +57,27 @@ static Error parseword(const char *start, const char *end)
|
|
|
|
static Error parseSource()
|
|
|
|
static Error parseSource()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto result = Error::none;
|
|
|
|
auto result = Error::none;
|
|
|
|
char *start = nullptr;
|
|
|
|
char *start = (char *)DICT[DIdxSource];
|
|
|
|
char *end;
|
|
|
|
char *end = start;
|
|
|
|
char *s;
|
|
|
|
auto& i = *((char *)&DICT[DIdxInBuf]);
|
|
|
|
|
|
|
|
|
|
|
|
while (result == Error::none && haskey()) {
|
|
|
|
while (result == Error::none && i < DICT[DIdxSrcLen]) {
|
|
|
|
s = (char *)DICT[DIdxSource];
|
|
|
|
if (isspace(*end) || *end == '\0') {
|
|
|
|
|
|
|
|
if (end - start < 1) {
|
|
|
|
++DICT[DIdxSource];
|
|
|
|
start = ++end;
|
|
|
|
--DICT[DIdxSrcLen];
|
|
|
|
++i;
|
|
|
|
|
|
|
|
|
|
|
|
if (isspace(*s)) {
|
|
|
|
|
|
|
|
if (start) {
|
|
|
|
|
|
|
|
result = parseword(start, end + 1);
|
|
|
|
|
|
|
|
start = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!start) {
|
|
|
|
|
|
|
|
start = s;
|
|
|
|
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
++end;
|
|
|
|
++i; // discard the space
|
|
|
|
|
|
|
|
result = parseword(start, end);
|
|
|
|
|
|
|
|
start = (char *)DICT[DIdxSource] + i;
|
|
|
|
|
|
|
|
end = start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
++end;
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Parse the final word if it is non-empty.
|
|
|
|
|
|
|
|
if (start)
|
|
|
|
|
|
|
|
result = parseword(start, s + 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -93,9 +85,11 @@ static Error parseSource()
|
|
|
|
Error parse()
|
|
|
|
Error parse()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Reset source buffer and try to fill it with getinput().
|
|
|
|
// Reset source buffer and try to fill it with getinput().
|
|
|
|
DICT[DIdxSource] = (Cell)&DICT[DIdxBegin];
|
|
|
|
DICT[DIdxSource] = (Cell)&DICT[DIdxInBuf] + 1;
|
|
|
|
DICT[DIdxSrcLen] = 0;
|
|
|
|
DICT[DIdxSrcLen] = 0;
|
|
|
|
|
|
|
|
*((char *)&DICT[DIdxInBuf]) = 0;
|
|
|
|
getinput();
|
|
|
|
getinput();
|
|
|
|
|
|
|
|
addkey('\0');
|
|
|
|
|
|
|
|
|
|
|
|
return parseSource();
|
|
|
|
return parseSource();
|
|
|
|
}
|
|
|
|
}
|
|
|
|