Parse ratios

This commit is contained in:
Richard Feldman 2019-03-14 20:58:27 -04:00
parent 956f305485
commit 6c2aaf3234
2 changed files with 46 additions and 6 deletions

View file

@ -1,16 +1,44 @@
use name::Name;
use typ::Type;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Operator {
Plus, Minus, FloatDivision, IntDivision,
Plus, Minus, Star, Slash, DoubleSlash,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Builtin {
// Default
Negate,
Not,
// String
// StringLength,
}
#[derive(Debug, PartialEq)]
pub enum Expr {
HexOctalBinary(i64), // : Int
FractionalNumber(f64), // : Float
WholeNumber(i64), // : Int | Float
Int(i64),
Ratio(i64, u64),
// Functions
CallOperator(Operator, Box<Expr>, Box<Expr>),
CallOperator(Box<Expr>, Operator, Box<Expr>),
CallBuiltin(Builtin, Box<Expr>),
CallLambda(Box<Expr>, Box<Expr>),
}
#[derive(Debug, PartialEq)]
pub enum Pattern {
Name(Name), // `foo =`
As(Name, Box<Pattern>), // `<pattern> as foo`
Type(Type),
Symbol(String),
String(String),
Char(char),
Int(i64),
Float(f64),
Tuple(Vec<Pattern>),
Record(Vec<(Name, Option<Pattern>)>), // { a = 5, b : Int as x, c }
}