Giter Site home page Giter Site logo

Set in context about expressions HOT 1 OPEN

appsup-dart avatar appsup-dart commented on August 19, 2024
Set in context

from expressions.

Comments (1)

rbellens avatar rbellens commented on August 19, 2024 2

The = operator is currently not supported.

You could implement it yourself and do a PR. This means adapting the parser class, creating an AssignmentExpression class and adding an evalAssignment method in the ExpressionEvaluator.

Alternatively, you could use a set method instead of the = operator. So, if you would have an expression like x["something"] = 'hello', write it as x.set("something", 'hello') instead. This will be parsed by the default parser. You would only need to create a custom evaluator that extends the default ExpressionEvaluator and overrides the evalMemberExpression. Something like this:

class MyEvaluator extends ExpressionEvaluator {
  const MyEvaluator();

  @override
  evalMemberExpression(MemberExpression expression, Map<String, dynamic> context) {
    var object = eval(expression.object, context).toJson();
    if (object is Map&&expression.property.name=='set') {
      return (key, value) => object[key] = value;
    }
    return super.evalMemberExpression(expression, context);
  }
}

from expressions.

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.