javascriptre 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ead84ce61d64d58eade0f1f4b53aa5f8fd89685e
4
+ data.tar.gz: fdefe51af340d0aa4506aa15cf0e25f3b5f4c889
5
+ SHA512:
6
+ metadata.gz: ee73f6d6b93d91204528ede21252bc72ddf1165794ce014149047617a655bbfc01e49921e0a0a29ba6b91f79bf58ddf7f631d5748f2497573df827dbcb32d728
7
+ data.tar.gz: 50e40694e1bade0f93495472030efde50e573b7246bde60e4f9c2ef6458d1242b700b72f6d51b3065165bca807f24b0d470040f4971ee525f4c8b30b3f3258b1
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ .bundle
2
+ .config
3
+ .yardoc
4
+ Gemfile.lock
5
+ coverage
6
+ doc
7
+ rdoc
8
+ tmp
9
+ vendor
10
+ *.bundle
11
+ *.gem
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ javascriptre.rb
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ #! /your/favourite/path/to/bundler
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2014 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ source 'https://rubygems.org'
25
+ gemspec require: false
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 Urabe, Shyouhei
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be
11
+ included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ Believe it or not this is a ECMA-262 edition 5.1-compatible regular expression converter. It converts JS regexp into Ruby's.
2
+
3
+ It has only one intuitive usage:
4
+
5
+ ```ruby
6
+ require 'javascriptre'
7
+ re = Javascriptre.new('JS re')
8
+ re.match('...')
9
+ ```
data/Rakefile ADDED
@@ -0,0 +1,83 @@
1
+ #! /your/favourite/path/to/rake
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2015 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ begin
25
+ require 'rubygems'
26
+ require 'bundler/setup'
27
+ require 'rake'
28
+ rescue Exception => e
29
+ $stderr.puts e.message
30
+ $stderr.puts "Run `bundle install` to install missing gems"
31
+ exit false
32
+ else
33
+ begin
34
+ Bundler.setup :default
35
+ rescue Bundler::BundlerError => e
36
+ $stderr.puts e.message
37
+ $stderr.puts "Run `bundle install` to install missing gems"
38
+ exit e.status_code
39
+ end
40
+ end
41
+
42
+ begin
43
+ Bundler.setup :default, :development
44
+ require 'rake/testtask'
45
+ require 'bundler/gem_tasks'
46
+
47
+ task 'default' => %w'test'
48
+ task 'spec' => %w'test'
49
+ desc "run tests"
50
+ Rake::TestTask.new do |t|
51
+ t.test_files = FileList['test/**/*.rb']
52
+ end
53
+
54
+ task 'yard' => %w'lib/javascriptre.rb'
55
+ task 'rdoc' => %w'lib/javascriptre.rb'
56
+ task 'build' => %w'lib/javascriptre.rb'
57
+ file 'lib/javascriptre.rb' => %w'lib/javascriptre.ry' do |t|
58
+ sh "bundle exec racc --output-file=#{t.name} #{t.prerequisites.first}"
59
+ end
60
+
61
+ rescue LoadError, NameError
62
+ p $!
63
+ # OK, they can be absent on non-development mode.
64
+ end
65
+
66
+ desc "a la rails console"
67
+ task :console => %w'lib/javascriptre.rb' do
68
+ require_relative 'lib/javascriptre'
69
+ require 'irb'
70
+ require 'irb/completion'
71
+ ARGV.clear
72
+ IRB.start
73
+ end
74
+ task :c => :console
75
+
76
+ desc "pry console"
77
+ task :pry => %w'lib/javascriptre.rb' do
78
+ require_relative 'lib/javascriptre'
79
+ require 'pry'
80
+ ARGV.clear
81
+ Pry.start
82
+ end
83
+
@@ -0,0 +1,49 @@
1
+ #! /your/favourite/path/to/gem
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2015 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ Gem::Specification.new do |spec|
25
+ spec.name = "javascriptre"
26
+ spec.version = 1.0
27
+ spec.authors = ["Urabe, Shyouhei"]
28
+ spec.email = ["shyouhei@ruby-lang.org"]
29
+ spec.summary = 'ECMAScript RegExp parser'
30
+ spec.description = <<-end.gsub(/[\s]+/m, ' ').strip
31
+ Believe it or not this is a ECMA-262 edition 5.1
32
+ -compatible Regular Expression parser and evaluator,
33
+ written in Ruby.
34
+ end
35
+ spec.homepage = "https://github.com/shyouhei/javascriptre"
36
+ spec.license = "MIT"
37
+
38
+ spec.files = `git ls-files -z`.split("\x0") + %w'lib/javascriptre.rb'
39
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
40
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
41
+ spec.require_paths = %w"lib"
42
+
43
+ spec.required_ruby_version = '>= 1.8'
44
+ spec.add_development_dependency 'bundler', '~> 1.5'
45
+ spec.add_development_dependency 'rake', '~> 10.3'
46
+ spec.add_development_dependency 'racc', '~> 1.4.11'
47
+ spec.add_development_dependency 'test-unit', '~> 3.0'
48
+ spec.add_development_dependency 'pry', '~> 0.10'
49
+ end
@@ -0,0 +1,166 @@
1
+ #! /your/favourite/path/to/racc
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2015 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # Believe it or not this is a ECMA-262 edition 5.1 -compatible Regular Expression
25
+ # parser and evaluator, written in Ruby.
26
+ #
27
+ # Of course it translates JS RegExp into Ruby's Regexp.
28
+ #
29
+ # @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.10.1
30
+ class Javascriptre
31
+
32
+ options no_result_var
33
+ rule
34
+
35
+ Pattern : Disjunction { val }
36
+ Disjunction : Alternative { val }
37
+ | Alternative '|' Disjunction { val }
38
+ Alternative : # [empty] { val }
39
+ | Alternative Term { val }
40
+ Term : Assertion { val }
41
+ | Atom { val }
42
+ | Atom Quantifier { val }
43
+ Assertion : '^' { '\\A' }
44
+ | '$' { '\\z' }
45
+ | '\\' 'b' { val }
46
+ | '\\' 'B' { val }
47
+ | '(' '?' '=' Disjunction ')' { val }
48
+ | '(' '?' '!' Disjunction ')' { val }
49
+ Quantifier : QuantifierPrefix { val }
50
+ | QuantifierPrefix '?' { val }
51
+ QuantifierPrefix : '*' { val }
52
+ | '+' { val }
53
+ | '?' { val }
54
+ | '{' DecimalDigits '}' { val }
55
+ | '{' DecimalDigits ',' '}' { val }
56
+ | '{' DecimalDigits ',' DecimalDigits '}' { val }
57
+ Atom : PatternCharacter { val }
58
+ | '.' { val }
59
+ | '\\' AtomEscape { val }
60
+ | CharacterClass { val }
61
+ | '(' Disjunction ')' { val }
62
+ | '(' '?' ':' Disjunction ')' { val }
63
+ PatternCharacter : others { val }
64
+ | ControlLetter { val }
65
+ | DecimalDigit { val }
66
+ | '!' | ',' | '-' | ':' | '=' { val }
67
+ AtomEscape : DecimalEscape { val }
68
+ | CharacterEscape { val }
69
+ | CharacterClassEscape { val }
70
+ CharacterEscape : ControlEscape { val }
71
+ | 'c' ControlLetter { val }
72
+ | HexEscapeSequence { val }
73
+ | UnicodeEscapeSequence { val }
74
+ | IdentityEscape { val }
75
+ ControlEscape : 'f' | 'n' | 't' | 'r' | 'v' { val }
76
+ ControlLetter : 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' { val }
77
+ | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' { val }
78
+ | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' { val }
79
+ | 'v' | 'w' | 'x' | 'y' | 'z' { val }
80
+ | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' { val }
81
+ | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' { val }
82
+ | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' { val }
83
+ | 'V' | 'W' | 'X' | 'Y' | 'Z' { val }
84
+ HexEscapeSequence : 'x' HexDigit HexDigit { val }
85
+ UnicodeEscapeSequence : 'u' HexDigit HexDigit HexDigit HexDigit { val }
86
+ IdentityEscape : others { val }
87
+ | '!' | ',' | '-' | ':' | '=' { val }
88
+ | '^' | '$' | '\\' | '.' | '*' | '+' | '?' { val }
89
+ | '(' | ')' | '[' | ']' | '{' | '}' | '|' { val }
90
+ DecimalEscape : '0' { val }
91
+ | nonzero DecimalDigits { val }
92
+ nonzero : '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' { val }
93
+ CharacterClassEscape : 'd' | 'D' | 's' | 'S' | 'w' | 'W' { val }
94
+ CharacterClass : '[' '^' ClassRanges ']' { val }
95
+ | '[' ClassRanges ']' { val }
96
+ ClassRanges : # [empty] { val }
97
+ | NonemptyClassRanges { val }
98
+ NonemptyClassRanges : ClassAtom { val }
99
+ | ClassAtom NonemptyClassRangesNoDash { val }
100
+ | ClassAtom '-' ClassAtom ClassRanges { val }
101
+ NonemptyClassRangesNoDash : ClassAtom { val }
102
+ | ClassAtomNoDash NonemptyClassRangesNoDash { val }
103
+ | ClassAtomNoDash '-' ClassAtom ClassRanges { val }
104
+ ClassAtom : '-' { val }
105
+ | ClassAtomNoDash { val }
106
+ ClassAtomNoDash : others { val }
107
+ | ControlLetter { val }
108
+ | DecimalDigit { val }
109
+ | '!' | ',' | ':' | '=' { val }
110
+ | '^' | '$' | '.' | '*' | '+' | '?' { val }
111
+ | '(' | ')' | '[' | '{' | '}' | '|' { val }
112
+ | '\\' ClassEscape { val }
113
+ ClassEscape : DecimalEscape { val }
114
+ | 'b' { val }
115
+ | CharacterEscape { val }
116
+ | CharacterClassEscape { val }
117
+ DecimalDigits : DecimalDigit { val }
118
+ | DecimalDigits DecimalDigit { val }
119
+ HexDigit : DecimalDigit { val }
120
+ | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' { val }
121
+ | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' { val }
122
+ DecimalDigit : '0' | nonzero { val }
123
+
124
+ ---- header
125
+ require 'strscan'
126
+
127
+ ---- inner
128
+
129
+ class << self
130
+ private
131
+ alias bare_new new
132
+
133
+ public
134
+ # Compiles the given JS RegExp.
135
+ #
136
+ # @param str [String] regular expression in ECMA-262 fashion.
137
+ def new str
138
+ obj = bare_new str
139
+ return obj.rexp
140
+ rescue Racc::ParseError
141
+ raise ArgumentError, "malformed JS Re: #{str.inspect} => #$!"
142
+ end
143
+ end
144
+
145
+ def initialize str
146
+ @buf = StringScanner.new str
147
+ @pattern = do_parse
148
+ @rexp = Regexp.new @pattern.join
149
+ end
150
+
151
+ attr_reader :rexp # @return [Regexp] the expression in ruby.
152
+
153
+ private
154
+
155
+ def next_token
156
+ case
157
+ when @buf.eos?
158
+ return false, nil
159
+ when c = @buf.scan(/[!$()*+,\-.0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^abcdefghijklmnopqrstuvwxyz{|}]/) then
160
+ return c, c
161
+ when c = @buf.scan(/./) then
162
+ return :others, c
163
+ else
164
+ raise @buf.inspect
165
+ end
166
+ end
data/test/00-load.rb ADDED
@@ -0,0 +1,31 @@
1
+ #! /your/favourite/path/to/ruby
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2015 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'test-unit'
25
+ class Test00Load < Test::Unit::TestCase
26
+ def test_require
27
+ assert_nothing_raised do
28
+ require 'javascriptre'
29
+ end
30
+ end
31
+ end
data/test/01-basic.rb ADDED
@@ -0,0 +1,57 @@
1
+ #! /your/favourite/path/to/ruby
2
+ # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level 2 -*-
3
+
4
+ # Copyright (c) 2015 Urabe, Shyouhei
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'test-unit'
25
+ require 'javascriptre'
26
+
27
+ class Test01Basic < Test::Unit::TestCase
28
+
29
+ test 'no args' do
30
+ assert_raise ArgumentError do
31
+ Javascriptre.new
32
+ end
33
+ end
34
+
35
+ test 'many args' do
36
+ assert_raise ArgumentError do
37
+ Javascriptre.new(*%w'q w e r t y u i o p')
38
+ end
39
+ end
40
+
41
+ test 'simple' do
42
+ assert { Javascriptre.new("foo") == /foo/ }
43
+ assert { Javascriptre.new("[bar]") == /[bar]/ }
44
+ assert { Javascriptre.new("(?:b(?:a(?:z)?)?)?") == /(?:b(?:a(?:z)?)?)?/ }
45
+ end
46
+
47
+ test '^$' do
48
+ assert { Javascriptre.new("^foo") == /\Afoo/ }
49
+ assert { Javascriptre.new("bar$") == /bar\z/ }
50
+ end
51
+
52
+ test 'invalid JS re' do
53
+ assert_raise ArgumentError do
54
+ Javascriptre.new("(?<name>foo)\g<foo>")
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: javascriptre
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Urabe, Shyouhei
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: racc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.11
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.11
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ description: Believe it or not this is a ECMA-262 edition 5.1 -compatible Regular
84
+ Expression parser and evaluator, written in Ruby.
85
+ email:
86
+ - shyouhei@ruby-lang.org
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - javascriptre.gemspec
97
+ - lib/javascriptre.rb
98
+ - lib/javascriptre.ry
99
+ - test/00-load.rb
100
+ - test/01-basic.rb
101
+ homepage: https://github.com/shyouhei/javascriptre
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '1.8'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.5
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: ECMAScript RegExp parser
125
+ test_files:
126
+ - test/00-load.rb
127
+ - test/01-basic.rb