private static void PushTermOnStack(string term, TermIndexAccessor index, Stack opStack) { if (!FullTextIndexer.isValuableToken(term)) { opStack.Push(new StopwordTerm()); if (Stopwords.IndexOf(term) == -1) { Stopwords.Add(term); } } else { TermIndexRecord record = index.GetRecord(term); if (record != null) { int order = Lexemes.IndexOf(term); if (order == -1) { Lexemes.Add(term); order = Lexemes.Count - 1; } record.PopulateRecordID((ushort)order); } opStack.Push(record); } }
// Заполнение таблиц private void AddLexeme(LexemeType lexemeType, StringBuilder lexeme) { ObservableCollection <string> list = null; string value = lexeme.ToString(); switch (lexemeType) { case LexemeType.KEY: case LexemeType.DL1: case LexemeType.DL2: case LexemeType.DLS: list = Keywords; break; case LexemeType.IDN: list = Identifiers; break; case LexemeType.INT: case LexemeType.STR: list = Literals; break; default: throw new ArgumentOutOfRangeException($"Lexeme Type '{lexemeType}' is not supported"); } int index = list.IndexOf(value); if (index == -1) { list.Add(value); index = list.Count - 1; } Lexemes.Add(new Lexeme(lexemeType, index, value)); }
private void AddLexeme(string value, int line, IdentifierType type = IdentifierType.Unknown) { Lexemes.Add(new LexemeInCode { Index = GetIndex(type, value), SubString = value, LineNumber = line, Token = GetToken(value, type) } ); }