2024-11-28 16:56:25 +00:00
|
|
|
#ifndef _AST_BLOCK_H_
|
|
|
|
|
#define _AST_BLOCK_H_
|
|
|
|
|
|
|
|
|
|
#include "ctx.h"
|
|
|
|
|
|
2025-01-16 13:15:18 +00:00
|
|
|
#define BLOCK_TERMINATOR_MAX 8
|
|
|
|
|
|
2024-11-28 16:56:25 +00:00
|
|
|
struct block_parser_state {
|
|
|
|
|
struct parser_state s_base;
|
|
|
|
|
bool s_single_expr;
|
2025-01-16 13:15:18 +00:00
|
|
|
|
|
|
|
|
/* 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;
|
2024-11-28 16:56:25 +00:00
|
|
|
};
|
|
|
|
|
|
2025-01-16 13:15:18 +00:00
|
|
|
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
|