improve tokenizer

This commit is contained in:
xianjimli 2020-07-10 12:01:22 +08:00
parent 7fe9535b00
commit 61076ffbf7
2 changed files with 11 additions and 1 deletions

View File

@ -134,8 +134,8 @@ const char* tokenizer_next_expr_until(tokenizer_t* tokenizer, const char* str) {
lparent++;
} else if (c == ')') {
lparent--;
tokenizer->cursor++;
if (lparent <= 0) {
tokenizer->cursor++;
break;
}
}

View File

@ -176,3 +176,13 @@ TEST(Tokenizer, expr8) {
tokenizer_deinit(t);
}
TEST(Tokenizer, expr9) {
tokenizer_t tokenizer;
tokenizer_t* t = tokenizer_init_ex(&tokenizer, "{fformat(\"%2.2lf F\", round($value * 1.8 + 32))}", 100, "{}", "=,");
ASSERT_EQ(string(tokenizer_next_expr_until(t, ",}")), string("fformat(\"%2.2lf F\", round($value * 1.8 + 32))"));
tokenizer_deinit(t);
}