pub struct Span {
pub start: ByteOffset,
pub end: ByteOffset,
}Expand description
Byte span of an AST node.
[start, end) into the original source, same basis as Token::start/
Token::end. Covers every (non-virtual) token that belongs to the node —
first token’s start to last token’s end.
Invariants the parser maintains (checked over the corpus by
render_from_ast): a child’s span is contained in its parent’s span, and
sibling spans are ordered and non-overlapping. Trivia (comments, blank
lines) live between sibling spans.
Fields§
§start: ByteOffsetInclusive byte offset at which the node starts.
end: ByteOffsetExclusive byte offset at which the node ends.
Implementations§
Source§impl Span
impl Span
Sourcepub const fn new(start: ByteOffset, end: ByteOffset) -> Self
pub const fn new(start: ByteOffset, end: ByteOffset) -> Self
Create a span from already-typed byte offsets.
Use Self::from_usize only at parser/source-slicing boundaries where
raw byte offsets are being converted deliberately.
use daml_parser::ast::Span;
let _ = Span::new(1usize, 2usize);Sourcepub const fn from_usize(start: usize, end: usize) -> Self
pub const fn from_usize(start: usize, end: usize) -> Self
Convert raw byte offsets into a typed parser span.
Sourcepub const fn start_usize(self) -> usize
pub const fn start_usize(self) -> usize
Raw start byte offset for source slicing and external interop.
Sourcepub const fn end_usize(self) -> usize
pub const fn end_usize(self) -> usize
Raw exclusive end byte offset for source slicing and external interop.