Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Patch numeric underscores #112

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions grammars/haskell autocompletion hint.cson
Original file line number Diff line number Diff line change
Expand Up @@ -911,21 +911,29 @@
]
'lit_num':
'patterns': [
{
'name': 'constant.numeric.hexfloat.haskell'
'match': '0[xX][0-9a-fA-F_]*(?:\\.[0-9a-fA-F_]+(?:[pP][+-]?[0-9_]+)?|[pP][+-]?[0-9_]+)'
}
{
'name': 'constant.numeric.hexadecimal.haskell'
'match': '0[xX][0-9a-fA-F]+'
'match': '0[xX][_0-9a-fA-F]+'
}
{
'name': 'constant.numeric.octal.haskell'
'match': '0[oO][0-7]+'
'match': '0[oO][_0-7]+'
}
{
'name': 'constant.numeric.binary.haskell'
'match': '0[bB][_01]+'
}
{
'name': 'constant.numeric.float.haskell'
'match': '[0-9]+(\\.[0-9]+[eE][+-]?|\\.|[eE][+-]?)[0-9]+'
'match': '[0-9][0-9_]*(?:\\.[0-9_]+(?:[eE][+-]?[0-9_]+)?|[eE][+-]?[0-9_]+)'
}
{
'name': 'constant.numeric.decimal.haskell'
'match': '[0-9]+'
'match': '[0-9][_0-9]*'
}
]
'operator':
Expand Down
16 changes: 12 additions & 4 deletions grammars/haskell message hint.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions grammars/haskell type hint.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions grammars/haskell.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions grammars/liquid haskell.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions grammars/literate haskell.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions grammars/module signature.cson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/include/repository.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prelude = require './prelude'
pragmas = require './pragmas'
{ balanced } = require './util'
{ balanced, floatPattern } = require './util'

module.exports=
block_comment:
Expand Down Expand Up @@ -496,17 +496,23 @@ module.exports=
name: 'punctuation.separator.comma.haskell'
match: /,/
lit_num: [
name: 'constant.numeric.hexfloat.haskell'
match: "0[xX]#{floatPattern('[0-9a-fA-F_]','[pP]')}"
,
name: 'constant.numeric.hexadecimal.haskell'
match: '0[xX][0-9a-fA-F]+'
match: '0[xX][_0-9a-fA-F]+'
,
name: 'constant.numeric.octal.haskell'
match: '0[oO][0-7]+'
match: '0[oO][_0-7]+'
,
name: 'constant.numeric.binary.haskell'
match: '0[bB][_01]+'
,
name: 'constant.numeric.float.haskell'
match: '[0-9]+(\\.[0-9]+[eE][+-]?|\\.|[eE][+-]?)[0-9]+'
match: "[0-9]#{floatPattern('[0-9_]', '[eE]')}"
,
name: 'constant.numeric.decimal.haskell'
match: '[0-9]+'
match: '[0-9][_0-9]*'
]
operator:
name: 'keyword.operator.haskell'
Expand Down
6 changes: 5 additions & 1 deletion src/include/util.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ balanced = (name, left, right, inner, ignore = '') ->
else
"(?<#{name}>(?:[^#{left}#{right}#{ignore}]|#{left}\\g<#{name}>#{right})*)"

module.exports = {list, listMaybe, concat, balanced}
floatPattern = (digit, exp) ->
exponent = "#{exp}[+-]?[0-9_]+"
"#{digit}*(?:\\.#{digit}+(?:#{exponent})?|#{exponent})"

module.exports = {list, listMaybe, concat, balanced, floatPattern}