regexp_parser 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +57 -0
- data/Gemfile +8 -0
- data/LICENSE +1 -1
- data/README.md +225 -206
- data/Rakefile +9 -3
- data/lib/regexp_parser.rb +7 -11
- data/lib/regexp_parser/expression.rb +72 -14
- data/lib/regexp_parser/expression/classes/alternation.rb +3 -16
- data/lib/regexp_parser/expression/classes/conditional.rb +57 -0
- data/lib/regexp_parser/expression/classes/free_space.rb +17 -0
- data/lib/regexp_parser/expression/classes/keep.rb +7 -0
- data/lib/regexp_parser/expression/classes/set.rb +28 -7
- data/lib/regexp_parser/expression/methods/strfregexp.rb +113 -0
- data/lib/regexp_parser/expression/methods/tests.rb +116 -0
- data/lib/regexp_parser/expression/methods/traverse.rb +63 -0
- data/lib/regexp_parser/expression/quantifier.rb +10 -0
- data/lib/regexp_parser/expression/sequence.rb +45 -0
- data/lib/regexp_parser/expression/subexpression.rb +29 -1
- data/lib/regexp_parser/lexer.rb +31 -8
- data/lib/regexp_parser/parser.rb +118 -45
- data/lib/regexp_parser/scanner.rb +1745 -1404
- data/lib/regexp_parser/scanner/property.rl +57 -3
- data/lib/regexp_parser/scanner/scanner.rl +161 -34
- data/lib/regexp_parser/syntax.rb +12 -2
- data/lib/regexp_parser/syntax/ruby/1.9.1.rb +3 -3
- data/lib/regexp_parser/syntax/ruby/1.9.3.rb +2 -7
- data/lib/regexp_parser/syntax/ruby/2.0.0.rb +4 -1
- data/lib/regexp_parser/syntax/ruby/2.1.4.rb +13 -0
- data/lib/regexp_parser/syntax/ruby/2.1.5.rb +13 -0
- data/lib/regexp_parser/syntax/ruby/2.1.rb +2 -2
- data/lib/regexp_parser/syntax/ruby/2.2.0.rb +16 -0
- data/lib/regexp_parser/syntax/ruby/2.2.rb +8 -0
- data/lib/regexp_parser/syntax/tokens.rb +19 -2
- data/lib/regexp_parser/syntax/tokens/conditional.rb +22 -0
- data/lib/regexp_parser/syntax/tokens/keep.rb +14 -0
- data/lib/regexp_parser/syntax/tokens/unicode_property.rb +45 -4
- data/lib/regexp_parser/token.rb +23 -8
- data/lib/regexp_parser/version.rb +5 -0
- data/regexp_parser.gemspec +35 -0
- data/test/expression/test_all.rb +6 -1
- data/test/expression/test_base.rb +19 -0
- data/test/expression/test_conditionals.rb +114 -0
- data/test/expression/test_free_space.rb +33 -0
- data/test/expression/test_set.rb +61 -0
- data/test/expression/test_strfregexp.rb +214 -0
- data/test/expression/test_subexpression.rb +24 -0
- data/test/expression/test_tests.rb +99 -0
- data/test/expression/test_to_h.rb +48 -0
- data/test/expression/test_to_s.rb +46 -0
- data/test/expression/test_traverse.rb +164 -0
- data/test/lexer/test_all.rb +16 -3
- data/test/lexer/test_conditionals.rb +101 -0
- data/test/lexer/test_keep.rb +24 -0
- data/test/lexer/test_literals.rb +51 -51
- data/test/lexer/test_nesting.rb +62 -62
- data/test/lexer/test_refcalls.rb +18 -20
- data/test/parser/test_all.rb +18 -3
- data/test/parser/test_alternation.rb +11 -14
- data/test/parser/test_conditionals.rb +148 -0
- data/test/parser/test_escapes.rb +29 -5
- data/test/parser/test_free_space.rb +139 -0
- data/test/parser/test_groups.rb +40 -0
- data/test/parser/test_keep.rb +21 -0
- data/test/scanner/test_all.rb +8 -2
- data/test/scanner/test_conditionals.rb +166 -0
- data/test/scanner/test_escapes.rb +8 -5
- data/test/scanner/test_free_space.rb +133 -0
- data/test/scanner/test_groups.rb +28 -0
- data/test/scanner/test_keep.rb +33 -0
- data/test/scanner/test_properties.rb +4 -0
- data/test/scanner/test_scripts.rb +71 -1
- data/test/syntax/ruby/test_1.9.3.rb +2 -2
- data/test/syntax/ruby/test_2.0.0.rb +38 -0
- data/test/syntax/ruby/test_2.2.0.rb +38 -0
- data/test/syntax/ruby/test_all.rb +1 -8
- data/test/syntax/ruby/test_files.rb +104 -0
- data/test/test_all.rb +2 -1
- data/test/token/test_all.rb +2 -0
- data/test/token/test_token.rb +109 -0
- metadata +75 -21
- data/VERSION.yml +0 -5
- data/lib/regexp_parser/ctype.rb +0 -48
- data/test/syntax/ruby/test_2.x.rb +0 -46
data/VERSION.yml
DELETED
data/lib/regexp_parser/ctype.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# defines character type constants (as arrays) and methods that test
|
2
|
-
# whether a given character belongs in one of them.
|
3
|
-
module CType
|
4
|
-
Digit = ('0'..'9').to_a.freeze
|
5
|
-
Lower = ('a'..'z').to_a.freeze
|
6
|
-
Upper = ('A'..'Z').to_a.freeze
|
7
|
-
|
8
|
-
Alpha = [Lower, Upper].flatten.freeze
|
9
|
-
Alnum = [Alpha, Digit].flatten.freeze
|
10
|
-
Word = [Alnum, '_'].flatten.freeze
|
11
|
-
|
12
|
-
Blank = [' ', "\t"].freeze
|
13
|
-
Space = [" ", "\t", "\r", "\n", "\v", "\f"].freeze
|
14
|
-
|
15
|
-
Cntrl = ( 0..31 ).map {|c| c.chr}.freeze
|
16
|
-
Graph = (33..126).map {|c| c.chr}.freeze
|
17
|
-
Print = (32..126).map {|c| c.chr}.freeze
|
18
|
-
ASCII = ( 0..127).map {|c| c.chr}.freeze
|
19
|
-
|
20
|
-
Punct = [
|
21
|
-
('!'..'/').to_a,
|
22
|
-
(':'..'@').to_a,
|
23
|
-
('['..'`').to_a,
|
24
|
-
('{'..'~').to_a
|
25
|
-
].flatten.freeze
|
26
|
-
|
27
|
-
XDigit = [
|
28
|
-
Digit,
|
29
|
-
('a'..'f').to_a,
|
30
|
-
('A'..'F').to_a
|
31
|
-
].flatten.freeze
|
32
|
-
|
33
|
-
def self.alnum?(c); Alnum.include?(c) end
|
34
|
-
def self.alpha?(c); Alpha.include?(c) end
|
35
|
-
def self.blank?(c); Blank.include?(c) end
|
36
|
-
def self.cntrl?(c); Cntrl.include?(c) end
|
37
|
-
def self.digit?(c); Digit.include?(c) end
|
38
|
-
def self.graph?(c); Graph.include?(c) end
|
39
|
-
def self.lower?(c); Lower.include?(c) end
|
40
|
-
def self.print?(c); Print.include?(c) end
|
41
|
-
def self.punct?(c); Punct.include?(c) end
|
42
|
-
def self.space?(c); Space.include?(c) end
|
43
|
-
def self.upper?(c); Upper.include?(c) end
|
44
|
-
def self.xdigit?(c); XDigit.include?(c) end
|
45
|
-
|
46
|
-
def self.word?(c); Word.include?(c) end
|
47
|
-
def self.ascii?(c); ASCII.include?(c) end
|
48
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.expand_path("../../../helpers", __FILE__)
|
2
|
-
|
3
|
-
class TestSyntaxRuby_V2x < Test::Unit::TestCase
|
4
|
-
|
5
|
-
# Since the only Regular expression change that was introduced in ruby 2.x
|
6
|
-
# (the conditional expressions) is not supportted yet, these tests only
|
7
|
-
# check that the syntax files have the correct inheritance (based off the
|
8
|
-
# last release) and load without error.
|
9
|
-
|
10
|
-
def test_syntax_file_2_0_0
|
11
|
-
syntax = Regexp::Syntax.new 'ruby/2.0.0'
|
12
|
-
|
13
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V19) )
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_syntax_file_2_0_alias
|
17
|
-
syntax = Regexp::Syntax.new 'ruby/2.0'
|
18
|
-
|
19
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V200) )
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_syntax_file_2_1_0
|
23
|
-
syntax = Regexp::Syntax.new 'ruby/2.1.0'
|
24
|
-
|
25
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V20) )
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_syntax_file_2_1_2
|
29
|
-
syntax = Regexp::Syntax.new 'ruby/2.1.2'
|
30
|
-
|
31
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V210) )
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_syntax_file_2_1_3
|
35
|
-
syntax = Regexp::Syntax.new 'ruby/2.1.3'
|
36
|
-
|
37
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V212) )
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_syntax_file_2_1_alias
|
41
|
-
syntax = Regexp::Syntax.new 'ruby/2.1'
|
42
|
-
|
43
|
-
assert_equal( true, syntax.kind_of?(Regexp::Syntax::Ruby::V213) )
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|