Skip to content
This repository was archived by the owner on Feb 6, 2018. It is now read-only.

Commit a3b6663

Browse files
committed
fixed: float sometimes mistaken for integer (C# scanner)
1 parent 94fb287 commit a3b6663

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/coderay/scanners/csharp.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,19 @@ def scan_tokens encoder, options
135135
label_expected = false
136136
encoder.text_token match, :hex
137137

138-
elsif match = scan(/(?:\d+)(?![.DEFM])(?:UL?|LU?|)/i)
138+
elsif match = scan(/
139+
\.\d+(?:E[+-]?\d+)?[DFM]? |
140+
\d+ (?:
141+
\.\d+(?:E[+-]?\d+)?[DFM]? |
142+
E[+-]?\d+[DFM]? |
143+
[DFM] )
144+
/xi)
139145
label_expected = false
140-
encoder.text_token match, :integer
146+
encoder.text_token match, :float
141147

142-
elsif match = scan(/\d*\.\d+(?:E[+-]?\d+)?[DFM]?|\d+E[+-]?\d+[DFM]?|\d[DFM]?/i)
148+
elsif match = scan(/\d+(?:UL?|LU?|)/i)
143149
label_expected = false
144-
encoder.text_token match, :float
150+
encoder.text_token match, :integer
145151

146152
else
147153
encoder.text_token getch, :error

0 commit comments

Comments
 (0)