Updated to remove field

With this, try_reduce_tuple were changed from self.lpop() to self.skip()
This commit is contained in:
GreasySlug 2022-08-21 11:34:55 +09:00
parent 1902ad5a15
commit e3135778d5
2 changed files with 7 additions and 15 deletions

View file

@ -493,8 +493,6 @@ impl_locational_for_enum!(Array; Normal, WithLength, Comprehension);
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NormalTuple { pub struct NormalTuple {
pub l_paren: Token,
pub r_paren: Token,
pub elems: Args, pub elems: Args,
} }
@ -505,13 +503,11 @@ impl NestedDisplay for NormalTuple {
} }
impl_display_from_nested!(NormalTuple); impl_display_from_nested!(NormalTuple);
impl_locational!(NormalTuple, l_paren, r_paren); impl_locational!(NormalTuple, elems, elems);
impl NormalTuple { impl NormalTuple {
pub fn new(l_paren: Token, r_paren: Token, elems: Args) -> Self { pub fn new(elems: Args) -> Self {
Self { Self {
l_paren,
r_paren,
elems, elems,
} }
} }

View file

@ -1854,17 +1854,13 @@ impl Parser {
#[inline] #[inline]
fn try_reduce_tuple(&mut self) -> ParseResult<Tuple> { fn try_reduce_tuple(&mut self) -> ParseResult<Tuple> {
debug_call_info!(self); debug_call_info!(self);
let l_paren = self.lpop(); self.skip();
let inner = self.try_reduce_elems().map_err(|_| self.stack_dec())?; let inner = self.try_reduce_elems().map_err(|_| self.stack_dec())?;
let r_paren = self.lpop(); self.skip();
if !r_paren.is(RParen) {
self.level -= 1;
self.errs
.push(ParseError::simple_syntax_error(0, r_paren.loc()));
return Err(());
}
let tpl = match inner { let tpl = match inner {
ArrayInner::Normal(elems) => Tuple::Normal(NormalTuple::new(l_paren, r_paren, elems)), ArrayInner::Normal(elems) => {
Tuple::Normal(NormalTuple::new(elems))
},
ArrayInner::Comprehension { ArrayInner::Comprehension {
elem: _, elem: _,
generators: _, generators: _,