Sha256: 38a0eccefc9cb1747716cc05f4ba28be77f93b16274b2fbee82f2d824e367977
Contents?: true
Size: 1.25 KB
Versions: 4
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Cel class Environment def initialize(declarations = nil) @declarations = declarations @parser = Parser.new @checker = Checker.new(@declarations) end def compile(expr) ast = @parser.parse(expr) @checker.check(ast) ast end def encode(expr) Encoder.encode(compile(expr)) end def decode(encoded_expr) ast = Encoder.decode(encoded_expr) @checker.check(ast) ast end def check(expr) ast = @parser.parse(expr) @checker.check(ast) end def program(expr) expr = @parser.parse(expr) if expr.is_a?(::String) @checker.check(expr) Runner.new(@declarations, expr) end def evaluate(expr, bindings = nil) context = Context.new(@declarations, bindings) expr = @parser.parse(expr) if expr.is_a?(::String) @checker.check(expr) Program.new(context).evaluate(expr) end private def validate(ast, structs); end end class Runner def initialize(declarations, ast) @declarations = declarations @ast = ast end def evaluate(bindings = nil) context = Context.new(@declarations, bindings) Program.new(context).evaluate(@ast) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cel-0.2.3 | lib/cel/environment.rb |
cel-0.2.2 | lib/cel/environment.rb |
cel-0.2.1 | lib/cel/environment.rb |
cel-0.2.0 | lib/cel/environment.rb |