[Gambas-user] Custom expression evaluator in rev. 7545
Benoît Minisini
gambas at ...1...
Sun Jan 3 17:50:48 CET 2016
Hi,
In revision #7545, it is now possible to inherit the Expression class to
customize the expression evaluator.
It works that way:
' Gambas class file
Inherits Expression
Static Public Sub IsIdentifier(Name As String) As Boolean
' Return if 'Name' is an allowed identifier.
End
Static Public Sub IsSubr(Name As String) As Boolean
' Return if a the 'Name' Gambas subroutine is allowed.
End
Public Sub GetValue(Name As String) As Variant
Return the value of the 'Name' identifier.
End
Public Sub MySubr(iVal As Integer) As Integer
' Example of a custom subroutine. The "MySubr" identifier
' must be allowed by the IsIdentifier() method.
End
It's mainly a present for Fabien so that he can write a simpler
evaluator for the gb.report2 component, but it may be helpful for other
people that need a custom evaluator.
It's not possible to disable Gambas operators or reimplement their
behaviour, and I don't think I would allow that.
But if you have other customization needs, you can tell!
Note : you can now evaluate an expression or call Eval() recursively,
and it should work. But it is not well tested and may crash.
Regards,
--
Benoît Minisini
More information about the User
mailing list