提交 ed388fc8 编写于 作者: J jp9000

replaced boolean trap parameter in the base lexer

上级 af5db87e
......@@ -335,7 +335,7 @@ static bool cf_lexer_nexttoken(struct cf_lexer *lex, struct cf_token *out_token)
base_token_clear(&start_token);
cf_token_clear(out_token);
while (lexer_getbasetoken(&lex->base_lexer, &token, false)) {
while (lexer_getbasetoken(&lex->base_lexer, &token, PARSE_WHITESPACE)) {
/* reclassify underscore as alpha for alnum tokens */
if (*token.text.array == '_')
token.type = BASETOKEN_ALPHA;
......
......@@ -101,7 +101,7 @@ static bool config_parse_string(struct lexer *lex, struct strref *ref,
struct base_token token;
base_token_clear(&token);
while (lexer_getbasetoken(lex, &token, false)) {
while (lexer_getbasetoken(lex, &token, PARSE_WHITESPACE)) {
if (end) {
if (*token.text.array == end) {
success = true;
......@@ -138,11 +138,11 @@ static void config_parse_section(struct config_section *section,
{
struct base_token token;
while (lexer_getbasetoken(lex, &token, false)) {
while (lexer_getbasetoken(lex, &token, PARSE_WHITESPACE)) {
struct strref name, value;
while (token.type == BASETOKEN_WHITESPACE) {
if (!lexer_getbasetoken(lex, &token, false))
if (!lexer_getbasetoken(lex, &token, PARSE_WHITESPACE))
return;
}
......@@ -150,7 +150,7 @@ static void config_parse_section(struct config_section *section,
if (*token.text.array == '#') {
do {
if (!lexer_getbasetoken(lex, &token,
false))
PARSE_WHITESPACE))
return;
} while (!is_newline(*token.text.array));
......@@ -198,17 +198,18 @@ static int config_parse(struct darray *sections, const char *file,
base_token_clear(&token);
while (lexer_getbasetoken(&lex, &token, false)) {
while (lexer_getbasetoken(&lex, &token, PARSE_WHITESPACE)) {
struct config_section *section;
while (token.type == BASETOKEN_WHITESPACE) {
if (!lexer_getbasetoken(&lex, &token, false))
if (!lexer_getbasetoken(&lex, &token, PARSE_WHITESPACE))
goto complete;
}
if (*token.text.array != '[') {
while (!is_newline(*token.text.array)) {
if (!lexer_getbasetoken(&lex, &token, false))
if (!lexer_getbasetoken(&lex, &token,
PARSE_WHITESPACE))
goto complete;
}
......
......@@ -250,11 +250,12 @@ static inline enum base_token_type get_char_token_type(const char ch)
}
bool lexer_getbasetoken(struct lexer *lex, struct base_token *token,
bool ignore_whitespace)
enum ignore_whitespace iws)
{
const char *offset = lex->offset;
const char *token_start = NULL;
enum base_token_type type = BASETOKEN_NONE;
bool ignore_whitespace = (iws == IGNORE_WHITESPACE);
if (!offset)
return false;
......
......@@ -280,8 +280,13 @@ static inline void lexer_reset(struct lexer *lex)
lex->offset = lex->text;
}
enum ignore_whitespace {
PARSE_WHITESPACE,
IGNORE_WHITESPACE
};
EXPORT bool lexer_getbasetoken(struct lexer *lex, struct base_token *t,
bool ignore_whitespace);
enum ignore_whitespace iws);
EXPORT void lexer_getstroffset(const struct lexer *lex, const char *str,
uint32_t *row, uint32_t *col);
......
......@@ -216,7 +216,7 @@ static bool lookup_gettoken(struct lexer *lex, struct strref *str)
base_token_clear(&temp);
strref_clear(str);
while (lexer_getbasetoken(lex, &temp, false)) {
while (lexer_getbasetoken(lex, &temp, PARSE_WHITESPACE)) {
char ch = *temp.text.array;
if (!str->array) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册