From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EJV5s-0004z4-UX for mharc-grub-devel@gnu.org; Sun, 25 Sep 2005 07:55:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EJV5q-0004yv-RY for grub-devel@gnu.org; Sun, 25 Sep 2005 07:54:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EJV5o-0004yj-ME for grub-devel@gnu.org; Sun, 25 Sep 2005 07:54:54 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EJV5L-0004Yx-VO for grub-devel@gnu.org; Sun, 25 Sep 2005 07:54:24 -0400 Received: from [66.249.82.192] (helo=xproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EJUs5-0001e9-KU for grub-devel@gnu.org; Sun, 25 Sep 2005 07:40:41 -0400 Received: by xproxy.gmail.com with SMTP id i29so442064wxd for ; Sun, 25 Sep 2005 04:40:40 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:disposition-notification-to:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=hEOTfWo8gC56uTvIlzwVS+gSyFzt4Hap+0Fqjtl457HWh/mo0Fw2+eeMCEqozP1TVgTAWgTU5pxfZa3qz0kPRhZunQ3B43ImsS+HG6mfl6fZri48Lk/9UEssEIS/q/OEMn24cXqqIv5Axe39YIhNZ6LcEssS77TxIu7/pp5H72Y= Received: by 10.70.91.18 with SMTP id o18mr1848835wxb; Sun, 25 Sep 2005 04:40:40 -0700 (PDT) Received: from ?192.168.1.100? ( [81.62.14.77]) by mx.gmail.com with ESMTP id i20sm2184975wxd.2005.09.25.04.40.38; Sun, 25 Sep 2005 04:40:39 -0700 (PDT) Message-ID: <43368CB4.6050806@gmail.com> Date: Sun, 25 Sep 2005 13:40:36 +0200 From: Vladimir Serbinenko User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <42FF0C53.1070601@gmail.com> <87vf27xfsq.fsf@student.han.nl> <430C3FA4.308@gmail.com> <200508281455.32569.okuji@enbug.org> In-Reply-To: <200508281455.32569.okuji@enbug.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Patch] Scripting engine X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Sep 2005 11:54:55 -0000 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 html? >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. Vladimir ------------------------------------------------------------------ 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_FORIN - used for for..in.. 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. for...in: 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 SEMICOLON: ';' 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 for..in) 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.