parse: add a range of internal parser definitions

This commit is contained in:
2026-05-12 22:55:59 +01:00
parent 2235d8593b
commit 5ce780e037
+26 -8
View File
@@ -2,15 +2,15 @@
#define PARSE_SYNTAX_H_
#include "../ast/ast.h"
#include "../operator.h"
#include "lex.h"
#include "parse.h"
#include "token.h"
#include <stdbool.h>
#include <stdio.h>
enum parse_operand_flags {
OPERAND_BASIC = 0x01u,
};
extern void report_error(struct parse_ctx *ctx, const char *format, ...);
extern struct lex_token *peek_token(struct parse_ctx *ctx);
extern enum token_type peek_token_type(struct parse_ctx *ctx);
@@ -28,21 +28,39 @@ extern bool peek_int(struct parse_ctx *ctx);
extern bool parse_linefeed(struct parse_ctx *ctx);
extern bool parse_symbol(struct parse_ctx *ctx, enum token_symbol sym);
extern bool parse_keyword(struct parse_ctx *ctx, enum token_keyword kw);
extern bool parse_int(struct parse_ctx *ctx, long long *out);
extern bool parse_word(struct parse_ctx *ctx, struct lex_token **out);
extern bool parse_var(struct parse_ctx *ctx, struct lex_token **out);
extern bool parse_flag(struct parse_ctx *ctx, struct lex_token **out);
extern bool peek_arith_expr(struct parse_ctx *ctx);
extern bool parse_arith_expr(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_operand(
extern bool parse_arith_value(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_arith_expr(
struct parse_ctx *ctx,
enum parse_operand_flags flags,
enum operator_precedence minimum_precedence,
struct ast_node **out);
extern bool parse_statement(struct parse_ctx *ctx, struct ast_node **out);
extern bool peek_keyword_expr(struct parse_ctx *ctx);
extern bool parse_keyword_expr(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_if(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_func(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_fstring(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_block(struct parse_ctx *ctx, struct ast_node **out);
extern bool peek_command(struct parse_ctx *ctx);
extern bool parse_pipeline(
struct parse_ctx *ctx,
struct ast_node *first_item,
struct ast_node **out);
extern bool parse_command(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_cmdcall(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_redirect(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_expr(struct parse_ctx *ctx, struct ast_node **out);
extern bool peek_statement(struct parse_ctx *ctx);
extern bool parse_statement(struct parse_ctx *ctx, struct ast_node **out);
extern bool parse_statement_list(struct parse_ctx *ctx, struct ast_node **out);
#endif