Class CelParser

java.lang.Object
com.google.mu.cel.CelParser

@Immutable public final class CelParser extends Object
Parser for Common Expression Language (CEL) syntax, producing CelExpr AST records.

Use this parser if pattern matching over records (as opposed to protos) is desirable to your use case. It's also about 2x faster than ANTLR-based cel-java parser (as benchmarks show).

Since:
10.7
  • Constructor Details

    • CelParser

      public CelParser()
  • Method Details

    • parse

      public CelExpr parse(String input)
      Parses the given CEL expression.
    • parseToProto

      public com.google.api.expr.v1alpha1.ParsedExpr parseToProto(String input)
      Parses the CEL expression and converts it to a ParsedExpr proto.

      The returned ParsedExpr.getSourceInfo() will have positions, line_offsets and macro_calls populated. The caller can also populate the other fields like location and syntax_version if such information is available.