Browse Source

Allow UnaryExpression with prefix increment/decrement (#844)

pull/849/head
croraf 4 years ago committed by GitHub
parent
commit
210a9ec285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      boa/src/syntax/parser/expression/update.rs

11
boa/src/syntax/parser/expression/update.rs

@ -11,7 +11,10 @@ use crate::{
syntax::{ syntax::{
ast::{node, op::UnaryOp, Node, Punctuator}, ast::{node, op::UnaryOp, Node, Punctuator},
lexer::TokenKind, lexer::TokenKind,
parser::{AllowAwait, AllowYield, Cursor, ParseError, ParseResult, TokenParser}, parser::{
expression::unary::UnaryExpression, AllowAwait, AllowYield, Cursor, ParseError,
ParseResult, TokenParser,
},
}, },
}; };
@ -58,8 +61,7 @@ where
cursor.next()?.expect("Punctuator::Inc token disappeared"); cursor.next()?.expect("Punctuator::Inc token disappeared");
return Ok(node::UnaryOp::new( return Ok(node::UnaryOp::new(
UnaryOp::IncrementPre, UnaryOp::IncrementPre,
LeftHandSideExpression::new(self.allow_yield, self.allow_await) UnaryExpression::new(self.allow_yield, self.allow_await).parse(cursor)?,
.parse(cursor)?,
) )
.into()); .into());
} }
@ -67,8 +69,7 @@ where
cursor.next()?.expect("Punctuator::Dec token disappeared"); cursor.next()?.expect("Punctuator::Dec token disappeared");
return Ok(node::UnaryOp::new( return Ok(node::UnaryOp::new(
UnaryOp::DecrementPre, UnaryOp::DecrementPre,
LeftHandSideExpression::new(self.allow_yield, self.allow_await) UnaryExpression::new(self.allow_yield, self.allow_await).parse(cursor)?,
.parse(cursor)?,
) )
.into()); .into());
} }

Loading…
Cancel
Save