actionpack 4.1.7 → 4.2.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (112) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +404 -451
  3. data/README.rdoc +7 -2
  4. data/lib/abstract_controller/base.rb +16 -6
  5. data/lib/abstract_controller/callbacks.rb +28 -51
  6. data/lib/abstract_controller/helpers.rb +11 -4
  7. data/lib/abstract_controller/railties/routes_helpers.rb +3 -3
  8. data/lib/abstract_controller/rendering.rb +7 -1
  9. data/lib/abstract_controller/url_for.rb +1 -1
  10. data/lib/action_controller/base.rb +3 -2
  11. data/lib/action_controller/caching/fragments.rb +7 -1
  12. data/lib/action_controller/caching.rb +1 -1
  13. data/lib/action_controller/log_subscriber.rb +26 -26
  14. data/lib/action_controller/metal/conditional_get.rb +37 -12
  15. data/lib/action_controller/metal/etag_with_template_digest.rb +50 -0
  16. data/lib/action_controller/metal/exceptions.rb +1 -1
  17. data/lib/action_controller/metal/force_ssl.rb +1 -1
  18. data/lib/action_controller/metal/head.rb +7 -3
  19. data/lib/action_controller/metal/http_authentication.rb +20 -10
  20. data/lib/action_controller/metal/instrumentation.rb +8 -5
  21. data/lib/action_controller/metal/live.rb +57 -6
  22. data/lib/action_controller/metal/mime_responds.rb +25 -246
  23. data/lib/action_controller/metal/params_wrapper.rb +5 -5
  24. data/lib/action_controller/metal/rack_delegation.rb +1 -1
  25. data/lib/action_controller/metal/redirecting.rb +14 -8
  26. data/lib/action_controller/metal/renderers.rb +29 -11
  27. data/lib/action_controller/metal/rendering.rb +2 -6
  28. data/lib/action_controller/metal/request_forgery_protection.rb +78 -7
  29. data/lib/action_controller/metal/streaming.rb +1 -1
  30. data/lib/action_controller/metal/strong_parameters.rb +129 -14
  31. data/lib/action_controller/metal/url_for.rb +11 -12
  32. data/lib/action_controller/metal.rb +12 -11
  33. data/lib/action_controller/model_naming.rb +1 -1
  34. data/lib/action_controller/railtie.rb +4 -0
  35. data/lib/action_controller/test_case.rb +119 -75
  36. data/lib/action_controller.rb +1 -1
  37. data/lib/action_dispatch/http/cache.rb +5 -4
  38. data/lib/action_dispatch/http/filter_parameters.rb +2 -2
  39. data/lib/action_dispatch/http/headers.rb +43 -9
  40. data/lib/action_dispatch/http/mime_negotiation.rb +10 -3
  41. data/lib/action_dispatch/http/mime_type.rb +18 -4
  42. data/lib/action_dispatch/http/parameter_filter.rb +1 -1
  43. data/lib/action_dispatch/http/parameters.rb +11 -26
  44. data/lib/action_dispatch/http/request.rb +37 -11
  45. data/lib/action_dispatch/http/response.rb +74 -23
  46. data/lib/action_dispatch/http/upload.rb +9 -8
  47. data/lib/action_dispatch/http/url.rb +89 -70
  48. data/lib/action_dispatch/journey/formatter.rb +34 -18
  49. data/lib/action_dispatch/journey/gtg/builder.rb +3 -3
  50. data/lib/action_dispatch/journey/gtg/simulator.rb +10 -7
  51. data/lib/action_dispatch/journey/gtg/transition_table.rb +20 -28
  52. data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
  53. data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
  54. data/lib/action_dispatch/journey/nfa/transition_table.rb +5 -5
  55. data/lib/action_dispatch/journey/nodes/node.rb +4 -0
  56. data/lib/action_dispatch/journey/parser.rb +52 -60
  57. data/lib/action_dispatch/journey/parser.y +11 -10
  58. data/lib/action_dispatch/journey/path/pattern.rb +16 -19
  59. data/lib/action_dispatch/journey/route.rb +4 -19
  60. data/lib/action_dispatch/journey/router/strexp.rb +9 -6
  61. data/lib/action_dispatch/journey/router/utils.rb +1 -1
  62. data/lib/action_dispatch/journey/router.rb +53 -77
  63. data/lib/action_dispatch/journey/routes.rb +4 -0
  64. data/lib/action_dispatch/journey/scanner.rb +5 -5
  65. data/lib/action_dispatch/journey/visitors.rb +81 -92
  66. data/lib/action_dispatch/journey/visualizer/fsm.css +0 -4
  67. data/lib/action_dispatch/journey/visualizer/index.html.erb +2 -2
  68. data/lib/action_dispatch/middleware/callbacks.rb +1 -1
  69. data/lib/action_dispatch/middleware/cookies.rb +34 -34
  70. data/lib/action_dispatch/middleware/debug_exceptions.rb +15 -4
  71. data/lib/action_dispatch/middleware/exception_wrapper.rb +50 -18
  72. data/lib/action_dispatch/middleware/flash.rb +13 -7
  73. data/lib/action_dispatch/middleware/params_parser.rb +1 -1
  74. data/lib/action_dispatch/middleware/public_exceptions.rb +12 -3
  75. data/lib/action_dispatch/middleware/remote_ip.rb +40 -54
  76. data/lib/action_dispatch/middleware/request_id.rb +1 -1
  77. data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
  78. data/lib/action_dispatch/middleware/show_exceptions.rb +1 -0
  79. data/lib/action_dispatch/middleware/ssl.rb +1 -1
  80. data/lib/action_dispatch/middleware/static.rb +75 -39
  81. data/lib/action_dispatch/middleware/templates/rescues/_source.erb +21 -19
  82. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +37 -9
  83. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +2 -8
  84. data/lib/action_dispatch/middleware/templates/rescues/{diagnostics.erb → diagnostics.html.erb} +0 -0
  85. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  86. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +6 -0
  87. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -0
  88. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +2 -0
  89. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -24
  90. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +0 -1
  91. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +120 -64
  92. data/lib/action_dispatch/railtie.rb +2 -0
  93. data/lib/action_dispatch/routing/endpoint.rb +10 -0
  94. data/lib/action_dispatch/routing/inspector.rb +5 -12
  95. data/lib/action_dispatch/routing/mapper.rb +414 -283
  96. data/lib/action_dispatch/routing/polymorphic_routes.rb +191 -79
  97. data/lib/action_dispatch/routing/redirection.rb +10 -12
  98. data/lib/action_dispatch/routing/route_set.rb +300 -173
  99. data/lib/action_dispatch/routing/routes_proxy.rb +5 -4
  100. data/lib/action_dispatch/routing/url_for.rb +17 -5
  101. data/lib/action_dispatch/testing/assertions/dom.rb +2 -26
  102. data/lib/action_dispatch/testing/assertions/response.rb +2 -7
  103. data/lib/action_dispatch/testing/assertions/routing.rb +22 -22
  104. data/lib/action_dispatch/testing/assertions/selector.rb +2 -429
  105. data/lib/action_dispatch/testing/assertions/tag.rb +2 -134
  106. data/lib/action_dispatch/testing/assertions.rb +11 -7
  107. data/lib/action_dispatch/testing/integration.rb +28 -20
  108. data/lib/action_dispatch/testing/test_request.rb +1 -1
  109. data/lib/action_dispatch/testing/test_response.rb +1 -5
  110. data/lib/action_pack/gem_version.rb +3 -3
  111. metadata +55 -13
  112. data/lib/action_controller/metal/responder.rb +0 -297
@@ -27,7 +27,7 @@ module ActionDispatch
27
27
  marked[s] = true # mark s
28
28
 
29
29
  s.group_by { |state| symbol(state) }.each do |sym, ps|
30
- u = ps.map { |l| followpos(l) }.flatten
30
+ u = ps.flat_map { |l| followpos(l) }
31
31
  next if u.empty?
32
32
 
33
33
  if u.uniq == [DUMMY]
@@ -90,7 +90,7 @@ module ActionDispatch
90
90
  firstpos(node.left)
91
91
  end
92
92
  when Nodes::Or
93
- node.children.map { |c| firstpos(c) }.flatten.uniq
93
+ node.children.flat_map { |c| firstpos(c) }.uniq
94
94
  when Nodes::Unary
95
95
  firstpos(node.left)
96
96
  when Nodes::Terminal
@@ -105,7 +105,7 @@ module ActionDispatch
105
105
  when Nodes::Star
106
106
  firstpos(node.left)
107
107
  when Nodes::Or
108
- node.children.map { |c| lastpos(c) }.flatten.uniq
108
+ node.children.flat_map { |c| lastpos(c) }.uniq
109
109
  when Nodes::Cat
110
110
  if nullable?(node.right)
111
111
  lastpos(node.left) | lastpos(node.right)
@@ -19,6 +19,14 @@ module ActionDispatch
19
19
  end
20
20
 
21
21
  def simulate(string)
22
+ ms = memos(string) { return }
23
+ MatchData.new(ms)
24
+ end
25
+
26
+ alias :=~ :simulate
27
+ alias :match :simulate
28
+
29
+ def memos(string)
22
30
  input = StringScanner.new(string)
23
31
  state = [0]
24
32
  while sym = input.scan(%r([/.?]|[^/.?]+))
@@ -29,15 +37,10 @@ module ActionDispatch
29
37
  tt.accepting? s
30
38
  }
31
39
 
32
- return if acceptance_states.empty?
40
+ return yield if acceptance_states.empty?
33
41
 
34
- memos = acceptance_states.map { |x| tt.memo(x) }.flatten.compact
35
-
36
- MatchData.new(memos)
42
+ acceptance_states.flat_map { |x| tt.memo(x) }.compact
37
43
  end
38
-
39
- alias :=~ :simulate
40
- alias :match :simulate
41
44
  end
42
45
  end
43
46
  end
@@ -40,7 +40,19 @@ module ActionDispatch
40
40
  end
41
41
 
42
42
  def move(t, a)
43
- move_string(t, a).concat(move_regexp(t, a))
43
+ return [] if t.empty?
44
+
45
+ regexps = []
46
+
47
+ t.map { |s|
48
+ if states = @regexp_states[s]
49
+ regexps.concat states.map { |re, v| re === a ? v : nil }
50
+ end
51
+
52
+ if states = @string_states[s]
53
+ states[a]
54
+ end
55
+ }.compact.concat regexps
44
56
  end
45
57
 
46
58
  def as_json(options = nil)
@@ -76,13 +88,13 @@ module ActionDispatch
76
88
  erb = File.read File.join(viz_dir, 'index.html.erb')
77
89
  states = "function tt() { return #{to_json}; }"
78
90
 
79
- fun_routes = paths.shuffle.first(3).map do |ast|
91
+ fun_routes = paths.sample(3).map do |ast|
80
92
  ast.map { |n|
81
93
  case n
82
94
  when Nodes::Symbol
83
95
  case n.left
84
96
  when ':id' then rand(100).to_s
85
- when ':format' then %w{ xml json }.shuffle.first
97
+ when ':format' then %w{ xml json }.sample
86
98
  else
87
99
  'omg'
88
100
  end
@@ -114,17 +126,17 @@ module ActionDispatch
114
126
  end
115
127
 
116
128
  def states
117
- ss = @string_states.keys + @string_states.values.map(&:values).flatten
118
- rs = @regexp_states.keys + @regexp_states.values.map(&:values).flatten
129
+ ss = @string_states.keys + @string_states.values.flat_map(&:values)
130
+ rs = @regexp_states.keys + @regexp_states.values.flat_map(&:values)
119
131
  (ss + rs).uniq
120
132
  end
121
133
 
122
134
  def transitions
123
- @string_states.map { |from, hash|
135
+ @string_states.flat_map { |from, hash|
124
136
  hash.map { |s, to| [from, s, to] }
125
- }.flatten(1) + @regexp_states.map { |from, hash|
137
+ } + @regexp_states.flat_map { |from, hash|
126
138
  hash.map { |s, to| [from, s, to] }
127
- }.flatten(1)
139
+ }
128
140
  end
129
141
 
130
142
  private
@@ -139,26 +151,6 @@ module ActionDispatch
139
151
  raise ArgumentError, 'unknown symbol: %s' % sym.class
140
152
  end
141
153
  end
142
-
143
- def move_regexp(t, a)
144
- return [] if t.empty?
145
-
146
- t.map { |s|
147
- if states = @regexp_states[s]
148
- states.map { |re, v| re === a ? v : nil }
149
- end
150
- }.flatten.compact.uniq
151
- end
152
-
153
- def move_string(t, a)
154
- return [] if t.empty?
155
-
156
- t.map do |s|
157
- if states = @string_states[s]
158
- states[a]
159
- end
160
- end.compact
161
- end
162
154
  end
163
155
  end
164
156
  end
@@ -16,9 +16,9 @@ module ActionDispatch
16
16
  # end
17
17
  # " #{n.object_id} [label=\"#{label}\", shape=box];"
18
18
  #}
19
- #memo_edges = memos.map { |k, memos|
19
+ #memo_edges = memos.flat_map { |k, memos|
20
20
  # (memos || []).map { |v| " #{k} -> #{v.object_id};" }
21
- #}.flatten.uniq
21
+ #}.uniq
22
22
 
23
23
  <<-eodot
24
24
  digraph nfa {
@@ -34,7 +34,7 @@ module ActionDispatch
34
34
 
35
35
  return if acceptance_states.empty?
36
36
 
37
- memos = acceptance_states.map { |x| tt.memo(x) }.flatten.compact
37
+ memos = acceptance_states.flat_map { |x| tt.memo(x) }.compact
38
38
 
39
39
  MatchData.new(memos)
40
40
  end
@@ -42,7 +42,7 @@ module ActionDispatch
42
42
  end
43
43
 
44
44
  def states
45
- (@table.keys + @table.values.map(&:keys).flatten).uniq
45
+ (@table.keys + @table.values.flat_map(&:keys)).uniq
46
46
  end
47
47
 
48
48
  # Returns a generalized transition graph with reduced states. The states
@@ -93,7 +93,7 @@ module ActionDispatch
93
93
  # Returns set of NFA states to which there is a transition on ast symbol
94
94
  # +a+ from some state +s+ in +t+.
95
95
  def following_states(t, a)
96
- Array(t).map { |s| inverted[s][a] }.flatten.uniq
96
+ Array(t).flat_map { |s| inverted[s][a] }.uniq
97
97
  end
98
98
 
99
99
  # Returns set of NFA states to which there is a transition on ast symbol
@@ -107,7 +107,7 @@ module ActionDispatch
107
107
  end
108
108
 
109
109
  def alphabet
110
- inverted.values.map(&:keys).flatten.compact.uniq.sort_by { |x| x.to_s }
110
+ inverted.values.flat_map(&:keys).compact.uniq.sort_by { |x| x.to_s }
111
111
  end
112
112
 
113
113
  # Returns a set of NFA states reachable from some NFA state +s+ in set
@@ -131,9 +131,9 @@ module ActionDispatch
131
131
  end
132
132
 
133
133
  def transitions
134
- @table.map { |to, hash|
134
+ @table.flat_map { |to, hash|
135
135
  hash.map { |from, sym| [from, sym, to] }
136
- }.flatten(1)
136
+ }
137
137
  end
138
138
 
139
139
  private
@@ -93,6 +93,10 @@ module ActionDispatch
93
93
 
94
94
  class Star < Unary # :nodoc:
95
95
  def type; :STAR; end
96
+
97
+ def name
98
+ left.name.tr '*:', ''
99
+ end
96
100
  end
97
101
 
98
102
  class Binary < Node # :nodoc:
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.9
4
- # from Racc grammar file "".
3
+ # This file is automatically generated by Racc 1.4.11
4
+ # from Racc grammer file "".
5
5
  #
6
6
 
7
7
  require 'racc/parser.rb'
@@ -9,42 +9,38 @@ require 'racc/parser.rb'
9
9
 
10
10
  require 'action_dispatch/journey/parser_extras'
11
11
  module ActionDispatch
12
- module Journey # :nodoc:
13
- class Parser < Racc::Parser # :nodoc:
12
+ module Journey
13
+ class Parser < Racc::Parser
14
14
  ##### State transition tables begin ###
15
15
 
16
16
  racc_action_table = [
17
- 17, 21, 13, 15, 14, 7, nil, 16, 8, 19,
18
- 13, 15, 14, 7, 23, 16, 8, 19, 13, 15,
19
- 14, 7, nil, 16, 8, 13, 15, 14, 7, nil,
20
- 16, 8, 13, 15, 14, 7, nil, 16, 8 ]
17
+ 13, 15, 14, 7, 21, 16, 8, 19, 13, 15,
18
+ 14, 7, 17, 16, 8, 13, 15, 14, 7, 24,
19
+ 16, 8, 13, 15, 14, 7, 19, 16, 8 ]
21
20
 
22
21
  racc_action_check = [
23
- 1, 17, 1, 1, 1, 1, nil, 1, 1, 1,
24
- 20, 20, 20, 20, 20, 20, 20, 20, 7, 7,
25
- 7, 7, nil, 7, 7, 19, 19, 19, 19, nil,
26
- 19, 19, 0, 0, 0, 0, nil, 0, 0 ]
22
+ 2, 2, 2, 2, 17, 2, 2, 2, 0, 0,
23
+ 0, 0, 1, 0, 0, 19, 19, 19, 19, 20,
24
+ 19, 19, 7, 7, 7, 7, 22, 7, 7 ]
27
25
 
28
26
  racc_action_pointer = [
29
- 30, 0, nil, nil, nil, nil, nil, 16, nil, nil,
30
- nil, nil, nil, nil, nil, nil, nil, 1, nil, 23,
31
- 8, nil, nil, nil ]
27
+ 6, 12, -2, nil, nil, nil, nil, 20, nil, nil,
28
+ nil, nil, nil, nil, nil, nil, nil, 4, nil, 13,
29
+ 13, nil, 17, nil, nil ]
32
30
 
33
31
  racc_action_default = [
34
- -18, -18, -2, -3, -4, -5, -6, -18, -9, -10,
35
- -11, -12, -13, -14, -15, -16, -17, -18, -1, -18,
36
- -18, 24, -8, -7 ]
32
+ -19, -19, -2, -3, -4, -5, -6, -19, -10, -11,
33
+ -12, -13, -14, -15, -16, -17, -18, -19, -1, -19,
34
+ -19, 25, -8, -9, -7 ]
37
35
 
38
36
  racc_goto_table = [
39
- 18, 1, nil, nil, nil, nil, nil, nil, 20, nil,
40
- nil, nil, nil, nil, nil, nil, nil, nil, 22, 18 ]
37
+ 1, 22, 18, 23, nil, nil, nil, 20 ]
41
38
 
42
39
  racc_goto_check = [
43
- 2, 1, nil, nil, nil, nil, nil, nil, 1, nil,
44
- nil, nil, nil, nil, nil, nil, nil, nil, 2, 2 ]
40
+ 1, 2, 1, 3, nil, nil, nil, 1 ]
45
41
 
46
42
  racc_goto_pointer = [
47
- nil, 1, -1, nil, nil, nil, nil, nil, nil, nil,
43
+ nil, 0, -18, -16, nil, nil, nil, nil, nil, nil,
48
44
  nil ]
49
45
 
50
46
  racc_goto_default = [
@@ -61,19 +57,20 @@ racc_reduce_table = [
61
57
  1, 12, :_reduce_none,
62
58
  3, 15, :_reduce_7,
63
59
  3, 13, :_reduce_8,
64
- 1, 16, :_reduce_9,
60
+ 3, 13, :_reduce_9,
61
+ 1, 16, :_reduce_10,
65
62
  1, 14, :_reduce_none,
66
63
  1, 14, :_reduce_none,
67
64
  1, 14, :_reduce_none,
68
65
  1, 14, :_reduce_none,
69
- 1, 19, :_reduce_14,
70
- 1, 17, :_reduce_15,
71
- 1, 18, :_reduce_16,
72
- 1, 20, :_reduce_17 ]
66
+ 1, 19, :_reduce_15,
67
+ 1, 17, :_reduce_16,
68
+ 1, 18, :_reduce_17,
69
+ 1, 20, :_reduce_18 ]
73
70
 
74
- racc_reduce_n = 18
71
+ racc_reduce_n = 19
75
72
 
76
- racc_shift_n = 24
73
+ racc_shift_n = 25
77
74
 
78
75
  racc_token_table = {
79
76
  false => 0,
@@ -89,7 +86,7 @@ racc_token_table = {
89
86
 
90
87
  racc_nt_base = 10
91
88
 
92
- racc_use_result_var = true
89
+ racc_use_result_var = false
93
90
 
94
91
  Racc_arg = [
95
92
  racc_action_table,
@@ -136,14 +133,12 @@ Racc_debug_parser = false
136
133
 
137
134
  # reduce 0 omitted
138
135
 
139
- def _reduce_1(val, _values, result)
140
- result = Cat.new(val.first, val.last)
141
- result
136
+ def _reduce_1(val, _values)
137
+ Cat.new(val.first, val.last)
142
138
  end
143
139
 
144
- def _reduce_2(val, _values, result)
145
- result = val.first
146
- result
140
+ def _reduce_2(val, _values)
141
+ val.first
147
142
  end
148
143
 
149
144
  # reduce 3 omitted
@@ -154,22 +149,21 @@ end
154
149
 
155
150
  # reduce 6 omitted
156
151
 
157
- def _reduce_7(val, _values, result)
158
- result = Group.new(val[1])
159
- result
152
+ def _reduce_7(val, _values)
153
+ Group.new(val[1])
160
154
  end
161
155
 
162
- def _reduce_8(val, _values, result)
163
- result = Or.new([val.first, val.last])
164
- result
156
+ def _reduce_8(val, _values)
157
+ Or.new([val.first, val.last])
165
158
  end
166
159
 
167
- def _reduce_9(val, _values, result)
168
- result = Star.new(Symbol.new(val.last))
169
- result
160
+ def _reduce_9(val, _values)
161
+ Or.new([val.first, val.last])
170
162
  end
171
163
 
172
- # reduce 10 omitted
164
+ def _reduce_10(val, _values)
165
+ Star.new(Symbol.new(val.last))
166
+ end
173
167
 
174
168
  # reduce 11 omitted
175
169
 
@@ -177,27 +171,25 @@ end
177
171
 
178
172
  # reduce 13 omitted
179
173
 
180
- def _reduce_14(val, _values, result)
181
- result = Slash.new('/')
182
- result
174
+ # reduce 14 omitted
175
+
176
+ def _reduce_15(val, _values)
177
+ Slash.new('/')
183
178
  end
184
179
 
185
- def _reduce_15(val, _values, result)
186
- result = Symbol.new(val.first)
187
- result
180
+ def _reduce_16(val, _values)
181
+ Symbol.new(val.first)
188
182
  end
189
183
 
190
- def _reduce_16(val, _values, result)
191
- result = Literal.new(val.first)
192
- result
184
+ def _reduce_17(val, _values)
185
+ Literal.new(val.first)
193
186
  end
194
187
 
195
- def _reduce_17(val, _values, result)
196
- result = Dot.new(val.first)
197
- result
188
+ def _reduce_18(val, _values)
189
+ Dot.new(val.first)
198
190
  end
199
191
 
200
- def _reduce_none(val, _values, result)
192
+ def _reduce_none(val, _values)
201
193
  val[0]
202
194
  end
203
195
 
@@ -1,11 +1,11 @@
1
1
  class ActionDispatch::Journey::Parser
2
-
2
+ options no_result_var
3
3
  token SLASH LITERAL SYMBOL LPAREN RPAREN DOT STAR OR
4
4
 
5
5
  rule
6
6
  expressions
7
- : expressions expression { result = Cat.new(val.first, val.last) }
8
- | expression { result = val.first }
7
+ : expression expressions { Cat.new(val.first, val.last) }
8
+ | expression { val.first }
9
9
  | or
10
10
  ;
11
11
  expression
@@ -14,13 +14,14 @@ rule
14
14
  | star
15
15
  ;
16
16
  group
17
- : LPAREN expressions RPAREN { result = Group.new(val[1]) }
17
+ : LPAREN expressions RPAREN { Group.new(val[1]) }
18
18
  ;
19
19
  or
20
- : expressions OR expression { result = Or.new([val.first, val.last]) }
20
+ : expression OR expression { Or.new([val.first, val.last]) }
21
+ | expression OR or { Or.new([val.first, val.last]) }
21
22
  ;
22
23
  star
23
- : STAR { result = Star.new(Symbol.new(val.last)) }
24
+ : STAR { Star.new(Symbol.new(val.last)) }
24
25
  ;
25
26
  terminal
26
27
  : symbol
@@ -29,16 +30,16 @@ rule
29
30
  | dot
30
31
  ;
31
32
  slash
32
- : SLASH { result = Slash.new('/') }
33
+ : SLASH { Slash.new('/') }
33
34
  ;
34
35
  symbol
35
- : SYMBOL { result = Symbol.new(val.first) }
36
+ : SYMBOL { Symbol.new(val.first) }
36
37
  ;
37
38
  literal
38
- : LITERAL { result = Literal.new(val.first) }
39
+ : LITERAL { Literal.new(val.first) }
39
40
  ;
40
41
  dot
41
- : DOT { result = Dot.new(val.first) }
42
+ : DOT { Dot.new(val.first) }
42
43
  ;
43
44
 
44
45
  end