mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:28:11 +00:00
LibJS: Add spreading in array literals
Implement the syntax and behavor necessary to support array literals such as [...[1, 2, 3]]. A type error is thrown if the target of the spread operator does not evaluate to an array (though it should eventually just check for an iterable). Note that the spread token's name is TripleDot, since the '...' token is used for two features: spread and rest. Calling it anything involving 'spread' or 'rest' would be a bit confusing.
This commit is contained in:
parent
49c438ce32
commit
80fecc615a
6 changed files with 101 additions and 2 deletions
|
@ -84,6 +84,7 @@ Lexer::Lexer(StringView source)
|
|||
s_three_char_tokens.set("<<=", TokenType::ShiftLeftEquals);
|
||||
s_three_char_tokens.set(">>=", TokenType::ShiftRightEquals);
|
||||
s_three_char_tokens.set(">>>", TokenType::UnsignedShiftRight);
|
||||
s_three_char_tokens.set("...", TokenType::TripleDot);
|
||||
}
|
||||
|
||||
if (s_two_char_tokens.is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue