repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/options_spec.rb
spec/expression/options_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Base#options') do it 'returns a hash of options/flags that affect the expression' do exp = RP.parse(/a/ix)[0] expect(exp).to be_a Literal expect(exp.options).to eq(i: true, x: true) end it 'includes options that are loc...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/construct_spec.rb
spec/expression/methods/construct_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Expression::Shared) do describe '::construct' do { Alternation => :meta, Alternative => :expression, Anchor::Base => :anchor, Anchor::EndOfLine ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/match_spec.rb
spec/expression/methods/match_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Base#match') do it 'returns the #match result of the respective Regexp' do expect(RP.parse(/a/).match('a')[0]).to eq 'a' end it 'can be given an offset, just like Regexp#match' do expect(RP.parse(/./).match('ab', 1)[0]).to ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/negative_spec.rb
spec/expression/methods/negative_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Base#negative?') do include_examples 'parse', //, [] => [:root, negative?: false] include_examples 'parse', /a/, [0] => [:literal, negative?: false] include_examples 'parse', /\b/, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/traverse_spec.rb
spec/expression/methods/traverse_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Subexpression#traverse') do specify('Subexpression#traverse') do root = RP.parse(/a(b(c(d)))|g[h-i]j|klmn/) enters = 0 visits = 0 exits = 0 root.traverse do |event, _exp, _index| enters = (enters + 1) if event == :enter ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/strfregexp_spec.rb
spec/expression/methods/strfregexp_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Base#strfregexp') do specify('#strfre alias') do expect(RP.parse(/a/)).to respond_to(:strfre) end specify('#strfregexp level') do root = RP.parse(/a(b(c))/) expect(root.strfregexp('%l')).to eq 'root' a = root.firs...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/tests_spec.rb
spec/expression/methods/tests_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('ExpressionTests') do specify('#type?') do root = RP.parse(/abcd|(ghij)|[klmn]/) alt = root.first expect(alt.type?(:meta)).to be true expect(alt.type?(:escape)).to be false expect(alt.type?(%i[meta escape])).to be true expe...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/human_name_spec.rb
spec/expression/methods/human_name_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Regexp::Expression::Shared#human_name') do include_examples 'parse', //, [] => [human_name: 'root'] include_examples 'parse', /a/, [0] => [human_name: 'literal'] include_examples 'parse', /./, [0] ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/parts_spec.rb
spec/expression/methods/parts_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Base#parts') do include_examples 'parse', //, [] => [:root, parts: []] include_examples 'parse', /a/, [0] => [:literal, parts: ['a']] include_examples 'parse', /\K/, [0] => [:mark, parts: ['\K']] inc...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/printing_spec.rb
spec/expression/methods/printing_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Expression::Shared#inspect') do it 'includes only essential information' do root = Regexp::Parser.parse(//) expect(root.inspect).to eq '#<Regexp::Expression::Root @expressions=[]>' root = Regexp::Parser.parse(/(a)+/) expect(root.in...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/methods/match_length_spec.rb
spec/expression/methods/match_length_spec.rb
# frozen_string_literal: true require 'spec_helper' ML = Regexp::MatchLength RSpec.describe(Regexp::MatchLength) do specify('literal') { expect(ML.of(/a/).minmax).to eq [1, 1] } specify('literal sequence') { expect(ML.of(/abc/).minmax).to eq [3, 3] } specify('dot') { expect(ML.of(/./).minmax).to eq [1, 1] } ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/token/token_spec.rb
spec/token/token_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Token) do specify('#offset') do regexp = /ab?cd/ tokens = RL.lex(regexp) expect(tokens[1].text).to eq 'b' expect(tokens[1].offset).to eq [1, 2] expect(tokens[2].text).to eq '?' expect(tokens[2].offset).to eq [2, 3] ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/syntax_token_map_spec.rb
spec/syntax/syntax_token_map_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::Token::Map) do let(:map) { Regexp::Syntax::Token::Map } let(:current_syntax) { Regexp::Syntax::CURRENT } specify('is complete') do current_syntax.features.each do |type, tokens| tokens.each { |token| expect(map[type])....
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/syntax_spec.rb
spec/syntax/syntax_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax) do describe('::for') do it { expect(Regexp::Syntax.for('ruby/1.8.6')).to eq Regexp::Syntax::V1_8_6 } it { expect(Regexp::Syntax.for('ruby/1.8')).to eq Regexp::Syntax::V1_8_6 } it { expect(Regexp::Syntax.for('ruby/1.9....
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/3.2.0_spec.rb
spec/syntax/versions/3.2.0_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V3_2_0) do include_examples 'syntax', implements: { property: T::UnicodeProperty::Script_V3_2_0 + T::UnicodeProperty::Age_V3_2_0, nonproperty: T::UnicodeProperty::Script_V3_2_0 + T::UnicodeProperty::Age_V3_2_0 } end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/2.0.0_spec.rb
spec/syntax/versions/2.0.0_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V2_0_0) do include_examples 'syntax', implements: { property: T::UnicodeProperty::Age_V2_0_0, nonproperty: T::UnicodeProperty::Age_V2_0_0 }, excludes: { property: %i[newline], nonproperty: %i[newline] } end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/1.8.6_spec.rb
spec/syntax/versions/1.8.6_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V1_8_6) do include_examples 'syntax', implements: { assertion: T::Assertion::Lookahead, backref: T::Backreference::Plain, escape: T::Escape::Basic + T::Escape::ASCII + T::Escape::Meta + T::Escape::Control, group: T:...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/1.9.3_spec.rb
spec/syntax/versions/1.9.3_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V1_9_3) do include_examples 'syntax', implements: { property: T::UnicodeProperty::Script_V1_9_3 + T::UnicodeProperty::Age_V1_9_3, nonproperty: T::UnicodeProperty::Script_V1_9_3 + T::UnicodeProperty::Age_V1_9_3 } end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/2.2.0_spec.rb
spec/syntax/versions/2.2.0_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V2_2_0) do include_examples 'syntax', implements: { property: T::UnicodeProperty::Script_V2_2_0 + T::UnicodeProperty::Age_V2_2_0, nonproperty: T::UnicodeProperty::Script_V2_2_0 + T::UnicodeProperty::Age_V2_2_0 } end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/syntax/versions/1.9.1_spec.rb
spec/syntax/versions/1.9.1_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Syntax::V1_9_1) do include_examples 'syntax', implements: { escape: T::Escape::Hex + T::Escape::Octal + T::Escape::Unicode, type: T::CharacterType::Hex, quantifier: T::Quantifier::Greedy + T::Quantifier::Reluctant + T::Quantifi...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/groups_spec.rb
spec/parser/groups_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Group parsing') do include_examples 'parse', /(?=abc)(?!def)/, 0 => [:assertion, :lookahead, Assertion::Lookahead], 1 => [:assertion, :nlookahead, Assertion::NegativeLookahead] include_examples 'parse', /(?<=abc)(?<!def)/, 0 => [:...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/properties_spec.rb
spec/parser/properties_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Property parsing') do # test various notations supported by Ruby include_examples 'parse', '\p{sd}', 0 => [:property, :soft_dotted] include_examples 'parse', '\p{SD}', 0 => [:property, :soft_dotted] include_examples 'parse...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/escapes_spec.rb
spec/parser/escapes_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('EscapeSequence parsing') do es = EscapeSequence include_examples 'parse', /a\ac/, 1 => [:escape, :bell, es::Bell] include_examples 'parse', /a\ec/, 1 => [:escape, :escape, es::AsciiEscape] include_examples...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/all_spec.rb
spec/parser/all_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Parser) do specify('parse returns a root expression') do expect(RP.parse('abc')).to be_instance_of(Root) end specify('parse can be called with block') do expect(RP.parse('abc') { |root| root.class }).to eq Root end specify(...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/alternation_spec.rb
spec/parser/alternation_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Alternation parsing') do include_examples 'parse', /a|b/, [0] => [Alternation, text: '|', count: 2], [0, 0] => [Alternative, text: '', count: 1], [0, 0, 0] => [:literal, text: 'a' ], [0, 1] => [Alternative, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/types_spec.rb
spec/parser/types_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('CharacterType parsing') do include_examples 'parse', /a\dc/, 1 => [:type, :digit, CharacterType::Digit] include_examples 'parse', /a\Dc/, 1 => [:type, :nondigit, CharacterType::NonDigit] include_examples 'parse', /a\sc/, 1 => [:type, :spa...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/posix_classes_spec.rb
spec/parser/posix_classes_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('PosixClass parsing') do include_examples 'parse', /[[:word:]]/, [0] => [CharacterSet, count: 1], [0, 0] => [:posixclass, :word, PosixClass, name: 'word', text: '[:word:]'] include_examples 'parse', /[[:^word:]]/, [0] => [Char...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/keep_spec.rb
spec/parser/keep_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Keep parsing') do include_examples 'parse', /ab\Kcd/, 1 => [:keep, :mark, Keep::Mark, text: '\K'] include_examples 'parse', /(a\K)/, [0, 1] => [:keep, :mark, Keep::Mark, text: '\K'] end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/refcalls_spec.rb
spec/parser/refcalls_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Refcall parsing') do include_examples 'parse', /(abc)\1/, 1 => [Backreference::Number, reference: 1] include_examples 'parse', /(?<X>abc)\k<X>/, 1 => [Backreference::Name, name: 'X', reference: 'X'] include_examples 'parse', /(?<X>abc)\...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/free_space_spec.rb
spec/parser/free_space_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('FreeSpace parsing') do include_examples 'parse', /a b c/, [0] => [Literal, text: 'a b c'] include_examples 'parse', /a b c/x, [0] => [Literal, text: 'a'], [1] => [WhiteSpace, text: ' '], [2] => [Literal, text: 'b'], [3] => [W...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/conditionals_spec.rb
spec/parser/conditionals_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Conditional parsing') do include_examples 'parse', /(?<A>a)(?(<A>)T|F)/, [1] => [:conditional, :open, Conditional::Expression, to_s: '(?(<A>)T|F)', reference: 'A', ts: 7], [1, 0] => [:conditional, :condition, Conditional::Condition...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/errors_spec.rb
spec/parser/errors_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Parsing errors') do let(:parser) { Regexp::Parser.new } before { parser.parse(/foo/) } # initializes ivars it('raises UnknownTokenTypeError for unknown token types') do expect { parser.send(:parse_token, Regexp::Token.new(:foo, :bar)) } ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/sets_spec.rb
spec/parser/sets_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('CharacterSet parsing') do include_examples 'parse', /[ab]+/, [0] => [:set, :character, CharacterSet, text: '[', count: 2, quantified?: true], [0, 0] => [:literal, :literal, Literal, text: 'a', set_level: 1], [0, 1] => [:literal, :lit...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/quantifiers_spec.rb
spec/parser/quantifiers_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Quantifier parsing') do include_examples 'parse', /a?b/, [0, :q] => [:zero_or_one, text: '?', mode: :greedy, min: 0, max: 1, ts: 1] include_examples 'parse', /a??b/, [0, :q] => [:zero_or_one, text: '??', mode: :reluctant, mi...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/options_spec.rb
spec/parser/options_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('passing options to parse') do it 'raises if if parsing from a Regexp and options are passed' do expect { RP.parse(/a+/, options: ::Regexp::EXTENDED) }.to raise_error( ArgumentError, 'options cannot be supplied unless parsing a Strin...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/anchors_spec.rb
spec/parser/anchors_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Anchor parsing') do include_examples 'parse', /^a/, 0 => [:anchor, :bol, Anchor::BOL] include_examples 'parse', /a$/, 1 => [:anchor, :eol, Anchor::EOL] include_examples 'parse', /\Aa/, 0 => [:anchor, :bos, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/set/ranges_spec.rb
spec/parser/set/ranges_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('CharacterSet::Range parsing') do include_examples 'parse', '[a-z]', [0] => [CharacterSet, count: 1], [0, 0] => [CharacterSet::Range, count: 2], [0, 0, 0] => [:literal, text: 'a'], [0, 0, 1] => [:literal, text: 'z'] inclu...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/parser/set/intersections_spec.rb
spec/parser/set/intersections_spec.rb
# frozen_string_literal: true require 'spec_helper' # edge cases with `...-&&...` and `...&&-...` are checked in ./ranges_spec.rb RSpec.describe('CharacterSet::Intersection parsing') do include_examples 'parse', /[a&&z]/, [0] => [CharacterSet, count: 1], [0, 0] => [CharacterSet::Intersection...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/escapes_spec.rb
spec/lexer/escapes_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Escape lexing') do include_examples 'lex', '\u{62}', 0 => [:escape, :codepoint_list, '\u{62}', 0, 6, 0, 0, 0] include_examples 'lex', '\u{62 63 64}', 0 => [:escape, :codepoint_list, '\u{62 63 64}', 0, 12, 0, 0, 0] include_exa...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/all_spec.rb
spec/lexer/all_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Regexp::Lexer) do specify('lexer returns an array') do expect(RL.lex('abc')).to be_instance_of(Array) end specify('lexer returns tokens') do tokens = RL.lex('^abc+[^one]{2,3}\b\d\C-C$') expect(tokens).to all(be_a Regexp::Token) ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/delimiters_spec.rb
spec/lexer/delimiters_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Literal delimiter lexing') do include_examples 'lex', '}', 0 => [:literal, :literal, '}', 0, 1, 0, 0, 0] include_examples 'lex', '}}', 0 => [:literal, :literal, '}}', 0, 2, 0, 0, 0] include_examples ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/keep_spec.rb
spec/lexer/keep_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Keep lexing') do include_examples 'lex', /ab\Kcd/, 1 => [:keep, :mark, '\K', 2, 4, 0, 0, 0] include_examples 'lex', /(a\Kb)|(c\\\Kd)ef/, 2 => [:keep, :mark, '\K', 2, 4, 1, 0, 0], 9 => [:keep, :mark, '\K', 11, 13, 1, 0, 0] end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/refcalls_spec.rb
spec/lexer/refcalls_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('RefCall lexing') do # Traditional numerical group back-reference include_examples 'lex', '(abc)\1', 3 => [:backref, :number, '\1', 5, 7, 0, 0, 0] # Group back-references, named, numbered, and relative include_exam...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/nesting_spec.rb
spec/lexer/nesting_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Nesting lexing') do include_examples 'lex', /(((b)))/, 0 => [:group, :capture, '(', 0, 1, 0, 0, 0], 1 => [:group, :capture, '(', 1, 2, 1, 0, 0], 2 => [:group, :capture, '(', 2, 3, 2, 0, 0], 3 => [:literal, :lit...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/conditionals_spec.rb
spec/lexer/conditionals_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Conditional lexing') do include_examples 'lex', /(?<A>a)(?(<A>)b|c)/, 3 => [:conditional, :open, '(?', 7, 9, 0, 0, 0], 4 => [:conditional, :condition, '(<A>)', 9, 14, 0, 0, 1], 6 => [:conditional, :separator, '|', 15, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/lexer/literals_spec.rb
spec/lexer/literals_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe('Literal lexing') do # ascii, single byte characters include_examples 'lex', 'a', 0 => [:literal, :literal, 'a', 0, 1, 0, 0, 0] include_examples 'lex', 'ab+', 0 => [:literal, :literal, 'a', 0, 1, 0, 0, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser.rb
lib/regexp_parser.rb
# frozen_string_literal: true require_relative 'regexp_parser/version' require_relative 'regexp_parser/token' require_relative 'regexp_parser/scanner' require_relative 'regexp_parser/syntax' require_relative 'regexp_parser/lexer' require_relative 'regexp_parser/parser'
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax.rb
lib/regexp_parser/syntax.rb
# frozen_string_literal: true require_relative 'error' module Regexp::Syntax class SyntaxError < Regexp::Parser::Error; end end require_relative 'syntax/token' require_relative 'syntax/base' require_relative 'syntax/any' require_relative 'syntax/version_lookup' require_relative 'syntax/versions'
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/version.rb
lib/regexp_parser/version.rb
# frozen_string_literal: true class Regexp class Parser VERSION = '2.11.3' end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/parser.rb
lib/regexp_parser/parser.rb
# frozen_string_literal: true require_relative 'error' require_relative 'expression' class Regexp::Parser include Regexp::Expression class ParserError < Regexp::Parser::Error; end class UnknownTokenTypeError < ParserError def initialize(type, token) super "Unknown token type #{type} #{token.inspect}...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/lexer.rb
lib/regexp_parser/lexer.rb
# frozen_string_literal: true # A very thin wrapper around the scanner that breaks quantified literal runs, # collects emitted tokens into an array, calculates their nesting depth, and # normalizes tokens for the parser, and checks if they are implemented by the # given syntax flavor. class Regexp::Lexer OPENING_TO...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/token.rb
lib/regexp_parser/token.rb
# frozen_string_literal: true class Regexp TOKEN_KEYS = %i[ type token text ts te level set_level conditional_level ].freeze Token = Struct.new(*TOKEN_KEYS) do attr_accessor :previous, :next def offset [ts, te] end def length te - ts end end en...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression.rb
lib/regexp_parser/expression.rb
# frozen_string_literal: true require_relative 'error' require_relative 'expression/shared' require_relative 'expression/base' require_relative 'expression/quantifier' require_relative 'expression/subexpression' require_relative 'expression/sequence' require_relative 'expression/sequence_operation' require_relative ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/error.rb
lib/regexp_parser/error.rb
# frozen_string_literal: true class Regexp::Parser # base class for all gem-specific errors class Error < StandardError; end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/scanner/errors/scanner_error.rb
lib/regexp_parser/scanner/errors/scanner_error.rb
# frozen_string_literal: true require_relative '../../../regexp_parser/error' class Regexp::Scanner # General scanner error (catch all) class ScannerError < Regexp::Parser::Error; end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/scanner/errors/validation_error.rb
lib/regexp_parser/scanner/errors/validation_error.rb
# frozen_string_literal: true class Regexp::Scanner # Base for all scanner validation errors class ValidationError < ScannerError # Centralizes and unifies the handling of validation related errors. def self.for(type, problem, reason = nil) types.fetch(type).new(problem, reason) end def self...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/scanner/errors/premature_end_error.rb
lib/regexp_parser/scanner/errors/premature_end_error.rb
# frozen_string_literal: true class Regexp::Scanner # Unexpected end of pattern class PrematureEndError < ScannerError def initialize(where = '') super "Premature end of pattern at #{where}" end end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/sequence_operation.rb
lib/regexp_parser/expression/sequence_operation.rb
# frozen_string_literal: true module Regexp::Expression # abstract class class SequenceOperation < Regexp::Expression::Subexpression alias :sequences :expressions alias :operands :expressions alias :operator :text def ts (head = expressions.first) ? head.ts : @ts end def <<(exp) ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/sequence.rb
lib/regexp_parser/expression/sequence.rb
# frozen_string_literal: true module Regexp::Expression # A sequence of expressions. Differs from a Subexpressions by how it handles # quantifiers, as it applies them to its last element instead of itself as # a whole subexpression. # # Used as the base class for the Alternation alternatives, Conditional #...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/subexpression.rb
lib/regexp_parser/expression/subexpression.rb
# frozen_string_literal: true module Regexp::Expression class Subexpression < Regexp::Expression::Base include Enumerable attr_accessor :expressions def initialize(token, options = {}) self.expressions = [] super end # Override base method to clone the expressions as well. def ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/base.rb
lib/regexp_parser/expression/base.rb
# frozen_string_literal: true module Regexp::Expression class Base include Regexp::Expression::Shared def initialize(token, options = {}) init_from_token_and_options(token, options) end def to_re(format = :full) if set_level > 0 warn "Calling #to_re on character set members is d...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/quantifier.rb
lib/regexp_parser/expression/quantifier.rb
# frozen_string_literal: true module Regexp::Expression # TODO: in v3.0.0, maybe put Shared back into Base, and inherit from Base and # call super in #initialize, but raise in #quantifier= and #quantify, # or introduce an Expression::Quantifiable intermediate class. # Or actually allow chaining as a more conci...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/shared.rb
lib/regexp_parser/expression/shared.rb
# frozen_string_literal: true module Regexp::Expression module Shared module ClassMethods; end # filled in ./methods/*.rb def self.included(mod) mod.class_eval do extend Shared::ClassMethods attr_accessor :type, :token, :text, :ts, :te, :level, :set_level, :condi...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/strfregexp.rb
lib/regexp_parser/expression/methods/strfregexp.rb
# frozen_string_literal: true module Regexp::Expression class Base # %l Level (depth) of the expression. Returns 'root' for the root # expression, returns zero or higher for all others. # # %> Indentation at expression's level. # # %x Index of the expression at its depth. Avai...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/options.rb
lib/regexp_parser/expression/methods/options.rb
# frozen_string_literal: true module Regexp::Expression class Base def multiline? options[:m] == true end alias :m? :multiline? def case_insensitive? options[:i] == true end alias :i? :case_insensitive? alias :ignore_case? :case_insensitive? def free_spacing? optio...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/match_length.rb
lib/regexp_parser/expression/methods/match_length.rb
# frozen_string_literal: true class Regexp::MatchLength include Enumerable def self.of(obj) exp = obj.is_a?(Regexp::Expression::Base) ? obj : Regexp::Parser.parse(obj) exp.match_length end def initialize(exp, opts = {}) self.exp_class = exp.class self.min_rep = exp.repetitions.min self.ma...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/parts.rb
lib/regexp_parser/expression/methods/parts.rb
# frozen_string_literal: true module Regexp::Expression module Shared # default implementation def parts [text.dup] end private def intersperse(expressions, separator) expressions.flat_map { |exp| [exp, separator] }.slice(0...-1) end end CharacterSet.class_eval {...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/referenced_expressions.rb
lib/regexp_parser/expression/methods/referenced_expressions.rb
# frozen_string_literal: true module Regexp::Expression module ReferencedExpressions attr_accessor :referenced_expressions def referenced_expression referenced_expressions && referenced_expressions.first end def initialize_copy(orig) exp_id = [self.class, self.starts_at] # preven...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/escape_sequence_codepoint.rb
lib/regexp_parser/expression/methods/escape_sequence_codepoint.rb
# frozen_string_literal: true module Regexp::Expression::EscapeSequence AsciiEscape.class_eval { def codepoint; 0x1B end } Backspace.class_eval { def codepoint; 0x8 end } Bell.class_eval { def codepoint; 0x7 end } FormFeed.class_eval { def codepoint; 0xC end } Newline.class_eval { def code...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/traverse.rb
lib/regexp_parser/expression/methods/traverse.rb
# frozen_string_literal: true module Regexp::Expression class Subexpression < Regexp::Expression::Base # Traverses the expression, passing each recursive child to the # given block. # If the block takes two arguments, the indices of the children within # their parents are also passed to it. def ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/match.rb
lib/regexp_parser/expression/methods/match.rb
# frozen_string_literal: true module Regexp::Expression class Base def match?(string) !!match(string) end alias :matches? :match? def match(string, offset = 0) Regexp.new(to_s).match(string, offset) end alias :=~ :match end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/construct.rb
lib/regexp_parser/expression/methods/construct.rb
# frozen_string_literal: true module Regexp::Expression module Shared module ClassMethods # Convenience method to init a valid Expression without a Regexp::Token def construct(params = {}) attrs = construct_defaults.merge(params) options = attrs.delete(:options) token_args = R...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/human_name.rb
lib/regexp_parser/expression/methods/human_name.rb
# frozen_string_literal: true module Regexp::Expression module Shared # default implementation, e.g. "atomic group", "hex escape", "word type", .. def human_name [token, type].compact.join(' ').tr('_', ' ') end end Alternation.class_eval { def human_name; 'alternation' ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/escape_sequence_char.rb
lib/regexp_parser/expression/methods/escape_sequence_char.rb
# frozen_string_literal: true Regexp::Expression::EscapeSequence::Base.class_eval do def char codepoint.chr('utf-8') end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/printing.rb
lib/regexp_parser/expression/methods/printing.rb
# frozen_string_literal: true module Regexp::Expression module Shared def inspect [ "#<#{self.class}", pretty_print_instance_variables.map { |v| " #{v}=#{instance_variable_get(v).inspect}" }, ">" ].join end # Make pretty-print work despite #inspect implementation. ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/tests.rb
lib/regexp_parser/expression/methods/tests.rb
# frozen_string_literal: true module Regexp::Expression module Shared # Test if this expression has the given test_type, which can be either # a symbol or an array of symbols to check against the expression's type. # # # is it a :group expression # exp.type? :group # # # is it a :s...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/methods/negative.rb
lib/regexp_parser/expression/methods/negative.rb
# frozen_string_literal: true module Regexp::Expression module Shared def negative? false end # not an alias so as to respect overrides of #negative? def negated? negative? end end Anchor::NonWordBoundary.class_eval { def negative?; true end } As...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/character_type.rb
lib/regexp_parser/expression/classes/character_type.rb
# frozen_string_literal: true module Regexp::Expression module CharacterType class Base < Regexp::Expression::Base; end class Any < CharacterType::Base; end class Digit < CharacterType::Base; end class NonDigit < CharacterType::Base; end class Hex < C...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/unicode_property.rb
lib/regexp_parser/expression/classes/unicode_property.rb
# frozen_string_literal: true module Regexp::Expression module UnicodeProperty class Base < Regexp::Expression::Base def name text[/\A\\[pP]\{([^}]+)\}\z/, 1] end def shortcut Regexp::Scanner.short_prop_map.key(token.to_s) end end class Alnum < Base; end ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/group.rb
lib/regexp_parser/expression/classes/group.rb
# frozen_string_literal: true module Regexp::Expression module Group class Base < Regexp::Expression::Subexpression end class Passive < Group::Base attr_writer :implicit def initialize(*) @implicit = false super end def implicit? @implicit end ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/literal.rb
lib/regexp_parser/expression/classes/literal.rb
# frozen_string_literal: true module Regexp::Expression class Literal < Regexp::Expression::Base; end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/alternation.rb
lib/regexp_parser/expression/classes/alternation.rb
# frozen_string_literal: true module Regexp::Expression # A sequence of expressions, used by Alternation as one of its alternatives. class Alternative < Regexp::Expression::Sequence; end class Alternation < Regexp::Expression::SequenceOperation OPERAND = Alternative alias :alternatives :expressions e...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/posix_class.rb
lib/regexp_parser/expression/classes/posix_class.rb
# frozen_string_literal: true module Regexp::Expression class PosixClass < Regexp::Expression::Base def name text[/\w+/] end end # alias for symmetry between token symbol and Expression class name Posixclass = PosixClass Nonposixclass = PosixClass end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/escape_sequence.rb
lib/regexp_parser/expression/classes/escape_sequence.rb
# frozen_string_literal: true module Regexp::Expression module EscapeSequence Base = Class.new(Regexp::Expression::Base) AsciiEscape = Class.new(Base) # \e Backspace = Class.new(Base) # \b Bell = Class.new(Base) # \a FormFeed = Class.new(Base) # \f Newline = Class.new(...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/keep.rb
lib/regexp_parser/expression/classes/keep.rb
# frozen_string_literal: true module Regexp::Expression module Keep # TODO: in regexp_parser v3.0.0 this should possibly be a Subexpression # that contains all expressions to its left. class Mark < Regexp::Expression::Base; end end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/character_set.rb
lib/regexp_parser/expression/classes/character_set.rb
# frozen_string_literal: true module Regexp::Expression class CharacterSet < Regexp::Expression::Subexpression attr_accessor :closed, :negative alias :closed? :closed def initialize(token, options = {}) self.negative = false self.closed = false super end def negate sel...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/root.rb
lib/regexp_parser/expression/classes/root.rb
# frozen_string_literal: true module Regexp::Expression class Root < Regexp::Expression::Subexpression def self.build(options = {}) warn "`#{self.class}.build(options)` is deprecated and will raise in "\ "regexp_parser v3.0.0. Please use `.construct(options: options)`." construct(options: ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/backreference.rb
lib/regexp_parser/expression/classes/backreference.rb
# frozen_string_literal: true module Regexp::Expression module Backreference class Base < Regexp::Expression::Base; end class Number < Backreference::Base attr_reader :number alias reference number def initialize(token, options = {}) @number = token.text[/-?\d+/].to_i supe...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/conditional.rb
lib/regexp_parser/expression/classes/conditional.rb
# frozen_string_literal: true module Regexp::Expression module Conditional class TooManyBranches < Regexp::Parser::Error def initialize super('The conditional expression has more than 2 branches') end end class Condition < Regexp::Expression::Base # Name or number of the refere...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/free_space.rb
lib/regexp_parser/expression/classes/free_space.rb
# frozen_string_literal: true module Regexp::Expression class FreeSpace < Regexp::Expression::Base def quantify(*_args) raise Regexp::Parser::Error, 'Can not quantify a free space object' end end class Comment < Regexp::Expression::FreeSpace end class WhiteSpace < Regexp::Expression::FreeSpac...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/anchor.rb
lib/regexp_parser/expression/classes/anchor.rb
# frozen_string_literal: true module Regexp::Expression module Anchor class Base < Regexp::Expression::Base; end class BeginningOfLine < Anchor::Base; end class EndOfLine < Anchor::Base; end class BeginningOfString < Anchor::Base; end class EndOfStr...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/character_set/range.rb
lib/regexp_parser/expression/classes/character_set/range.rb
# frozen_string_literal: true module Regexp::Expression class CharacterSet < Regexp::Expression::Subexpression class Range < Regexp::Expression::Subexpression def ts (head = expressions.first) ? head.ts : @ts end def <<(exp) complete? and raise Regexp::Parser::Error, ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/expression/classes/character_set/intersection.rb
lib/regexp_parser/expression/classes/character_set/intersection.rb
# frozen_string_literal: true module Regexp::Expression class CharacterSet < Regexp::Expression::Subexpression class IntersectedSequence < Regexp::Expression::Sequence; end class Intersection < Regexp::Expression::SequenceOperation OPERAND = IntersectedSequence end end end
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/any.rb
lib/regexp_parser/syntax/any.rb
# frozen_string_literal: true module Regexp::Syntax # A syntax that always returns true, passing all tokens as implemented. This # is useful during development, testing, and should be useful for some types # of transformations as well. class Any < Base implements :*, [:*] def self.implements?(_type, _...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/version_lookup.rb
lib/regexp_parser/syntax/version_lookup.rb
# frozen_string_literal: true module Regexp::Syntax VERSION_FORMAT = '\Aruby/\d+\.\d+(\.\d+)?\z' VERSION_REGEXP = /#{VERSION_FORMAT}/.freeze VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/.freeze class InvalidVersionNameError < Regexp::Syntax::SyntaxError def initialize(name) super "Invalid version n...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/base.rb
lib/regexp_parser/syntax/base.rb
# frozen_string_literal: true module Regexp::Syntax class NotImplementedError < Regexp::Syntax::SyntaxError def initialize(syntax, type, token) super "#{syntax} does not implement: [#{type}:#{token}]" end end # A lookup map of supported types and tokens in a given syntax class Base include R...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/token.rb
lib/regexp_parser/syntax/token.rb
# frozen_string_literal: true # Define the base module and the simplest of tokens. module Regexp::Syntax module Token Map = Hash.new module Literal All = %i[literal].freeze Type = :literal end module FreeSpace All = %i[comment whitespace].freeze Type = :free_space end ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/versions.rb
lib/regexp_parser/syntax/versions.rb
# frozen_string_literal: true # Ruby 1.x is no longer a supported runtime, # but its regex features are still recognized. # # Aliases for the latest patch version are provided as 'ruby/n.n', # e.g. 'ruby/1.9' refers to Ruby v1.9.3. Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require_relative f ...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/token/character_type.rb
lib/regexp_parser/syntax/token/character_type.rb
# frozen_string_literal: true module Regexp::Syntax module Token module CharacterType Basic = [].freeze Extended = %i[digit nondigit space nonspace word nonword].freeze Hex = %i[hex nonhex].freeze Clustered = %i[linebreak xgrapheme].freeze All = Basic + Extended + Hex +...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false
ammar/regexp_parser
https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/lib/regexp_parser/syntax/token/meta.rb
lib/regexp_parser/syntax/token/meta.rb
# frozen_string_literal: true module Regexp::Syntax module Token module Meta Basic = %i[dot].freeze Alternation = %i[alternation].freeze Extended = Basic + Alternation All = Extended Type = :meta end Map[Meta::Type] = Meta::All # alias for symmetry between To...
ruby
MIT
c5094a84e56eb445297556500f19bcc2128a8859
2026-01-04T17:37:37.784074Z
false