Example #1
0
        /// <summary>
        /// Creates a new interpreter
        /// </summary>
        public Interpreter(TrsProgramBlock programBlock, List <ITrsNativeFunction> nativeFunctions = null,
                           List <ITrsUnifierCalculation> customUnifiersCalculations = null)
        {
            if (nativeFunctions == null)
            {
                nativeFunctions = new List <ITrsNativeFunction>();
            }
            else
            {
                this.nativeFunctions = nativeFunctions;
            }
            mguCalculation      = new MguCalculation(customUnifiersCalculations);
            this.initialProgram = programBlock;
            var validator = new TrsProgramBlockValidator();

            validator.Validate(this.initialProgram);
            ValidationMessages = new List <InterpreterResultMessage>();
            ValidationMessages.AddRange(validator.ValidationMessages);
            this.hasErrors = ValidationMessages.Where(msg => msg.MessageType == InterpreterMessageType.Error).Count() > 0;
            if (!hasErrors)
            {
                ClassifyInput();
            }
        }
Example #2
0
   /// <summary>
   /// Creates a new interpreter
   /// </summary>
   public Interpreter(TrsProgramBlock programBlock, List<ITrsNativeFunction> nativeFunctions = null,
 List<ITrsUnifierCalculation> customUnifiersCalculations = null)
   {
       if (nativeFunctions == null) nativeFunctions = new List<ITrsNativeFunction>();
         else this.nativeFunctions = nativeFunctions;
         mguCalculation = new MguCalculation(customUnifiersCalculations);
         this.initialProgram = programBlock;
         var validator = new TrsProgramBlockValidator();
         validator.Validate(this.initialProgram);
         ValidationMessages = new List<InterpreterResultMessage>();
         ValidationMessages.AddRange(validator.ValidationMessages);
         this.hasErrors = ValidationMessages.Where(msg => msg.MessageType == InterpreterMessageType.Error).Count() > 0;
         if (!hasErrors) ClassifyInput();
   }