Comments (5)
@skyf0cker Do you know if there is any other alternative for getting list of variables and functions from expression. It will be very helpful.
from gval.
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 eval(ctx, x)
from gval.
When I am trying to use gval.VariableAnalytics() in my code, I am getting compilation error with VariableAnalytics not declared by package gval
Please can you share more on how I can get list of functions and variables from expression before evaluation.
from gval.
AnalyticContext
this has not been implemented. But i'm working on this recently.
from gval.
i'm trying to implement it by the method you recommended before. Can you assign this issue to me?
@generikvault
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....
If we can build a tree like ast tree through the context, this will be solved maybe. We will get a pointer points to the root node of the ast tree when invoke gval.AnalyticContext
and the pointer is injected into the context. Then metadata will be added in the parsing process.
for example:
// 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.
I cannot figure out how to build the tree considering all these operators.
Hope that i can get your help.
Anyway if this is not a good method, i will simply implement the variable name analystic
from gval.
Related Issues (20)
- how to visit json node whose key with special characters,like $
- Question on thread safety of concurrent evaluations HOT 2
- getting list of parsed variables before expression is evaluated for validation HOT 6
- Passing a context to the custom functions HOT 1
- feat request: null safe operator
- functions inside expression are evaluated in coroutine and on panic are not recovered thus crashing whole application
- How to get rendered expressions HOT 4
- Publish new version for DecimalArithmetic HOT 2
- Allow variables to overload functoins HOT 2
- Allow dashes in identfiers HOT 1
- I need to check string contains using gval expression
- Feature Request: high order functions (collection)
- Evaluating strings with backslashes raises parsing errors HOT 1
- Move `parseIf` operator in `base` HOT 2
- evaluate with operator in value not expected HOT 1
- how to parse complex json with jsonpath?
- Hexadecimal support HOT 2
- Allow single quotes for Strings to allow parsing JSONPath HOT 1
- LineFeed in string results in error on Evaluate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gval.