[Top][All Lists]

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

Re: Pre-alpha scripting engine

From: Serbinenko Vladimir
Subject: Re: Pre-alpha scripting engine
Date: Tue, 18 Jan 2005 20:54:12 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

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] <function
   <function body here>

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 <file>
And there is no mess between scripts and shell(however shell functions can be used by scripts...will in alpha)

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)


Grub-devel mailing list

reply via email to

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