Add concept of Null expression
Finally, the null-only behavior is starting to manifest itself!
This commit is contained in:
parent
15d4317191
commit
e9dd0d9ae8
@ -56,6 +56,7 @@ impl Evaluable for Expression {
|
|||||||
fn is_reducible(&self) -> bool {
|
fn is_reducible(&self) -> bool {
|
||||||
use parser::Expression::*;
|
use parser::Expression::*;
|
||||||
match *self {
|
match *self {
|
||||||
|
Null => false,
|
||||||
StringLiteral(_) => false,
|
StringLiteral(_) => false,
|
||||||
Number(_) => false,
|
Number(_) => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
@ -123,11 +124,11 @@ impl Evaluator {
|
|||||||
match &op[..] {
|
match &op[..] {
|
||||||
"+" => match (left, right) {
|
"+" => match (left, right) {
|
||||||
(Number(l), Number(r)) => Number(l + r),
|
(Number(l), Number(r)) => Number(l + r),
|
||||||
_ => unimplemented!(),
|
_ => Null,
|
||||||
},
|
},
|
||||||
"-" => match (left, right) {
|
"-" => match (left, right) {
|
||||||
(Number(l), Number(r)) => Number(l - r),
|
(Number(l), Number(r)) => Number(l - r),
|
||||||
_ => unimplemented!(),
|
_ => Null,
|
||||||
},
|
},
|
||||||
"=" => match (left, right) {
|
"=" => match (left, right) {
|
||||||
_ => unimplemented!()
|
_ => unimplemented!()
|
||||||
|
Loading…
Reference in New Issue
Block a user