runtime: lex: fix incorrect state-transition when scanning func keyword

This commit is contained in:
2026-06-20 15:06:04 +01:00
parent 907e0c1832
commit 4e6493da58
2 changed files with 10 additions and 4 deletions
+3 -2
View File
@@ -188,10 +188,11 @@ enum bshell_status command_pump_token(struct bshell_lex_ctx *ctx)
const struct bshell_lex_state_link links[] = {
LINK_PUSH(BSHELL_SYM_DQUOTE, BSHELL_LEX_STATE_STRING, 0),
LINK_PUSH(
LINK_PUSH_WITH_TERM(
BSHELL_SYM_LEFT_PAREN,
BSHELL_LEX_STATE_STATEMENT,
STATEMENT_F_DISABLE_KEYWORDS),
STATEMENT_F_DISABLE_KEYWORDS,
BSHELL_SYM_RIGHT_PAREN),
LINK_PUSH(BSHELL_SYM_DOLLAR_LEFT_PAREN, BSHELL_LEX_STATE_STATEMENT, 0),
LINK_POP(BSHELL_SYM_RIGHT_PAREN),
LINK_POP(BSHELL_SYM_RIGHT_BRACE),
+7 -2
View File
@@ -142,7 +142,8 @@ static enum bshell_status statement_pump_token(struct bshell_lex_ctx *ctx)
}
if (newline) {
struct bshell_lex_token *tok = bshell_lex_token_create(BSHELL_TOK_LINEFEED);
struct bshell_lex_token *tok
= bshell_lex_token_create(BSHELL_TOK_LINEFEED);
enqueue_token(ctx, tok);
handle_lex_state_transition(ctx, BSHELL_TOK_LINEFEED);
return BSHELL_SUCCESS;
@@ -203,7 +204,11 @@ static const struct bshell_lex_state_link links[] = {
BSHELL_SYM_RIGHT_PAREN),
/* command tokens */
LINK_CHANGE(BSHELL_KW_FUNC, BSHELL_LEX_STATE_COMMAND),
LINK_PUSH_WITH_TERM(
BSHELL_KW_FUNC,
BSHELL_LEX_STATE_COMMAND,
0,
BSHELL_SYM_RIGHT_BRACE),
LINK_CHANGE(BSHELL_SYM_AMPERSAND, BSHELL_LEX_STATE_COMMAND),
LINK_CHANGE(BSHELL_TOK_WORD, BSHELL_LEX_STATE_COMMAND),
LINK_END,