class Regextest::Front
This routine defines front-end of Regextest
Front
end processes
Public Class Methods
new(reg_string, options)
click to toggle source
# File lib/regextest/front.rb, line 16 def initialize(reg_string, options) @options = options # Json option as a workaround for ruby 1.9.* @json_option = { max_nesting: 999 } # scanning the string scanner = Regextest::Front::Scanner.new lex_words = scanner.scan(reg_string) # initialize management class of parentheses @options[:parens] = Regextest::Front::ManageParentheses.new() # Prepare parsers (for whole regex parser and bracket parser) @parser = RegextestFrontParser.new # Do parse @parse_result = @parser.parse(lex_words, @options) # process options @parse_result.set_options(options) # sort parentheses, since number of parenthesis is by offset-order (not by parsing-order) @options[:parens].sort @parse_result end
Public Instance Methods
get_json_regex()
click to toggle source
Return JSON of regex
# File lib/regextest/front.rb, line 61 def get_json_regex JSON.pretty_generate(get_object["regex"], @json_option) end
get_json_string()
click to toggle source
Return JSON string
# File lib/regextest/front.rb, line 56 def get_json_string JSON.pretty_generate(get_object, @json_option) end
get_object()
click to toggle source
Output JSON format parse result of the regex
# File lib/regextest/front.rb, line 45 def get_object json_obj = JSON.parse(@parse_result.json, @json_option) parsed_object = { "regex" => json_obj, "source" => @options[:reg_source] } TstLog("JSON param:\n" + JSON.pretty_generate(parsed_object, @json_option)) parsed_object end