mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Parse ratios
This commit is contained in:
parent
956f305485
commit
6c2aaf3234
2 changed files with 46 additions and 6 deletions
40
src/expr.rs
40
src/expr.rs
|
@ -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 }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue