diff options
| author | Martin Haug <mhaug@live.de> | 2021-10-23 19:03:27 +0200 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2021-11-05 13:44:49 +0100 |
| commit | 4875633acf4701705b9b3b014eb7d94268b897c2 (patch) | |
| tree | 0aedda87c8c2dc65316e2455c35e72054d9bae0e /src/syntax/ident.rs | |
| parent | ea6ee3f667e922ed2f21b08719a45d2395787932 (diff) | |
Change parser
Diffstat (limited to 'src/syntax/ident.rs')
| -rw-r--r-- | src/syntax/ident.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/syntax/ident.rs b/src/syntax/ident.rs index 398e2ff9..2c61329d 100644 --- a/src/syntax/ident.rs +++ b/src/syntax/ident.rs @@ -3,7 +3,7 @@ use std::ops::Deref; use unicode_xid::UnicodeXID; -use super::Span; +use super::{NodeKind, RedTicket, Span, TypedNode}; use crate::util::EcoString; /// An unicode identifier with a few extra permissible characters. @@ -66,6 +66,16 @@ impl From<&Ident> for EcoString { } } +impl TypedNode for Ident { + fn cast_from(node: RedTicket) -> Option<Self> { + if let NodeKind::Ident(i) = node.kind() { + Some(Ident::new(i, node.own().span()).unwrap()) + } else { + None + } + } +} + /// Whether a string is a valid identifier. pub fn is_ident(string: &str) -> bool { let mut chars = string.chars(); |
