[fpc-pascal] Using FPC as a scripting engine
Michael Van Canneyt
michael at freepascal.org
Fri Oct 13 12:45:55 CEST 2006
On Fri, 13 Oct 2006, Alexander Todorov wrote:
> On 10/11/06, Alexander Todorov <alexx.todorov at gmail.com> wrote:
> > Hello list,
> > currently I am using RemObjects Pascal Script as a scripting language
> > for a project of mine.
> > All scripts are simple programs that use "API" exported from the main
> > program. They have and some global variables defined as well.
> > example:
> > begin
> > Context.ShowMessage(Params.Param('message').AsVariant);
> > end.
> > The above will cause the main program to show a message. "Context" is
> > object providing all the used functions and "Params" is just a list of
> > parameters passed to the script.
> > I know Pascal Script has been made compatible to work with FPC but I
> > intend to drop its usage because of many reasons.
> > One alternative is http://www.paxscript.com/. but the other is the FPC
> > compiler embedded into my program. Here is how I see it:
> > - Use the parser, code generator, assembler, linker (internal) from
> > the FPC/compiler directory and compile it into the main program.
> > - Make the compiler engine compile and link any Pascal text (script)
> > and place it into memory.
> > - Place into memory some other stuff required by the script, e.g.
> > global variables, environment, parameters, ...
> > - Use platform native function to execute the in-memory image, e.g.
> > some sort of exec on Unix, CreateProcess on Windows.
> > - Get the results somehow and return to the main program.
> > Using this approach one can benefit from the FPC development and can
> > use some new stuff (generics) or things missing in Pascal Script
> > (indexing arrays, ).
> > Any thoughts on this are very welcome. Please share your opinion.
> > Thanks!
> > Alexander.
> There was no response to my first e-mail so here are some examples of
> what I want to do:
I find this all horribly complicated.
Why don't you simply keep the compiler external, compile everything
in a library, load the library and execute a well-known function,
passing it an 'environment' interface ?
More information about the fpc-pascal