Skip to content

Commit

Permalink
[JavaScript] Signs aren't part of numbers (sublimehq#2130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom1729 authored and mitranim committed Mar 20, 2022
1 parent fcadca9 commit 3dc5c41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
21 changes: 10 additions & 11 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1731,40 +1731,39 @@ contexts:
- include: object-property

literal-number:
- match: '[+-]?0[0-9]+{{identifier_break}}'
- match: '0[0-9]+{{identifier_break}}'
scope: constant.numeric.octal.js invalid.deprecated.numeric.octal.js
pop: true

- match: '[+-]?(0[Xx])[0-9a-fA-F_]*(n)?{{identifier_break}}'
- match: '(0[Xx])[0-9a-fA-F_]*(n)?{{identifier_break}}'
scope: constant.numeric.hexadecimal.js
captures:
1: punctuation.definition.numeric.hexadecimal.js
2: storage.type.numeric.bigint.js
pop: true

- match: '[+-]?(0[Oo])[0-7_]*(n)?{{identifier_break}}'
- match: '(0[Oo])[0-7_]*(n)?{{identifier_break}}'
scope: constant.numeric.octal.js
captures:
1: punctuation.definition.numeric.octal.js
2: storage.type.numeric.bigint.js
pop: true

- match: '[+-]?(0[Bb])[0-1_]*(n)?{{identifier_break}}'
- match: '(0[Bb])[0-1_]*(n)?{{identifier_break}}'
scope: constant.numeric.binary.js
captures:
1: punctuation.definition.numeric.binary.js
2: storage.type.numeric.bigint.js
pop: true

- match: '[+-]?(?:0|[1-9][0-9_]*)(n){{identifier_break}}'
- match: '(?:0|[1-9][0-9_]*)(n){{identifier_break}}'
scope: constant.numeric.decimal.js
captures:
1: storage.type.numeric.bigint.js
pop: true

- match: |-
(?x)
[-+]?
(
(?:0|[1-9][0-9_]*)
(?:\.[0-9_]*|(?!\.))
Expand All @@ -1776,23 +1775,23 @@ contexts:
scope: constant.numeric.decimal.js
pop: true
- match: '[+-]?0[Xx]{{identifier_part}}+{{identifier_break}}'
- match: '0[Xx]{{identifier_part}}+{{identifier_break}}'
scope: invalid.illegal.numeric.hexadecimal.js
pop: true

- match: '[+-]?0[Oo]{{identifier_part}}+{{identifier_break}}'
- match: '0[Oo]{{identifier_part}}+{{identifier_break}}'
scope: invalid.illegal.numeric.octal.js
pop: true

- match: '[+-]?0[Bb]{{identifier_part}}+{{identifier_break}}'
- match: '0[Bb]{{identifier_part}}+{{identifier_break}}'
scope: invalid.illegal.numeric.binary.js
pop: true

- match: '[+-]?0{{identifier_part}}+{{identifier_break}}'
- match: '0{{identifier_part}}+{{identifier_break}}'
scope: invalid.illegal.numeric.octal.js
pop: true

- match: '[+-]?[1-9]{{identifier_part}}+{{identifier_break}}(?:\.{{identifier_part}}*{{identifier_break}})?'
- match: '[1-9]{{identifier_part}}+{{identifier_break}}(?:\.{{identifier_part}}*{{identifier_break}})?'
scope: invalid.illegal.numeric.decimal.js
pop: true

Expand Down
6 changes: 4 additions & 2 deletions JavaScript/tests/syntax_test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1843,10 +1843,12 @@ function yy (a, b) {
// ^^^ meta.property.object

+123;
// ^^^^ constant.numeric.decimal - keyword
// ^ keyword.operator.arithmetic
// ^^^ constant.numeric.decimal - keyword

-123;
// ^^^^ constant.numeric.decimal - keyword
// ^ keyword.operator.arithmetic
// ^^^ constant.numeric.decimal - keyword

+ 123;
// ^ keyword.operator.arithmetic
Expand Down

0 comments on commit 3dc5c41

Please sign in to comment.