Skip to content

Commit 3ce4743

Browse files
committed
Scan TkRATIONAL and TkIMAGINARY
1 parent 3a2f782 commit 3ce4743

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ def identify_number(op = "")
11251125
type = TkINTEGER
11261126
allow_point = true
11271127
allow_e = true
1128+
allow_ri = true
11281129
non_digit = false
11291130
while ch = getc
11301131
num << ch
@@ -1154,8 +1155,25 @@ def identify_number(op = "")
11541155
num << getc
11551156
end
11561157
allow_e = false
1158+
allow_ri = false
11571159
allow_point = false
11581160
non_digit = ch
1161+
when allow_ri && "r"
1162+
if non_digit
1163+
raise Error, "trailing `#{non_digit}' in number"
1164+
end
1165+
type = TkRATIONAL
1166+
if peek(0) == 'i'
1167+
type = TkIMAGINARY
1168+
num << getc
1169+
end
1170+
break
1171+
when allow_ri && "i"
1172+
if non_digit && non_digit != "r"
1173+
raise Error, "trailing `#{non_digit}' in number"
1174+
end
1175+
type = TkIMAGINARY
1176+
break
11591177
else
11601178
if non_digit
11611179
raise Error, "trailing `#{non_digit}' in number"

0 commit comments

Comments
 (0)