Skip to content

Commit

Permalink
Merge pull request #4 from gbaptista/gb-numbers
Browse files Browse the repository at this point in the history
Numbers
  • Loading branch information
gbaptista authored Mar 29, 2022
2 parents 79bc676 + 37d3806 commit bd66dea
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
15 changes: 8 additions & 7 deletions Fennel.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ variables:
evil_octal: '[-+]?0\d+N?(?=[{{non_symbol_chars}}])'
sign: '[-+]?'
exponent: (?:[eE]{{sign}}\d+)
dec_integer: ({{sign}})\d+(N?)(?=[{{non_number_chars}}])
number_separator: \d+(?:_\d+)*
dec_integer: ({{sign}}){{number_separator}}(N?)(?=[{{non_number_chars}}])
hex_integer: ({{sign}})(0[Xx])\h+(N?)(?=[{{non_number_chars}}])
other_integer: ({{sign}})((?:[2-9]|[1-9]\d+)[Rr])[0-9A-Za-z]+(?=[{{non_number_chars}}])
rational: ({{sign}})\d+(/)\d+(?=[{{non_number_chars}}])
float: ({{sign}})\d+(?:(?:(\.)\d+{{exponent}}?|{{exponent}})(M)?|(M))(?=[{{non_number_chars}}])
float: ({{sign}}){{number_separator}}(?:(?:(\.){{number_separator}}{{exponent}}?|{{exponent}})(M)?|(M))(?=[{{non_number_chars}}])

contexts:
main:
Expand Down Expand Up @@ -142,11 +143,11 @@ contexts:
captures:
1: punctuation.definition.numeric.sign.fennel
2: punctuation.definition.numeric.base.fennel
- match: '{{rational}}'
scope: constant.numeric.rational.decimal.fennel
captures:
1: punctuation.definition.numeric.sign.fennel
2: punctuation.separator.rational.fennel
# - match: '{{rational}}'
# scope: constant.numeric.rational.decimal.fennel
# captures:
# 1: punctuation.definition.numeric.sign.fennel
# 2: punctuation.separator.rational.fennel
- match: '{{float}}'
scope: constant.numeric.float.decimal.fennel
captures:
Expand Down
2 changes: 1 addition & 1 deletion tests/syntax_test_fennel_reference.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@
; ^^^^ source.fennel
; ^ punctuation.section.parens.begin.fennel
; ^^^^^ entity.name.tag.lua_support.fennel
; ^^ variable.language.lua_constant.fennel
; ^^ entity.other.inherited-class.constant.fennel
; ^ punctuation.section.parens.end.fennel
; ^ punctuation.section.brackets.end.fennel
(print name)))
Expand Down
19 changes: 17 additions & 2 deletions tests/syntax_test_fennel_reference_110.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@

; New forms

_1 7/8 1_
; <- source.fennel
;^^^^^^^^ source.fennel

10 120_000 1.5 120_0_00.10_10_0
; <- constant.numeric.integer.decimal.fennel
;^ constant.numeric.integer.decimal.fennel
; ^^^^^^^ constant.numeric.integer.decimal.fennel
; ^ constant.numeric.float.decimal.fennel
; ^ punctuation.separator.decimal.fennel
; ^ constant.numeric.float.decimal.fennel
; ^^^^^^^^ constant.numeric.float.decimal.fennel
; ^ punctuation.separator.decimal.fennel
; ^^^^^^^ constant.numeric.float.decimal.fennel

(collect [k v (pairs {:apple "red" :orange "orange"})]
; <- punctuation.section.parens.begin.fennel
;^^^^^^^ entity.name.tag.fennel_support.fennel
Expand Down Expand Up @@ -250,15 +265,15 @@
(set _G.a 1)
; <- punctuation.section.parens.begin.fennel
;^^^ entity.name.tag.fennel_support.fennel
; ^^ variable.language.lua_constant.fennel
; ^^ entity.other.inherited-class.constant.fennel
; ^^ source.fennel
; ^ constant.numeric.integer.decimal.fennel
; ^ punctuation.section.parens.end.fennel

(set _ENV.a 2)
; <- punctuation.section.parens.begin.fennel
;^^^ entity.name.tag.fennel_support.fennel
; ^^^^ variable.language.lua_constant.fennel
; ^^^^ entity.other.inherited-class.constant.fennel
; ^^ source.fennel
; ^ constant.numeric.integer.decimal.fennel
; ^ punctuation.section.parens.end.fennel
4 changes: 2 additions & 2 deletions tests/syntax_test_lua.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(print _G)
; <- punctuation.section.parens.begin.fennel
;^^^^^ entity.name.tag.lua_support.fennel
; ^^ variable.language.lua_constant.fennel
; ^^ entity.other.inherited-class.constant.fennel
; ^ punctuation.section.parens.end.fennel

(print (_G 1))
Expand All @@ -41,7 +41,7 @@
(print _VERSION)
; <- punctuation.section.parens.begin.fennel
;^^^^^ entity.name.tag.lua_support.fennel
; ^^^^^^^^ variable.language.lua_constant.fennel
; ^^^^^^^^ entity.other.inherited-class.constant.fennel
; ^ punctuation.section.parens.end.fennel

(print (_VERSION 1))
Expand Down

0 comments on commit bd66dea

Please sign in to comment.