lang: ast: add support for multiple block termination tokens

This commit is contained in:
2025-01-16 13:15:18 +00:00
parent fa33336ed7
commit 143d61e329
7 changed files with 102 additions and 31 deletions

View File

@@ -3,10 +3,24 @@
#include "ctx.h"
#define BLOCK_TERMINATOR_MAX 8
struct block_parser_state {
struct parser_state s_base;
bool s_single_expr;
unsigned int s_terminator;
/* the block will be terminated when any token in this list
* is encountered. the token that terminated the block will
* not be consumed. */
unsigned short s_terminators[BLOCK_TERMINATOR_MAX];
unsigned short s_nr_terminators;
};
#endif
extern void block_add_terminator(
struct block_parser_state *state, unsigned short tok);
extern void block_copy_terminators(
const struct block_parser_state *src, struct block_parser_state *dest);
extern bool block_terminates_at_token(
struct block_parser_state *state, unsigned short tok);
#endif