[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] Scripting engine

From: Vladimir Serbinenko
Subject: Re: [Patch] Scripting engine
Date: Sun, 25 Sep 2005 13:40:36 +0200
User-agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)

Unfortunately I haven't had a lot of time to work with GRUB2. I'll have
some more when my holidays begin in mid October.

Yoshinori K. Okuji wrote:

>I'd like to see a kind of "design document", since it is a bit hard for others 
>to understand.
Ok. I send one with this mail. Perhaps it would be good to add a folder for
developpement docs and standartisize the format. What about /devdocs and

>We must wait until your assignment is finished. How is it going?

It's strange. It's already a month that I sent my assignment and I've
still nothing received.


The scripting engine is separated into 2 parts: parser and executer.
Parser is wirtten with bison using hand-written yylex. It transforms one
command into grub_script_commandlist. This structure represents a chain
of commands in the form of linked list. Every single command is
represented by grub_script_command. Which has the following fields:
enum grub_script_command_type type
which indicates what command it is:
GRUB_SCRIPT_COMMAND_NORMAL - just a non-scripting command
GRUB_SCRIPT_COMMAND_LOOKUP - used for block-end keyword like done, fi
indicating to interpreter to relaunch or end the loop
enum grub_script_command_chain
which indicates how this command is linked with previous: independent,
with && or with ||.
flags: command flags. Now only GRUB_SCRIPT_COMMAND_FLAG_NOT (command was
with !) is defined.
non-scripting command:
struct grub_script_superchars *normal - a non-scripting command to execute.
struct grub_script_superchars *var - a variable to set
struct grub_script_superchars *vals - the values to set to var
struct grub_script_commandlist *lookup - where the end of loop is.

grub_script_sueprchar is used to store the strings. char * is
unappropriated because value of the string is unknown at parsing time.
it's separated in chunks which are represented in linked list. There are
4 types of chunks: plain (just a string), variable ($var), arithmethic
($((expression)))  and command (`cmd` or $(cmd)) to transform to char* 
superchartostring is used.

grub_script_superchars is used to store array of strings like command
with arguments a variable list. supercharstostrings is used to transform
to char**

terminal tokens:
ENTER: '\n'
FOR: "for" keyword
IN: "in" keyword
DO: "do" keyword
DONE: "done" keyword
NOP: not used
WORD: any word, that is not a keyword. Represented like superchars
OR: "||" keyword
AND: "&&" keyword
NOT: '!' keyword

other symbols
out: output
commandlist  : list of commands
arglist : list of words (like not scripting command with arguments or
vallist for
command :
execlist : list of inter-linked (by || or &&) commands

pre_command : solitary command that waits for ||, &&, ; or newline
cmdend: end of execlist (; or newline)

I hope that this small design document will help. All propositions and
questions are welcome.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]