diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index e1bf6f22e..9eccb9028 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -61,7 +61,7 @@ struct grub_script_arg char *str; /* Parsed block argument. */ - struct grub_script_cmd *block; + struct grub_script block; /* Next argument part. */ struct grub_script_arg *next; diff --git a/script/parser.y b/script/parser.y index 9d256a153..6669b783c 100644 --- a/script/parser.y +++ b/script/parser.y @@ -33,7 +33,10 @@ struct grub_script_arglist *arglist; struct grub_script_arg *arg; char *string; - unsigned offset; + struct { + unsigned offset; + struct grub_script_mem *memory; + }; } %token GRUB_PARSER_TOKEN_BAD @@ -147,24 +150,30 @@ argument : "case" { $$ = grub_script_add_arglist (state, 0, $1); } | word { $$ = $1; } ; -block: "{" +block: "{" { grub_script_lexer_ref (state->lexerstate); $$ = grub_script_lexer_record_start (state); + $$ = grub_script_mem_record (state); } commands1 delimiters0 "}" { char *p; struct grub_script_arg *arg; + struct grub_script_mem *memory; - grub_script_lexer_deref (state->lexerstate); - if (p = grub_script_lexer_record_stop (state, $2)) + memory = grub_script_mem_record_stop (state, $2); + if ((p = grub_script_lexer_record_stop (state, $2))) *grub_strrchr (p, '}') = '\0'; if (arg = grub_script_arg_add (state, 0, GRUB_SCRIPT_ARG_TYPE_BLOCK, p)) - arg->block = $3; + { + arg->block.cmd = $3; + arg->block.mem = memory; + } $$ = grub_script_add_arglist (state, 0, arg); + grub_script_lexer_deref (state->lexerstate); } ;