Add null expression

This commit is contained in:
greg 2016-01-21 19:10:21 -08:00
parent 7114e446a4
commit 15d4317191

View File

@ -37,6 +37,7 @@ pub struct Prototype {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Expression { pub enum Expression {
Null,
StringLiteral(String), StringLiteral(String),
Number(f64), Number(f64),
Variable(String), Variable(String),
@ -257,6 +258,7 @@ impl Parser {
fn primary_expression(&mut self) -> ParseResult<Expression> { fn primary_expression(&mut self) -> ParseResult<Expression> {
use tokenizer::Token::*; use tokenizer::Token::*;
Ok(match self.peek() { Ok(match self.peek() {
Some(Keyword(Kw::Null)) => { self.next(); Expression::Null },
Some(NumLiteral(n)) => { self.next(); Expression::Number(n) }, Some(NumLiteral(n)) => { self.next(); Expression::Number(n) },
Some(StrLiteral(s)) => { self.next(); Expression::StringLiteral(s) }, Some(StrLiteral(s)) => { self.next(); Expression::StringLiteral(s) },
Some(Identifier(_)) => { try!(self.identifier_expr()) }, Some(Identifier(_)) => { try!(self.identifier_expr()) },