pub struct Token {
pub kind: SyntaxKind,
pub span: Span,
pub preceded_by_newline: bool,
}Expand description
A token the lexer emits before it is folded into the lossless tree: its kind, the source span it covers, and whether a line break sits in front of it.
The parser consumes these into a rowan::GreenNode; the spans are kept so
diagnostics can point at lexer-level locations (§6).
Fields§
§kind: SyntaxKind§span: Span§preceded_by_newline: boolTrue iff the trivia run immediately before this token contained a \n
or \r, or was a line comment.
A newline is trivia, so folding it into the tree loses the one fact statement separation needs: whether the next token starts a new line (D8, ADR-049). Recording it on the token is what lets the parser ask without re-reading the source, and what keeps the answer available after the trivia has already been emitted into the green tree.
Implementations§
Trait Implementations§
impl Copy for Token
impl Eq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more