Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete future reserved keywords from javascript.rb. #1126

Merged
merged 6 commits into from
May 29, 2019

Conversation

Masa-Shin
Copy link
Contributor

These keywords are no longer reserved(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Future_reserved_keywords). There might be no backward compatibility issue because they have never really been keyword.

These keywords are no longer reserved. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Future_reserved_keywords There might be no backward compatibility issue because they have never really been keyword.
@pyrmont
Copy link
Contributor

pyrmont commented May 23, 2019

I ran it locally and tests passed fine.

I can kind of see the backwards compatibility argument but that's true about any update to a lexer that changes behaviour based on changes to the language.

According to ES2018 specification, the Latest ECMA Standards(https://www.ecma-international.org/ecma-262/9.0/index.html#sec-keywords), the following are the keywords:

```
await break case catch class const continue debugger default delete do else export extends finally for function if import in instanceof new return super switch this throw try typeof var void while with yield
```

The list above has some declarations keywords so I removed it. And the list lacks some words that is used as keyword: 'from', 'as', 'of', and 'async'. I added these 4 words because they have been in our list and should be highlighted.

So as the result I just added 'await' and 'debugger' to our list and nothing is removed.
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of identifiers in both self.keywords and self.reserved doesn't actually match the reserved words in the ES6 spec. Do you think it's worth taking this opportunity to update everything to be consistent?

@pyrmont pyrmont added the author-action The PR has been reviewed but action by the author is needed label May 28, 2019
@Masa-Shin
Copy link
Contributor Author

@pyrmont Yes, would be more consistent. I'll make a PR.

@pyrmont
Copy link
Contributor

pyrmont commented May 28, 2019

Thanks! Feel free just to update this PR :)

@Masa-Shin
Copy link
Contributor Author

Update the keywords, the declarations, and the reserved words according to the latest ES Specification.
ECMA2018

Some words like 'async', 'from', and 'of' are not listed as keyword in the specification but I added them to our list of keywords because they have already been, and widely recognized as keywords. For more detail please see the commit messages.

@pyrmont
Copy link
Contributor

pyrmont commented May 28, 2019

In case it's of assistance for future reference, the following terms have special meaning in JavaScript even if they aren't formally listed as keywords or reserved words:

They remain in Rouge's list for that reason.

lib/rouge/lexers/javascript.rb Outdated Show resolved Hide resolved
@pyrmont pyrmont merged commit 683551a into rouge-ruby:master May 29, 2019
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants