diff --git a/bshell/parse/syntax/generic.c b/bshell/parse/syntax/generic.c index 2eda2ef..27125d2 100644 --- a/bshell/parse/syntax/generic.c +++ b/bshell/parse/syntax/generic.c @@ -126,6 +126,36 @@ bool parse_keyword(struct parse_ctx *ctx, enum token_keyword kw) return true; } +bool parse_word(struct parse_ctx *ctx, struct lex_token **out) +{ + struct lex_token *tok = peek_token(ctx); + if (!tok) { + return false; + } + + if (tok->tok_type != TOK_WORD) { + return false; + } + + *out = claim_token(ctx); + return true; +} + +bool parse_var(struct parse_ctx *ctx, struct lex_token **out) +{ + struct lex_token *tok = peek_token(ctx); + if (!tok) { + return false; + } + + if (tok->tok_type != TOK_VAR) { + return false; + } + + *out = claim_token(ctx); + return true; +} + bool parse_int(struct parse_ctx *ctx, long long *out) { struct lex_token *tok = peek_token(ctx);