Files
bshell/bshell.runtime/parse/syntax.h
T
wash edfb3e24a3 bshell: re-organise build into three separate components
bshell: the front-end binary
bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts
bshell.core: contains the builtin commandlets and aliases
2026-05-25 10:33:29 +01:00

74 lines
3.0 KiB
C

#ifndef PARSE_SYNTAX_H_
#define PARSE_SYNTAX_H_
#include <bshell/ast.h>
#include <bshell/parse/lex.h>
#include <bshell/parse/parse.h>
#include <bshell/parse/token.h>
#include <bshell/runtime/operator.h>
#include <stdbool.h>
#include <stdio.h>
extern void report_error(struct bshell_parse_ctx *ctx, const char *format, ...);
extern struct bshell_lex_token *peek_token(struct bshell_parse_ctx *ctx);
extern enum bshell_lex_token_type peek_token_type(struct bshell_parse_ctx *ctx);
extern enum bshell_lex_keyword peek_unknown_keyword(struct bshell_parse_ctx *ctx);
extern enum bshell_lex_symbol peek_unknown_symbol(struct bshell_parse_ctx *ctx);
extern struct bshell_lex_token *claim_token(struct bshell_parse_ctx *ctx);
extern void discard_token(struct bshell_parse_ctx *ctx);
extern bool peek_linefeed(struct bshell_parse_ctx *ctx);
extern bool peek_symbol(struct bshell_parse_ctx *ctx, enum bshell_lex_symbol sym);
extern bool peek_word(struct bshell_parse_ctx *ctx, struct bshell_lex_token **out);
extern bool peek_int(struct bshell_parse_ctx *ctx);
extern bool parse_linefeed(struct bshell_parse_ctx *ctx);
extern bool parse_symbol(struct bshell_parse_ctx *ctx, enum bshell_lex_symbol sym);
extern bool parse_keyword(struct bshell_parse_ctx *ctx, enum bshell_lex_keyword kw);
extern bool parse_word(struct bshell_parse_ctx *ctx, struct bshell_lex_token **out);
extern bool parse_var(struct bshell_parse_ctx *ctx, struct bshell_lex_token **out);
extern bool parse_flag(struct bshell_parse_ctx *ctx, struct bshell_lex_token **out);
extern bool peek_arith_expr(struct bshell_parse_ctx *ctx);
extern bool parse_arith_value(
struct bshell_parse_ctx *ctx,
struct bshell_ast_node **out);
extern bool parse_arith_expr(
struct bshell_parse_ctx *ctx,
enum bshell_operator_precedence minimum_precedence,
struct bshell_ast_node **out);
extern bool peek_keyword_expr(struct bshell_parse_ctx *ctx);
extern bool parse_keyword_expr(
struct bshell_parse_ctx *ctx,
struct bshell_ast_node **out);
extern bool parse_if(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_func(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_fstring(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_block(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool peek_command(struct bshell_parse_ctx *ctx);
extern bool parse_pipeline(
struct bshell_parse_ctx *ctx,
struct bshell_ast_node *first_item,
struct bshell_ast_node **out);
extern bool parse_command(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_cmdcall(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_redirect(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool parse_expr(struct bshell_parse_ctx *ctx, struct bshell_ast_node **out);
extern bool peek_statement(struct bshell_parse_ctx *ctx);
extern bool parse_statement(
struct bshell_parse_ctx *ctx,
struct bshell_ast_node **out);
extern bool parse_statement_list(
struct bshell_parse_ctx *ctx,
struct bshell_ast_node **out);
#endif