[fine] Parent pointers in trees
This commit is contained in:
parent
4f3536ea50
commit
7abb8eafc2
3 changed files with 132 additions and 55 deletions
|
|
@ -58,11 +58,18 @@ pub enum TokenKind {
|
|||
Yield,
|
||||
}
|
||||
|
||||
// NOTE: Tokens are kinda big (like 40 bytes?) and AFAICT the only way to go
|
||||
// smaller would be to stop using string pointers and use smaller
|
||||
// sizes/offsets instead, e.g., 32b for offset and 32b for size, and
|
||||
// stop tracking the position independently from the start, and then
|
||||
// require the source text when converting to line/col. I'm unwilling to
|
||||
// give up the ergonomics of &str and String right now, so we're just
|
||||
// not doing it.
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Token<'a> {
|
||||
pub kind: TokenKind,
|
||||
pub start: usize,
|
||||
value: Result<&'a str, String>,
|
||||
value: Result<&'a str, Box<str>>,
|
||||
}
|
||||
|
||||
impl<'a> Token<'a> {
|
||||
|
|
@ -78,7 +85,7 @@ impl<'a> Token<'a> {
|
|||
Token {
|
||||
kind: TokenKind::Error,
|
||||
start,
|
||||
value: Err(message),
|
||||
value: Err(message.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue