MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / peek

Method peek

compiler/src/modules/parser/mod.rs:357–369  ·  view source on GitHub ↗

Skips Newline/Nl/Comment; maps Endmarker->None; latches saw_newline for ternary detection. */

(&mut self)

Source from the content-addressed store, hash-verified

355
356 /* Skips Newline/Nl/Comment; maps Endmarker->None; latches saw_newline for ternary detection. */
357 pub(super) fn peek(&mut self) -> Option<TokenType> {
358 loop {
359 match self.tokens.peek().map(|t| t.kind) {
360 Some(TokenType::Newline) => {
361 self.saw_newline = true;
362 self.tokens.next();
363 }
364 Some(TokenType::Nl | TokenType::Comment) => { self.tokens.next(); }
365 Some(TokenType::Endmarker) | None => return None,
366 Some(k) => return Some(k),
367 }
368 }
369 }
370
371 /* Like `peek` but stops at the logical-line boundary: a `Newline` yields `None` (unconsumed) so postfix trailers don't bind across statements. `Nl`/`Comment` (bracket-internal) still skip, so multiline `()`/`[]`/`{}` are unaffected. */
372 pub(super) fn peek_same_line(&mut self) -> Option<TokenType> {

Callers 15

stmtMethod · 0.45
name_stmtMethod · 0.45
brace_literalMethod · 0.45
fstringMethod · 0.45
drain_annotationMethod · 0.45
diag_at_peekMethod · 0.45
errorMethod · 0.45
error_atMethod · 0.45
at_endMethod · 0.45
peek_same_lineMethod · 0.45
eatMethod · 0.45
comma_listMethod · 0.45

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected