diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-09-03 19:16:19 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-09-03 19:16:19 +0200 |
| commit | 7f8f225cb3cb44367d731c544f7ce1eebdb97dd5 (patch) | |
| tree | eb0084ea898a6e2e7c9034778654b02944048cbb /src/syntax/mod.rs | |
| parent | 7f575dc09870848a1a4e5ba1f17a47cf83b60046 (diff) | |
Split up parser into multiple files 🧱
Splits up into:
- escaping: resolving of escape sequences
- parser: the parsing code
- tests: all integrated parsing tests
Also moves Ident from the root syntax module into the tree module.
Diffstat (limited to 'src/syntax/mod.rs')
| -rw-r--r-- | src/syntax/mod.rs | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index a9fe7c2e..70935e79 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -6,35 +6,6 @@ pub mod span; pub mod tokens; pub mod tree; -use std::fmt::{self, Debug, Formatter}; -use tokens::is_identifier; - -/// An identifier as defined by unicode with a few extra permissible characters. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct Ident(pub String); - -impl Ident { - /// Create a new identifier from a string checking that it is a valid. - pub fn new(ident: impl AsRef<str> + Into<String>) -> Option<Self> { - if is_identifier(ident.as_ref()) { - Some(Self(ident.into())) - } else { - None - } - } - - /// Return a reference to the underlying string. - pub fn as_str(&self) -> &str { - self.0.as_str() - } -} - -impl Debug for Ident { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "`{}`", self.0) - } -} - #[cfg(test)] mod tests { use super::span; |
