Git Product home page Git Product logo

Comments (1)

TristonianJones avatar TristonianJones commented on May 7, 2024

Hi @arghness, what you're looking for would typically come out of a CEL type-checker and the CheckedExpr proto. Currently, C++ only implements a parser and not a type-checker; however, if you want to look at the https://github.com/google/cel-go/checker implementation for how the reference_map is constructed you could presumably implement the variable reference tracking logic without implementing the full type-checking behavior.

A rough sketch of what you're looking for functionality-wise would be as follow:

  1. Walk the AST
  2. For each Ident and Select expr node, determine whether the expression node could be a qualified name.
  3. An expression node may be a qualified name if it is composed of only Ident and Select expr nodes and none of the Select expr nodes is TestOnly.
  4. Join expr nodes into a qualified name, e.g. Select(Ident('first'), 'second') -> first.second
  5. Test whether the qualified name is declared as a variable, if not continue the AST walk. In the example, the more qualified name first.second would be checked as a variable before first.

The CEL-Go PR google/cel-go#341 introduced some changes to perform AST rewrites that would consolidate all possible variables into Ident nodes as qualified names if you're looking for an example to follow.

from cel-cpp.

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.