private void PushDedents(int untilPosition) { while (Indents.Peek() > untilPosition) { Indents.Pop(); PushOutlineToken(_grammar.Dedent, CurrentToken.Location); } }
public IToken <INode> PeekToken() { if (Store.IsNull()) { READ_LINE_: var line = BaseReader.LineNumber; var ts = ReadLineTokens(BaseReader, Parser?.TokenStack.LastOrNull()); if (ts.First().Type == Symbols.EOL) { goto READ_LINE_; } Store.AddRange(ts); if (!Store[0].EndOfToken && (Indents.Count == 0 || Store[0].Indent > Indents.Peek())) { Store.Insert(0, new Token { Type = Symbols.BEGIN, LineNumber = line, Indent = Store[0].Indent }); Indents.Push(Store[0].Indent); } else { var count = 0; var head = Store[0]; while (Indents.Count > 0 && (head.EndOfToken || head.Indent < Indents.Peek())) { Store.Insert(count, new Token { Type = Symbols.END, LineNumber = line, Indent = Indents.Pop() }); count++; } } } READ_FIRST_: var first = Store.First(); if (Parser is { } && first.Type == Symbols.EOL && !Parser.IsAccept(first))