Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tokenising of numbers in Elixir lexer #1225

Merged
merged 2 commits into from
Jun 28, 2019
Merged
Changes from 1 commit
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
Next Next commit
Improve Elixir lexer number rules
  • Loading branch information
thth authored and pyrmont committed Jun 26, 2019
commit 518d73dffbbb4ab7e6e72792cb44d0a41e5a1bae
7 changes: 5 additions & 2 deletions lib/rouge/lexers/elixir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ class Elixir < RegexLexer
rule %r/[a-zA-Z_!]\w*[!\?]?/, Name
rule %r{::|[%(){};,/\|:\\\[\]]}, Punctuation
rule %r/@[a-zA-Z_]\w*|&\d/, Name::Variable
rule %r{\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])
(_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, Num
rule %r{\b\d(_?\d)*(\.(?![^\d\s])(_?\d)+)([eE][-+]?\d(_?\d)*)?\b}, Num::Float
rule %r{\b0x[0-9A-Fa-f](_?[0-9A-Fa-f])*\b}, Num::Hex
rule %r{\b0o[0-7](_?[0-7])*\b}, Num::Oct
rule %r{\b0b[01](_?[01])*\b}, Num::Bin
rule %r{\b\d(_?\d)*\b}, Num::Integer

mixin :strings
mixin :sigil_strings
Expand Down