2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/bato/ruby_parser_patches.rb', line 2
def parse_number
self.lex_state = :expr_end
if src.scan(/[+-]?0[xXbBdD]\b/)
rb_compile_error 'Invalid numeric format'
elsif src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\,\d)\b|0[Dd][0-9_]+)/)
int_with_base(10)
elsif src.scan(/[+-]?0x[a-f0-9_]+/i)
int_with_base(16)
elsif src.scan(/[+-]?0[Bb][01_]+/)
int_with_base(2)
elsif src.scan(/[+-]?0[Oo]?[0-7_]*[89]/)
rb_compile_error 'Illegal octal digit.'
elsif src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/)
int_with_base(8)
elsif src.scan(/[+-]?[\d_]+_(e|\.)/)
rb_compile_error "Trailing '_' in number."
elsif src.scan(/[+-]?[\d_]+\,[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i)
number = src.matched.sub(',', '.')
rb_compile_error 'Invalid numeric format' if number =~ /__/
self.yacc_value = number.to_f
:tFLOAT
elsif src.scan(/[+-]?[0-9_]+(?![e])/)
int_with_base(10)
else
rb_compile_error 'Bad number format'
end
end
|