diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-04-29 13:41:00 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-04-29 13:41:00 +0200 |
| commit | c384e524800bb55da0c5614f412e7d835ed67945 (patch) | |
| tree | 91ff5b4de641bdd089b9396a8f3631b9ac0405e6 /src/syntax.rs | |
| parent | d514a05af1e7249412b3ecd257cd4673db3cd14b (diff) | |
Improve code quality 🎫
Diffstat (limited to 'src/syntax.rs')
| -rw-r--r-- | src/syntax.rs | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/src/syntax.rs b/src/syntax.rs index 8d248ab7..bad7ab26 100644 --- a/src/syntax.rs +++ b/src/syntax.rs @@ -1,11 +1,7 @@ //! Tokenized and syntax tree representations of source code. use std::collections::HashMap; -use std::fmt::{self, Display, Formatter}; -use std::ops::Deref; - use crate::func::Function; -use crate::utility::StrExt; /// A logical unit of the incoming text stream. @@ -72,7 +68,7 @@ pub enum Node { Func(FuncCall), } -/// A complete function invocation consisting of header and body. +/// A function invocation consisting of header and body. #[derive(Debug)] pub struct FuncCall { pub header: FuncHeader, @@ -88,49 +84,11 @@ impl PartialEq for FuncCall { /// Contains header information of a function invocation. #[derive(Debug, Clone, PartialEq)] pub struct FuncHeader { - pub name: Ident, + pub name: String, pub args: Vec<Expression>, - pub kwargs: HashMap<Ident, Expression> + pub kwargs: HashMap<String, Expression> } /// A potentially unevaluated expression. #[derive(Debug, Clone, PartialEq)] pub enum Expression {} - -/// An owned valid identifier. -#[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub struct Ident(String); - -impl Ident { - /// Create a new identifier if the string is a valid one. - #[inline] - pub fn new<S: Into<String>>(ident: S) -> Option<Ident> { - let ident = ident.into(); - if ident.is_identifier() { - Some(Ident(ident)) - } else { - None - } - } - - /// Consume self and return the underlying string. - #[inline] - pub fn into_inner(self) -> String { - self.0 - } -} - -impl Display for Ident { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(&self.0, f) - } -} - -impl Deref for Ident { - type Target = str; - - #[inline] - fn deref(&self) -> &str { - &*self.0 - } -} |
