Skip to content

Commit

Permalink
[Matlab] Add meta.number (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann authored Sep 16, 2020
1 parent 558e49b commit d0faf86
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 43 deletions.
29 changes: 16 additions & 13 deletions Matlab/Matlab.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,26 @@ contexts:
comment: Not equal is written ~= not !=.
scope: invalid.illegal.invalid-inequality.matlab
number:
- match: '\b(0[xX])\h+(u8|u16|u32|u64|s8|s16|s32|s64)?\b'
scope: constant.numeric.integer.hexadecimal.matlab
- match: '\b(0[xX])(\h+)(u8|u16|u32|u64|s8|s16|s32|s64)?\b'
scope: meta.number.integer.hexadecimal.matlab
captures:
1: punctuation.definition.numeric.base.matlab
2: storage.type.numeric.matlab
- match: '\b(0[bB])[01]+(u8|u16|u32|u64|s8|s16|s32|s64)?\b'
scope: constant.numeric.integer.binary.matlab
1: constant.numeric.base.matlab
2: constant.numeric.value.matlab
3: constant.numeric.suffix.matlab
- match: '\b(0[bB])([01]+)(u8|u16|u32|u64|s8|s16|s32|s64)?\b'
scope: meta.number.integer.binary.matlab
captures:
1: punctuation.definition.numeric.base.matlab
2: storage.type.numeric.matlab
- match: '(?:\d*(\.))?\d+(?:[Ee][-+]?\d+)?(i|j)\b'
scope: constant.numeric.imaginary.decimal.matlab
1: constant.numeric.base.matlab
2: constant.numeric.value.matlab
3: constant.numeric.suffix.matlab
- match: '((?:\d*(\.))?\d+(?:[Ee][-+]?\d+)?)(i|j)\b'
scope: meta.number.imaginary.decimal.matlab
captures:
1: punctuation.separator.decimal.matlab
2: storage.type.numeric.matlab
1: constant.numeric.value.matlab
2: punctuation.separator.decimal.matlab
3: constant.numeric.suffix.matlab
- match: '(?:\d*(\.))?\d+(?:[Ee][-+]?\d+)?\b'
scope: constant.numeric.float.decimal.matlab
scope: meta.number.float.decimal.matlab constant.numeric.value.matlab
captures:
1: punctuation.separator.decimal.matlab
operators:
Expand Down
70 changes: 40 additions & 30 deletions Matlab/syntax_test_matlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
% <- source.matlab meta.variable.other.valid.matlab
% ^ source.matlab keyword.operator.symbols.matlab
% ^ source.matlab punctuation.section.brackets.begin.matlab
% ^^^^ source.matlab meta.brackets.matlab constant.numeric.float.decimal.matlab
% ^^^^ source.matlab meta.brackets.matlab meta.number.float.decimal.matlab constant.numeric.value.matlab
% ^ source.matlab punctuation.section.brackets.end.matlab


Expand Down Expand Up @@ -79,7 +79,7 @@
x = 5 %{ not block comment
% ^ keyword.operator.symbols.matlab
x = 5
% ^ constant.numeric.float.decimal.matlab
% ^ meta.number.float.decimal.matlab constant.numeric.value.matlab


%---------------------------------------------
Expand Down Expand Up @@ -146,52 +146,62 @@ function foo(bar)
% Numbers

1
%^ constant.numeric.float.decimal.matlab
%^ meta.number.float.decimal.matlab constant.numeric.value.matlab
.1
%^^ constant.numeric.float.decimal.matlab
%^^ meta.number.float.decimal.matlab constant.numeric.value.matlab
%^ punctuation.separator.decimal.matlab
1.1
%^^^ constant.numeric.float.decimal.matlab
%^^^ meta.number.float.decimal.matlab constant.numeric.value.matlab
% ^ punctuation.separator.decimal.matlab
.1e1
%^^^^ constant.numeric.float.decimal.matlab
%^^^^ meta.number.float.decimal.matlab constant.numeric.value.matlab
%^ punctuation.separator.decimal.matlab
1.1e1
%^^^^^ constant.numeric.float.decimal.matlab
%^^^^^ meta.number.float.decimal.matlab constant.numeric.value.matlab
% ^ punctuation.separator.decimal.matlab
1e1
%^^^ constant.numeric.float.decimal.matlab
%^^^ meta.number.float.decimal.matlab constant.numeric.value.matlab
1i - (4i)
%^^ constant.numeric.imaginary.decimal.matlab
% ^ storage.type.numeric.matlab
% ^^ constant.numeric.imaginary.decimal.matlab
% ^ storage.type.numeric.matlab
%^^ meta.number.imaginary.decimal.matlab constant.numeric
%^ constant.numeric.value.matlab
% ^ constant.numeric.suffix.matlab
% ^^ meta.number.imaginary.decimal.matlab constant.numeric
% ^ constant.numeric.value.matlab
% ^ constant.numeric.suffix.matlab
1j
%^^ constant.numeric.imaginary.decimal.matlab
% ^ storage.type.numeric.matlab
%^^ meta.number.imaginary.decimal.matlab constant.numeric
%^ constant.numeric.value.matlab
% ^ constant.numeric.suffix.matlab
1e2j
%^^^^ constant.numeric.imaginary.decimal.matlab
% ^ storage.type.numeric.matlab
%^^^^ meta.number.imaginary.decimal.matlab constant.numeric
%^^^ constant.numeric.value.matlab
% ^ constant.numeric.suffix.matlab
0x2A
%^^^^ constant.numeric.integer.hexadecimal.matlab
%^^ punctuation.definition.numeric.base.matlab
%^^^^ meta.number.integer.hexadecimal.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^ constant.numeric.value.matlab
0X2A
%^^^^ constant.numeric.integer.hexadecimal.matlab
%^^ punctuation.definition.numeric.base.matlab
%^^^^ meta.number.integer.hexadecimal.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^ constant.numeric.value.matlab
0b101010
%^^^^^^^^ constant.numeric.integer.binary.matlab
%^^ punctuation.definition.numeric.base.matlab
%^^^^^^^^ meta.number.integer.binary.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^^^^^ constant.numeric.value.matlab
0B101010
%^^^^^^^^ constant.numeric.integer.binary.matlab
%^^ punctuation.definition.numeric.base.matlab
%^^^^^^^^ meta.number.integer.binary.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^^^^^ constant.numeric.value.matlab
0x2Au8
%^^^^^^ constant.numeric.integer.hexadecimal.matlab
%^^ punctuation.definition.numeric.base.matlab
% ^^ storage.type.numeric.matlab
%^^^^^^ meta.number.integer.hexadecimal.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^ constant.numeric.value.matlab
% ^^ constant.numeric.suffix.matlab
0x2As32
%^^^^^^^ constant.numeric.integer.hexadecimal.matlab
%^^ punctuation.definition.numeric.base.matlab
% ^^^ storage.type.numeric.matlab
%^^^^^^^ meta.number.integer.hexadecimal.matlab constant.numeric
%^^ constant.numeric.base.matlab
% ^^ constant.numeric.value.matlab
% ^^^ constant.numeric.suffix.matlab


%---------------------------------------------
Expand Down

0 comments on commit d0faf86

Please sign in to comment.