Giter Club home page Giter Club logo

Comments (5)

shivam-940 avatar shivam-940 commented on August 31, 2024 1

@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.

generikvault avatar generikvault commented on August 31, 2024

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.

shivam-940 avatar shivam-940 commented on August 31, 2024

Hi @generikvault

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.

skyf0cker avatar skyf0cker commented on August 31, 2024
AnalyticContext

this has not been implemented. But i'm working on this recently.

from gval.

skyf0cker avatar skyf0cker commented on August 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.