class Lexer
Lexer
The Parsing method is explicitly UTF-8 so the Lexer
is also explicitly UTF-8 Inorder to use the functions of yacc, we need to use BNF Grammar
Public Instance Methods
parse_number()
click to toggle source
# File lib/filipinomemes/ruby_parser_patches.rb, line 5 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_]+)/) 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) 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 #values of token which had a value associated with it. :tFLOAT elsif src.scan(/[+-]?[0-9_]+(?![e])/) int_with_base(10) else rb_compile_error 'Bad number format' end end