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

[JavaScript] Eliminate goto, add break/continue labels. #1613

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ contexts:
scope: keyword.control.trycatch.js
set: restricted-production

- match: (?:break|continue|goto){{identifier_break}}
- match: (?:break|continue){{identifier_break}}
scope: keyword.control.loop.js
set: expect-semicolon
set:
- expect-semicolon
- expect-label

- match: return{{identifier_break}}
scope: keyword.control.flow.js
Expand All @@ -295,6 +297,14 @@ contexts:
pop: true
- include: else-pop

expect-label:
- match: '{{identifier}}'
scope: variable.label.js
pop: true
- match: $
pop: true
- include: else-pop

block:
- match: '\{'
scope: punctuation.section.block.begin.js
Expand Down
24 changes: 23 additions & 1 deletion JavaScript/tests/syntax_test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,29 @@ while (true)
// ^^^^^ keyword.control.flow

break;
// ^^^^^^ meta.while meta.block
// ^^^^^ keyword.control.loop

break foo;
// ^^^^^ keyword.control.loop
// ^^^ variable.label

break
foo;
// ^^^ variable.other.readwrite - variable.label

continue;
// ^^^^^^^^ keyword.control.loop

continue foo;
// ^^^^^^^^ keyword.control.loop
// ^^^ variable.label

continue
foo;
// ^^^ variable.other.readwrite - variable.label

goto;
// ^^^^ variable.other.readwrite - keyword
}
// <- meta.block

Expand Down