Documentation ¶
Overview ¶
Example (BuiltinDefault) ¶
package main import ( "fmt" "github.com/howardjohn/celpp" "github.com/howardjohn/celpp/macros" ) func main() { parser, _ := celpp.New(macros.All...) output, _ := parser.Process("default(self.x, 'DEF')") fmt.Println(output) }
Output: has(self.x) ? self.x : "DEF"
Example (BuiltinIndex) ¶
package main import ( "fmt" "github.com/howardjohn/celpp" "github.com/howardjohn/celpp/macros" ) func main() { parser, _ := celpp.New(macros.All...) output, _ := parser.Process("self.index({}, x, z, b)") fmt.Println(output) }
Output: (has(self.x) && has(self.x.z) && has(self.x.z.b)) ? self.x.z.b : {}
Example (BuiltinOneof) ¶
package main import ( "fmt" "github.com/howardjohn/celpp" "github.com/howardjohn/celpp/macros" ) func main() { parser, _ := celpp.New(macros.All...) output, _ := parser.Process("oneof(self.x, self.y, self.z)") fmt.Println(output) }
Output: (has(self.x) ? 1 : 0) + (has(self.y) ? 1 : 0) + (has(self.z) ? 1 : 0) <= 1
Example (BuiltinUnrollmap) ¶
package main import ( "fmt" "github.com/howardjohn/celpp" "github.com/howardjohn/celpp/macros" ) func main() { parser, _ := celpp.New(macros.All...) output, _ := parser.Process("self.unrollmap(0, 3, x, x.matches.size()).sum()<=128") fmt.Println(output) }
Output: [(size(self) > 0) ? ([self[0]].map(x, x.matches.size())[0]) : 0, (size(self) > 1) ? ([self[1]].map(x, x.matches.size())[0]) : 0, (size(self) > 2) ? ([self[2]].map(x, x.matches.size())[0]) : 0].sum() <= 128
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Preprocessor ¶
type Preprocessor struct {
// contains filtered or unexported fields
}
func (*Preprocessor) ProcessToAST ¶
func (p *Preprocessor) ProcessToAST(expr string) (*celast.AST, error)
Click to show internal directories.
Click to hide internal directories.