From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Cqzfy-0006gt-Na for mharc-grub-devel@gnu.org; Tue, 18 Jan 2005 15:10:07 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cqzfs-0006en-Ov for grub-devel@gnu.org; Tue, 18 Jan 2005 15:10:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cqzfp-0006dv-UW for grub-devel@gnu.org; Tue, 18 Jan 2005 15:09:58 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cqzfp-0006dc-Ne for grub-devel@gnu.org; Tue, 18 Jan 2005 15:09:57 -0500 Received: from [194.67.23.122] (helo=mx2.mail.ru) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CqzQJ-0002E9-HA for grub-devel@gnu.org; Tue, 18 Jan 2005 14:53:55 -0500 Received: from [81.62.37.121] (port=1332 helo=[192.168.1.100]) by mx2.mail.ru with esmtp id 1CqzQH-0009Xv-00 for grub-devel@gnu.org; Tue, 18 Jan 2005 22:53:53 +0300 Message-ID: <41ED6964.9010102@list.ru> Date: Tue, 18 Jan 2005 20:54:12 +0100 From: Serbinenko Vladimir User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <41E813E7.9070206@list.ru> <87zmz6in2h.fsf@marco.marco-g.com> In-Reply-To: <87zmz6in2h.fsf@marco.marco-g.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: Not detected Subject: Re: Pre-alpha 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: Tue, 18 Jan 2005 20:10:04 -0000 Marco Gerards wrote: >Can you please explain how the parser itself works? What kind of >parser is it, something about the scanner perhaps, etc? > > > It's two times parser. First time it removes comments and creates function list.Then it launches "script_load" function. Real script execution is in script_execute. This function detects what structure is used. IF it's a loop it makes a recursive call. If it's return, brake,... if return value and status(why exited?) for expressions it uses recursive function script_eval_expr. It checks the type of first token(string,function, variable,...) ,calculates it and stores to cur, then it repeats until end of expression. If it's an operator it can be unary operator only if cur==NULL. Then it determines the part of expression that must be passed as right argument Ex: $a+$b*$c When it finds+ cur contains $a so it's binary+ right part is $b*$c as priority of * is bigger than binary+. Then it invokes corresponding function(in that case script_arith). There are some special operators like ?:, ||, &&,... that control execution so they must be calculated directly in script_eval_expr and so .func_do=NULL Function script_parse_args converts script-like argument to internal format. Function import_args imports arguments to local environment. script_exec_* are made to call different functions. For information about other functions just mail me or wait alpha-beta version where I'll add some comments >>For now all script files must be made of functions and nothing except >>functions. All other will be ignored. Function must be declared as: >>function [global] >name>([$arg1[=defval1]][,$arg2[=defval2]][,...]){ >> >>} >> >> > >How about grub.cfg? It would be nice if it would be possible to embed >code there. > > > You can just write in grub.cfg insmod script script And there is no mess between scripts and shell(however shell functions can be used by scripts...will in alpha) >>Notes: >> >> >[...] > > >>Spaces in (type) are not supported, >> >> > >Sorry, I don't understand this one. > > > in PHP you can write ( int ), ( int), (int ), (int ),... and so on but current version supports only (int), (bool) and (str) >Thanks, >Marco > > > >_______________________________________________ >Grub-devel mailing list >Grub-devel@gnu.org >http://lists.gnu.org/mailman/listinfo/grub-devel > > > >