nushell/src/parser/parse2/token_tree.rs

30 lines
671 B
Rust
Raw Normal View History

2019-06-11 07:53:04 +02:00
use crate::parser::parse2::{span::*, tokens::*};
use derive_new::new;
use enum_utils::FromStr;
2019-06-11 07:53:04 +02:00
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
2019-06-11 07:53:04 +02:00
pub enum TokenNode {
Token(Token),
Delimited(Spanned<DelimitedNode>),
2019-06-13 07:33:38 +02:00
Path(Spanned<PathNode>),
}
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, new)]
pub struct DelimitedNode {
delimiter: Delimiter,
children: Vec<TokenNode>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromStr)]
pub enum Delimiter {
Paren,
Brace,
Square,
2019-06-11 07:53:04 +02:00
}
2019-06-13 07:33:38 +02:00
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, new)]
pub struct PathNode {
head: Box<TokenNode>,
tail: Vec<Token>,
}