Elif support to GRUB script (by Deepak Vankadaru).
* tests/grub_script_if.in: New testcase. * conf/tests.rmk: Rule for new testcase. * script/parser.y: Grammar rules for elif.
This commit is contained in:
commit
7d65244782
4 changed files with 67 additions and 12 deletions
|
@ -1,3 +1,11 @@
|
|||
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
Elif support to GRUB script (by Deepak Vankadaru).
|
||||
|
||||
* tests/grub_script_if.in: New testcase.
|
||||
* conf/tests.rmk: Rule for new testcase.
|
||||
* script/parser.y: Grammar rules for elif.
|
||||
|
||||
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
While and until loops support to GRUB script.
|
||||
|
|
|
@ -56,6 +56,9 @@ grub_script_for1_SOURCES = tests/grub_script_for1.in
|
|||
check_SCRIPTS += grub_script_while1
|
||||
grub_script_while1_SOURCES = tests/grub_script_while1.in
|
||||
|
||||
check_SCRIPTS += grub_script_if
|
||||
grub_script_if_SOURCES = tests/grub_script_if.in
|
||||
|
||||
check_SCRIPTS += grub_script_blanklines
|
||||
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
||||
|
||||
|
@ -73,9 +76,11 @@ SCRIPTED_TESTS += grub_script_echo_keywords
|
|||
SCRIPTED_TESTS += grub_script_vars1
|
||||
SCRIPTED_TESTS += grub_script_for1
|
||||
SCRIPTED_TESTS += grub_script_while1
|
||||
SCRIPTED_TESTS += grub_script_if
|
||||
SCRIPTED_TESTS += grub_script_blanklines
|
||||
SCRIPTED_TESTS += grub_script_final_semicolon
|
||||
|
||||
|
||||
# dependencies between tests and testing-tools
|
||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
||||
$(FUNCTIONAL_TESTS): functional_test.mod
|
||||
|
|
|
@ -74,8 +74,9 @@
|
|||
%token <arg> GRUB_PARSER_TOKEN_WORD "word"
|
||||
|
||||
%type <arglist> word argument arguments0 arguments1
|
||||
|
||||
%type <cmd> script_init script
|
||||
%type <cmd> grubcmd ifcmd forcmd whilecmd untilcmd
|
||||
%type <cmd> grubcmd ifclause ifcmd forcmd whilecmd untilcmd
|
||||
%type <cmd> command commands1 menuentry statement
|
||||
|
||||
%pure-parser
|
||||
|
@ -227,18 +228,28 @@ menuentry: "menuentry"
|
|||
}
|
||||
;
|
||||
|
||||
if: "if" { grub_script_lexer_ref (state->lexerstate); }
|
||||
ifcmd: "if"
|
||||
{
|
||||
grub_script_lexer_ref (state->lexerstate);
|
||||
}
|
||||
ifclause "fi"
|
||||
{
|
||||
$$ = $3;
|
||||
grub_script_lexer_deref (state->lexerstate);
|
||||
}
|
||||
;
|
||||
ifcmd: if commands1 delimiters1 "then" commands1 delimiters1 "fi"
|
||||
{
|
||||
$$ = grub_script_create_cmdif (state, $2, $5, 0);
|
||||
grub_script_lexer_deref (state->lexerstate);
|
||||
}
|
||||
| if commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1 "fi"
|
||||
{
|
||||
$$ = grub_script_create_cmdif (state, $2, $5, $8);
|
||||
grub_script_lexer_deref (state->lexerstate);
|
||||
}
|
||||
ifclause: commands1 delimiters1 "then" commands1 delimiters1
|
||||
{
|
||||
$$ = grub_script_create_cmdif (state, $1, $4, 0);
|
||||
}
|
||||
| commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1
|
||||
{
|
||||
$$ = grub_script_create_cmdif (state, $1, $4, $7);
|
||||
}
|
||||
| commands1 delimiters1 "then" commands1 delimiters1 "elif" ifclause
|
||||
{
|
||||
$$ = grub_script_create_cmdif (state, $1, $4, $7);
|
||||
}
|
||||
;
|
||||
|
||||
forcmd: "for" "name"
|
||||
|
|
31
tests/grub_script_if.in
Normal file
31
tests/grub_script_if.in
Normal file
|
@ -0,0 +1,31 @@
|
|||
#! @builddir@/grub-shell-tester
|
||||
|
||||
#basic if, execute
|
||||
if true; then echo yes; fi
|
||||
|
||||
#basic if, no execution
|
||||
if false; then echo no; fi
|
||||
|
||||
#if else, execute if path
|
||||
if true; then echo yes; else echo no; fi
|
||||
|
||||
#if else, execute else path
|
||||
if false; then echo no; else echo yes; fi
|
||||
|
||||
#if elif, execute elif
|
||||
if false; then echo no; elif true; then echo yes; fi
|
||||
|
||||
#if elif else, execute else
|
||||
if false; then echo no; elif false; then echo no; else echo yes; fi
|
||||
|
||||
#if elif(1) elif(2), execute elif(2)
|
||||
if false; then echo no; elif false; then echo no; elif true; then echo yes; fi
|
||||
|
||||
#if elif(1) elif(2) else, execute else
|
||||
if false; then echo no; elif false; then echo no; elif false; then echo no; else echo yes; fi
|
||||
|
||||
#if {if elif else}, execute elif
|
||||
if true; then if false; then echo no; elif true; then echo yes; else echo no; fi; fi
|
||||
|
||||
#if {if elif} else, execute elif. ofcourse no dangling-else problem due to "fi"
|
||||
if true; then if false; then echo no; elif true; then echo yes; fi; else echo no; fi
|
Loading…
Reference in a new issue