lang: replace stack-based parser with a recursive parser
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user