int until;
};
-/* A menu entry generate statement. */
-struct grub_script_cmd_menuentry
-{
- struct grub_script_cmd cmd;
-
- /* The arguments for this menu entry. */
- struct grub_script_arglist *arglist;
-
- /* The sourcecode the entry will be generated from. */
- const char *sourcecode;
-
- /* Options. XXX: Not used yet. */
- int options;
-};
-
/* State of the lexer as passed to the lexer. */
struct grub_lexer_param
{
struct grub_script_cmd *list,
int is_an_until_loop);
-struct grub_script_cmd *
-grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arglist *arglist,
- char *sourcecode,
- int options);
-
struct grub_script_cmd *
grub_script_append_cmd (struct grub_parser_param *state,
struct grub_script_cmd *list,
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
-grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
/* Execute any GRUB pre-parsed command or script. */
grub_err_t grub_script_execute (struct grub_script *script);
return result;
}
-/* Execute the menu entry generate statement. */
-grub_err_t
-grub_script_execute_menuentry (struct grub_script_cmd *cmd)
-{
- struct grub_script_cmd_menuentry *cmd_menuentry;
- struct grub_script_argv argv = { 0, 0, 0 };
-
- cmd_menuentry = (struct grub_script_cmd_menuentry *) cmd;
-
- if (cmd_menuentry->arglist)
- {
- if (grub_script_arglist_to_argv (cmd_menuentry->arglist, &argv))
- return grub_errno;
- }
-
- grub_normal_add_menu_entry (argv.argc, (const char **) argv.args,
- cmd_menuentry->sourcecode);
-
- grub_script_argv_free (&argv);
-
- return grub_errno;
-}
-
-
-
/* Execute any GRUB pre-parsed command or script. */
grub_err_t
grub_script_execute (struct grub_script *script)
%token <arg> GRUB_PARSER_TOKEN_WHILE "while"
%token <arg> GRUB_PARSER_TOKEN_TIME "time"
%token <arg> GRUB_PARSER_TOKEN_FUNCTION "function"
-%token <arg> GRUB_PARSER_TOKEN_MENUENTRY "menuentry"
%token <arg> GRUB_PARSER_TOKEN_NAME "name"
%token <arg> GRUB_PARSER_TOKEN_WORD "word"
%type <cmd> script_init script
%type <cmd> grubcmd ifclause ifcmd forcmd whilecmd untilcmd
-%type <cmd> command commands1 menuentry statement
+%type <cmd> command commands1 statement
%pure-parser
%lex-param { struct grub_parser_param *state };
statement: command { $$ = $1; }
| function { $$ = 0; }
- | menuentry { $$ = $1; }
-
+;
argument : "case" { $$ = grub_script_add_arglist (state, 0, $1); }
| "do" { $$ = grub_script_add_arglist (state, 0, $1); }
| "done" { $$ = grub_script_add_arglist (state, 0, $1); }
| "until" { $$ = grub_script_add_arglist (state, 0, $1); }
| "while" { $$ = grub_script_add_arglist (state, 0, $1); }
| "function" { $$ = grub_script_add_arglist (state, 0, $1); }
- | "menuentry" { $$ = grub_script_add_arglist (state, 0, $1); }
| word { $$ = $1; }
;
}
;
-menuentry: "menuentry"
- {
- grub_script_lexer_ref (state->lexerstate);
- }
- arguments1
- {
- $<offset>$ = grub_script_lexer_record_start (state);
- }
- delimiters0 "{" commands1 delimiters1 "}"
- {
- char *def;
- def = grub_script_lexer_record_stop (state, $<offset>4);
- *grub_strrchr(def, '}') = '\0';
-
- grub_script_lexer_deref (state->lexerstate);
- $$ = grub_script_create_cmdmenu (state, $3, def, 0);
- }
-;
-
ifcmd: "if"
{
grub_script_lexer_ref (state->lexerstate);
return (struct grub_script_cmd *) cmd;
}
-/* Create a command that adds a menu entry to the menu. Title is an
- argument that is parsed to generate a string that can be used as
- the title. The sourcecode for this entry is passed in SOURCECODE.
- The options for this entry are passed in OPTIONS. */
-struct grub_script_cmd *
-grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arglist *arglist,
- char *sourcecode, int options)
-{
- struct grub_script_cmd_menuentry *cmd;
-
- cmd = grub_script_malloc (state, sizeof (*cmd));
- if (!cmd)
- return 0;
-
- cmd->cmd.exec = grub_script_execute_menuentry;
- cmd->cmd.next = 0;
- cmd->sourcecode = sourcecode;
- cmd->arglist = arglist;
- cmd->options = options;
-
- return (struct grub_script_cmd *) cmd;
-}
-
/* Create a chain of commands. LAST contains the command that should
be added at the end of LIST's list. If LIST is zero, a new list
will be created. */
"until" { RECORD; return GRUB_PARSER_TOKEN_UNTIL; }
"while" { RECORD; return GRUB_PARSER_TOKEN_WHILE; }
"function" { RECORD; return GRUB_PARSER_TOKEN_FUNCTION; }
-"menuentry" { RECORD; return GRUB_PARSER_TOKEN_MENUENTRY; }
{NAME} { RECORD; return GRUB_PARSER_TOKEN_NAME; }
{WORD} {
return 0;
}
-grub_err_t
-grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
-{
- return 0;
-}
-
grub_err_t
grub_script_execute (struct grub_script *script)
{