lang: replace stack-based parser with a recursive parser

This commit is contained in:
2026-04-06 18:25:43 +01:00
parent 3a549aa6df
commit b904813cef
77 changed files with 2984 additions and 6499 deletions
+31
View File
@@ -0,0 +1,31 @@
#include "ctx.h"
bool peek_keyword(struct ivy_parser *parser, enum ivy_keyword kw)
{
struct ivy_token *tok = peek_token(parser);
if (!tok || tok->t_type != IVY_TOK_KEYWORD) {
return false;
}
if (tok->t_keyword != kw) {
return false;
}
return true;
}
bool parse_keyword(struct ivy_parser *parser, enum ivy_keyword kw)
{
struct ivy_token *tok = peek_token(parser);
if (!tok || tok->t_type != IVY_TOK_KEYWORD) {
return false;
}
if (tok->t_keyword != kw) {
return false;
}
parse_token(parser);
ivy_token_destroy(tok);
return true;
}