public void Test() { int blockSize = 4096; Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); DiskIo stream = DiskIo.CreateMemoryFile(Globals.MemoryPool, blockSize); SubFileName name = SubFileName.CreateRandom(); SubFileHeader node = new SubFileHeader(1, name, false,false); SubFileDiskIoSessionPool pool = new SubFileDiskIoSessionPool(stream, stream.LastCommittedHeader, node, true); IndexParser parse = new IndexParser(pool); parse.SetPositionAndLookup(14312); pool.Dispose(); Assert.IsTrue(true); Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
public async Task ParseVariableInFileAsync() { const string testFilePath = "C:/bla.py"; _fileSystem.FileExists(testFilePath).Returns(true); using (var fileStream = MakeStream("x = 1")) { SetFileOpen(_fileSystem, testFilePath, fileStream); using (IIndexParser indexParser = new IndexParser(_fileSystem, _pythonLanguageVersion)) { var ast = await indexParser.ParseAsync(testFilePath); var symbols = GetIndexSymbols(ast); symbols.Should().HaveCount(1); symbols.First().Kind.Should().BeEquivalentTo(SymbolKind.Variable); symbols.First().Name.Should().BeEquivalentTo("x"); } } }
public void CancelParsingAsync() { const string testFilePath = "C:/bla.py"; _fileSystem.FileExists(testFilePath).Returns(true); using (var fileStream = MakeStream("x = 1")) { SetFileOpen(_fileSystem, testFilePath, fileStream); } using (var indexParser = new IndexParser(_fileSystem, _pythonLanguageVersion)) using (var cancellationTokenSource = new CancellationTokenSource()) { cancellationTokenSource.Cancel(); Func <Task> parse = async() => { await indexParser.ParseAsync(testFilePath, cancellationTokenSource.Token); }; parse.Should().Throw <TaskCanceledException>(); } }
public static bool Parse(SyntaxContext context, int position) { var list = context.list; var offset = 0; var index = position; var count = 0; var isMissed = false; while (ParenParser.Parse(context, index)) { ; } while (TableIParser.Parse(context, index)) { ; } while (TableSParser.Parse(context, index)) { ; } while (ListParser.Parse(context, index)) { ; } while (PropertyParser.Parse(context, index)) { ; } while (IndexParser.Parse(context, index)) { ; } while (CallParser.Parse(context, index)) { ; } while (NotParser.Parse(context, index)) { ; } while (LengthParser.Parse(context, index)) { ; } while (NegateParser.Parse(context, index)) { ; } while (PowerParser.Parse(context, index)) { ; } while (MultiplyParser.Parse(context, index)) { ; } while (DivisionParser.Parse(context, index)) { ; } while (ModParser.Parse(context, index)) { ; } while (AddParser.Parse(context, index)) { ; } while (SubtractParser.Parse(context, index)) { ; } if (!list[index].isRightValue) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsOperator(list[index], "<")) { return(false); } else { // ignored } offset += 1; index = position + offset; while (ParenParser.Parse(context, index)) { ; } while (TableIParser.Parse(context, index)) { ; } while (TableSParser.Parse(context, index)) { ; } while (ListParser.Parse(context, index)) { ; } while (PropertyParser.Parse(context, index)) { ; } while (IndexParser.Parse(context, index)) { ; } while (CallParser.Parse(context, index)) { ; } while (NotParser.Parse(context, index)) { ; } while (LengthParser.Parse(context, index)) { ; } while (NegateParser.Parse(context, index)) { ; } while (PowerParser.Parse(context, index)) { ; } while (MultiplyParser.Parse(context, index)) { ; } while (DivisionParser.Parse(context, index)) { ; } while (ModParser.Parse(context, index)) { ; } while (AddParser.Parse(context, index)) { ; } while (SubtractParser.Parse(context, index)) { ; } if (!list[index].isRightValue) { return(false); } else { // ignored } offset += 1; index = position + offset; context.Insert(position, ExpressionCreator.CreateLess(list, position, offset)); context.Remove(position + 1, offset); return(true); }
protected override bool ParseIndexes(out int[] indexes) { return(IndexParser.ParseIndexes(Entry.Text, 2, out indexes)); }
public static bool Parse(SyntaxContext context, int position) { var list = context.list; var offset = 0; var index = position; var count = 0; var isMissed = false; if (!ParserHelper.IsKeyword(list[index], "for")) { return(false); } else { // ignored } offset += 1; index = position + offset; if (list[index].type != Expression.Type.Word) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsOperator(list[index], "=")) { return(false); } else { // ignored } offset += 1; index = position + offset; while (FunctionAParser.Parse(context, index)) { ; } while (ParenParser.Parse(context, index)) { ; } while (TableIParser.Parse(context, index)) { ; } while (TableSParser.Parse(context, index)) { ; } while (ListParser.Parse(context, index)) { ; } while (PropertyParser.Parse(context, index)) { ; } while (IndexParser.Parse(context, index)) { ; } while (CallParser.Parse(context, index)) { ; } while (NotParser.Parse(context, index)) { ; } while (LengthParser.Parse(context, index)) { ; } while (NegateParser.Parse(context, index)) { ; } while (PowerParser.Parse(context, index)) { ; } while (MultiplyParser.Parse(context, index)) { ; } while (DivisionParser.Parse(context, index)) { ; } while (ModParser.Parse(context, index)) { ; } while (AddParser.Parse(context, index)) { ; } while (SubtractParser.Parse(context, index)) { ; } while (ConcatParser.Parse(context, index)) { ; } while (LessParser.Parse(context, index)) { ; } while (GreaterParser.Parse(context, index)) { ; } while (LessEqualParser.Parse(context, index)) { ; } while (GreaterEqualParser.Parse(context, index)) { ; } while (EqualParser.Parse(context, index)) { ; } while (NotEqualParser.Parse(context, index)) { ; } while (AndParser.Parse(context, index)) { ; } while (OrParser.Parse(context, index)) { ; } if (!list[index].isRightValue) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsOperator(list[index], ",")) { return(false); } else { // ignored } offset += 1; index = position + offset; while (FunctionAParser.Parse(context, index)) { ; } while (ParenParser.Parse(context, index)) { ; } while (TableIParser.Parse(context, index)) { ; } while (TableSParser.Parse(context, index)) { ; } while (ListParser.Parse(context, index)) { ; } while (PropertyParser.Parse(context, index)) { ; } while (IndexParser.Parse(context, index)) { ; } while (CallParser.Parse(context, index)) { ; } while (NotParser.Parse(context, index)) { ; } while (LengthParser.Parse(context, index)) { ; } while (NegateParser.Parse(context, index)) { ; } while (PowerParser.Parse(context, index)) { ; } while (MultiplyParser.Parse(context, index)) { ; } while (DivisionParser.Parse(context, index)) { ; } while (ModParser.Parse(context, index)) { ; } while (AddParser.Parse(context, index)) { ; } while (SubtractParser.Parse(context, index)) { ; } while (ConcatParser.Parse(context, index)) { ; } while (LessParser.Parse(context, index)) { ; } while (GreaterParser.Parse(context, index)) { ; } while (LessEqualParser.Parse(context, index)) { ; } while (GreaterEqualParser.Parse(context, index)) { ; } while (EqualParser.Parse(context, index)) { ; } while (NotEqualParser.Parse(context, index)) { ; } while (AndParser.Parse(context, index)) { ; } while (OrParser.Parse(context, index)) { ; } if (!list[index].isRightValue) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsKeyword(list[index], "do")) { return(false); } else { // ignored } offset += 1; index = position + offset; while (ModuleParser.Parse(context, index)) { ; } if (list[index].type != Expression.Type.Module) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsKeyword(list[index], "end")) { return(false); } else { // ignored } offset += 1; index = position + offset; context.Insert(position, ExpressionCreator.CreateFor(list, position, offset)); context.Remove(position + 1, offset); return(true); }
public static bool Parse(SyntaxContext context, int position) { var list = context.list; var offset = 0; var index = position; var count = 0; var isMissed = false; while (ParenParser.Parse(context, index)) { ; } while (TableIParser.Parse(context, index)) { ; } while (TableSParser.Parse(context, index)) { ; } while (ListParser.Parse(context, index)) { ; } while (PropertyParser.Parse(context, index)) { ; } while (IndexParser.Parse(context, index)) { ; } if (!list[index].isRightValue) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsOperator(list[index], "(")) { return(false); } else { // ignored } offset += 1; index = position + offset; while (RightList1Parser.Parse(context, index)) { ; } if (list[index].type != Expression.Type.RightList1) { return(false); } else { // ignored } offset += 1; index = position + offset; if (!ParserHelper.IsOperator(list[index], ")")) { return(false); } else { // ignored } offset += 1; index = position + offset; context.Insert(position, ExpressionCreator.CreateCall(list, position, offset)); context.Remove(position + 1, offset); return(true); }
internal void IndexParse(ExtractFileInfo fileInfo) { IndexParser sectionParser = new IndexParser(_log, fileInfo, IsPreservation, DatabasePreservationNoPrefix, Version); WriteTables(sectionParser); }
public IndexCrawlerWebDao() { IndexParser = new IndexParser(); }