Ejemplo n.º 1
0
        private void ParseQueryString(string queryStr)
        {
            _logger.Log($"queryStr = {queryStr}");

            var result = new CodeFile();

            result.IsMain   = false;
            result.FileName = "Hi!";

            var internalParserContext = new InternalParserContext(queryStr, result, _context);

            var globalStorage = _context.Storage.GlobalStorage;

            internalParserContext.SetCurrentDefaultSetings(globalStorage.DefaultSettingsOfCodeEntity);

            var parser = new LogicalQueryParser(internalParserContext);

            parser.Run();

            var parsedQuery = parser.Result;

            //_logger.Log($"parsedQuery = {parsedQuery}");

            _logger.Log($"DebugHelperForRuleInstance.ToString(parsedQuery) = {DebugHelperForRuleInstance.ToString(parsedQuery)}");

            //var indexedQuery = parsedQuery.GetIndexed(_context);

            //_logger.Log($"indexedQuery = {indexedQuery}");

            //_logger.Log($"DebugHelperForIndexedRuleInstance.ToString(indexedQuery) = {DebugHelperForIndexedRuleInstance.ToString(indexedQuery, _context.Dictionary)}");

            _context.Storage.GlobalStorage.LogicalStorage.Append(parsedQuery);

            //throw new NotImplementedException();
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public void DbgPrintFactsAndRules()
        {
            lock (_lockObj)
            {
                var sb = new StringBuilder();
                sb.AppendLine($"Begin {_kind} of {_mainStorageContext.Id}");

                foreach (var ruleInstance in _ruleInstancesList)
                {
                    sb.AppendLine(DebugHelperForRuleInstance.ToString(ruleInstance));
                }

                sb.AppendLine($"End {_kind} of {_mainStorageContext.Id}");

                Log(sb.ToString());
            }
        }
Ejemplo n.º 3
0
        private ulong ParseQueryStringAndGetLongHashCode(string queryStr)
        {
            _logger.Log($"queryStr = {queryStr}");

            var result = new CodeFile();

            result.IsMain   = false;
            result.FileName = "Hi!";

            var internalParserContext = new InternalParserContext(queryStr, result, _context);

            var globalStorage = _context.Storage.GlobalStorage;

            internalParserContext.SetCurrentDefaultSetings(globalStorage.DefaultSettingsOfCodeEntity);

            var parser = new LogicalQueryParser(internalParserContext);

            parser.Run();

            var parsedQuery = parser.Result;

            _logger.Log($"parsedQuery = {parsedQuery}");

            _logger.Log($"DebugHelperForRuleInstance.ToString(parsedQuery) = {DebugHelperForRuleInstance.ToString(parsedQuery)}");

            //var indexedQuery = parsedQuery.GetIndexed(_context);

            parsedQuery.CheckDirty();

            var longConditionalHashCode = parsedQuery.GetLongConditionalHashCode();

            _logger.Log($"longConditionalHashCode = {longConditionalHashCode}");

            var longHashCode = parsedQuery.GetLongHashCode();

            _logger.Log($"longHashCode = {longHashCode}");

            return(longHashCode);
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        protected override string PropertiesToDbgString(uint n)
        {
            var spaces = DisplayHelper.Spaces(n);

            return($"{spaces}{DebugHelperForRuleInstance.ToString(this)}");
        }
Ejemplo n.º 5
0
        /// <inheritdoc/>
        public Value Write(Value value)
        {
#if DEBUG
            //Log($"value = {value}");
#endif

            switch (value.KindOfValue)
            {
            case KindOfValue.LogicalSearchResultValue:
                LogChannel(DebugHelperForLogicalSearchResult.ToString(value.AsLogicalSearchResultValue.LogicalSearchResult));
                break;

            case KindOfValue.ErrorValue:
                LogChannel($"ERROR: {DebugHelperForRuleInstance.ToString(value.AsErrorValue.RuleInstance)}");
                break;

            case KindOfValue.NullValue:
                LogChannel("NULL");
                break;

            default:
            {
                var sysValue = value.GetSystemValue();

                if (sysValue == null)
                {
                    LogChannel("NULL");
                    break;
                }

                var sysValueType = sysValue.GetType();

#if DEBUG
                //Log($"sysValue = {sysValue}");
                //Log($"sysValue.GetType().FullName = {sysValue.GetType().FullName}");
#endif

                if (sysValueType == typeof(double))
                {
                    LogChannel(((double)sysValue).ToString(CultureInfo.InvariantCulture));
                    break;
                }

                if (sysValueType == typeof(float))
                {
                    LogChannel(((float)sysValue).ToString(CultureInfo.InvariantCulture));
                    break;
                }

                if (sysValueType == typeof(decimal))
                {
                    LogChannel(((decimal)sysValue).ToString(CultureInfo.InvariantCulture));
                    break;
                }

                LogChannel(sysValue.ToString());
            }

            break;
            }

            return(value);
        }
Ejemplo n.º 6
0
 public string GetHumanizeDbgString()
 {
     return(DebugHelperForRuleInstance.ToString(this));
 }
Ejemplo n.º 7
0
        private void Search(string queryStr)
        {
            _logger.Log($"queryStr = {queryStr}");

            var result = new CodeFile();

            result.IsMain   = false;
            result.FileName = "Hi!";

            var internalParserContext = new InternalParserContext(queryStr, result, _context);

            var globalStorage = _context.Storage.GlobalStorage;

            internalParserContext.SetCurrentDefaultSetings(globalStorage.DefaultSettingsOfCodeEntity);

            var parser = new LogicalQueryParser(internalParserContext);

            parser.Run();

            var parsedQuery = parser.Result;

            //_logger.Log($"parsedQuery = {parsedQuery}");

            _logger.Log($"DebugHelperForRuleInstance.ToString(parsedQuery) = {DebugHelperForRuleInstance.ToString(parsedQuery)}");

            //var indexedQuery = parsedQuery.GetIndexed(_context);

            //_logger.Log($"indexedQuery = {indexedQuery}");

            //_logger.Log($"DebugHelperForIndexedRuleInstance.ToString(indexedQuery) = {DebugHelperForIndexedRuleInstance.ToString(indexedQuery, dictionary)}");

            var searcher = _context.DataResolversFactory.GetLogicalSearchResolver();

            var searchOptions = new LogicalSearchOptions();

            searchOptions.QueryExpression = parsedQuery;

            var localCodeExecutionContext = new LocalCodeExecutionContext();

            searchOptions.LocalCodeExecutionContext = localCodeExecutionContext;
            localCodeExecutionContext.Storage       = _context.Storage.GlobalStorage;
            localCodeExecutionContext.Holder        = _context.CommonNamesStorage.DefaultHolder;

            //_logger.Log($"searchOptions = {searchOptions}");

            var searchResult = searcher.Run(searchOptions);

            //_logger.Log($"searchResult = {searchResult}");

            _logger.Log($"searchResult.IsSuccess = {searchResult.IsSuccess}");
            _logger.Log($"searchResult.Items.Count = {searchResult.Items.Count}");

            _logger.Log(DebugHelperForLogicalSearchResult.ToString(searchResult));

            foreach (var item in searchResult.Items)
            {
                _logger.Log($"item.ResultOfVarOfQueryToRelationList.Count = {item.ResultOfVarOfQueryToRelationList.Count}");

                foreach (var resultOfVarOfQueryToRelation in item.ResultOfVarOfQueryToRelationList)
                {
                    var varName = resultOfVarOfQueryToRelation.NameOfVar;

                    _logger.Log($"varName = {varName}");

                    var foundNode = resultOfVarOfQueryToRelation.FoundExpression;

                    _logger.Log($"DebugHelperForRuleInstance.ToString(foundNode) = {DebugHelperForRuleInstance.ToString(foundNode)}");
                }

                //_logger.Log($" = {}");
            }
        }