/// <inheritdoc/> public CodeFile Parse(ParsedFileInfo parsedFileInfo, DefaultSettingsOfCodeEntity defaultSettings) { #if DEBUG //Log($"parsedFileInfo = {parsedFileInfo}"); #endif var text = File.ReadAllText(parsedFileInfo.FileName); #if DEBUG //Log($"text = {text}"); #endif var result = new CodeFile(); result.IsLocator = parsedFileInfo.IsLocator; result.FileName = parsedFileInfo.FileName; var internalParserContext = new InternalParserContext(text, result, _context); internalParserContext.SetCurrentDefaultSetings(defaultSettings); var parser = new SourceCodeParser(internalParserContext); parser.Run(); var codeEntitiesList = parser.Result; #if DEBUG //Log($"codeEntitiesList = {codeEntitiesList.WriteListToString()}"); #endif result.CodeEntities = codeEntitiesList; return(result); }
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(); }
private void ParseQueryStringAndGetInheritanceInformation(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}"); var inheritanceRelationsList = parsedQuery.GetInheritanceRelations(); //_logger.Log($"inheritanceRelationsList = {inheritanceRelationsList.WriteListToString()}"); var inheritanceItemsList = new List <InheritanceItem>(); var ruleInstanceName = parsedQuery.Name; foreach (var inheritanceRelation in inheritanceRelationsList) { _logger.Log($"inheritanceRelation = {inheritanceRelation}"); var inheritanceItem = new InheritanceItem(); inheritanceItem.SuperName = inheritanceRelation.Name; inheritanceItem.SubName = inheritanceRelation.ParamsList.Single().Name; inheritanceItem.Rank = new LogicalValue(1); inheritanceItem.KeysOfPrimaryRecords.Add(ruleInstanceName); inheritanceItemsList.Add(inheritanceItem); } _logger.Log($"inheritanceItemsList = {inheritanceItemsList.WriteListToString()}"); }
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); }
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($" = {}"); } }