use std::{error, fmt, result};
pub struct Error(String);
pub type Result<T> = result::Result<T, Error>;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Type {
Binary,
Float,
Integer,
String,
}
pub trait Typable where Self: Sized {
type Output;
fn kind(self, value: Type) -> Self::Output;
#[inline]
fn binary(self) -> Self::Output {
self.kind(Type::Binary)
}
#[inline]
fn float(self) -> Self::Output {
self.kind(Type::Float)
}
#[inline]
fn integer(self) -> Self::Output {
self.kind(Type::Integer)
}
#[inline]
fn string(self) -> Self::Output {
self.kind(Type::String)
}
}
impl fmt::Debug for Error {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(formatter)
}
}
impl fmt::Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(formatter)
}
}
impl error::Error for Error {
fn description(&self) -> &str {
&self.0
}
}
macro_rules! raise(
($message:expr) => (
return Err(::Error($message.to_string()));
);
);
pub mod grammar;
pub mod language;
pub mod prelude;