32 lines
553 B
C
32 lines
553 B
C
|
|
#include "ctx.h"
|
||
|
|
|
||
|
|
bool peek_symbol(struct ivy_parser *parser, enum ivy_symbol sym)
|
||
|
|
{
|
||
|
|
struct ivy_token *tok = peek_token(parser);
|
||
|
|
if (!tok || tok->t_type != IVY_TOK_SYMBOL) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tok->t_symbol != sym) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
bool parse_symbol(struct ivy_parser *parser, enum ivy_symbol sym)
|
||
|
|
{
|
||
|
|
struct ivy_token *tok = peek_token(parser);
|
||
|
|
if (!tok || tok->t_type != IVY_TOK_SYMBOL) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tok->t_symbol != sym) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
parse_token(parser);
|
||
|
|
ivy_token_destroy(tok);
|
||
|
|
return true;
|
||
|
|
}
|