class JsRegex::Converter::MetaConverter

Template class implementation.

Constants

DOT_EXPANSION
ML_DOT_EXPANSION

Private Instance Methods

convert_alternatives() click to toggle source
# File lib/js_regex/converter/meta_converter.rb, line 25
def convert_alternatives
  kept_any_previous_branch = nil

  convert_subexpressions.transform do |node|
    unless dropped_branch?(node)
      node.children.unshift('|') if kept_any_previous_branch
      kept_any_previous_branch = true
    end
    node
  end
end
convert_data() click to toggle source
# File lib/js_regex/converter/meta_converter.rb, line 14
def convert_data
  case subtype
  when :alternation
    convert_alternatives
  when :dot
    expression.multiline? ? ML_DOT_EXPANSION : DOT_EXPANSION
  else
    warn_of_unsupported_feature
  end
end
dropped_branch?(branch_node) click to toggle source
# File lib/js_regex/converter/meta_converter.rb, line 37
def dropped_branch?(branch_node)
  branch_node.children.any? && branch_node.children.all?(&:dropped?)
end