scanner: exponent without sign
							parent
							
								
									1007dd8f23
								
							
						
					
					
						commit
						80861f2219
					
				|  | @ -213,8 +213,13 @@ fn (s mut Scanner) ident_dec_number() string { | |||
| 	} | ||||
| 	// scan exponential part
 | ||||
| 	mut has_exponential_part := false | ||||
| 	if s.expect('e+', s.pos) || s.expect('e-', s.pos) { | ||||
| 		exp_start_pos := s.pos += 2 | ||||
| 	if s.expect('e', s.pos) || s.expect('E', s.pos) { | ||||
| 		exp_start_pos := (s.pos++) | ||||
| 
 | ||||
| 		if s.text[s.pos] in [`-`, `+`] { | ||||
| 			s.pos++ | ||||
| 		} | ||||
| 
 | ||||
| 		for s.pos < s.text.len && s.text[s.pos].is_digit() { | ||||
| 			s.pos++ | ||||
| 		} | ||||
|  |  | |||
|  | @ -208,8 +208,13 @@ fn (s mut Scanner) ident_dec_number() string { | |||
| 	} | ||||
| 	// scan exponential part
 | ||||
| 	mut has_exponential_part := false | ||||
| 	if s.expect('e+', s.pos) || s.expect('e-', s.pos) { | ||||
| 		exp_start_pos := s.pos += 2 | ||||
| 	if s.expect('e', s.pos) || s.expect('E', s.pos) { | ||||
| 		exp_start_pos := (s.pos++) | ||||
| 
 | ||||
| 		if s.text[s.pos] in [`-`, `+`] { | ||||
| 			s.pos++ | ||||
| 		} | ||||
| 
 | ||||
| 		for s.pos < s.text.len && s.text[s.pos].is_digit() { | ||||
| 			s.pos++ | ||||
| 		} | ||||
|  |  | |||
|  | @ -33,7 +33,16 @@ fn test_scan() { | |||
| 	assert c == 9 | ||||
| 	c = 1_000_000 | ||||
| 	assert c == 1000000 | ||||
| 	 | ||||
| 	// test float conversion and reading
 | ||||
| 	d := f64(23_000_000e-3) | ||||
| 	assert int(d) == 23000  | ||||
| 	mut e := f64(1.2E3) * f64(-1e-1) | ||||
| 	assert e == -120.0 | ||||
| 	e = f64(1.2E3) * f64(1e-1) | ||||
| 	assert e == 120.0 | ||||
| 	assert 1.23e+10 == 1.23e10 | ||||
| 	assert 1.23e+10 == 1.23e0010 | ||||
| 	assert -1.23e+10 == 1.23e0010*-1.0 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue