Skip to content

Commit

Permalink
Support literals with underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jun 29, 2020
1 parent 6c995f9 commit 2f73059
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const scalaTmLanguage: TmLanguage = {
name: 'constant.language.scala'
},
{
match: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.[0-9]+)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?|[0-9]+)([LlFfDd]|UL|ul)?\\b',
match: '\\b((0(x|X)[0-9a-fA-F_]*)|(([0-9][0-9_]*\\.[0-9][0-9_]*)|(\\.[0-9][0-9_]*))((e|E)(\\+|-)?[0-9][0-9_]*)?|[0-9][0-9_]*)([LlFfDd]|UL|ul)?\\b',
name: 'constant.numeric.scala'
},
{
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/numeric.literals.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SYNTAX TEST "source.scala"

1 2l 2L 3f 3F 4d 4D 5.6 2.3e56 2.3E56
// ^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^ constant.numeric.scala
// ^^^ constant.numeric.scala
// ^^^^^^ constant.numeric.scala
// ^^^^^^ constant.numeric.scala

-1
// ^ keyword.operator.arithmetic.scala
// ^ constant.numeric.scala

0x123abc
// ^^^^^^^^^ constant.numeric.scala

123_456
// ^^^^^^^ constant.numeric.scala

0x123_abc
// ^^^^^^^^^ constant.numeric.scala

110_222_795_799.99
// ^^^^^^^^^^^^^^^^^^ constant.numeric.scala

110.9499_999
// ^^^^^^^^^^^ constant.numeric.scala

2_000.343_999e561_100
// ^^^^^^^^^^^^^^^^^^^^^ constant.numeric.scala

.123_456
// ^^^^^^^ constant.numeric.scala

0 comments on commit 2f73059

Please sign in to comment.