-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: add metadata in evaluable #78
Comments
Hi skyf0cker, I think the meta data should be collected via the context.Context inside the parser closures. This should be an optional feature that can be activated by swapping standard components with analytic versions of these components. Something like lang := gval.Full(gval.VariableAnalytics())
vars, ctx = gval.VariableAnalyticContext(ctx)
eval, err := lang.NewEvaluableWithContext(ctx, ...)
variableList := vars.VariableNames() This would preserve backwards compabillity for calls like |
When I am trying to use gval.VariableAnalytics() in my code, I am getting compilation error with |
this has not been implemented. But i'm working on this recently. |
i'm trying to implement it by the method you recommended before. Can you assign this issue to me? Btw, i don't think it is expandable if we just implement the variable name analystic. Instead analystic should be a general ability for parsing stuff including operater, functions, literal values.... // here we open the parse analystic
lang := gval.Full(gval.ParseAnalystic())
// inject the metadata pointer(a tree node) into ctx
root, ctx = gval.AnalyticContext(ctx)
// build the tree through context when parsing
eval, err := lang.NewEvaluableWithContext(ctx, ...)
// here we can access the metadata by traversing the root node
root.traverse(func(node *gval.Metadata) {
// access to the parsing metadata
}) But the structure of tree node is hard to be defined because of all kinds of operator like postfixOperator, prefixOperator. Hope that i can get your help. Anyway if this is not a good method, i will simply implement the variable name analystic |
@skyf0cker Do you know if there is any other alternative for getting list of variables and functions from expression. It will be very helpful. |
I use this project in my job and solve a lot problems. Really appreciate for it.
But i found there are some scences that i need to get the metadata of parsed evaluable.
For example:
in our system, we allow users to configure their expression with functions and operators our language supported like a rule engine.
Apperently we want to check if user's input is valid (not syntax but business logic) but i found it is hard to get metadata by gval now, like which function does this expr use and the params pass by user.
From a legitimate point of view, this is an ability that parse module should support instead of user use init language and context to hack it.
I have read the other issues and found this problem also made other guys confused like #75
I have tried to solve it by adding wrap gval.Evaluable with a metadata, it looks fine to solve this problem. if you guys agree this request, i can work on it.
expect your replies. @generikvault @darh @impl
The text was updated successfully, but these errors were encountered: