Comments (1)
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:
- Walk the AST
- For each
Ident
andSelect
expr node, determine whether the expression node could be a qualified name. - An expression node may be a qualified name if it is composed of only
Ident
andSelect
expr nodes and none of theSelect
expr nodes isTestOnly
. - Join expr nodes into a qualified name, e.g.
Select(Ident('first'), 'second')
->first.second
- 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 beforefirst
.
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)
- Integer overflow on enum assignments should error
- Duration and timestamp range errors should result in evaluation errors HOT 1
- Strong typing for enums
- Not use "TRUE" and "FALSE" for token name? HOT 6
- Ensure CelMap operator[] is const correct
- How to parse a cel expression? HOT 6
- string length scans twice
- Resolve +-0 in protobuf tests since libraries are inconsistent HOT 2
- Failure in conversions/int/double_to_int_min
- Do you have compilation instructions? HOT 6
- Consistent typenames between runtime, debugging, and spec
- Add separate runtime type for null
- AST renumbering doesn't renumber macro calls
- Support heterogeneous null comparisons
- OSS-Fuzz issue 45526 HOT 1
- OSS-Fuzz issue 47721
- Make a release
- An error occurred during the fetch of repository 'antlr4_runtimes'
- Missing definitions from 0.9.0 HOT 1
- Is there any example about how to add user-defined macros or functions in cel-cpp HOT 1
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 cel-cpp.