From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1ETKdj-0006sQ-9x for mharc-grub-devel@gnu.org; Sat, 22 Oct 2005 10:46:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ETKdh-0006sF-Ci for grub-devel@gnu.org; Sat, 22 Oct 2005 10:46:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ETKdf-0006s3-TM for grub-devel@gnu.org; Sat, 22 Oct 2005 10:46:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ETKdf-0006s0-PO for grub-devel@gnu.org; Sat, 22 Oct 2005 10:46:27 -0400 Received: from [64.233.184.198] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ETKdf-0007rj-BY for grub-devel@gnu.org; Sat, 22 Oct 2005 10:46:27 -0400 Received: by wproxy.gmail.com with SMTP id 71so369466wri for ; Sat, 22 Oct 2005 07:46:25 -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=g3puPoAon7g5aUeKndtLSkxLwMKOmcuf88IOwSWo4/5dWg+dCmrh6N1+kmSx2/vMkWVdPSijXcD3Is7QcIMhUpyK0haYjAdwbi2V+cljfa7CW+dUpDp/wDafPxVCeYBDldhdlXVZokDfJkMxthbmeMgDdusDV28w9vxzAg8VU3E= Received: by 10.54.144.3 with SMTP id r3mr2133447wrd; Sat, 22 Oct 2005 07:46:25 -0700 (PDT) Received: from ?192.168.1.100? ( [83.76.227.245]) by mx.gmail.com with ESMTP id 9sm7959458wrl.2005.10.22.07.46.24; Sat, 22 Oct 2005 07:46:25 -0700 (PDT) Message-ID: <435A50BE.5030801@gmail.com> Date: Sat, 22 Oct 2005 16:46:22 +0200 From: Vladimir Serbinenko User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050804) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <87pspxtzyu.fsf@student.han.nl> In-Reply-To: <87pspxtzyu.fsf@student.han.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Scripting support 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: Sat, 22 Oct 2005 14:46:29 -0000 Marco Gerards wrote: >Hi, > >Last days I have been thinking about scripting support. With my last >patch it should be easy to implement. I hope Vladimir is still >interested in this. > > Yes. Exactly now I'm on holiday so I have a lot of time. And also I have some ideas for some new GRUB features but theese features aren't useful without scripting so I'm interested more than ever. >The most important is the general design. I think we shouldn't put >too much in the core and not even in normal mode. This is the same >approach bash has taken. I think the core functionality should be: > >- variables (we have that) >- functions > Functions should work *exactly* like normal GRUB commands. In > that case we can easily mix GRUB commands and functions. > > In bash when you define a function it appears under environment variables. IMHO it's useless to store completely the source code as an environment variables. I propose that the functions will be preparsed (converted to internal format ready for execution) because it will gretelya simplify lexer and parser >- Return values > All commands should be able to return a value. That's also what > bash has. This value can be stored in a variable or simply > returned, I am not too sure about that. Just check what bash > does. > > Could it be merged with error variable. It's what bash does >- Conditional statements like if and case >- loops: until, while and for > > > I propose the following argorithm. Bison parser transforms the text-form to internal form of a linked list of commands with some special commands like jump if last value was true, ... . Think about assembler. Then it's executed by simple engine that works like CPU: it takes one command from a linked list. Executes it and changes the pointer so it points to the next command. A command is a structure containing: variable showing it's type (normal command, jump, loop, end of loop, ...) union of data necessary for necessary commands pointer to next command. I made a simple example I posted as preview version of scripting engine and I also posted on this list simple design doc. Any ideas are welcome. Vladimir 'phcoder' Serbinenko