<commit_before>=begin copyright
    reg - the ruby extended grammar
    Copyright (C) 2005  <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=end

=begin
this file contains the various 'convenience constructors' which might pollute the
global namespace. it's optional, but highly recommended.

(note that reg.rb calls this, so requiring 'reg' gives you global sugar by default). 
=end

require 'set'



#tla sugar moved into the related files plus central stuff in regcore.rb
#(maybe the regcore stuff can move here?,,, but sugar is supposed to be optional...\

 
#need tlas for Reg::Knows, Reg::Symbol
 
    class Array
      def +@
        ::Reg::Array.new(*self)
      end
      def -@
        ::Reg::Subseq.new(*self)
      end
    end
    
    class Hash
      def +@
        ::Reg::Hash.new(self)
      end
      def -@
        ::Reg::Object.new(self)
      end
    end
    
    class Symbol
      def [](*args)
        huh #is the [] method even defined below?
        ::Reg::Knows.new(self)[*args]
      end
      
      def **(other)
        reg ** other
      end
      
      def -@
        #item_that.respond_to?(self).reg
        ::Reg::Knows.new(self)
      end
      
      def <<(other)
        ::Reg::Bound.new(self,other)
      end
    end
    #i'd like to take String#-@ and #** too...
    
    
    class Regexp
      #just like the original version of ::Regexp#~ 
      #(except this takes an optional argument to 
      #compare against something else.)
      def cmp(other=$_); 
        self =~ other 
      end
            
      include ::Reg::Reg

      def matches_class; ::String end

      #creates a Regexp that works with symbols instead of strings
      def sym; ::Reg::Symbol.new(self) end
<commit_msg>sugar syntax for BoundRef: Symbol#~<commit_after>=begin copyright
    reg - the ruby extended grammar
    Copyright (C) 2005  <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=end

=begin
this file contains the various 'convenience constructors' which might pollute the
global namespace. it's optional, but highly recommended.

(note that reg.rb calls this, so requiring 'reg' gives you global sugar by default). 
=end

require 'set'



#tla sugar moved into the related files plus central stuff in regcore.rb
#(maybe the regcore stuff can move here?,,, but sugar is supposed to be optional...\

 
#need tlas for Reg::Knows, Reg::Symbol
 
    class Array
      def +@
        ::Reg::Array.new(*self)
      end
      def -@
        ::Reg::Subseq.new(*self)
      end
    end
    
    class Hash
      def +@
        ::Reg::Hash.new(self)
      end
      def -@
        ::Reg::Object.new(self)
      end
    end
    
    class Symbol
      def [](*args)
        huh #is the [] method even defined below?
        ::Reg::Knows.new(self)[*args]
      end
      
      def **(other)
        reg ** other
      end
      
      def -@
        #item_that.respond_to?(self).reg
        ::Reg::Knows.new(self)
      end
      
      def <<(other)
        ::Reg::Bound.new(self,other)
      end

      def ~
        ::Reg::BoundRef.new(self)
      end
    end
    #i'd like to take String#-@ and #** too...
    
    
    class Regexp
      #just like the original version of ::Regexp#~ 
      #(except this takes an optional argument to 
      #compare against something else.)
      def cmp(other=$_); 
        self =~ other 
      end
            
      include ::Reg::Reg

      def matches_class; ::String end

      #creates a Regexp that works with symbols instead of strings
      def sym; ::Reg::Symbol.new(self) end

{'fraction_non_alphanumeric': 0.0830470802182259, 'fraction_numerical': 0.00808244089715094, 'mean_word_length': 2.2934131736526946, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6759052', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1370, 'n_words': 591}