parser

package
v0.0.0-...-99a2e32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package parser provides helpers to locate and validate CEL expressions embedded in strings.

CEL expressions are delimited by the literal sequence `${` and a matching `}`. The parser recognizes string literals and escape sequences and enforces the rule that nested expressions are not allowed unless they appear inside a string literal. For example:

  • `${outer("${inner}")}` is allowed
  • `${outer(${inner})}` is not allowed and will cause ErrNestedExpression

The primary behaviors implemented in this package:

  • ParseSchemaless: returns all CEL expressions found in a schemaless map[string]any structure

Index

Constants

This section is empty.

Variables

View Source
var ErrNestedExpression = errors.New("nested expressions are not allowed unless inside string literals")

ErrNestedExpression is returned when an expression contains another unescaped expression. Nested expressions are only allowed when the inner expression appears inside a string literal, for example:

${outer("${inner}")}   // allowed
${outer(${inner})}     // not allowed

Functions

func ExtractExpressions

func ExtractExpressions(str string) ([]string, error)

ExtractExpressions extracts all non-nested CEL expressions from a string. It returns an error if it encounters an illegal nested expression.

func IsStandaloneExpression

func IsStandaloneExpression(str string) (bool, error)

IsStandaloneExpression checks if input is exactly one full expression.

func ParseSchemaless

func ParseSchemaless(resource map[string]any) ([]variable.FieldDescriptor, error)

ParseSchemaless extracts CEL expressions without a schema

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL