module Regexgen::Ast

Classes in the abstract syntax tree representation

Public Class Methods

parens(exp, parent) click to toggle source
# File lib/regexgen/ast.rb, line 187
def parens(exp, parent)
  str = exp.to_s
  if exp.precedence < parent.precedence
    unless exp.respond_to?(:single_character?) && exp.single_character?
      return "(?:#{str})" unless exp.respond_to?(:single_codepoint?) && exp.single_codepoint?
    end
  end

  str
end