srl_ruby 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -6
- data/lib/srl_ruby/ast_builder.rb +20 -0
- data/lib/srl_ruby/grammar.rb +6 -2
- data/lib/srl_ruby/tokenizer.rb +4 -0
- data/lib/srl_ruby/version.rb +1 -1
- data/spec/acceptance/srl_test_suite_spec.rb +11 -1
- data/spec/srl_ruby_spec.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13bb293008059e97968eab3b976e05f7fe9c353e
|
4
|
+
data.tar.gz: 933e9531ae294fe4adb46e3c7ef87c58a3243388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c585bfad3f6330b87f47ab7c1dae115bc953a50220bc3d87642524c523cfbe1ae19193cfc0173730d456ec6691611abd59964ea4722a42bdbb1571f6c06ce9c
|
7
|
+
data.tar.gz: f835d81332961e020addee4ec8b5e4c46378f29ad12a7497fb03f5545eee1c884b1da5b8a621d4f76713b348b3b324fc96c4eb9f60b98037c1c7e9b98ab5d9c6
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
##
|
2
|
-
|
1
|
+
## [0.2.5] - 2018-04-02
|
2
|
+
SrlRuby passes 12 tests out of 15 standard SRL tests in total.
|
3
3
|
### Changed
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
- Class `SrlRuby#Tokenizer` added keywords CARRIAGE, RETURN, VERTICAL, WORD
|
5
|
+
- Grammar expanded to support 'CARRIAGE RETURN', 'VERTICAL TAB', 'WORD', 'NO WORD' expressions
|
6
|
+
- Class `SrlRuby::ASTBuilder` updates to reflect changes in the grammar.
|
7
|
+
- File `acceptance/srl_test_suite_spec.rb`. 12 test files from official test suite are passing.
|
8
|
+
|
8
9
|
|
9
10
|
## [0.2.4] - 2018-04-02
|
10
11
|
SrlRuby passes 10 tests out of 15 standard SRL tests in total.
|
@@ -74,3 +75,11 @@ SrlRuby passes 3 standard out of 15 standard SRL tests in total.
|
|
74
75
|
### Added
|
75
76
|
- Initial working Github commit
|
76
77
|
|
78
|
+
## Unreleased
|
79
|
+
### Added
|
80
|
+
### Changed
|
81
|
+
### Deprecated
|
82
|
+
### Removed
|
83
|
+
### Fixed
|
84
|
+
### Security
|
85
|
+
|
data/lib/srl_ruby/ast_builder.rb
CHANGED
@@ -276,6 +276,11 @@ module SrlRuby
|
|
276
276
|
def reduce_tab(_production, _range, _tokens, _children)
|
277
277
|
Regex::Character.new('\t')
|
278
278
|
end
|
279
|
+
|
280
|
+
# rule('special_char' => ' VERTICAL TAB').as 'vtab'
|
281
|
+
def reduce_vtab(_production, _range, _tokens, _children)
|
282
|
+
Regex::Character.new('\v')
|
283
|
+
end
|
279
284
|
|
280
285
|
# rule('special_char' => 'BACKSLASH').as 'backslash'
|
281
286
|
def reduce_backslash(_production, _range, _tokens, _children)
|
@@ -288,6 +293,21 @@ module SrlRuby
|
|
288
293
|
# TODO: control portability
|
289
294
|
Regex::Character.new('\n')
|
290
295
|
end
|
296
|
+
|
297
|
+
# rule('special_char' => %w[CARRIAGE RETURN]).as 'carriage_return'
|
298
|
+
def reduce_carriage_return(_production, _range, _tokens, _children)
|
299
|
+
Regex::Character.new('\r')
|
300
|
+
end
|
301
|
+
|
302
|
+
# rule('special_char' => %w[WORD]).as 'word'
|
303
|
+
def reduce_word(_production, _range, _tokens, _children)
|
304
|
+
Regex::Anchor.new('\b')
|
305
|
+
end
|
306
|
+
|
307
|
+
# rule('special_char' => %w[NO WORD]).as 'no word'
|
308
|
+
def reduce_no_word(_production, _range, _tokens, _children)
|
309
|
+
Regex::Anchor.new('\B')
|
310
|
+
end
|
291
311
|
|
292
312
|
# rule('literal' => %w[LITERALLY STRING_LIT]).as 'literally'
|
293
313
|
def reduce_literally(_production, _range, _tokens, theChildren)
|
data/lib/srl_ruby/grammar.rb
CHANGED
@@ -12,8 +12,8 @@ module SrlRuby
|
|
12
12
|
add_terminals('UPPERCASE', 'LETTER', 'FROM', 'TO')
|
13
13
|
add_terminals('DIGIT', 'NUMBER', 'ANY', 'NO')
|
14
14
|
add_terminals('CHARACTER', 'WHITESPACE', 'ANYTHING')
|
15
|
-
add_terminals('TAB', 'BACKSLASH', 'NEW', 'LINE')
|
16
|
-
add_terminals('OF', 'ONE')
|
15
|
+
add_terminals('TAB', 'BACKSLASH', 'NEW', 'LINE', 'WORD')
|
16
|
+
add_terminals('CARRIAGE', 'RETURN', 'VERTICAL', 'OF', 'ONE')
|
17
17
|
add_terminals('EXACTLY', 'TIMES', 'ONCE', 'TWICE')
|
18
18
|
add_terminals('BETWEEN', 'AND', 'OPTIONAL', 'OR')
|
19
19
|
add_terminals('MORE', 'NEVER', 'AT', 'LEAST')
|
@@ -74,8 +74,12 @@ module SrlRuby
|
|
74
74
|
rule('character_class' => 'ANYTHING').as 'anything'
|
75
75
|
rule('character_class' => %w[ONE OF STRING_LIT]).as 'one_of'
|
76
76
|
rule('special_char' => 'TAB').as 'tab'
|
77
|
+
rule('special_char' => 'VERTICAL TAB').as 'vtab'
|
77
78
|
rule('special_char' => 'BACKSLASH').as 'backslash'
|
78
79
|
rule('special_char' => %w[NEW LINE]).as 'new_line'
|
80
|
+
rule('special_char' => %w[CARRIAGE RETURN]).as 'carriage_return'
|
81
|
+
rule('special_char' => %w[WORD]).as 'word'
|
82
|
+
rule('special_char' => %w[NO WORD]).as 'no_word'
|
79
83
|
rule('literal' => %w[LITERALLY STRING_LIT]).as 'literally'
|
80
84
|
rule('alternation' => %w[ANY OF LPAREN alternatives RPAREN]).as 'any_of'
|
81
85
|
rule('alternatives' => %w[alternatives separator quantifiable]).as 'alternative_list'
|
data/lib/srl_ruby/tokenizer.rb
CHANGED
@@ -38,6 +38,7 @@ module SrlRuby
|
|
38
38
|
BETWEEN
|
39
39
|
BY
|
40
40
|
CAPTURE
|
41
|
+
CARRIAGE
|
41
42
|
CASE
|
42
43
|
CHARACTER
|
43
44
|
DIGIT
|
@@ -66,6 +67,7 @@ module SrlRuby
|
|
66
67
|
ONE
|
67
68
|
OPTIONAL
|
68
69
|
OR
|
70
|
+
RETURN
|
69
71
|
STARTS
|
70
72
|
TAB
|
71
73
|
TIMES
|
@@ -73,8 +75,10 @@ module SrlRuby
|
|
73
75
|
TWICE
|
74
76
|
UNTIL
|
75
77
|
UPPERCASE
|
78
|
+
VERTICAL
|
76
79
|
WHITESPACE
|
77
80
|
WITH
|
81
|
+
WORD
|
78
82
|
].map { |x| [x, x] } .to_h
|
79
83
|
|
80
84
|
class ScanError < StandardError; end
|
data/lib/srl_ruby/version.rb
CHANGED
@@ -61,6 +61,11 @@ RSpec.describe Acceptance do
|
|
61
61
|
rule_file_repr = load_file('literally_spaces.rule')
|
62
62
|
test_rule_file(rule_file_repr)
|
63
63
|
end
|
64
|
+
|
65
|
+
it 'should support non word boundary' do
|
66
|
+
rule_file_repr = load_file('no_word.rule')
|
67
|
+
test_rule_file(rule_file_repr)
|
68
|
+
end
|
64
69
|
|
65
70
|
it 'should match non digit pattern' do
|
66
71
|
rule_file_repr = load_file('nondigit.rule')
|
@@ -87,8 +92,13 @@ RSpec.describe Acceptance do
|
|
87
92
|
test_rule_file(rule_file_repr)
|
88
93
|
end
|
89
94
|
|
90
|
-
it 'should' do
|
95
|
+
it 'should process an URL' do
|
91
96
|
rule_file_repr = load_file('website_example_url.rule')
|
92
97
|
test_rule_file(rule_file_repr)
|
93
98
|
end
|
99
|
+
|
100
|
+
it 'should match a word boundary' do
|
101
|
+
rule_file_repr = load_file('word.rule')
|
102
|
+
test_rule_file(rule_file_repr)
|
103
|
+
end
|
94
104
|
end
|
data/spec/srl_ruby_spec.rb
CHANGED
@@ -100,6 +100,11 @@ describe SrlRuby do
|
|
100
100
|
regexp = SrlRuby.parse('tab')
|
101
101
|
expect(regexp.source).to eq('\t')
|
102
102
|
end
|
103
|
+
|
104
|
+
it "should parse 'vertical tab' syntax" do
|
105
|
+
regexp = SrlRuby.parse('vertical tab')
|
106
|
+
expect(regexp.source).to eq('\v')
|
107
|
+
end
|
103
108
|
|
104
109
|
it "should parse 'backslash' syntax" do
|
105
110
|
regexp = SrlRuby.parse('backslash')
|
@@ -110,6 +115,21 @@ describe SrlRuby do
|
|
110
115
|
regexp = SrlRuby.parse('new line')
|
111
116
|
expect(regexp.source).to eq('\n')
|
112
117
|
end
|
118
|
+
|
119
|
+
it "should parse 'carriage return' syntax" do
|
120
|
+
regexp = SrlRuby.parse('carriage return')
|
121
|
+
expect(regexp.source).to eq('\r')
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should parse 'word' syntax" do
|
125
|
+
regexp = SrlRuby.parse('word, literally "is"')
|
126
|
+
expect(regexp.source).to eq('\bis')
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should parse 'no word' syntax" do
|
130
|
+
regexp = SrlRuby.parse('no word, literally "is"')
|
131
|
+
expect(regexp.source).to eq('\Bis')
|
132
|
+
end
|
113
133
|
end # context
|
114
134
|
|
115
135
|
context 'Parsing alternations:' do
|