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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3642f7f1361cb920e2a9e42dcd8969d5ec75c7fe
4
- data.tar.gz: 480c7561fd6972a8872e472166d07d0905c4612d
3
+ metadata.gz: 13bb293008059e97968eab3b976e05f7fe9c353e
4
+ data.tar.gz: 933e9531ae294fe4adb46e3c7ef87c58a3243388
5
5
  SHA512:
6
- metadata.gz: d60a8e33fbf0b2fafdacf03127fe1502efd60bc5fc69de9d97fa9ddd07d0505d3c6577f0fb078277980b6a024f76f88887fcd01e0798f02f6b55c41ebef65bbe
7
- data.tar.gz: 838e7c67fa30ac58d2fefffd701394db75a632087c2440aaaac0d2fb3b349857c79eefd446089b6ccb6878232ed56c987dcd669847b1b4aff2cf40025e0df20e
6
+ metadata.gz: 1c585bfad3f6330b87f47ab7c1dae115bc953a50220bc3d87642524c523cfbe1ae19193cfc0173730d456ec6691611abd59964ea4722a42bdbb1571f6c06ce9c
7
+ data.tar.gz: f835d81332961e020addee4ec8b5e4c46378f29ad12a7497fb03f5545eee1c884b1da5b8a621d4f76713b348b3b324fc96c4eb9f60b98037c1c7e9b98ab5d9c6
data/CHANGELOG.md CHANGED
@@ -1,10 +1,11 @@
1
- ## Unreleased
2
- ### Added
1
+ ## [0.2.5] - 2018-04-02
2
+ SrlRuby passes 12 tests out of 15 standard SRL tests in total.
3
3
  ### Changed
4
- ### Deprecated
5
- ### Removed
6
- ### Fixed
7
- ### Security
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
+
@@ -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)
@@ -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'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SrlRuby
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.5'.freeze
3
3
  end
@@ -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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srl_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef