public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var stringOp = operandStack.PopString(); var stringVal = stringOp.Value; var seekOp = operandStack.PopString(); var seekVal = seekOp.Value; var index = stringVal.IndexOf(seekVal); if (index >= 0) { var post = stringVal.Substring(index + seekVal.Length); var postOp = new StringOperand(post); operandStack.Push(postOp); operandStack.Push(seekOp); var pre = stringVal.Substring(0, index); var preOp = new StringOperand(pre); operandStack.Push(preOp); var boolOp = new BooleanOperand(true); operandStack.Push(boolOp); } else { operandStack.Push(stringOp); var boolOp = new BooleanOperand(false); operandStack.Push(boolOp); } }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var operand1 = operandStack.Pop(); var operand2 = operandStack.Pop(); switch (operand1) { case BooleanOperand boolOperand1: { var boolOperand2 = (BooleanOperand)operand2; var boolean = new BooleanOperand(boolOperand1.Value ^ boolOperand2.Value); operandStack.Push(boolean); break; } case IntegerOperand intOperand1: { var intOperand2 = (IntegerOperand)operand2; var boolean = new IntegerOperand(intOperand1.Value ^ intOperand2.Value); operandStack.Push(boolean); break; } default: throw new Exception("illegal operator"); } }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var stringVal = operandStack.PopStringValue(); byte[] bytes = System.Text.Encoding.ASCII.GetBytes(stringVal); var memoryStream = new MemoryStream(bytes); var scriptReader = new StreamReader(memoryStream); var fileReader = new EpsStreamReader(scriptReader); var parser = new Parser(fileReader); var operand = parser.GetNextOperand(); if (operand != null) { var post = scriptReader.ReadToEnd(); var postOp = new StringOperand(post); operandStack.Push(postOp); operandStack.Push(operand); var boolOp = new BooleanOperand(true); operandStack.Push(boolOp); } else { var boolOp = new BooleanOperand(false); operandStack.Push(boolOp); } scriptReader.Dispose(); memoryStream.Dispose(); }
internal BooleanOperand Build(BooleanOperand ParsedExp, string StringExp) { if (ParsedExp == null) { return(BooleanOperand.Create(StringExp)); } return(new BooleanExpression(StringExp, ParsedExp)); }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var operand = operandStack.Pop(); var boolOp = new BooleanOperand(false); operandStack.Push(boolOp); }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var operand = operandStack.Pop(); var b = new BooleanOperand(operand.IsExecutable); operandStack.Push(b); }
public BooleanOperand Parse(string str) { Stack <ElementarExpressionString> st = new Stack <ElementarExpressionString>(); BooleanOperand Left = null; ElementarExpressionString Current = new ElementarExpressionString(); for (int i = 0; i < str.Length; i++) { if (str[i] == '(') { st.Push(Current); Current = new ElementarExpressionString(); continue; } if (str[i] == ')') { ElementarExpressionString expr = st.Pop(); string MaybeOperator = expr.Expression.Trim(); if (MaybeOperator.Length == 2) // operatore? { BooleanOperand exp = BooleanOperand.Create(Current.Expression); Left = new BooleanExpression(Left, MaybeOperator, exp); Current = new ElementarExpressionString(); continue; } if (Current.Expression.Length > 0) { if (BooleanOperand.IsSimple(Current.Expression)) { continue; } Left = BooleanOperand.Create(Current.Expression); } if (expr.Expression.Length > 0) { Left = new BooleanExpression(expr.Expression, Left); } Current = new ElementarExpressionString(); continue; } Current.Append(str[i]); } if (Current.Expression.Length > 0) { Left = Build(Left, Current.Expression); } return(Left); }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var key = operandStack.Pop(); var dict = operandStack.PopDictionary(); var contains = dict.Dictionary.Contains(key); var boolean = new BooleanOperand(contains); operandStack.Push(boolean); }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var operand2 = operandStack.Pop(); var operand1 = operandStack.Pop(); var isLess = OperandComparator.IsLess(operand1, operand2); var boolean = new BooleanOperand(isLess); operandStack.Push(boolean); }
public Prerequisite(string code, string defaultNPCName, Conversation conversation) { code = CodeInterpreter.RemoveComments(code); if (code.Equals("")){ rootNode = null; } else { try { rootNode = PrerequisiteInterpreter.Interpret(code, defaultNPCName, conversation); } catch (InvalidScriptException e) { e.PrintMessage(); rootNode = null; } } }
public static IOperand CreateDynamic(object value) { if (value == null) { return(new NullValueOperand()); } Type t = value.GetType(); IOperand op; if (ReferenceEquals(t, typeof(double))) { op = new DoubleOperand((double)value); } else if (ReferenceEquals(t, typeof(string))) { op = new StringOperand((string)value); } else if (ReferenceEquals(t, typeof(bool))) { op = new BooleanOperand((bool)value); } else if (ReferenceEquals(t, typeof(int))) { op = new IntegerOperand((int)value); } else if ((value) is IReference) { op = (IOperand)value; } else if (ReferenceEquals(t, typeof(ErrorValueWrapper))) { op = new ErrorValueOperand((ErrorValueWrapper)value); } else if (ReferenceEquals(t, typeof(DateTime))) { op = new DateTimeOperand((DateTime)value); } else { throw new ArgumentException(String.Format("The type {0} is not supported as an operand", t.Name)); } return(op); }
public BooleanExpression(string Left, BooleanOperand Right) { Regex re = new Regex(@"(?:(?<exp>\S+)\s*(?<op>[&][&]|[|][|])\s*)|(?:(?<op>[&][&]|[|][|])\s*(?<exp>\S+)\s*)"); Match m = re.Match(Left); if (!m.Success) { throw new Exception("Invalid SimpleExpression: " + Left); } //SimpleExpression exp = new SimpleExpression(m.Groups["exp"].Value); BooleanOperand exp = BooleanOperand.Create(m.Groups["exp"].Value); this.Left = exp; this.Right = Right; string op = m.Groups["op"].Value; BooleanOperator = BooleanExpression.GetBooleanOperator(op); }
public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; bool ret = false; var key = operandStack.Pop(); var dict = DictionaryStackHelper.FindDictionary(interpreter.DictionaryStack, key); if (dict != null) { var dictOperand = new DictionaryOperand(dict); operandStack.Push(dictOperand); ret = true; } var boolean = new BooleanOperand { Value = ret }; operandStack.Push(boolean); }
public override void Execute(EpsInterpreter interpreter) { var b = new BooleanOperand(); interpreter.OperandStack.Push(b); }
public Not(BooleanOperand operand0) : base(operand0) { }
public AbstractLogicalOperator(BooleanOperand operand0, BooleanOperand operand1) : base(operand0, operand1) { }
public WhereClause(BooleanOperand boolOp, PropertyReference prop, Comparison comp, object literal) : base(prop, comp, literal) { BooleanOperand = boolOp; }
public And(BooleanOperand operand0, BooleanOperand operand1) : base(operand0, operand1) { }
public BooleanExpression(BooleanOperand Left, string Operator, BooleanOperand Right) { _Left = Left; _BooleanOperator = BooleanExpression.GetBooleanOperator(Operator); _Right = Right; }
public BooleanExpression(BooleanOperand Left, BooleanOperatorType Operator, BooleanOperand Right) { _Left = Left; _BooleanOperator = Operator; _Right = Right; }