2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>

Script fixes

	* include/grub/script_sh.h (grub_script_cmdline): remove cmdline
	(grub_lexer_param): add tokenonhold
	(grub_script_create_cmdline): remove cmdline. All callers updated
	(grub_script_function_create): make functionname
	grub_script_arg. All callers updated
	(grub_script_execute_argument_to_string): new prototype
	* kern/parser.c (state_transitions): reorder
	(grub_parser_cmdline_state): fix a bug and make more compact
	* script/sh/execute.c (grub_script_execute_argument_to_string): 
	make global
	(grub_script_execute_cmdline): use new format
	* script/sh/function.c (grub_script_function_create): make functionname
	grub_script_arg. All callers updated
	* script/sh/lexer.c (grub_script_lexer_init): initilaize tokenonhold
	(grub_script_yylex): remove
	(grub_script_yylex2): renamed to ...
	(grub_script_yylex): ...renamed
	parse the expressions like a${b}c
	* script/sh/parser.y (GRUB_PARSER_TOKEN_ARG): new typed terminal
	(GRUB_PARSER_TOKEN_VAR): remove
	(GRUB_PARSER_TOKEN_NAME): likewise
	("if"): declare as typeless
	("while"): likewise
	("function"): likewise
	("else"): likewise
	("then"): likewise
	("fi"): likewise
	(text): remove
	(argument): likewise
	(script): accept empty scripts and make exit on error
	(arguments): use GRUB_PARSER_TOKEN_ARG
	(function): likewise
	(command): move error handling to script
	(menuentry): move grub_script_lexer_ref before
	* script/sh/script.c (grub_script_create_cmdline): remove cmdline 
	argument. All callers updated
This commit is contained in:
phcoder 2009-06-04 16:18:35 +00:00
parent f4448a0792
commit fda6cb987f
8 changed files with 304 additions and 280 deletions

View file

@ -77,11 +77,6 @@ struct grub_script_cmdline
/* The arguments for this command. */
struct grub_script_arglist *arglist;
/* The command name of this command. XXX: Perhaps an argument
should be used for this so we can use variables as command
name. */
char *cmdname;
};
/* A block of commands, this can be used to group commands. */
@ -161,6 +156,9 @@ struct grub_lexer_param
/* Size of RECORDING. */
int recordlen;
/* The token that is already parsed but not yet returned. */
int tokenonhold;
};
/* State of the parser as passes to the parser. */
@ -191,7 +189,6 @@ grub_script_add_arglist (struct grub_parser_param *state,
struct grub_script_arg *arg);
struct grub_script_cmd *
grub_script_create_cmdline (struct grub_parser_param *state,
char *cmdname,
struct grub_script_arglist *arglist);
struct grub_script_cmd *
grub_script_create_cmdblock (struct grub_parser_param *state);
@ -276,7 +273,7 @@ struct grub_script_function
};
typedef struct grub_script_function *grub_script_function_t;
grub_script_function_t grub_script_function_create (char *functionname,
grub_script_function_t grub_script_function_create (struct grub_script_arg *functionname,
struct grub_script *cmd);
void grub_script_function_remove (const char *name);
grub_script_function_t grub_script_function_find (char *functionname);
@ -284,4 +281,7 @@ int grub_script_function_iterate (int (*iterate) (grub_script_function_t));
int grub_script_function_call (grub_script_function_t func,
int argc, char **args);
char *
grub_script_execute_argument_to_string (struct grub_script_arg *arg);
#endif /* ! GRUB_NORMAL_PARSER_HEADER */