Add null expression
This commit is contained in:
parent
7114e446a4
commit
15d4317191
@ -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()) },
|
||||||
|
Loading…
Reference in New Issue
Block a user