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
This commit is contained in:
2026-05-25 10:33:29 +01:00
parent 58c76a1f57
commit edfb3e24a3
165 changed files with 5173 additions and 4995 deletions
+232
View File
@@ -0,0 +1,232 @@
#ifndef BSHELL_AST_H_
#define BSHELL_AST_H_
#include <bshell/status.h>
#include <fx/bstr.h>
#include <fx/queue.h>
struct bshell_lex_token;
#define BSHELL_AST_ITERATE_OK(flags) \
((struct bshell_ast_iterate_result) {.r_status = BSHELL_SUCCESS, \
.r_flags = (flags)})
#define BSHELL_AST_ITERATE_ERR(status) \
((struct bshell_ast_iterate_result) {.r_status = (status)})
enum bshell_ast_node_type {
BSHELL_AST_NONE = 0x00u,
BSHELL_AST_NULL,
BSHELL_AST_STMT_LIST,
BSHELL_AST_INT,
BSHELL_AST_DOUBLE,
BSHELL_AST_WORD,
BSHELL_AST_STRING,
BSHELL_AST_FSTRING,
BSHELL_AST_VAR,
BSHELL_AST_VAR_SPLAT,
BSHELL_AST_FLAG,
BSHELL_AST_CMDCALL,
BSHELL_AST_FUNCALL,
BSHELL_AST_PIPELINE,
BSHELL_AST_REDIRECTION,
BSHELL_AST_BLOCK,
BSHELL_AST_FUNC,
BSHELL_AST_ARRAY,
BSHELL_AST_HASHTABLE,
BSHELL_AST_HASHTABLE_ITEM,
BSHELL_AST_OP,
BSHELL_AST_IF,
BSHELL_AST_IF_BRANCH,
};
struct bshell_ast_iterator_entry {
fx_queue_entry e_entry;
unsigned long e_depth;
};
struct bshell_ast_node {
enum bshell_ast_node_type n_type;
struct bshell_ast_node *n_parent;
fx_queue_entry n_entry;
struct bshell_ast_iterator_entry n_it;
};
struct bshell_null_ast_node {
struct bshell_ast_node n_base;
};
struct bshell_int_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_value;
};
struct bshell_double_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_value;
};
struct bshell_word_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_value;
};
struct bshell_string_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_value;
};
struct bshell_fstring_ast_node {
struct bshell_ast_node n_base;
fx_queue n_elements;
};
struct bshell_var_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_ident;
};
struct bshell_var_splat_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_ident;
};
struct bshell_cmdcall_ast_node {
struct bshell_ast_node n_base;
fx_queue n_args;
fx_queue n_redirect;
};
struct bshell_funcall_ast_node {
struct bshell_ast_node n_base;
struct bshell_ast_node *n_func;
fx_queue n_args;
};
struct bshell_pipeline_ast_node {
struct bshell_ast_node n_base;
fx_queue n_stages;
};
struct bshell_redirection_ast_node {
struct bshell_ast_node n_base;
bool n_append : 1;
bool n_out_is_fd : 1;
bool n_out_is_expr : 1;
unsigned int n_in, n_out;
struct bshell_ast_node *n_out_path_expr;
const char *n_out_path;
struct bshell_lex_token *n_out_tok;
};
struct bshell_stmt_list_ast_node {
struct bshell_ast_node n_base;
fx_queue n_statements;
};
struct bshell_block_ast_node {
struct bshell_ast_node n_base;
fx_queue n_statements;
};
struct bshell_func_ast_node {
struct bshell_ast_node n_base;
struct bshell_lex_token *n_name;
fx_queue n_params;
struct bshell_ast_node *n_body;
};
struct bshell_array_ast_node {
struct bshell_ast_node n_base;
fx_queue n_items;
};
struct bshell_hashtable_ast_node {
struct bshell_ast_node n_base;
fx_queue n_items;
};
struct bshell_hashtable_item_ast_node {
struct bshell_ast_node n_base;
struct bshell_ast_node *n_key, *n_value;
};
struct bshell_op_ast_node {
struct bshell_ast_node n_base;
const struct bshell_operator_info *n_op;
struct bshell_ast_node *n_left, *n_right;
};
struct bshell_if_branch_ast_node {
struct bshell_ast_node n_base;
struct bshell_ast_node *n_cond;
struct bshell_ast_node *n_body;
};
struct bshell_if_ast_node {
struct bshell_ast_node n_base;
fx_queue n_branches;
};
struct bshell_ast_iterator {
struct bshell_ast_node *it_cur;
fx_queue it_queue;
unsigned int it_depth;
fx_queue_entry *it_insert_after;
};
struct bshell_ast_iterate_result {
enum bshell_status r_status;
enum {
BSHELL_AST_ITERATE_CONTINUE = 0x00u,
BSHELL_AST_ITERATE_STOP = 0x01u,
BSHELL_AST_ITERATE_ADD_CHILDREN = 0x02u,
BSHELL_AST_ITERATE_REPEAT = 0x04u,
} r_flags;
};
enum bshell_ast_iteration_type {
BSHELL_AST_ITERATION_PRE,
BSHELL_AST_ITERATION_POST,
};
typedef struct bshell_ast_iterate_result (*bshell_ast_iterator_callback)(
struct bshell_ast_node *,
enum bshell_ast_iteration_type,
struct bshell_ast_iterator *,
void *);
struct bshell_ast_node_definition {
enum bshell_ast_node_type def_id;
size_t def_node_size;
enum bshell_status (*def_collect_children)(
struct bshell_ast_node *,
struct bshell_ast_iterator *);
enum bshell_status (*def_cleanup)(struct bshell_ast_node *);
void (*def_to_string)(const struct bshell_ast_node *, fx_bstr *);
};
extern struct bshell_ast_node *bshell_ast_node_create(
enum bshell_ast_node_type type);
extern void bshell_ast_node_destroy(struct bshell_ast_node *node);
extern void bshell_ast_node_to_string(
const struct bshell_ast_node *node,
fx_bstr *out);
extern enum bshell_status bshell_ast_node_iterate(
struct bshell_ast_node *node,
struct bshell_ast_iterator *it,
bshell_ast_iterator_callback callback,
void *arg);
extern const char *bshell_ast_node_type_to_string(
enum bshell_ast_node_type type);
extern struct bshell_ast_node *bshell_ast_iterator_peek(
struct bshell_ast_iterator *it);
extern struct bshell_ast_node *bshell_ast_iterator_dequeue(
struct bshell_ast_iterator *it);
extern void bshell_ast_iterator_enqueue(
struct bshell_ast_iterator *it,
struct bshell_ast_node *node);
#endif
@@ -0,0 +1,35 @@
#ifndef BSHELL_COMMAND_ALIAS_H_
#define BSHELL_COMMAND_ALIAS_H_
#include "../verb.h"
#include <fx/macros.h>
#include <fx/string.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_ALIAS (bshell_alias_get_type())
FX_DECLARE_TYPE(bshell_alias);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_alias)
const char *a_callable_name;
const char *a_target_name;
const char *(*a_get_callable_name)(const bshell_alias *);
const char *(*a_get_target_name)(const bshell_alias *);
FX_TYPE_CLASS_DECLARATION_END(bshell_alias)
extern fx_type_id bshell_alias_get_type(void);
extern enum bshell_status bshell_alias_get_callable_name(
const bshell_alias *alias,
fx_string *out);
extern enum bshell_status bshell_alias_get_target_name(
const bshell_alias *alias,
fx_string *out);
FX_DECLS_END;
#endif
@@ -0,0 +1,25 @@
#ifndef BSHELL_COMMAND_CMDLET_H_
#define BSHELL_COMMAND_CMDLET_H_
#include "../verb.h"
#include <fx/macros.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_CMDLET (bshell_cmdlet_get_type())
FX_DECLARE_TYPE(bshell_cmdlet);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_cmdlet)
enum bshell_verb_id c_verb;
const char *c_noun;
FX_TYPE_CLASS_DECLARATION_END(bshell_cmdlet)
extern fx_type_id bshell_cmdlet_get_type(void);
FX_DECLS_END;
#endif
@@ -0,0 +1,62 @@
#ifndef BSHELL_COMMAND_COMMAND_H_
#define BSHELL_COMMAND_COMMAND_H_
#include <fx/macros.h>
#include <fx/reflection/type.h>
#include <fx/string.h>
#include <fx/value.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_COMMAND (bshell_command_get_type())
FX_DECLARE_TYPE(bshell_command);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_command)
const char *c_command_type;
enum bshell_status (
*c_get_callable_name)(const bshell_command *, fx_string *);
enum bshell_status (
*c_get_callable_name_static)(const fx_type *, fx_string *);
enum bshell_status (
*c_get_description)(const bshell_command *, fx_string *);
enum bshell_status (
*c_get_description_static)(const fx_type *, fx_string *);
enum bshell_status (*c_begin_processing)(bshell_command *);
enum bshell_status (*c_process_record)(
bshell_command *,
FX_TYPE_FWDREF(bshell_pipeline) * pipeline,
struct bshell_runtime *);
enum bshell_status (*c_end_processing)(bshell_command *);
FX_TYPE_CLASS_DECLARATION_END(bshell_command)
extern fx_type_id bshell_command_get_type(void);
extern bshell_command *bshell_command_find_static(const char *callable_name);
extern void bshell_command_set_args(
bshell_command *cmd,
fx_value *args,
size_t nr_args);
extern void bshell_command_set_args_reverse(
bshell_command *cmd,
fx_value *args,
size_t nr_args);
extern const fx_value *bshell_command_get_arg(
bshell_command *cmd,
size_t index);
extern enum bshell_status bshell_command_begin_processing(
bshell_command *command);
extern enum bshell_status bshell_command_process_record(
bshell_command *command,
FX_TYPE_FWDREF(bshell_pipeline) * pipeline,
struct bshell_runtime *rt);
extern enum bshell_status bshell_command_end_processing(
bshell_command *command);
FX_DECLS_END;
#endif
@@ -0,0 +1,23 @@
#ifndef BSHELL_COMMAND_FUNCTION_H_
#define BSHELL_COMMAND_FUNCTION_H_
#include <fx/macros.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_FUNCTION (bshell_function_get_type())
FX_DECLARE_TYPE(bshell_function);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_function)
FX_TYPE_CLASS_DECLARATION_END(bshell_function)
extern fx_type_id bshell_function_get_type(void);
extern bshell_function *bshell_function_create(const char *name);
FX_DECLS_END;
#endif
+12
View File
@@ -0,0 +1,12 @@
#ifndef BSHELL_COMPILE_H_
#define BSHELL_COMPILE_H_
#include <bshell/runtime/script-block.h>
struct bshell_ast_node;
extern enum bshell_status bshell_compile(
struct bshell_ast_node *src,
bshell_scriptblock *dest);
#endif
+21
View File
@@ -0,0 +1,21 @@
#ifndef BSHELL_FILE_H_
#define BSHELL_FILE_H_
#include <bshell/line-source.h>
#include <fx/collections/array.h>
#include <stdio.h>
struct bshell_file {
struct bshell_line_source f_base;
fx_array *f_lines;
char *f_path;
fx_stream *f_strp;
FILE *f_fp;
};
extern enum bshell_status bshell_file_open(
const char *path,
struct bshell_file **out);
extern void bshell_file_close(struct bshell_file *file);
#endif
+77
View File
@@ -0,0 +1,77 @@
#ifndef BSHELL_FORMAT_H_
#define BSHELL_FORMAT_H_
#include <bshell/status.h>
#include <fx/namemap.h>
#include <fx/object.h>
#include <fx/queue.h>
#include <fx/reflection/property.h>
#include <fx/reflection/type.h>
#include <fx/stream.h>
#include <fx/value.h>
#define TABLE_COLUMN(display_name, property_name, width) \
{ \
.col_display_name = (display_name), \
.col_property_name = (property_name), \
.col_width = (width), \
}
#define COL_WIDTH_INFINITE ((size_t)-1)
struct bshell_table_column {
const char *col_display_name;
const char *col_property_name;
size_t col_width;
};
struct bshell_table {
fx_namemap_entry fmt_entry;
const struct bshell_table_column *fmt_columns;
size_t fmt_column_count;
};
struct bshell_table_ctx_column {
const char *col_title;
size_t col_width;
size_t col_title_chars_written;
const char *col_title_ptr;
const fx_property *col_property;
};
struct bshell_table_ctx {
const struct bshell_table *ctx_fmt;
struct bshell_table_ctx_column *ctx_columns;
size_t ctx_columns_count;
unsigned int ctx_tty_width;
size_t ctx_variable_columns_count;
fx_stream *ctx_out;
};
extern enum bshell_status bshell_table_init(void);
extern const struct bshell_table *bshell_table_get_for_type(const fx_type *ty);
extern enum bshell_status format_object_table(
fx_object *object,
fx_stream *dest);
extern enum bshell_status format_value_default(
const fx_value *value,
fx_stream *dest);
extern enum bshell_status bshell_table_ctx_init(
struct bshell_table_ctx *ctx,
fx_stream *out);
extern enum bshell_status bshell_table_ctx_cleanup(
struct bshell_table_ctx *ctx);
extern enum bshell_status bshell_table_ctx_prepare_columns_from_format(
struct bshell_table_ctx *ctx,
const fx_type *record_type,
const struct bshell_table *fmt);
extern enum bshell_status bshell_table_ctx_prepare_columns_from_object(
struct bshell_table_ctx *ctx,
const fx_type *record_type);
extern enum bshell_status bshell_table_ctx_print_headers(
struct bshell_table_ctx *ctx);
extern enum bshell_status bshell_table_ctx_print_record(
struct bshell_table_ctx *ctx,
const fx_value *record);
#endif
@@ -0,0 +1,40 @@
#ifndef BSHELL_LINE_SOURCE_H_
#define BSHELL_LINE_SOURCE_H_
#include "status.h"
#include <fx/stringstream.h>
#include <stddef.h>
struct bshell_line_source {
enum bshell_status (*s_get_name)(
struct bshell_line_source *,
char *,
size_t,
size_t *);
enum bshell_status (
*s_readline)(struct bshell_line_source *, fx_stringstream *);
enum bshell_status (*s_get_row)(
struct bshell_line_source *,
size_t,
char *,
size_t,
size_t *);
};
extern enum bshell_status bshell_line_source_get_name(
struct bshell_line_source *src,
char *buf,
size_t count,
size_t *nr_read);
extern enum bshell_status bshell_line_source_readline(
struct bshell_line_source *src,
fx_stringstream *out);
extern enum bshell_status bshell_line_source_get_row(
struct bshell_line_source *src,
size_t row,
char *buf,
size_t count,
size_t *nr_read);
#endif
+97
View File
@@ -0,0 +1,97 @@
#ifndef BSHELL_PARSE_LEX_H_
#define BSHELL_PARSE_LEX_H_
#include <bshell/parse/token.h>
#include <bshell/status.h>
#include <fx/queue.h>
#include <fx/string.h>
#include <fx/stringstream.h>
#define BSHELL_LEX_STATE_MAX_TERMINATORS 16
struct bshell_line_source;
enum bshell_lex_flags {
LEX_PRINT_TOKENS = 0x01u,
};
enum bshell_lex_token_flags {
/* a token with this flag not only interrupts the word currently being
* scanned, but also stops multi-words */
BSHELL_LEX_TOKEN_TERMINATES_WORD = 0x01u,
/* a token with this flag can appear at the start of an arithmetic
* expression. a statement that encounters this token as its first char
* will switch to arithmetic mode */
BSHELL_LEX_TOKEN_UNARY_ARITHMETIC = 0x02u,
/* if a token has this flag defined, the lexer will
* switch to command mode after encountering it. */
BSHELL_LEX_TOKEN_COMMAND_MODE = 0x08u,
/* if a token has this flag defined, the lexer will
* switch to statement mode after encountering it. */
BSHELL_LEX_TOKEN_STATEMENT_MODE = 0x10u,
};
enum bshell_lex_state_id {
BSHELL_LEX_STATE_STATEMENT = 0x01u,
BSHELL_LEX_STATE_COMMAND = 0x02u,
BSHELL_LEX_STATE_ARITHMETIC = 0x04u,
BSHELL_LEX_STATE_STRING = 0x08u,
BSHELL_LEX_STATE_WORD = 0x10u,
BSHELL_LEX_STATE_HASHTABLE = 0x20u,
};
struct bshell_lex_token_definition {
int id;
const char *name;
uint64_t name_hash;
enum bshell_lex_state_id enabled_states;
enum bshell_lex_token_flags flags;
};
struct bshell_lex_symbol_node {
char s_char;
struct bshell_lex_token_definition *s_def;
fx_queue_entry s_entry;
fx_queue s_children;
};
struct bshell_lex_state {
const struct bshell_lex_state_type *s_type;
unsigned int s_terminators[BSHELL_LEX_STATE_MAX_TERMINATORS];
unsigned int s_nr_terminators;
unsigned int s_paren_depth;
fx_queue_entry s_entry;
fx_string *s_tempstr;
unsigned int s_flags;
};
struct bshell_lex_ctx {
enum bshell_lex_flags lex_flags;
fx_queue lex_tokens;
struct bshell_line_source *lex_src;
fx_stringstream *lex_buf;
fx_string *lex_tmp;
fx_wchar lex_ch;
fx_queue lex_state;
void (*lex_token_scanned)(
struct bshell_lex_ctx *,
struct bshell_lex_token *);
enum bshell_lex_token_type lex_prev_token;
struct bshell_char_cell lex_cursor, lex_start, lex_end;
struct bshell_lex_symbol_node *lex_sym_tree;
enum bshell_status lex_status;
};
extern enum bshell_status bshell_lex_ctx_init(
struct bshell_lex_ctx *ctx,
enum bshell_lex_flags flags,
struct bshell_line_source *src);
extern enum bshell_status bshell_lex_ctx_cleanup(struct bshell_lex_ctx *ctx);
extern struct bshell_lex_token *bshell_lex_ctx_peek(struct bshell_lex_ctx *ctx);
extern struct bshell_lex_token *bshell_lex_ctx_claim(
struct bshell_lex_ctx *ctx);
extern void bshell_lex_ctx_discard(struct bshell_lex_ctx *ctx);
#endif
@@ -0,0 +1,22 @@
#ifndef BSHELL_PARSE_PARSE_H_
#define BSHELL_PARSE_PARSE_H_
#include <bshell/status.h>
struct bshell_lex_ctx;
struct bshell_ast_node;
struct bshell_parse_ctx {
struct bshell_lex_ctx *p_src;
enum bshell_status p_status;
};
extern enum bshell_status bshell_parse_ctx_init(
struct bshell_parse_ctx *ctx,
struct bshell_lex_ctx *src);
extern void bshell_parse_ctx_cleanup(struct bshell_parse_ctx *ctx);
extern struct bshell_ast_node *bshell_parse_ctx_read_node(
struct bshell_parse_ctx *ctx);
#endif
+190
View File
@@ -0,0 +1,190 @@
#ifndef BSHELL_PARSE_TOKEN_H_
#define BSHELL_PARSE_TOKEN_H_
#include <fx/queue.h>
#include <fx/value.h>
#include <stdbool.h>
struct bshell_char_cell {
unsigned long c_row, c_col;
};
enum bshell_lex_token_type {
BSHELL_TOK_NONE = 0,
__BSHELL_TOK_INDEX_BASE = 100,
BSHELL_TOK_KEYWORD,
BSHELL_TOK_SYMBOL,
BSHELL_TOK_INT,
BSHELL_TOK_DOUBLE,
BSHELL_TOK_WORD,
BSHELL_TOK_WORD_START,
BSHELL_TOK_WORD_END,
BSHELL_TOK_FLAG,
BSHELL_TOK_OPERATOR,
BSHELL_TOK_VAR,
BSHELL_TOK_VAR_SPLAT,
BSHELL_TOK_STRING,
BSHELL_TOK_STR_START,
BSHELL_TOK_STR_END,
BSHELL_TOK_LINEFEED,
__BSHELL_TOK_INDEX_LIMIT,
};
enum bshell_lex_keyword {
BSHELL_KW_NONE = 0,
__BSHELL_KW_INDEX_BASE = 200,
BSHELL_KW_FUNC,
BSHELL_KW_IF,
BSHELL_KW_ELSEIF,
BSHELL_KW_ELSE,
__BSHELL_KW_INDEX_LIMIT,
};
enum bshell_lex_operator {
BSHELL_TKOP_NONE = 0,
__BSHELL_TKOP_INDEX_BASE = 300,
BSHELL_TKOP_F,
BSHELL_TKOP_BAND,
BSHELL_TKOP_BOR,
BSHELL_TKOP_BXOR,
BSHELL_TKOP_BNOT,
BSHELL_TKOP_SHL,
BSHELL_TKOP_SHR,
BSHELL_TKOP_EQ,
BSHELL_TKOP_NE,
BSHELL_TKOP_GT,
BSHELL_TKOP_LT,
BSHELL_TKOP_GE,
BSHELL_TKOP_LE,
BSHELL_TKOP_MATCH,
BSHELL_TKOP_NOTMATCH,
BSHELL_TKOP_REPLACE,
BSHELL_TKOP_LIKE,
BSHELL_TKOP_NOTLIKE,
BSHELL_TKOP_IN,
BSHELL_TKOP_NOTIN,
BSHELL_TKOP_CONTAINS,
BSHELL_TKOP_NOTCONTAINS,
BSHELL_TKOP_AND,
BSHELL_TKOP_OR,
BSHELL_TKOP_XOR,
BSHELL_TKOP_NOT,
BSHELL_TKOP_SPLIT,
BSHELL_TKOP_JOIN,
BSHELL_TKOP_IS,
BSHELL_TKOP_ISNOT,
BSHELL_TKOP_AS,
__BSHELL_TKOP_INDEX_LIMIT,
};
enum bshell_lex_symbol {
BSHELL_SYM_NONE = 0,
__BSHELL_SYM_INDEX_BASE = 400,
BSHELL_SYM_BANG,
BSHELL_SYM_PLUS,
BSHELL_SYM_HYPHEN,
BSHELL_SYM_FORWARD_SLASH,
BSHELL_SYM_ASTERISK,
BSHELL_SYM_AMPERSAND,
BSHELL_SYM_PERCENT,
BSHELL_SYM_SQUOTE,
BSHELL_SYM_DQUOTE,
BSHELL_SYM_HASH,
BSHELL_SYM_COLON_COLON,
BSHELL_SYM_SEMICOLON,
BSHELL_SYM_COMMA,
BSHELL_SYM_DOLLAR,
BSHELL_SYM_DOLLAR_LEFT_PAREN,
BSHELL_SYM_DOLLAR_LEFT_BRACE,
BSHELL_SYM_DOT,
BSHELL_SYM_DOT_DOT,
BSHELL_SYM_PIPE,
BSHELL_SYM_AT,
BSHELL_SYM_AT_LEFT_PAREN,
BSHELL_SYM_AT_LEFT_BRACE,
BSHELL_SYM_LEFT_BRACE,
BSHELL_SYM_RIGHT_BRACE,
BSHELL_SYM_LEFT_BRACKET,
BSHELL_SYM_RIGHT_BRACKET,
BSHELL_SYM_LEFT_PAREN,
BSHELL_SYM_RIGHT_PAREN,
BSHELL_SYM_EQUAL,
BSHELL_SYM_PLUS_EQUAL,
BSHELL_SYM_HYPHEN_EQUAL,
BSHELL_SYM_ASTERISK_EQUAL,
BSHELL_SYM_FORWARD_SLASH_EQUAL,
BSHELL_SYM_PERCENT_EQUAL,
BSHELL_SYM_QUESTION_DOT,
BSHELL_SYM_QUESTION_LEFT_BRACKET,
__BSHELL_SYM_INDEX_LIMIT,
};
struct bshell_lex_token {
enum bshell_lex_token_type tok_type;
struct bshell_char_cell tok_start, tok_end;
fx_queue_entry tok_entry;
union {
enum bshell_lex_keyword tok_keyword;
enum bshell_lex_symbol tok_symbol;
enum bshell_lex_operator tok_operator;
fx_value tok_number;
char *tok_str;
};
};
extern struct bshell_lex_token *bshell_lex_token_create(
enum bshell_lex_token_type type);
extern struct bshell_lex_token *bshell_lex_token_create_with_string(
enum bshell_lex_token_type type,
const char *s);
extern void bshell_lex_token_destroy(struct bshell_lex_token *tok);
extern struct bshell_lex_token *bshell_lex_token_change_type(
struct bshell_lex_token *tok,
enum bshell_lex_token_type new_type);
extern void bshell_lex_token_change_string(
struct bshell_lex_token *tok,
const char *s);
static inline bool bshell_lex_token_is_symbol(
struct bshell_lex_token *tok,
enum bshell_lex_symbol sym)
{
return (tok->tok_type == BSHELL_TOK_SYMBOL && tok->tok_symbol == sym);
}
static inline bool bshell_lex_token_is_keyword(
struct bshell_lex_token *tok,
enum bshell_lex_keyword kw)
{
return (tok->tok_type == BSHELL_TOK_KEYWORD && tok->tok_keyword == kw);
}
static inline bool bshell_lex_token_type_has_string_value(
enum bshell_lex_token_type type)
{
switch (type) {
case BSHELL_TOK_WORD:
case BSHELL_TOK_STRING:
case BSHELL_TOK_FLAG:
case BSHELL_TOK_VAR:
case BSHELL_TOK_VAR_SPLAT:
return true;
default:
return false;
}
}
static inline bool bshell_lex_token_has_string_value(
const struct bshell_lex_token *tok)
{
return bshell_lex_token_type_has_string_value(tok->tok_type);
}
extern const char *bshell_token_type_to_string(enum bshell_lex_token_type type);
extern const char *bshell_lex_keyword_to_string(
enum bshell_lex_keyword keyword);
extern const char *bshell_lex_symbol_to_string(enum bshell_lex_symbol sym);
extern const char *bshell_lex_operator_to_string(enum bshell_lex_operator op);
#endif
@@ -0,0 +1,36 @@
#ifndef BSHELL_RUNTIME_CMDCALL_H_
#define BSHELL_RUNTIME_CMDCALL_H_
#include <fx/macros.h>
#include <fx/value.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_CMDCALL (bshell_cmdcall_get_type())
FX_DECLARE_TYPE(bshell_cmdcall);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_cmdcall)
FX_TYPE_CLASS_DECLARATION_END(bshell_cmdcall)
extern fx_type_id bshell_cmdcall_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(bshell_cmdcall, BSHELL_TYPE_CMDCALL);
extern enum bshell_status bshell_cmdcall_push_arg(
bshell_cmdcall *cmdcall,
fx_value arg);
extern enum bshell_status bshell_cmdcall_resolve(
bshell_cmdcall *cmdcall,
struct bshell_runtime *rt);
extern enum bshell_status bshell_cmdcall_process_record(
bshell_cmdcall *cmdcall,
FX_TYPE_FWDREF(bshell_pipeline) * pipeline,
struct bshell_runtime *rt);
FX_DECLS_END;
#endif
@@ -0,0 +1,82 @@
#ifndef BSHELL_RUNTIME_OPCODE_H_
#define BSHELL_RUNTIME_OPCODE_H_
#include <stdint.h>
#define BSHELL_INSTRUCTION_INVALID 0xFFFFFFFF
typedef uint32_t bshell_instruction;
enum bshell_opcode {
BSHELL_OPCODE_NOP = 0,
BSHELL_OPCODE_LDC_INT,
BSHELL_OPCODE_LDC_STR,
BSHELL_OPCODE_LDC_FP,
BSHELL_OPCODE_LDGLOBAL,
BSHELL_OPCODE_LDLOCAL,
BSHELL_OPCODE_LDBLOCK,
BSHELL_OPCODE_LDENV,
BSHELL_OPCODE_LDSTATIC,
BSHELL_OPCODE_LDARG,
BSHELL_OPCODE_LDPROP,
BSHELL_OPCODE_LDELEM,
BSHELL_OPCODE_LDELEM_C,
BSHELL_OPCODE_STLOCAL,
BSHELL_OPCODE_STPROP,
BSHELL_OPCODE_STELEM,
BSHELL_OPCODE_LDCMD,
BSHELL_OPCODE_PEXEC,
BSHELL_OPCODE_CALL,
BSHELL_OPCODE_MK_STR,
BSHELL_OPCODE_MK_ARRAY,
BSHELL_OPCODE_MK_HTAB,
BSHELL_OPCODE_POP,
BSHELL_OPCODE_ADD,
BSHELL_OPCODE_SUB,
BSHELL_OPCODE_MUL,
BSHELL_OPCODE_DIV,
BSHELL_OPCODE_ADD_IP,
BSHELL_OPCODE_MOD,
BSHELL_OPCODE_INC,
BSHELL_OPCODE_DEC,
BSHELL_OPCODE_SHL,
BSHELL_OPCODE_SHR,
BSHELL_OPCODE_BAND,
BSHELL_OPCODE_BOR,
BSHELL_OPCODE_BXOR,
BSHELL_OPCODE_BNOT,
BSHELL_OPCODE_CMP_NULL,
BSHELL_OPCODE_CMP_EQ,
BSHELL_OPCODE_CMP_NE,
BSHELL_OPCODE_CMP_LT,
BSHELL_OPCODE_CMP_GT,
BSHELL_OPCODE_CMP_LE,
BSHELL_OPCODE_CMP_GE,
BSHELL_OPCODE_LAND,
BSHELL_OPCODE_LOR,
BSHELL_OPCODE_LXOR,
BSHELL_OPCODE_LNOT,
BSHELL_OPCODE_BR,
BSHELL_OPCODE_BR_TRUE,
BSHELL_OPCODE_RANGE,
BSHELL_OPCODE_MATCH,
BSHELL_OPCODE_REPLACE,
BSHELL_OPCODE_LIKE,
BSHELL_OPCODE_IN,
BSHELL_OPCODE_FMT,
BSHELL_OPCODE_CONTAINS,
BSHELL_OPCODE_SPLIT,
BSHELL_OPCODE_JOIN,
BSHELL_OPCODE_IS,
BSHELL_OPCODE_AS,
};
extern bshell_instruction bshell_instruction_encode(
enum bshell_opcode opcode,
uint32_t arg);
extern void bshell_instruction_decode(
bshell_instruction instr,
enum bshell_opcode *out_opcode,
uint32_t *out_arg);
#endif
@@ -0,0 +1,126 @@
#ifndef BSHELL_RUNTIME_OPERATOR_H_
#define BSHELL_RUNTIME_OPERATOR_H_
enum bshell_operator_precedence {
BSHELL_PRECEDENCE_MINIMUM = 0,
BSHELL_PRECEDENCE_ASSIGN,
BSHELL_PRECEDENCE_PIPELINE,
BSHELL_PRECEDENCE_LOGICAL,
BSHELL_PRECEDENCE_BITWISE,
BSHELL_PRECEDENCE_COMPARISON,
BSHELL_PRECEDENCE_ADDITION,
BSHELL_PRECEDENCE_MULTIPLICATION,
BSHELL_PRECEDENCE_NEGATE,
BSHELL_PRECEDENCE_FORMAT,
BSHELL_PRECEDENCE_RANGE,
BSHELL_PRECEDENCE_NOT,
BSHELL_PRECEDENCE_INCREMENT,
BSHELL_PRECEDENCE_ARRAY,
BSHELL_PRECEDENCE_JOIN,
BSHELL_PRECEDENCE_SPLIT,
BSHELL_PRECEDENCE_CAST,
BSHELL_PRECEDENCE_SUBSCRIPT,
BSHELL_PRECEDENCE_STATIC_ACCESS,
BSHELL_PRECEDENCE_MEMBER_ACCESS,
BSHELL_PRECEDENCE_PARENTHESIS,
};
enum bshell_operator_associativity {
BSHELL_ASSOCIATIVITY_LEFT,
BSHELL_ASSOCIATIVITY_RIGHT,
};
enum bshell_operator_location {
BSHELL_OPL_PREFIX,
BSHELL_OPL_INFIX,
BSHELL_OPL_POSTFIX,
};
enum bshell_operator_arity {
BSHELL_OPA_UNARY,
BSHELL_OPA_BINARY,
};
enum bshell_operator_id {
BSHELL_OP_NONE = 0,
BSHELL_OP_ADD,
BSHELL_OP_SUBTRACT,
BSHELL_OP_MULTIPLY,
BSHELL_OP_DIVIDE,
BSHELL_OP_MODULO,
BSHELL_OP_INCREMENT,
BSHELL_OP_DECREMENT,
BSHELL_OP_LEFT_SHIFT,
BSHELL_OP_RIGHT_SHIFT,
BSHELL_OP_BINARY_AND,
BSHELL_OP_BINARY_OR,
BSHELL_OP_BINARY_XOR,
BSHELL_OP_BINARY_NOT,
BSHELL_OP_LESS_THAN,
BSHELL_OP_GREATER_THAN,
BSHELL_OP_EQUAL,
BSHELL_OP_NOT_EQUAL,
BSHELL_OP_LESS_EQUAL,
BSHELL_OP_GREATER_EQUAL,
BSHELL_OP_ASSIGN,
BSHELL_OP_ADD_ASSIGN,
BSHELL_OP_SUBTRACT_ASSIGN,
BSHELL_OP_MULTIPLY_ASSIGN,
BSHELL_OP_DIVIDE_ASSIGN,
BSHELL_OP_MODULO_ASSIGN,
BSHELL_OP_LOGICAL_AND,
BSHELL_OP_LOGICAL_OR,
BSHELL_OP_LOGICAL_XOR,
BSHELL_OP_LOGICAL_NOT,
BSHELL_OP_RANGE,
BSHELL_OP_MATCH,
BSHELL_OP_NOTMATCH,
BSHELL_OP_REPLACE,
BSHELL_OP_LIKE,
BSHELL_OP_NOTLIKE,
BSHELL_OP_IN,
BSHELL_OP_NOTIN,
BSHELL_OP_FORMAT,
BSHELL_OP_CONTAINS,
BSHELL_OP_NOTCONTAINS,
BSHELL_OP_USPLIT,
BSHELL_OP_BSPLIT,
BSHELL_OP_UJOIN,
BSHELL_OP_BJOIN,
BSHELL_OP_IS,
BSHELL_OP_ISNOT,
BSHELL_OP_AS,
BSHELL_OP_SUBSCRIPT,
BSHELL_OP_CONDITIONAL_SUBSCRIPT,
BSHELL_OP_ARRAY_DELIMITER,
BSHELL_OP_ACCESS,
BSHELL_OP_STATIC_ACCESS,
BSHELL_OP_CONDITIONAL_ACCESS,
/* these are not real operators, and are just used internally by the
* parser. */
BSHELL_OP_CAST,
BSHELL_OP_SUBEXPR,
BSHELL_OP_PAREN,
BSHELL_OP_SCRIPTBLOCK,
BSHELL_OP_ARRAY_START,
BSHELL_OP_HASHTABLE_START,
};
struct bshell_operator_info {
enum bshell_operator_id op_id;
enum bshell_operator_precedence op_precedence;
enum bshell_operator_associativity op_associativity;
enum bshell_operator_location op_location;
enum bshell_operator_arity op_arity;
};
extern const struct bshell_operator_info *bshell_operator_get_by_id(
enum bshell_operator_id id);
extern const struct bshell_operator_info *bshell_operator_get_by_token(
unsigned int token);
extern const char *bshell_operator_id_to_string(enum bshell_operator_id op);
#endif
@@ -0,0 +1,49 @@
#ifndef BSHELL_RUNTIME_PIPELINE_H_
#define BSHELL_RUNTIME_PIPELINE_H_
#include "../command/command.h"
#include "../runtime/cmdcall.h"
#include "../status.h"
#include <fx/macros.h>
#include <fx/value.h>
FX_DECLS_BEGIN;
struct bshell_runtime;
#define BSHELL_TYPE_PIPELINE (bshell_pipeline_get_type())
FX_DECLARE_TYPE(bshell_pipeline);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_pipeline)
FX_TYPE_CLASS_DECLARATION_END(bshell_pipeline)
extern fx_type_id bshell_pipeline_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(bshell_pipeline, BSHELL_TYPE_PIPELINE);
extern enum bshell_status bshell_pipeline_add_input_value(
bshell_pipeline *pipeline,
fx_value value,
bool enumerate);
extern enum bshell_status bshell_pipeline_add_cmdcall(
bshell_pipeline *pipeline,
bshell_cmdcall *cmd);
extern enum bshell_status bshell_pipeline_execute_single(
bshell_pipeline *pipeline);
extern enum bshell_status bshell_pipeline_pump_record(
bshell_pipeline *pipeline,
struct bshell_runtime *rt,
fx_value *out,
int *out_end_of_data);
extern fx_value bshell_pipeline_read_value(bshell_pipeline *pipeline);
extern enum bshell_status bshell_pipeline_write_value(
bshell_pipeline *pipeline,
fx_value val,
bool enumerate);
FX_DECLS_END;
#endif
@@ -0,0 +1,52 @@
#ifndef BSHELL_RUNTIME_RUNTIME_H_
#define BSHELL_RUNTIME_RUNTIME_H_
#include <bshell/command/command.h>
#include <bshell/runtime/script-block.h>
#include <bshell/runtime/var.h>
#include <fx/collections/hashtable.h>
#include <fx/queue.h>
#include <fx/value.h>
struct bshell_runtime_scope;
struct bshell_runtime {
struct bshell_runtime_scope *rt_global;
fx_hashtable *rt_aliases;
fx_queue rt_scope;
};
extern struct bshell_runtime *bshell_runtime_create(void);
extern void bshell_runtime_destroy(struct bshell_runtime *rt);
extern fx_value bshell_runtime_eval_global(
struct bshell_runtime *rt,
bshell_scriptblock *block);
extern fx_value bshell_runtime_eval_script(
struct bshell_runtime *rt,
bshell_scriptblock *block);
extern bshell_variable *bshell_runtime_find_var(
struct bshell_runtime *rt,
const char *name);
extern bshell_variable *bshell_runtime_define_var(
struct bshell_runtime *rt,
const char *name);
extern bshell_command *bshell_runtime_find_command(
struct bshell_runtime *rt,
const char *callable_name);
extern enum bshell_status bshell_runtime_push_scope(
struct bshell_runtime *rt,
bshell_scriptblock *block);
extern enum bshell_status bshell_runtime_pop_scope(struct bshell_runtime *rt);
extern fx_value bshell_runtime_eval(struct bshell_runtime *rt);
extern struct bshell_runtime_scope *bshell_runtime_get_current_scope(
struct bshell_runtime *rt);
extern struct bshell_runtime_scope *bshell_runtime_get_parent_scope(
struct bshell_runtime *rt,
struct bshell_runtime_scope *scope);
#endif
@@ -0,0 +1,11 @@
#ifndef BSHELL_RUNTIME_SCOPE_H_
#define BSHELL_RUNTIME_SCOPE_H_
#include <fx/collections/hashtable.h>
struct bshell_runtime_scope;
extern fx_hashtable *bshell_runtime_scope_get_functions(
struct bshell_runtime_scope *scope);
#endif
@@ -0,0 +1,64 @@
#ifndef BSHELL_RUNTIME_SCRIPT_BLOCK_H_
#define BSHELL_RUNTIME_SCRIPT_BLOCK_H_
#include <bshell/runtime/opcode.h>
#include <fx/macros.h>
#include <fx/value.h>
FX_DECLS_BEGIN;
enum bshell_opcode;
#define POOL_INDEX_INVALID ((unsigned long)-1)
#define BSHELL_TYPE_SCRIPTBLOCK (bshell_scriptblock_get_type())
FX_DECLARE_TYPE(bshell_scriptblock);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_scriptblock)
FX_TYPE_CLASS_DECLARATION_END(bshell_scriptblock)
extern fx_type_id bshell_scriptblock_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(bshell_scriptblock, BSHELL_TYPE_SCRIPTBLOCK);
extern size_t bshell_scriptblock_push_instruction(
bshell_scriptblock *block,
enum bshell_opcode opcode,
uint32_t arg);
extern enum bshell_status bshell_scriptblock_read_instruction(
bshell_scriptblock *block,
size_t offset,
enum bshell_opcode *out_opcode,
uint32_t *out_arg);
extern void bshell_scriptblock_patch_instruction(
bshell_scriptblock *block,
size_t offset,
enum bshell_opcode opcode,
uint32_t arg);
extern void bshell_scriptblock_clear_text(bshell_scriptblock *block);
extern void bshell_scriptblock_get_text(
const bshell_scriptblock *block,
bshell_instruction **out_ptr,
size_t *out_count);
extern void bshell_scriptblock_get_pool(
const bshell_scriptblock *block,
fx_value **out_ptr,
size_t *out_count);
extern unsigned long bshell_scriptblock_add_pool_value(
bshell_scriptblock *block,
fx_value *value);
extern fx_value *bshell_scriptblock_get_pool_value(
const bshell_scriptblock *block,
unsigned long index,
fx_type_id expected_type);
extern unsigned long bshell_scriptblock_get_string(
bshell_scriptblock *block,
const char *s);
extern unsigned long bshell_scriptblock_get_double(
bshell_scriptblock *block,
double v);
FX_DECLS_END;
#endif
@@ -0,0 +1,26 @@
#ifndef BSHELL_RUNTIME_VAR_H_
#define BSHELL_RUNTIME_VAR_H_
#include <fx/macros.h>
#include <fx/value.h>
FX_DECLS_BEGIN;
#define BSHELL_TYPE_VARIABLE (bshell_variable_get_type())
FX_DECLARE_TYPE(bshell_variable);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_variable)
FX_TYPE_CLASS_DECLARATION_END(bshell_variable)
extern fx_type_id bshell_variable_get_type(void);
extern bshell_variable *bshell_variable_create(const char *name);
extern const char *bshell_variable_get_name(const bshell_variable *var);
extern const fx_value *bshell_variable_get_value(const bshell_variable *var);
extern void bshell_variable_set_value(bshell_variable *var, fx_value *value);
FX_DECLS_END;
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef BSHELL_STATUS_H_
#define BSHELL_STATUS_H_
enum bshell_status {
BSHELL_SUCCESS = 0,
BSHELL_ERR_EOF,
BSHELL_ERR_BAD_SYNTAX,
BSHELL_ERR_BAD_FORMAT,
BSHELL_ERR_BAD_STATE,
BSHELL_ERR_INVALID_VALUE,
BSHELL_ERR_INVALID_ARGUMENT,
BSHELL_ERR_NO_MEMORY,
BSHELL_ERR_NO_ENTRY,
BSHELL_ERR_NO_DATA,
BSHELL_ERR_NAME_EXISTS,
BSHELL_ERR_NOT_SUPPORTED,
BSHELL_ERR_IO_FAILURE,
BSHELL_ERR_ACCESS_DENIED,
BSHELL_ERR_INTERNAL_FAILURE,
};
extern enum bshell_status bshell_status_from_errno(int err);
#endif
+144
View File
@@ -0,0 +1,144 @@
#ifndef BSHELL_VERB_H_
#define BSHELL_VERB_H_
#include <fx/collections/hashtable.h>
#include <fx/macros.h>
FX_DECLS_BEGIN;
#define BSHELL_TYPE_VERB (bshell_verb_get_type())
enum bshell_verb_id {
BSHELL_VERB_NONE = 0,
BSHELL_VERB_ADD,
BSHELL_VERB_CLEAR,
BSHELL_VERB_CLOSE,
BSHELL_VERB_COPY,
BSHELL_VERB_ENTER,
BSHELL_VERB_EXIT,
BSHELL_VERB_FIND,
BSHELL_VERB_FORMAT,
BSHELL_VERB_GET,
BSHELL_VERB_HIDE,
BSHELL_VERB_JOIN,
BSHELL_VERB_LOCK,
BSHELL_VERB_MOVE,
BSHELL_VERB_NEW,
BSHELL_VERB_OPEN,
BSHELL_VERB_OPTIMIZE,
BSHELL_VERB_PUSH,
BSHELL_VERB_POP,
BSHELL_VERB_REDO,
BSHELL_VERB_REMOVE,
BSHELL_VERB_RENAME,
BSHELL_VERB_RESET,
BSHELL_VERB_RESIZE,
BSHELL_VERB_SEARCH,
BSHELL_VERB_SELECT,
BSHELL_VERB_SET,
BSHELL_VERB_SHOW,
BSHELL_VERB_SKIP,
BSHELL_VERB_SPLIT,
BSHELL_VERB_STEP,
BSHELL_VERB_SWITCH,
BSHELL_VERB_UNDO,
BSHELL_VERB_UNLOCK,
BSHELL_VERB_WATCH,
BSHELL_VERB_CONNECT,
BSHELL_VERB_DISCONNECT,
BSHELL_VERB_READ,
BSHELL_VERB_RECEIVE,
BSHELL_VERB_SEND,
BSHELL_VERB_WRITE,
BSHELL_VERB_BACKUP,
BSHELL_VERB_CHECKPOINT,
BSHELL_VERB_COMPARE,
BSHELL_VERB_COMPRESS,
BSHELL_VERB_CONVERT,
BSHELL_VERB_CONVERTFROM,
BSHELL_VERB_CONVERTTO,
BSHELL_VERB_DISMOUNT,
BSHELL_VERB_EDIT,
BSHELL_VERB_EXPAND,
BSHELL_VERB_EXPORT,
BSHELL_VERB_GROUP,
BSHELL_VERB_IMPORT,
BSHELL_VERB_INITIALIZE,
BSHELL_VERB_LIMIT,
BSHELL_VERB_MERGE,
BSHELL_VERB_MOUNT,
BSHELL_VERB_OUT,
BSHELL_VERB_PUBLISH,
BSHELL_VERB_RESTORE,
BSHELL_VERB_SAVE,
BSHELL_VERB_SYNC,
BSHELL_VERB_UNPUBLISH,
BSHELL_VERB_UPDATE,
BSHELL_VERB_DEBUG,
BSHELL_VERB_MEASURE,
BSHELL_VERB_REPAIR,
BSHELL_VERB_RESOLVE,
BSHELL_VERB_TEST,
BSHELL_VERB_TRACE,
BSHELL_VERB_APPROVE,
BSHELL_VERB_ASSERT,
BSHELL_VERB_BUILD,
BSHELL_VERB_COMPLETE,
BSHELL_VERB_CONFIRM,
BSHELL_VERB_DENY,
BSHELL_VERB_DEPLOY,
BSHELL_VERB_DISABLE,
BSHELL_VERB_ENABLE,
BSHELL_VERB_INSTALL,
BSHELL_VERB_INVOKE,
BSHELL_VERB_REGISTER,
BSHELL_VERB_REQUEST,
BSHELL_VERB_RESTART,
BSHELL_VERB_RESUME,
BSHELL_VERB_START,
BSHELL_VERB_STOP,
BSHELL_VERB_SUBMIT,
BSHELL_VERB_SUSPEND,
BSHELL_VERB_UNINSTALL,
BSHELL_VERB_UNREGISTER,
BSHELL_VERB_WAIT,
BSHELL_VERB_USE,
BSHELL_VERB_BLOCK,
BSHELL_VERB_GRANT,
BSHELL_VERB_PROTECT,
BSHELL_VERB_REVOKE,
BSHELL_VERB_UNBLOCK,
BSHELL_VERB_UNPROTECT,
/* reserved verbs */
BSHELL_VERB_FOREACH,
BSHELL_VERB_PING,
BSHELL_VERB_SORT,
BSHELL_VERB_TEE,
BSHELL_VERB_WHERE,
__BSHELL_VERB_MAX,
};
FX_DECLARE_TYPE(bshell_verb);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_verb)
FX_TYPE_CLASS_DECLARATION_END(bshell_verb)
extern enum bshell_status bshell_init_all_verbs(void);
extern fx_hashtable *bshell_get_all_verbs(void);
extern bshell_verb *bshell_verb_get_by_id(enum bshell_verb_id id);
extern bshell_verb *bshell_verb_get_by_name(const char *name);
extern fx_type_id bshell_verb_get_type(void);
extern bshell_verb *bshell_verb_create(
enum bshell_verb_id id,
const char *name,
const char *alias_prefix,
const char *group,
const char *description);
extern bool bshell_verb_is_reserved(const bshell_verb *verb);
extern enum bshell_verb_id bshell_verb_get_id(const bshell_verb *verb);
extern const char *bshell_verb_get_name(const bshell_verb *verb);
#endif