public static IFsm BuildFsm(Expr expr, Func <Expr, IFsm> checkerFsmBuilder)
        {
            var builder     = new ExprFsmBuilder(checkerFsmBuilder);
            var fsmFragment = expr.Apply(builder);
            var fsm         = builder._fsm;

            fsm.SetInitialState(fsmFragment.From);
            fsmFragment.To.SetFinal();

            return(fsm);
        }
Beispiel #2
0
        protected override async Task <IBifoqlObject> DoApply(QueryContext context)
        {
            // Since this function essentialy works as a "catch", then we want to handle any unexpected errors as well.
            try
            {
                var obj = await _obj.Apply(context);

                if (!(obj is IBifoqlError))
                {
                    return(obj);
                }
            }
            catch
            {
                // Nothing to do here.
            }

            return(await _ifIsError.Apply(context));
        }
Beispiel #3
0
        protected override async Task <IBifoqlObject> DoApply(QueryContext context)
        {
            var val = await _obj.Apply(context);

            string type = "undefined";

            if (val == null || val is IBifoqlNull)
            {
                type = "null";
            }
            else if (val is IBifoqlBoolean)
            {
                type = "boolean";
            }
            else if (val is IBifoqlError)
            {
                type = "error";
            }
            else if (val is IBifoqlArrayInternal)
            {
                type = "array";
            }
            else if (val is IBifoqlMapInternal)
            {
                type = "object";
            }
            else if (val is IBifoqlString)
            {
                type = "string";
            }
            else if (val is IBifoqlNumber)
            {
                type = "number";
            }

            return(new AsyncString(type));
        }
Beispiel #4
0
 public Task <IBifoqlObject> Evaluate(QueryContext context)
 {
     return(_expr.Apply(context));
 }
Beispiel #5
0
 public Expr Apply(Val value, Expr expr) =>
 new App(f.Apply(value, expr),
         x.Apply(value, expr));