[Top][All Lists]

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

Re: Scripting support

From: Vladimir Serbinenko
Subject: Re: Scripting support
Date: Sat, 22 Oct 2005 16:46:22 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050804)

Marco Gerards wrote:


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
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

reply via email to

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