From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EWFgF-0003nn-Ke for mharc-grub-devel@gnu.org; Sun, 30 Oct 2005 11:05:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EWFgA-0003mj-Vr for grub-devel@gnu.org; Sun, 30 Oct 2005 11:05:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EWFg8-0003lx-9y for grub-devel@gnu.org; Sun, 30 Oct 2005 11:05:05 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWFg6-0003lJ-MC for grub-devel@gnu.org; Sun, 30 Oct 2005 11:05:02 -0500 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EWFg6-00067h-9p for grub-devel@gnu.org; Sun, 30 Oct 2005 11:05:02 -0500 Received: from vscan-cn.han.nl (venus.han.nl [145.74.65.6]) by mail-cn.han.nl (Postfix) with ESMTP id C23888AFC for ; Sun, 30 Oct 2005 17:05:01 +0100 (CET) Received: from mail-cn.han.nl ([145.74.66.11]) by vscan-cn.han.nl (venus.han.nl [145.74.65.6]) (amavisd-new, port 10024) with ESMTP id 15094-01 for ; Sun, 30 Oct 2005 17:05:01 +0100 (CET) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id 13BF98AF7 for ; Sun, 30 Oct 2005 17:05:01 +0100 (CET) Received: from localhost.localdomain (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id C6920C046 for ; Sun, 30 Oct 2005 17:05:00 +0100 (CET) Mail-Copies-To: metgerards@student.han.nl To: The development of GRUB 2 References: <87u0f0t30k.fsf@student.han.nl> <4364DB7F.1060309@gmail.com> From: Marco Gerards Date: Sun, 30 Oct 2005 17:05:01 +0100 In-Reply-To: <4364DB7F.1060309@gmail.com> (Vladimir Serbinenko's message of "Sun, 30 Oct 2005 15:41:03 +0100") Message-ID: <87vezfgfde.fsf@student.han.nl> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new (2.2.0) at vscan-cn.han.nl Subject: Re: Scripting support (PATCH) 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, 30 Oct 2005 16:05:10 -0000 Vladimir Serbinenko writes: > But the next questions are menu entries. I propose the following syntax: > menu [arguments] name > { > Commands > } > > arguments can be --default, --fallback perhaps some more in the future. > > But the main question is about realization. We need to store the > source code to be able to edit it. Marco and me propose the following > solution: > lexer keeps the buffer of current parsed script/block and it stores > begin and end of tokens in this buffer in yylloc's new fields: buf_beg > and buf_end. Then when parser founds a menu entry it copies a part of > buffer using position of command. E.g (schematically): > > "menu" string '{' commands '}' I would even propose something like: menuargs: /* Empty */ menuargs ARG ... ; menuentry: "menu" menuargs '{' commands '}' ; Or something like that. Arg is something the scanner can recognize or so. I am not sure how that should work :) > { > char was = buf[@4.buf_end]; > buf[@4.buf_end] = 0; > create_menu_command ($2, grub_strdup (&buf[@4.buf_beg])); > } I didn't know that bison had such buffer. I think it is cleaner to use grub_strndup so you don't have to modify the buffer. You also have to pass the result of `commands' ($4 in your example) to create_menu_command. > And menu is always stored unparsed and parsed only just before > execution. Than editing is no problem. I think you have to parse it immediately and both store parsed and the unparsed code. After editing you do the same again. > Other solution proposed by Marco was to rerun the script file or part > of it. This solution is required if you want to be able to edit the complete script instead of just the separate menu entries. I think this is not interesting, but if someone wants to know I can say more about this. Thanks, Marco