implement From for Expression-types

This commit is contained in:
greg 2018-11-16 14:06:04 -08:00
parent 58779f8470
commit b198984fc5

View File

@ -1,4 +1,7 @@
use std::rc::Rc;
use std::convert::From;
use source_map::{SourceMap};
use builtin::{BinOp, PrefixOp};
@ -63,6 +66,12 @@ pub enum Variant {
#[derive(Debug, PartialEq, Clone)]
pub struct Expression(pub ExpressionType, pub Option<TypeIdentifier>);
impl From<Expression> for SourceMap<Expression> {
fn from(node: Expression) -> Self {
SourceMap { node, data: None }
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum TypeIdentifier {
Tuple(Vec<TypeIdentifier>),
@ -116,6 +125,13 @@ pub enum ExpressionType {
},
ListLiteral(Vec<Expression>),
}
impl From<ExpressionType> for SourceMap<ExpressionType> {
fn from(node: ExpressionType) -> Self {
SourceMap { node, data: None }
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum Discriminator {
Simple(Expression),