|
|
@ -68,7 +68,7 @@ impl Parser { |
|
|
|
_ => { |
|
|
|
_ => { |
|
|
|
return Err(ParseError::Expected( |
|
|
|
return Err(ParseError::Expected( |
|
|
|
vec![TokenData::Identifier("identifier".to_string())], |
|
|
|
vec![TokenData::Identifier("identifier".to_string())], |
|
|
|
tk.clone(), |
|
|
|
tk, |
|
|
|
"function arguments", |
|
|
|
"function arguments", |
|
|
|
)) |
|
|
|
)) |
|
|
|
} |
|
|
|
} |
|
|
@ -193,9 +193,7 @@ impl Parser { |
|
|
|
|
|
|
|
|
|
|
|
Ok(Expr::new(ExprDef::ConstDecl(vars))) |
|
|
|
Ok(Expr::new(ExprDef::ConstDecl(vars))) |
|
|
|
} |
|
|
|
} |
|
|
|
Keyword::Return => Ok(Expr::new(ExprDef::Return(Some(Box::new( |
|
|
|
Keyword::Return => Ok(Expr::new(ExprDef::Return(Some(Box::new(self.parse()?))))), |
|
|
|
self.parse()?.clone(), |
|
|
|
|
|
|
|
))))), |
|
|
|
|
|
|
|
Keyword::New => { |
|
|
|
Keyword::New => { |
|
|
|
let call = self.parse()?; |
|
|
|
let call = self.parse()?; |
|
|
|
match call.def { |
|
|
|
match call.def { |
|
|
@ -310,7 +308,7 @@ impl Parser { |
|
|
|
_ => { |
|
|
|
_ => { |
|
|
|
return Err(ParseError::Expected( |
|
|
|
return Err(ParseError::Expected( |
|
|
|
vec![TokenData::Identifier("identifier".to_string())], |
|
|
|
vec![TokenData::Identifier("identifier".to_string())], |
|
|
|
tk.clone(), |
|
|
|
tk, |
|
|
|
"function name", |
|
|
|
"function name", |
|
|
|
)) |
|
|
|
)) |
|
|
|
} |
|
|
|
} |
|
|
@ -382,7 +380,7 @@ impl Parser { |
|
|
|
if let ExprDef::UnaryOp(UnaryOp::Spread, _) = next.def { |
|
|
|
if let ExprDef::UnaryOp(UnaryOp::Spread, _) = next.def { |
|
|
|
return Err(ParseError::Expected( |
|
|
|
return Err(ParseError::Expected( |
|
|
|
vec![TokenData::Punctuator(Punctuator::CloseParen)], |
|
|
|
vec![TokenData::Punctuator(Punctuator::CloseParen)], |
|
|
|
next_tok.clone(), |
|
|
|
next_tok, |
|
|
|
"arrow function", |
|
|
|
"arrow function", |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -425,7 +423,7 @@ impl Parser { |
|
|
|
vec![TokenData::Identifier( |
|
|
|
vec![TokenData::Identifier( |
|
|
|
"identifier".to_string(), |
|
|
|
"identifier".to_string(), |
|
|
|
)], |
|
|
|
)], |
|
|
|
ident_token.clone(), |
|
|
|
ident_token, |
|
|
|
"arrow function", |
|
|
|
"arrow function", |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -439,7 +437,7 @@ impl Parser { |
|
|
|
vec![TokenData::Identifier( |
|
|
|
vec![TokenData::Identifier( |
|
|
|
"identifier".to_string(), |
|
|
|
"identifier".to_string(), |
|
|
|
)], |
|
|
|
)], |
|
|
|
curr_tk.clone(), |
|
|
|
curr_tk, |
|
|
|
"arrow function", |
|
|
|
"arrow function", |
|
|
|
)) |
|
|
|
)) |
|
|
|
} |
|
|
|
} |
|
|
@ -499,7 +497,7 @@ impl Parser { |
|
|
|
TokenData::Punctuator(Punctuator::Comma), |
|
|
|
TokenData::Punctuator(Punctuator::Comma), |
|
|
|
TokenData::Punctuator(Punctuator::CloseBracket), |
|
|
|
TokenData::Punctuator(Punctuator::CloseBracket), |
|
|
|
], |
|
|
|
], |
|
|
|
token.clone(), |
|
|
|
token, |
|
|
|
"array declaration", |
|
|
|
"array declaration", |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -850,11 +848,7 @@ impl Parser { |
|
|
|
Expr::new(ExprDef::BinOp( |
|
|
|
Expr::new(ExprDef::BinOp( |
|
|
|
op2.clone(), |
|
|
|
op2.clone(), |
|
|
|
b.clone(), |
|
|
|
b.clone(), |
|
|
|
Box::new(Expr::new(ExprDef::BinOp( |
|
|
|
Box::new(Expr::new(ExprDef::BinOp(op, Box::new(orig), a.clone()))), |
|
|
|
op.clone(), |
|
|
|
|
|
|
|
Box::new(orig), |
|
|
|
|
|
|
|
a.clone(), |
|
|
|
|
|
|
|
))), |
|
|
|
|
|
|
|
)) |
|
|
|
)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Expr::new(ExprDef::BinOp(op, Box::new(orig), Box::new(next.clone()))) |
|
|
|
Expr::new(ExprDef::BinOp(op, Box::new(orig), Box::new(next.clone()))) |
|
|
|