Ejemplo n.º 1
0
 public RumorCompiler LinkAction
     (string name, Engine.ValueType p1, Engine.ValueType p2,
     Engine.ValueType p3, Engine.ValueType p4)
 {
     userState.LinkAction(name, p1, p2, p3, p4);
     return(this);
 }
Ejemplo n.º 2
0
 public RumorCompiler LinkFunction
     (string name, Engine.ValueType p1, Engine.ValueType p2,
     Engine.ValueType p3, Engine.ValueType result)
 {
     userState.LinkFunction(name, p1, p2, p3, result);
     return(this);
 }
Ejemplo n.º 3
0
 public void LinkAction
     (string name, Engine.ValueType p1, Engine.ValueType p2,
     Engine.ValueType p3, Engine.ValueType p4)
 {
     BindingHints[BindingUtil.MungeName(BindingType.Action, name, 4)] =
         new BindingActionHint4(p1, p2, p3, p4);
 }
Ejemplo n.º 4
0
 public void LinkFunction
     (string name, Engine.ValueType p1, Engine.ValueType p2,
     Engine.ValueType p3, Engine.ValueType p4, Engine.ValueType result)
 {
     BindingHints[BindingUtil.MungeName(BindingType.Function, name, 4)] =
         new BindingFunctionHint4(p1, p2, p3, p4, result);
 }
Ejemplo n.º 5
0
        public void LinkVariable(int errorIndex, string id, Engine.ValueType type)
        {
            if (UsedVariables.ContainsKey(id) && UsedVariables[id] != type)
            {
                throw new ReasonException(errorIndex,
                                          "we are trying to use the variable \"" + id +
                                          "\" as a " + type + ", but it has already been " +
                                          "used as a " + UsedVariables[id] + "!"
                                          );
            }

            UsedVariables[id] = type;
            ResolveVariables(errorIndex);
        }
Ejemplo n.º 6
0
        public static Parser <string> Variable(Engine.ValueType type)
        {
            return(state =>
            {
                using (var transaction = new Transaction(state))
                {
                    var errorIndex = state.Index;
                    var id = Identifier(state);

                    var userState = (RumorParserState)state.UserState;
                    userState.LinkVariable(errorIndex, id, type);

                    transaction.CommitIndex();
                    return id;
                }
            });
        }
Ejemplo n.º 7
0
        private static Parser <Expression> Param(Engine.ValueType t)
        {
            return(state =>
            {
                switch (t)
                {
                case Engine.ValueType.Boolean:
                    return Logic(state);

                case Engine.ValueType.Number:
                    return Math(state);

                case Engine.ValueType.String:
                    return Quote(state);

                default:
                    throw new InvalidOperationException(
                        "Unknown value type!"
                        );
                }
            });
        }
Ejemplo n.º 8
0
 public void LinkAction
     (string name, Engine.ValueType p1, Engine.ValueType p2)
 {
     BindingHints[BindingUtil.MungeName(BindingType.Action, name, 2)] =
         new BindingActionHint2(p1, p2);
 }
Ejemplo n.º 9
0
 public void LinkFunction
     (string name, Engine.ValueType p1, Engine.ValueType result)
 {
     BindingHints[BindingUtil.MungeName(BindingType.Function, name, 1)] =
         new BindingFunctionHint1(p1, result);
 }