This repository was archived by the owner on Aug 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -257,16 +257,17 @@ pub fn tokenize(source: &str, debug: bool) -> Vec<String> {
257257 continue ;
258258 }
259259
260- // 检查数字
261- if c. is_digit ( 10 ) || ( c == '.' && i + 1 < chars. len ( ) && chars[ i + 1 ] . is_digit ( 10 ) ) {
260+ // 检查数字(包括科学计数法)
261+ if c. is_digit ( 10 ) || ( c == '.' && i + 1 < chars. len ( ) && chars[ i + 1 ] . is_digit ( 10 ) ) || ( c == 'e' || c == 'E' ) {
262262 let mut number = String :: new ( ) ;
263263 let mut has_dot = c == '.' ;
264-
264+
265265 if has_dot {
266266 number. push ( '.' ) ;
267267 i += 1 ;
268268 }
269-
269+
270+ // 解析整数部分和小数部分
270271 while i < chars. len ( ) && ( chars[ i] . is_digit ( 10 ) || ( chars[ i] == '.' && !has_dot) ) {
271272 if chars[ i] == '.' {
272273 // 检查是否是范围操作符
@@ -278,6 +279,25 @@ pub fn tokenize(source: &str, debug: bool) -> Vec<String> {
278279 number. push ( chars[ i] ) ;
279280 i += 1 ;
280281 }
282+
283+ // 检查科学计数法 (e 或 E)
284+ if i < chars. len ( ) && ( chars[ i] == 'e' || chars[ i] == 'E' ) {
285+ number. push ( chars[ i] ) ;
286+ i += 1 ;
287+
288+ // 检查可选的正负号
289+ if i < chars. len ( ) && ( chars[ i] == '+' || chars[ i] == '-' ) {
290+ number. push ( chars[ i] ) ;
291+ i += 1 ;
292+ }
293+
294+ // 解析指数部分
295+ while i < chars. len ( ) && chars[ i] . is_digit ( 10 ) {
296+ number. push ( chars[ i] ) ;
297+ i += 1 ;
298+ }
299+ }
300+
281301 tokens. push ( number) ;
282302 continue ;
283303 }
You can’t perform that action at this time.
0 commit comments