aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_tt
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-11 16:28:39 +0000
committerAleksey Kladov <[email protected]>2019-02-11 18:02:19 +0000
commit58897dd8ddfd08ef494b7bc05ac15f5b1e3a4e1a (patch)
treefdd3ffbdca1ee8a9711d4080931e71f13d72e154 /crates/ra_tt
parentb356ab46f2b7482bf1ae0c0f6cd5a87ece8742bf (diff)
assign ids to tokens
Diffstat (limited to 'crates/ra_tt')
-rw-r--r--crates/ra_tt/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs
index df31f72f3..e0a4cdb8b 100644
--- a/crates/ra_tt/src/lib.rs
+++ b/crates/ra_tt/src/lib.rs
@@ -18,6 +18,15 @@ use std::fmt;
18 18
19use smol_str::SmolStr; 19use smol_str::SmolStr;
20 20
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub struct TokenId(pub u32);
23
24impl TokenId {
25 pub const fn unspecified() -> TokenId {
26 TokenId(!0)
27 }
28}
29
21#[derive(Debug, Clone)] 30#[derive(Debug, Clone)]
22pub enum TokenTree { 31pub enum TokenTree {
23 Leaf(Leaf), 32 Leaf(Leaf),
@@ -67,6 +76,7 @@ pub enum Spacing {
67#[derive(Debug, Clone)] 76#[derive(Debug, Clone)]
68pub struct Ident { 77pub struct Ident {
69 pub text: SmolStr, 78 pub text: SmolStr,
79 pub id: TokenId,
70} 80}
71 81
72impl fmt::Display for TokenTree { 82impl fmt::Display for TokenTree {