artlr_syntax/token/
token.rs1pub struct Token<TLex, TSyntax> {
2 pub lex: Option<TLex>,
3 pub t_type: TSyntax,
4}
5
6impl<TLex, TSyntax> Token<TLex, TSyntax> {
7 pub fn new(lex: Option<TLex>, t_type: TSyntax) -> Self {
8 Self { lex, t_type }
9 }
10}
11
12impl<TLex: Clone, TSyntax: Clone> Clone for Token<TLex, TSyntax> {
13 fn clone(&self) -> Self {
14 Self::new(self.lex.clone(), self.t_type.clone())
15 }
16}
17
18impl<TLex, TSyntax: PartialEq> PartialEq for Token<TLex, TSyntax> {
19 fn eq(&self, other: &Self) -> bool {
20 self.t_type.eq(&other.t_type)
21 }
22
23 fn ne(&self, other: &Self) -> bool {
24 self.t_type.ne(&other.t_type)
25 }
26}