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

Method peek_same_line

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

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. */

(&mut self)

Source from the content-addressed store, hash-verified

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> {
373 loop {
374 match self.tokens.peek().map(|t| t.kind) {
375 Some(TokenType::Nl | TokenType::Comment) => { self.tokens.next(); }
376 Some(TokenType::Newline) | Some(TokenType::Endmarker) | None => return None,
377 Some(k) => return Some(k),
378 }
379 }
380 }
381
382 pub(super) fn patch(&mut self, pos: usize) {
383 let target = self.chunk.instructions.len() as u16;

Callers 3

stmtMethod · 0.80
assignMethod · 0.80
postfix_tailMethod · 0.80

Calls 2

nextMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected