regexp_parser 0.1.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +45 -0
- data/Rakefile +12 -44
- data/VERSION.yml +5 -0
- data/lib/regexp_parser.rb +5 -38
- data/lib/regexp_parser/expression.rb +68 -221
- data/lib/regexp_parser/expression/classes/alternation.rb +47 -0
- data/lib/regexp_parser/expression/classes/anchor.rb +26 -0
- data/lib/regexp_parser/expression/classes/backref.rb +42 -0
- data/lib/regexp_parser/expression/classes/escape.rb +27 -0
- data/lib/regexp_parser/expression/classes/group.rb +67 -0
- data/lib/regexp_parser/expression/classes/literal.rb +7 -0
- data/lib/regexp_parser/expression/{property.rb → classes/property.rb} +1 -1
- data/lib/regexp_parser/expression/classes/root.rb +26 -0
- data/lib/regexp_parser/expression/classes/set.rb +100 -0
- data/lib/regexp_parser/expression/classes/type.rb +17 -0
- data/lib/regexp_parser/expression/quantifier.rb +26 -0
- data/lib/regexp_parser/expression/subexpression.rb +69 -0
- data/lib/regexp_parser/lexer.rb +4 -4
- data/lib/regexp_parser/parser.rb +31 -13
- data/lib/regexp_parser/scanner.rb +1849 -1488
- data/lib/regexp_parser/scanner/property.rl +7 -2
- data/lib/regexp_parser/scanner/scanner.rl +377 -191
- data/lib/regexp_parser/syntax.rb +7 -0
- data/lib/regexp_parser/syntax/ruby/1.8.6.rb +4 -4
- data/lib/regexp_parser/syntax/ruby/1.9.1.rb +9 -9
- data/lib/regexp_parser/syntax/ruby/2.0.0.rb +16 -0
- data/lib/regexp_parser/syntax/ruby/2.1.0.rb +13 -0
- data/lib/regexp_parser/syntax/tokens.rb +21 -320
- data/lib/regexp_parser/syntax/tokens/anchor.rb +17 -0
- data/lib/regexp_parser/syntax/tokens/assertion.rb +15 -0
- data/lib/regexp_parser/syntax/tokens/backref.rb +26 -0
- data/lib/regexp_parser/syntax/tokens/character_set.rb +48 -0
- data/lib/regexp_parser/syntax/tokens/character_type.rb +16 -0
- data/lib/regexp_parser/syntax/tokens/escape.rb +29 -0
- data/lib/regexp_parser/syntax/tokens/group.rb +22 -0
- data/lib/regexp_parser/syntax/tokens/meta.rb +15 -0
- data/lib/regexp_parser/syntax/tokens/quantifier.rb +37 -0
- data/lib/regexp_parser/syntax/tokens/unicode_property.rb +204 -0
- data/lib/regexp_parser/token.rb +37 -0
- data/test/expression/test_all.rb +7 -0
- data/test/expression/test_base.rb +72 -0
- data/test/expression/test_clone.rb +144 -0
- data/test/{parser/test_expression.rb → expression/test_to_s.rb} +10 -10
- data/test/helpers.rb +1 -0
- data/test/parser/test_all.rb +1 -1
- data/test/parser/test_alternation.rb +35 -0
- data/test/parser/test_anchors.rb +2 -2
- data/test/parser/test_refcalls.rb +1 -1
- data/test/parser/test_sets.rb +54 -8
- data/test/scanner/test_anchors.rb +2 -2
- data/test/scanner/test_conditionals.rb +31 -0
- data/test/scanner/test_errors.rb +88 -8
- data/test/scanner/test_escapes.rb +4 -4
- data/test/scanner/test_groups.rb +7 -0
- data/test/scanner/test_quoting.rb +29 -0
- data/test/scanner/test_sets.rb +1 -0
- data/test/syntax/ruby/test_1.8.rb +3 -3
- data/test/test_all.rb +1 -1
- metadata +62 -48
- data/lib/regexp_parser/expression/set.rb +0 -59
@@ -1,59 +0,0 @@
|
|
1
|
-
module Regexp::Expression
|
2
|
-
|
3
|
-
class CharacterSet < Regexp::Expression::Base
|
4
|
-
attr_accessor :members
|
5
|
-
|
6
|
-
def initialize(token)
|
7
|
-
@members = []
|
8
|
-
@negative = false
|
9
|
-
super
|
10
|
-
end
|
11
|
-
|
12
|
-
def <<(member)
|
13
|
-
if @members.last.is_a?(CharacterSubSet)
|
14
|
-
@members.last << member
|
15
|
-
else
|
16
|
-
@members << member
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def include?(member)
|
21
|
-
@members.each do |m|
|
22
|
-
if m.is_a?(CharacterSubSet)
|
23
|
-
return true if m.include?(member)
|
24
|
-
else
|
25
|
-
return true if member == m.to_s
|
26
|
-
end
|
27
|
-
end; false
|
28
|
-
end
|
29
|
-
|
30
|
-
def negate
|
31
|
-
if @members.last.is_a?(CharacterSubSet)
|
32
|
-
@members.last.negate
|
33
|
-
else
|
34
|
-
@negative = true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def negative?
|
39
|
-
@negative
|
40
|
-
end
|
41
|
-
alias :negated? :negative?
|
42
|
-
|
43
|
-
def to_s
|
44
|
-
s = @text
|
45
|
-
s << '^' if negative?
|
46
|
-
s << @members.join
|
47
|
-
s << ']'
|
48
|
-
s << @quantifier.to_s if quantified?
|
49
|
-
s
|
50
|
-
end
|
51
|
-
|
52
|
-
def matches?(input)
|
53
|
-
input =~ /#{to_s}/ ? true : false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class CharacterSubSet < CharacterSet; end
|
58
|
-
|
59
|
-
end # module Regexp::Expression
|