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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +57 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE +1 -1
  5. data/README.md +225 -206
  6. data/Rakefile +9 -3
  7. data/lib/regexp_parser.rb +7 -11
  8. data/lib/regexp_parser/expression.rb +72 -14
  9. data/lib/regexp_parser/expression/classes/alternation.rb +3 -16
  10. data/lib/regexp_parser/expression/classes/conditional.rb +57 -0
  11. data/lib/regexp_parser/expression/classes/free_space.rb +17 -0
  12. data/lib/regexp_parser/expression/classes/keep.rb +7 -0
  13. data/lib/regexp_parser/expression/classes/set.rb +28 -7
  14. data/lib/regexp_parser/expression/methods/strfregexp.rb +113 -0
  15. data/lib/regexp_parser/expression/methods/tests.rb +116 -0
  16. data/lib/regexp_parser/expression/methods/traverse.rb +63 -0
  17. data/lib/regexp_parser/expression/quantifier.rb +10 -0
  18. data/lib/regexp_parser/expression/sequence.rb +45 -0
  19. data/lib/regexp_parser/expression/subexpression.rb +29 -1
  20. data/lib/regexp_parser/lexer.rb +31 -8
  21. data/lib/regexp_parser/parser.rb +118 -45
  22. data/lib/regexp_parser/scanner.rb +1745 -1404
  23. data/lib/regexp_parser/scanner/property.rl +57 -3
  24. data/lib/regexp_parser/scanner/scanner.rl +161 -34
  25. data/lib/regexp_parser/syntax.rb +12 -2
  26. data/lib/regexp_parser/syntax/ruby/1.9.1.rb +3 -3
  27. data/lib/regexp_parser/syntax/ruby/1.9.3.rb +2 -7
  28. data/lib/regexp_parser/syntax/ruby/2.0.0.rb +4 -1
  29. data/lib/regexp_parser/syntax/ruby/2.1.4.rb +13 -0
  30. data/lib/regexp_parser/syntax/ruby/2.1.5.rb +13 -0
  31. data/lib/regexp_parser/syntax/ruby/2.1.rb +2 -2
  32. data/lib/regexp_parser/syntax/ruby/2.2.0.rb +16 -0
  33. data/lib/regexp_parser/syntax/ruby/2.2.rb +8 -0
  34. data/lib/regexp_parser/syntax/tokens.rb +19 -2
  35. data/lib/regexp_parser/syntax/tokens/conditional.rb +22 -0
  36. data/lib/regexp_parser/syntax/tokens/keep.rb +14 -0
  37. data/lib/regexp_parser/syntax/tokens/unicode_property.rb +45 -4
  38. data/lib/regexp_parser/token.rb +23 -8
  39. data/lib/regexp_parser/version.rb +5 -0
  40. data/regexp_parser.gemspec +35 -0
  41. data/test/expression/test_all.rb +6 -1
  42. data/test/expression/test_base.rb +19 -0
  43. data/test/expression/test_conditionals.rb +114 -0
  44. data/test/expression/test_free_space.rb +33 -0
  45. data/test/expression/test_set.rb +61 -0
  46. data/test/expression/test_strfregexp.rb +214 -0
  47. data/test/expression/test_subexpression.rb +24 -0
  48. data/test/expression/test_tests.rb +99 -0
  49. data/test/expression/test_to_h.rb +48 -0
  50. data/test/expression/test_to_s.rb +46 -0
  51. data/test/expression/test_traverse.rb +164 -0
  52. data/test/lexer/test_all.rb +16 -3
  53. data/test/lexer/test_conditionals.rb +101 -0
  54. data/test/lexer/test_keep.rb +24 -0
  55. data/test/lexer/test_literals.rb +51 -51
  56. data/test/lexer/test_nesting.rb +62 -62
  57. data/test/lexer/test_refcalls.rb +18 -20
  58. data/test/parser/test_all.rb +18 -3
  59. data/test/parser/test_alternation.rb +11 -14
  60. data/test/parser/test_conditionals.rb +148 -0
  61. data/test/parser/test_escapes.rb +29 -5
  62. data/test/parser/test_free_space.rb +139 -0
  63. data/test/parser/test_groups.rb +40 -0
  64. data/test/parser/test_keep.rb +21 -0
  65. data/test/scanner/test_all.rb +8 -2
  66. data/test/scanner/test_conditionals.rb +166 -0
  67. data/test/scanner/test_escapes.rb +8 -5
  68. data/test/scanner/test_free_space.rb +133 -0
  69. data/test/scanner/test_groups.rb +28 -0
  70. data/test/scanner/test_keep.rb +33 -0
  71. data/test/scanner/test_properties.rb +4 -0
  72. data/test/scanner/test_scripts.rb +71 -1
  73. data/test/syntax/ruby/test_1.9.3.rb +2 -2
  74. data/test/syntax/ruby/test_2.0.0.rb +38 -0
  75. data/test/syntax/ruby/test_2.2.0.rb +38 -0
  76. data/test/syntax/ruby/test_all.rb +1 -8
  77. data/test/syntax/ruby/test_files.rb +104 -0
  78. data/test/test_all.rb +2 -1
  79. data/test/token/test_all.rb +2 -0
  80. data/test/token/test_token.rb +109 -0
  81. metadata +75 -21
  82. data/VERSION.yml +0 -5
  83. data/lib/regexp_parser/ctype.rb +0 -48
  84. data/test/syntax/ruby/test_2.x.rb +0 -46
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 1
4
- :patch: 6
5
- :build:
@@ -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