Rip out objects
This commit is contained in:
parent
25fe7933f2
commit
0524efef03
@ -20,7 +20,6 @@ pub enum Expr {
|
|||||||
Mult(Box<Expr>, Box<Expr>),
|
Mult(Box<Expr>, Box<Expr>),
|
||||||
Div(Box<Expr>, Box<Expr>),
|
Div(Box<Expr>, Box<Expr>),
|
||||||
Block(Vec<Stmt>),
|
Block(Vec<Stmt>),
|
||||||
Object(Vec<Stmt>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,PartialEq,Clone)]
|
#[derive(Debug,PartialEq,Clone)]
|
||||||
@ -69,7 +68,6 @@ peg::parser! {
|
|||||||
f:funcall() { f }
|
f:funcall() { f }
|
||||||
f:funcdef() { f }
|
f:funcdef() { f }
|
||||||
b:boolean() _ { Expr::Atom(Atom::Bool(b)) }
|
b:boolean() _ { Expr::Atom(Atom::Bool(b)) }
|
||||||
o:object() { o }
|
|
||||||
i:id() _ { Expr::Id(i) }
|
i:id() _ { Expr::Id(i) }
|
||||||
n:num() _ { Expr::Atom(Atom::Num(n)) }
|
n:num() _ { Expr::Atom(Atom::Num(n)) }
|
||||||
|
|
||||||
@ -89,9 +87,6 @@ peg::parser! {
|
|||||||
= i:id()? "->" _ e:(expr() / block()) { Expr::Funcdef(i, Box::new(e)) }
|
= i:id()? "->" _ e:(expr() / block()) { Expr::Funcdef(i, Box::new(e)) }
|
||||||
rule conditional() -> Stmt
|
rule conditional() -> Stmt
|
||||||
= i:_if() __* ei:elif()* __* e:_else()? __* { Stmt::Conditional([vec![i], ei].concat(), e) }
|
= i:_if() __* ei:elif()* __* e:_else()? __* { Stmt::Conditional([vec![i], ei].concat(), e) }
|
||||||
rule object() -> Expr
|
|
||||||
= "{" _ stop() indent() __* a:assignment()+ dedent() __* "}" _ { Expr::Object(a) }
|
|
||||||
|
|
||||||
rule _if() -> GuardedBlock
|
rule _if() -> GuardedBlock
|
||||||
= "if" _ g:expr() b:block() {
|
= "if" _ g:expr() b:block() {
|
||||||
GuardedBlock {
|
GuardedBlock {
|
||||||
@ -344,22 +339,6 @@ else
|
|||||||
)];
|
)];
|
||||||
assert_eq!(deelang_parser::program(prgm).unwrap(), expected);
|
assert_eq!(deelang_parser::program(prgm).unwrap(), expected);
|
||||||
}
|
}
|
||||||
#[test]
|
|
||||||
fn test_object() {
|
|
||||||
let prgm = r"fruit <- {
|
|
||||||
>>>apple <- 1
|
|
||||||
pear <- 2
|
|
||||||
<<<
|
|
||||||
}";
|
|
||||||
let expected = vec![Stmt::Assignment(
|
|
||||||
"fruit".to_string(),
|
|
||||||
Expr::Object(vec![
|
|
||||||
Stmt::Assignment("apple".to_string(), Expr::Atom(Atom::Num(1.0))),
|
|
||||||
Stmt::Assignment("pear".to_string(), Expr::Atom(Atom::Num(2.0))),
|
|
||||||
]),
|
|
||||||
)];
|
|
||||||
assert_eq!(deelang_parser::program(prgm).unwrap(), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_preprocess() {
|
fn test_preprocess() {
|
||||||
|
Loading…
Reference in New Issue
Block a user