Example #1
0
static bool
tnt_sql_tk(struct tnt_sql *sql, int tk, struct tnt_tk **tkp)
{
	struct tnt_tk *tkp_ = NULL;
	int tk_ = tnt_lex(sql->l, &tkp_);
	if (tk_ == TNT_TK_ERROR)
		return tnt_sql_error(sql, NULL, "%s", sql->l->error);
	if (tk_ != tk) {
		if (tk < 0xff && ispunct(tk))
			return tnt_sql_error(sql, tkp_, "expected '%c'", tk);
		return tnt_sql_error(sql, tkp_, "expected '%s'", tnt_lex_nameof(sql->l, tk));
	}
	if (tkp)
		*tkp = tkp_;
	return true;
}
Example #2
0
static int
nb_config_expect(struct nb_config *cfg, int tk, struct tnt_tk **tkp)
{
	struct tnt_tk *tkp_ = NULL;
	int tk_ = tnt_lex(&cfg->lex, &tkp_);
	if (tk_ == TNT_TK_ERROR)
		return nb_config_error(cfg, NULL, "%s", cfg->lex.error);
	if (tk_ != tk) {
		if (tk < 0xff && ispunct(tk))
			return nb_config_error(cfg, tkp_, "expected '%c'", tk);
		return nb_config_error(cfg, tkp_, "expected '%s'",
				       tnt_lex_nameof(&cfg->lex, tk));
	}
	if (tkp)
		*tkp = tkp_;
	return 0;
}