Module: Regexgen::Ast
- Defined in:
- lib/regexgen/ast.rb
Overview
Classes in the abstract syntax tree representation
Defined Under Namespace
Classes: Alternation, CharClass, Concatenation, Literal, Repetition
Class Method Summary collapse
Class Method Details
.parens(exp, parent) ⇒ Object
190 191 192 193 194 195 196 197 198 |
# File 'lib/regexgen/ast.rb', line 190 def parens(exp, parent) if exp.precedence < parent.precedence && !(exp.respond_to?(:single_character?) && exp.single_character?) && !(exp.respond_to?(:single_codepoint?) && exp.single_codepoint?) "(?:#{exp})" else exp.to_s end end |