# class Treetop::Compiler::CharacterClass

### Public Instance Methods

compile(address, builder, parent_expression = nil) click to toggle source
Calls superclass method

    # File lib/treetop/compiler/node_classes/character_class.rb, line 4
    def compile(address, builder, parent_expression = nil)
      super

      builder.if__ "has_terminal?(#{grounded_regexp(text_value)}, true, index)" do
        if address == 0 || decorated?
          assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))"
          extend_result_with_inline_module
        else
          assign_lazily_instantiated_node
        end
        builder << "@index += 1"
      end
      builder.else_ do
        # "terminal_parse_failure(#{single_quote(characters)})"
        assign_result 'nil'
      end
    end

grounded_regexp(string) click to toggle source

    # File lib/treetop/compiler/node_classes/character_class.rb, line 22
    def grounded_regexp(string)
      # Double any backslashes, then backslash any single-quotes:
      "'\\G#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'"
    end