[Gambas-user] Custom Eval (was Re: The new Border class)

Fabien Bodard gambas.fr at ...626...
Mon Jan 5 22:16:11 CET 2015


2015-01-05 22:02 GMT+01:00 Benoît Minisini <gambas at ...1...>:
> Le 05/01/2015 21:46, Fabien Bodard a écrit :
>>> What do you mean?
>>>
>>> --
>>> Benoît Minisini
>>
>> I think about a tool that will be able to interpret inline formulas
>> like in a spreedsheet.
>>
>> i have done something like that for playing myself but i'm not a
>> specialist of interpreters like you.
>>
>> for example :
>>
>> =Myvar1 + 3 *(3*myvar2)
>> =MYFUNCTION(myvar1; myvar2) + MyVar3
>>
>> the function can be initialised for example like
>>
>> Interpret.Function.Add("MYFunction", nbreArgs, typeRetVal)
>>
>> And will call Public Sub Interpret_MyFunction(Arg1 as variant, arg2 as
>> variant,...) as variant
>>
>> A Special Event will query the vars values : Public Sub
>> Interpret_GetVar(sVarName as string) as Variant
>>
>> All the stuff of the interpreter will be to manage conditionnal
>> requirement and calculate values  or concatenate strings. So this tool
>> will be usefull for user level programmation.
>> Like in spreadsheet or in reports formulas. It can be extended near to
>> unlimited. Some functions can be hardcoded like mathematical ones.
>> Others are depend of the context so must be implemented for each
>> widget or component. It's not the fastest way to make compute but the
>> most flexible.
>>
>> I hope my english is not inapprehensible
>>
>
> If I understand well, you need some sort of custom Eval().
>
> More precisely, I think what you need is a Gambas hook inside the reader
> part of Eval() (the first part of its internal compiler) where you tell
> how to translate any symbol into a Gambas function or a call to a method
> into one of your classes, everything else being forbidden.
>
> That way, you keep the Gambas syntax, except that all function names are
> redefined, and every interpreter class is forbidden except the one you
> allow explicitly.

Yes it can be the idea. But can it be compatible with 'STANDARD'
formulas style too ? were separtors are ';'...

But your idea will be a great step too and i think you have understand
the back of my mind.



>
> Just an idea...
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list