Skip to content

Commit

Permalink
Fix floating point separators in Rust lexer (#1581)
Browse files Browse the repository at this point in the history
The Rust lexer does not currently support the use of `_` in floating
point numbers. If the separator comes immedately after the first digit,
Rouge lexes it as an error. This commit fixes that bug.
  • Loading branch information
hugopeixoto committed Sep 8, 2020
1 parent a9fdd44 commit 6c9d1b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/rust.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def macro_closed?
flt = /f32|f64/

rule %r(
[0-9]+
[0-9_]+
(#{dot} #{exp}? #{flt}?
|#{dot}? #{exp} #{flt}?
|#{dot}? #{exp}? #{flt}
Expand Down
4 changes: 4 additions & 0 deletions spec/visual/samples/rust
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ fn int_literals_delimiter() {
let red_color = 0xff_60_60;
}

fn float_literals_delimiter() {
let billion = 1000_000_000.0;
}

// Some hidden lines by starting with hash
# extern crate core;
# use core::str;
Expand Down

0 comments on commit 6c9d1b7

Please sign in to comment.