private ParsingResult parseLeaf(Node leaf, int timeIndex, int intervalDuration) { string leafExpression = leaf.getExpression(); string result = leafExpression; double number; if (!double.TryParse(result, out number)) { string timeVariable = timeIndex == 0 ? "time" : string.Format("t{0}", timeIndex); if (intervalDuration > 0) { timeVariable = string.Format("(+ {0} {1})", timeVariable, intervalDuration); } List <string> expressions = new List <string> { timeVariable }; ICollection <string> functionInputs = PropositionParser.extractParameters(leafExpression); string functionName = PropositionParser.extractName(leafExpression); foreach (string fInput in functionInputs) { expressions.Add(fInput); } result = SMTConstructsInstantiator.instantiateNaryOperator(functionName, expressions.ToArray()); } return(new ParsingResult(result)); }
private ParsingResult parseUniaryOperator(InternalNode _operator, int timeIndex, int intervalDuration) { /*unary node in the tree structure, * which means that the next expression for parsing is * always in the right-hand-side node */ string operatorString = _operator.getExpression(); operatorString = PropositionParser.trnasformOperatorToSMTLIB(operatorString); string result = SMTConstructsInstantiator.instantiateUnaryOperator(operatorString, parseNode(_operator.getRightHandSide(), timeIndex, intervalDuration).SmtExpression); return(new ParsingResult(result)); }
private ParsingResult parseBinaryOperator(InternalNode _operator, int timeIndex, int intervalDuration) { string operatorString = _operator.getExpression(); ParsingResult leftSide = parseNode(_operator.getLeftHandSide(), timeIndex, intervalDuration); /*only in a case of implication the interval duration is transferred to the right-hand size, otherwise not*/ if (operatorString.Equals("=>") && leftSide.IntervalDuration > intervalDuration) { intervalDuration = leftSide.IntervalDuration; } ParsingResult rightSide = parseNode(_operator.getRightHandSide(), timeIndex, leftSide.IntervalDuration); operatorString = PropositionParser.trnasformOperatorToSMTLIB(operatorString); string expression = SMTConstructsInstantiator.instantiateBinaryOperator(operatorString, leftSide.SmtExpression, rightSide.SmtExpression); return(new ParsingResult(expression)); }