aslakhellesoy-cucumber 0.0.1 → 0.1.1
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.
- data/License.txt +1 -1
- data/Manifest.txt +38 -24
- data/README.textile +31 -0
- data/TODO.txt +30 -0
- data/config/hoe.rb +6 -7
- data/examples/java/README.textile +52 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/steps/hello_steps.rb +25 -0
- data/examples/java/features/steps/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- data/examples/java/src/cucumber/demo/Hello.java +15 -0
- data/examples/pure_ruby/Rakefile +6 -0
- data/examples/pure_ruby/features/addition.rb +23 -0
- data/examples/pure_ruby/{steps → features/steps}/addition_steps.rb +0 -0
- data/examples/simple_norwegian/Rakefile +6 -0
- data/examples/simple_norwegian/{steg → features/steps}/matte_steg.rb.rb +0 -0
- data/examples/simple_norwegian/{summering.story → features/summering.feature} +4 -1
- data/examples/web/Rakefile +6 -0
- data/examples/web/features/search.feature +9 -0
- data/examples/web/features/steps/stories_steps.rb +51 -0
- data/gem_tasks/treetop.rake +8 -14
- data/lib/cucumber.rb +10 -3
- data/lib/cucumber/cli.rb +29 -19
- data/lib/cucumber/core_ext/proc.rb +13 -5
- data/lib/cucumber/executor.rb +8 -10
- data/lib/cucumber/formatters/ansicolor.rb +2 -2
- data/lib/cucumber/formatters/html_formatter.rb +6 -6
- data/lib/cucumber/formatters/pretty_formatter.rb +68 -15
- data/lib/cucumber/{parser/languages.yml → languages.yml} +0 -4
- data/lib/cucumber/rake/task.rb +24 -26
- data/lib/cucumber/step_mother.rb +3 -3
- data/lib/cucumber/tree.rb +8 -117
- data/lib/cucumber/tree/feature.rb +45 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/scenario.rb +79 -0
- data/lib/cucumber/tree/step.rb +133 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/{parser → tree}/top_down_visitor.rb +5 -8
- data/lib/cucumber/treetop_parser/feature.treetop.erb +98 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +32 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +923 -0
- data/lib/cucumber/version.rb +2 -2
- data/script/console +1 -1
- data/spec/cucumber/executor_spec.rb +9 -9
- data/spec/cucumber/formatters/{stories.html → features.html} +9 -9
- data/spec/cucumber/formatters/html_formatter_spec.rb +11 -11
- data/spec/cucumber/{sell_cucumbers.story → sell_cucumbers.feature} +1 -1
- data/spec/spec_helper.rb +8 -1
- metadata +61 -30
- data/README.txt +0 -78
- data/examples/Rakefile +0 -7
- data/examples/pure_ruby/addition.rb +0 -16
- data/examples/simple/addition.story +0 -12
- data/examples/simple/division.story +0 -17
- data/examples/simple/steps/addition_steps.rb +0 -43
- data/examples/web/run_stories.story +0 -10
- data/examples/web/steps/stories_steps.rb +0 -39
- data/lib/cucumber/parser/nodes.rb +0 -88
- data/lib/cucumber/parser/story_parser.rb +0 -13
- data/lib/cucumber/parser/story_parser.treetop.erb +0 -41
- data/lib/cucumber/parser/story_parser_en.rb +0 -554
- data/lib/cucumber/parser/story_parser_fr.rb +0 -554
- data/lib/cucumber/parser/story_parser_no.rb +0 -554
- data/lib/cucumber/parser/story_parser_pt.rb +0 -554
- data/lib/cucumber/ruby_tree.rb +0 -14
- data/lib/cucumber/ruby_tree/nodes.rb +0 -68
@@ -1,12 +0,0 @@
|
|
1
|
-
Story: Addition
|
2
|
-
As a math idiot
|
3
|
-
I want to be told the sum of two numbers
|
4
|
-
So that I don't make silly mistakes
|
5
|
-
|
6
|
-
Scenario: 50+70
|
7
|
-
Given I have entered 50 into the calculator
|
8
|
-
Given foo bar
|
9
|
-
And I have entered 70 into the calculator
|
10
|
-
When I add
|
11
|
-
Then the result should be 12 on the screen
|
12
|
-
And the result class should be Float
|
@@ -1,17 +0,0 @@
|
|
1
|
-
Story: Division
|
2
|
-
As a math genius
|
3
|
-
I want to be told the division of two floats
|
4
|
-
So that I don't make silly mistakes
|
5
|
-
|
6
|
-
Scenario: 7/2
|
7
|
-
Given I have entered 3 into the calculator
|
8
|
-
And I have entered 2 into the calculator
|
9
|
-
When I divide
|
10
|
-
Then the result should be 2.5 on the screen
|
11
|
-
And the result class should be Float
|
12
|
-
|
13
|
-
Scenario: 3/0
|
14
|
-
Given I have entered 3 into the calculator
|
15
|
-
And I have entered 2 into the calculator
|
16
|
-
When I divide
|
17
|
-
Then the result should be NaN on the screen
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
class Calculator
|
4
|
-
def push(n)
|
5
|
-
@args ||= []
|
6
|
-
@args << n
|
7
|
-
end
|
8
|
-
|
9
|
-
def add
|
10
|
-
@args.inject(0){|n,sum| sum+=n}
|
11
|
-
end
|
12
|
-
|
13
|
-
def divide
|
14
|
-
@args[0].to_f / @args[1].to_f
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Before do
|
19
|
-
@calc = Calculator.new
|
20
|
-
end
|
21
|
-
|
22
|
-
After do
|
23
|
-
end
|
24
|
-
|
25
|
-
Given /I have entered (\d+) into the calculator/ do |n|
|
26
|
-
@calc.push n.to_i
|
27
|
-
end
|
28
|
-
|
29
|
-
When 'I add' do
|
30
|
-
@result = @calc.add
|
31
|
-
end
|
32
|
-
|
33
|
-
When 'I divide' do
|
34
|
-
@result = @calc.divide
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /the result should be (\d*) on the screen/ do |result|
|
38
|
-
@result.should == result.to_i
|
39
|
-
end
|
40
|
-
|
41
|
-
Then /the result class should be (\w*)/ do |class_name|
|
42
|
-
@result.class.name.should == class_name
|
43
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Story: Run Stories
|
2
|
-
As an information seeker
|
3
|
-
I want to find more information
|
4
|
-
So that I can learn more
|
5
|
-
|
6
|
-
Scenario: Find what I'm looking for
|
7
|
-
Given I am on the search page
|
8
|
-
And I have entered "rspec"
|
9
|
-
When I search
|
10
|
-
Then I should see a link to "RSpec-1.1.3: Overview":http://rspec.info/
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
case PLATFORM
|
4
|
-
when /darwin/
|
5
|
-
require 'safariwatir'
|
6
|
-
Browser = Watir::Safari
|
7
|
-
when /win32/
|
8
|
-
require 'watir'
|
9
|
-
Browser = Watir::IE
|
10
|
-
when /java/
|
11
|
-
require 'celerity'
|
12
|
-
Browser = Celerity::Browser
|
13
|
-
else
|
14
|
-
raise "Can't do web stories on #{PLATFORM}"
|
15
|
-
end
|
16
|
-
|
17
|
-
Before do
|
18
|
-
@b = Browser.new
|
19
|
-
end
|
20
|
-
|
21
|
-
After do
|
22
|
-
@b.close
|
23
|
-
end
|
24
|
-
|
25
|
-
Given 'I am on the search page' do
|
26
|
-
@b.goto 'http://www.google.com/'
|
27
|
-
end
|
28
|
-
|
29
|
-
Given /I have entered "(.*)"/ do |query|
|
30
|
-
@b.text_field(:name, 'q').set(query)
|
31
|
-
end
|
32
|
-
|
33
|
-
When 'I search' do
|
34
|
-
@b.button(:name, 'btnG').click
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /I should see a link to "(.*)":(.*)/ do |text, url|
|
38
|
-
@b.link(:url, url).text.should == text
|
39
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'cucumber/core_ext/string'
|
2
|
-
require 'cucumber/tree'
|
3
|
-
|
4
|
-
module Cucumber
|
5
|
-
module Parser
|
6
|
-
class StoryNode < Treetop::Runtime::SyntaxNode
|
7
|
-
include Tree::Story
|
8
|
-
attr_accessor :file
|
9
|
-
|
10
|
-
def self.parse(file, parser)
|
11
|
-
story = parser.parse(IO.read(file))
|
12
|
-
if story.nil?
|
13
|
-
raise parser.compile_error(file)
|
14
|
-
end
|
15
|
-
story.file = file
|
16
|
-
story
|
17
|
-
end
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
def header
|
22
|
-
header_node.sentence_line.text_value
|
23
|
-
end
|
24
|
-
|
25
|
-
def narrative
|
26
|
-
narrative_node.text_value
|
27
|
-
end
|
28
|
-
|
29
|
-
def scenarios
|
30
|
-
scenario_nodes.elements
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class HeaderNode < Treetop::Runtime::SyntaxNode
|
35
|
-
def name
|
36
|
-
sentence_line.text_value.strip
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class NarrativeNode < Treetop::Runtime::SyntaxNode
|
41
|
-
def narrative
|
42
|
-
text_value
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class ScenarioNode < Treetop::Runtime::SyntaxNode
|
47
|
-
include Tree::Scenario
|
48
|
-
|
49
|
-
def name
|
50
|
-
sentence.text_value.strip
|
51
|
-
end
|
52
|
-
|
53
|
-
def file
|
54
|
-
parent.parent.file
|
55
|
-
end
|
56
|
-
|
57
|
-
protected
|
58
|
-
|
59
|
-
def steps
|
60
|
-
step_nodes.elements
|
61
|
-
end
|
62
|
-
|
63
|
-
def line
|
64
|
-
input.line_of(interval.first)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class StepNode < Treetop::Runtime::SyntaxNode
|
69
|
-
include Tree::Step
|
70
|
-
|
71
|
-
def line
|
72
|
-
input.line_of(interval.first)
|
73
|
-
end
|
74
|
-
|
75
|
-
def name
|
76
|
-
sentence.text_value.strip
|
77
|
-
end
|
78
|
-
|
79
|
-
def keyword
|
80
|
-
step_type.text_value.strip
|
81
|
-
end
|
82
|
-
|
83
|
-
def file
|
84
|
-
parent.parent.file
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'cucumber/parser/nodes'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Parser
|
5
|
-
class StoryParser < Treetop::Runtime::CompiledParser
|
6
|
-
def compile_error(file)
|
7
|
-
tf = terminal_failures
|
8
|
-
expected = tf.size == 1 ? tf[0].expected_string : "one of #{tf.map{|f| f.expected_string}.uniq*', '}"
|
9
|
-
"#{file}:#{failure_line}: Parse error, expected #{expected}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
grammar Story
|
2
|
-
rule story
|
3
|
-
header_node narrative_node scenario_nodes:scenario* <Cucumber::Parser::StoryNode>
|
4
|
-
end
|
5
|
-
|
6
|
-
rule header_node
|
7
|
-
'<%= words['story'] %>:' space sentence_line <Cucumber::Parser::HeaderNode>
|
8
|
-
end
|
9
|
-
|
10
|
-
rule narrative_node
|
11
|
-
(!scenario_start .)* <Cucumber::Parser::NarrativeNode>
|
12
|
-
end
|
13
|
-
|
14
|
-
rule scenario
|
15
|
-
scenario_start sentence:sentence_line step_nodes:(step)* <Cucumber::Parser::ScenarioNode>
|
16
|
-
end
|
17
|
-
|
18
|
-
rule scenario_start
|
19
|
-
space '<%= words['scenario'] %>: '
|
20
|
-
end
|
21
|
-
|
22
|
-
rule step
|
23
|
-
space step_type:('<%= words['given'] %>' / '<%= words['when'] %>' / '<%= words['then'] %>'/ '<%= words['and'] %>' / '<%= words['given_scenario'] %>') space sentence:sentence_line <Cucumber::Parser::StepNode>
|
24
|
-
end
|
25
|
-
|
26
|
-
rule sentence_line
|
27
|
-
(!eol .)* eol
|
28
|
-
end
|
29
|
-
|
30
|
-
rule space
|
31
|
-
[ \t\r\n]*
|
32
|
-
end
|
33
|
-
|
34
|
-
rule eol
|
35
|
-
"\r\n" / "\n" / eof
|
36
|
-
end
|
37
|
-
|
38
|
-
rule eof
|
39
|
-
!.
|
40
|
-
end
|
41
|
-
end
|
@@ -1,554 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Parser
|
3
|
-
module Story
|
4
|
-
include Treetop::Runtime
|
5
|
-
|
6
|
-
def root
|
7
|
-
@root || :story
|
8
|
-
end
|
9
|
-
|
10
|
-
module Story0
|
11
|
-
def header_node
|
12
|
-
elements[0]
|
13
|
-
end
|
14
|
-
|
15
|
-
def narrative_node
|
16
|
-
elements[1]
|
17
|
-
end
|
18
|
-
|
19
|
-
def scenario_nodes
|
20
|
-
elements[2]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def _nt_story
|
25
|
-
start_index = index
|
26
|
-
if node_cache[:story].has_key?(index)
|
27
|
-
cached = node_cache[:story][index]
|
28
|
-
@index = cached.interval.end if cached
|
29
|
-
return cached
|
30
|
-
end
|
31
|
-
|
32
|
-
i0, s0 = index, []
|
33
|
-
r1 = _nt_header_node
|
34
|
-
s0 << r1
|
35
|
-
if r1
|
36
|
-
r2 = _nt_narrative_node
|
37
|
-
s0 << r2
|
38
|
-
if r2
|
39
|
-
s3, i3 = [], index
|
40
|
-
loop do
|
41
|
-
r4 = _nt_scenario
|
42
|
-
if r4
|
43
|
-
s3 << r4
|
44
|
-
else
|
45
|
-
break
|
46
|
-
end
|
47
|
-
end
|
48
|
-
r3 = SyntaxNode.new(input, i3...index, s3)
|
49
|
-
s0 << r3
|
50
|
-
end
|
51
|
-
end
|
52
|
-
if s0.last
|
53
|
-
r0 = (Cucumber::Parser::StoryNode).new(input, i0...index, s0)
|
54
|
-
r0.extend(Story0)
|
55
|
-
else
|
56
|
-
self.index = i0
|
57
|
-
r0 = nil
|
58
|
-
end
|
59
|
-
|
60
|
-
node_cache[:story][start_index] = r0
|
61
|
-
|
62
|
-
return r0
|
63
|
-
end
|
64
|
-
|
65
|
-
module HeaderNode0
|
66
|
-
def space
|
67
|
-
elements[1]
|
68
|
-
end
|
69
|
-
|
70
|
-
def sentence_line
|
71
|
-
elements[2]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def _nt_header_node
|
76
|
-
start_index = index
|
77
|
-
if node_cache[:header_node].has_key?(index)
|
78
|
-
cached = node_cache[:header_node][index]
|
79
|
-
@index = cached.interval.end if cached
|
80
|
-
return cached
|
81
|
-
end
|
82
|
-
|
83
|
-
i0, s0 = index, []
|
84
|
-
if input.index('Story:', index) == index
|
85
|
-
r1 = (SyntaxNode).new(input, index...(index + 6))
|
86
|
-
@index += 6
|
87
|
-
else
|
88
|
-
terminal_parse_failure('Story:')
|
89
|
-
r1 = nil
|
90
|
-
end
|
91
|
-
s0 << r1
|
92
|
-
if r1
|
93
|
-
r2 = _nt_space
|
94
|
-
s0 << r2
|
95
|
-
if r2
|
96
|
-
r3 = _nt_sentence_line
|
97
|
-
s0 << r3
|
98
|
-
end
|
99
|
-
end
|
100
|
-
if s0.last
|
101
|
-
r0 = (Cucumber::Parser::HeaderNode).new(input, i0...index, s0)
|
102
|
-
r0.extend(HeaderNode0)
|
103
|
-
else
|
104
|
-
self.index = i0
|
105
|
-
r0 = nil
|
106
|
-
end
|
107
|
-
|
108
|
-
node_cache[:header_node][start_index] = r0
|
109
|
-
|
110
|
-
return r0
|
111
|
-
end
|
112
|
-
|
113
|
-
module NarrativeNode0
|
114
|
-
end
|
115
|
-
|
116
|
-
def _nt_narrative_node
|
117
|
-
start_index = index
|
118
|
-
if node_cache[:narrative_node].has_key?(index)
|
119
|
-
cached = node_cache[:narrative_node][index]
|
120
|
-
@index = cached.interval.end if cached
|
121
|
-
return cached
|
122
|
-
end
|
123
|
-
|
124
|
-
s0, i0 = [], index
|
125
|
-
loop do
|
126
|
-
i1, s1 = index, []
|
127
|
-
i2 = index
|
128
|
-
r3 = _nt_scenario_start
|
129
|
-
if r3
|
130
|
-
r2 = nil
|
131
|
-
else
|
132
|
-
self.index = i2
|
133
|
-
r2 = SyntaxNode.new(input, index...index)
|
134
|
-
end
|
135
|
-
s1 << r2
|
136
|
-
if r2
|
137
|
-
if index < input_length
|
138
|
-
r4 = (SyntaxNode).new(input, index...(index + 1))
|
139
|
-
@index += 1
|
140
|
-
else
|
141
|
-
terminal_parse_failure("any character")
|
142
|
-
r4 = nil
|
143
|
-
end
|
144
|
-
s1 << r4
|
145
|
-
end
|
146
|
-
if s1.last
|
147
|
-
r1 = (SyntaxNode).new(input, i1...index, s1)
|
148
|
-
r1.extend(NarrativeNode0)
|
149
|
-
else
|
150
|
-
self.index = i1
|
151
|
-
r1 = nil
|
152
|
-
end
|
153
|
-
if r1
|
154
|
-
s0 << r1
|
155
|
-
else
|
156
|
-
break
|
157
|
-
end
|
158
|
-
end
|
159
|
-
r0 = Cucumber::Parser::NarrativeNode.new(input, i0...index, s0)
|
160
|
-
|
161
|
-
node_cache[:narrative_node][start_index] = r0
|
162
|
-
|
163
|
-
return r0
|
164
|
-
end
|
165
|
-
|
166
|
-
module Scenario0
|
167
|
-
def scenario_start
|
168
|
-
elements[0]
|
169
|
-
end
|
170
|
-
|
171
|
-
def sentence
|
172
|
-
elements[1]
|
173
|
-
end
|
174
|
-
|
175
|
-
def step_nodes
|
176
|
-
elements[2]
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def _nt_scenario
|
181
|
-
start_index = index
|
182
|
-
if node_cache[:scenario].has_key?(index)
|
183
|
-
cached = node_cache[:scenario][index]
|
184
|
-
@index = cached.interval.end if cached
|
185
|
-
return cached
|
186
|
-
end
|
187
|
-
|
188
|
-
i0, s0 = index, []
|
189
|
-
r1 = _nt_scenario_start
|
190
|
-
s0 << r1
|
191
|
-
if r1
|
192
|
-
r2 = _nt_sentence_line
|
193
|
-
s0 << r2
|
194
|
-
if r2
|
195
|
-
s3, i3 = [], index
|
196
|
-
loop do
|
197
|
-
r4 = _nt_step
|
198
|
-
if r4
|
199
|
-
s3 << r4
|
200
|
-
else
|
201
|
-
break
|
202
|
-
end
|
203
|
-
end
|
204
|
-
r3 = SyntaxNode.new(input, i3...index, s3)
|
205
|
-
s0 << r3
|
206
|
-
end
|
207
|
-
end
|
208
|
-
if s0.last
|
209
|
-
r0 = (Cucumber::Parser::ScenarioNode).new(input, i0...index, s0)
|
210
|
-
r0.extend(Scenario0)
|
211
|
-
else
|
212
|
-
self.index = i0
|
213
|
-
r0 = nil
|
214
|
-
end
|
215
|
-
|
216
|
-
node_cache[:scenario][start_index] = r0
|
217
|
-
|
218
|
-
return r0
|
219
|
-
end
|
220
|
-
|
221
|
-
module ScenarioStart0
|
222
|
-
def space
|
223
|
-
elements[0]
|
224
|
-
end
|
225
|
-
|
226
|
-
end
|
227
|
-
|
228
|
-
def _nt_scenario_start
|
229
|
-
start_index = index
|
230
|
-
if node_cache[:scenario_start].has_key?(index)
|
231
|
-
cached = node_cache[:scenario_start][index]
|
232
|
-
@index = cached.interval.end if cached
|
233
|
-
return cached
|
234
|
-
end
|
235
|
-
|
236
|
-
i0, s0 = index, []
|
237
|
-
r1 = _nt_space
|
238
|
-
s0 << r1
|
239
|
-
if r1
|
240
|
-
if input.index('Scenario: ', index) == index
|
241
|
-
r2 = (SyntaxNode).new(input, index...(index + 10))
|
242
|
-
@index += 10
|
243
|
-
else
|
244
|
-
terminal_parse_failure('Scenario: ')
|
245
|
-
r2 = nil
|
246
|
-
end
|
247
|
-
s0 << r2
|
248
|
-
end
|
249
|
-
if s0.last
|
250
|
-
r0 = (SyntaxNode).new(input, i0...index, s0)
|
251
|
-
r0.extend(ScenarioStart0)
|
252
|
-
else
|
253
|
-
self.index = i0
|
254
|
-
r0 = nil
|
255
|
-
end
|
256
|
-
|
257
|
-
node_cache[:scenario_start][start_index] = r0
|
258
|
-
|
259
|
-
return r0
|
260
|
-
end
|
261
|
-
|
262
|
-
module Step0
|
263
|
-
def space
|
264
|
-
elements[0]
|
265
|
-
end
|
266
|
-
|
267
|
-
def step_type
|
268
|
-
elements[1]
|
269
|
-
end
|
270
|
-
|
271
|
-
def space
|
272
|
-
elements[2]
|
273
|
-
end
|
274
|
-
|
275
|
-
def sentence
|
276
|
-
elements[3]
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def _nt_step
|
281
|
-
start_index = index
|
282
|
-
if node_cache[:step].has_key?(index)
|
283
|
-
cached = node_cache[:step][index]
|
284
|
-
@index = cached.interval.end if cached
|
285
|
-
return cached
|
286
|
-
end
|
287
|
-
|
288
|
-
i0, s0 = index, []
|
289
|
-
r1 = _nt_space
|
290
|
-
s0 << r1
|
291
|
-
if r1
|
292
|
-
i2 = index
|
293
|
-
if input.index('Given', index) == index
|
294
|
-
r3 = (SyntaxNode).new(input, index...(index + 5))
|
295
|
-
@index += 5
|
296
|
-
else
|
297
|
-
terminal_parse_failure('Given')
|
298
|
-
r3 = nil
|
299
|
-
end
|
300
|
-
if r3
|
301
|
-
r2 = r3
|
302
|
-
else
|
303
|
-
if input.index('When', index) == index
|
304
|
-
r4 = (SyntaxNode).new(input, index...(index + 4))
|
305
|
-
@index += 4
|
306
|
-
else
|
307
|
-
terminal_parse_failure('When')
|
308
|
-
r4 = nil
|
309
|
-
end
|
310
|
-
if r4
|
311
|
-
r2 = r4
|
312
|
-
else
|
313
|
-
if input.index('Then', index) == index
|
314
|
-
r5 = (SyntaxNode).new(input, index...(index + 4))
|
315
|
-
@index += 4
|
316
|
-
else
|
317
|
-
terminal_parse_failure('Then')
|
318
|
-
r5 = nil
|
319
|
-
end
|
320
|
-
if r5
|
321
|
-
r2 = r5
|
322
|
-
else
|
323
|
-
if input.index('And', index) == index
|
324
|
-
r6 = (SyntaxNode).new(input, index...(index + 3))
|
325
|
-
@index += 3
|
326
|
-
else
|
327
|
-
terminal_parse_failure('And')
|
328
|
-
r6 = nil
|
329
|
-
end
|
330
|
-
if r6
|
331
|
-
r2 = r6
|
332
|
-
else
|
333
|
-
if input.index('GivenScenario', index) == index
|
334
|
-
r7 = (SyntaxNode).new(input, index...(index + 13))
|
335
|
-
@index += 13
|
336
|
-
else
|
337
|
-
terminal_parse_failure('GivenScenario')
|
338
|
-
r7 = nil
|
339
|
-
end
|
340
|
-
if r7
|
341
|
-
r2 = r7
|
342
|
-
else
|
343
|
-
self.index = i2
|
344
|
-
r2 = nil
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
s0 << r2
|
351
|
-
if r2
|
352
|
-
r8 = _nt_space
|
353
|
-
s0 << r8
|
354
|
-
if r8
|
355
|
-
r9 = _nt_sentence_line
|
356
|
-
s0 << r9
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
if s0.last
|
361
|
-
r0 = (Cucumber::Parser::StepNode).new(input, i0...index, s0)
|
362
|
-
r0.extend(Step0)
|
363
|
-
else
|
364
|
-
self.index = i0
|
365
|
-
r0 = nil
|
366
|
-
end
|
367
|
-
|
368
|
-
node_cache[:step][start_index] = r0
|
369
|
-
|
370
|
-
return r0
|
371
|
-
end
|
372
|
-
|
373
|
-
module SentenceLine0
|
374
|
-
end
|
375
|
-
|
376
|
-
module SentenceLine1
|
377
|
-
def eol
|
378
|
-
elements[1]
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
def _nt_sentence_line
|
383
|
-
start_index = index
|
384
|
-
if node_cache[:sentence_line].has_key?(index)
|
385
|
-
cached = node_cache[:sentence_line][index]
|
386
|
-
@index = cached.interval.end if cached
|
387
|
-
return cached
|
388
|
-
end
|
389
|
-
|
390
|
-
i0, s0 = index, []
|
391
|
-
s1, i1 = [], index
|
392
|
-
loop do
|
393
|
-
i2, s2 = index, []
|
394
|
-
i3 = index
|
395
|
-
r4 = _nt_eol
|
396
|
-
if r4
|
397
|
-
r3 = nil
|
398
|
-
else
|
399
|
-
self.index = i3
|
400
|
-
r3 = SyntaxNode.new(input, index...index)
|
401
|
-
end
|
402
|
-
s2 << r3
|
403
|
-
if r3
|
404
|
-
if index < input_length
|
405
|
-
r5 = (SyntaxNode).new(input, index...(index + 1))
|
406
|
-
@index += 1
|
407
|
-
else
|
408
|
-
terminal_parse_failure("any character")
|
409
|
-
r5 = nil
|
410
|
-
end
|
411
|
-
s2 << r5
|
412
|
-
end
|
413
|
-
if s2.last
|
414
|
-
r2 = (SyntaxNode).new(input, i2...index, s2)
|
415
|
-
r2.extend(SentenceLine0)
|
416
|
-
else
|
417
|
-
self.index = i2
|
418
|
-
r2 = nil
|
419
|
-
end
|
420
|
-
if r2
|
421
|
-
s1 << r2
|
422
|
-
else
|
423
|
-
break
|
424
|
-
end
|
425
|
-
end
|
426
|
-
r1 = SyntaxNode.new(input, i1...index, s1)
|
427
|
-
s0 << r1
|
428
|
-
if r1
|
429
|
-
r6 = _nt_eol
|
430
|
-
s0 << r6
|
431
|
-
end
|
432
|
-
if s0.last
|
433
|
-
r0 = (SyntaxNode).new(input, i0...index, s0)
|
434
|
-
r0.extend(SentenceLine1)
|
435
|
-
else
|
436
|
-
self.index = i0
|
437
|
-
r0 = nil
|
438
|
-
end
|
439
|
-
|
440
|
-
node_cache[:sentence_line][start_index] = r0
|
441
|
-
|
442
|
-
return r0
|
443
|
-
end
|
444
|
-
|
445
|
-
def _nt_space
|
446
|
-
start_index = index
|
447
|
-
if node_cache[:space].has_key?(index)
|
448
|
-
cached = node_cache[:space][index]
|
449
|
-
@index = cached.interval.end if cached
|
450
|
-
return cached
|
451
|
-
end
|
452
|
-
|
453
|
-
s0, i0 = [], index
|
454
|
-
loop do
|
455
|
-
if input.index(Regexp.new('[ \\t\\r\\n]'), index) == index
|
456
|
-
r1 = (SyntaxNode).new(input, index...(index + 1))
|
457
|
-
@index += 1
|
458
|
-
else
|
459
|
-
r1 = nil
|
460
|
-
end
|
461
|
-
if r1
|
462
|
-
s0 << r1
|
463
|
-
else
|
464
|
-
break
|
465
|
-
end
|
466
|
-
end
|
467
|
-
r0 = SyntaxNode.new(input, i0...index, s0)
|
468
|
-
|
469
|
-
node_cache[:space][start_index] = r0
|
470
|
-
|
471
|
-
return r0
|
472
|
-
end
|
473
|
-
|
474
|
-
def _nt_eol
|
475
|
-
start_index = index
|
476
|
-
if node_cache[:eol].has_key?(index)
|
477
|
-
cached = node_cache[:eol][index]
|
478
|
-
@index = cached.interval.end if cached
|
479
|
-
return cached
|
480
|
-
end
|
481
|
-
|
482
|
-
i0 = index
|
483
|
-
if input.index("\r\n", index) == index
|
484
|
-
r1 = (SyntaxNode).new(input, index...(index + 2))
|
485
|
-
@index += 2
|
486
|
-
else
|
487
|
-
terminal_parse_failure("\r\n")
|
488
|
-
r1 = nil
|
489
|
-
end
|
490
|
-
if r1
|
491
|
-
r0 = r1
|
492
|
-
else
|
493
|
-
if input.index("\n", index) == index
|
494
|
-
r2 = (SyntaxNode).new(input, index...(index + 1))
|
495
|
-
@index += 1
|
496
|
-
else
|
497
|
-
terminal_parse_failure("\n")
|
498
|
-
r2 = nil
|
499
|
-
end
|
500
|
-
if r2
|
501
|
-
r0 = r2
|
502
|
-
else
|
503
|
-
r3 = _nt_eof
|
504
|
-
if r3
|
505
|
-
r0 = r3
|
506
|
-
else
|
507
|
-
self.index = i0
|
508
|
-
r0 = nil
|
509
|
-
end
|
510
|
-
end
|
511
|
-
end
|
512
|
-
|
513
|
-
node_cache[:eol][start_index] = r0
|
514
|
-
|
515
|
-
return r0
|
516
|
-
end
|
517
|
-
|
518
|
-
def _nt_eof
|
519
|
-
start_index = index
|
520
|
-
if node_cache[:eof].has_key?(index)
|
521
|
-
cached = node_cache[:eof][index]
|
522
|
-
@index = cached.interval.end if cached
|
523
|
-
return cached
|
524
|
-
end
|
525
|
-
|
526
|
-
i0 = index
|
527
|
-
if index < input_length
|
528
|
-
r1 = (SyntaxNode).new(input, index...(index + 1))
|
529
|
-
@index += 1
|
530
|
-
else
|
531
|
-
terminal_parse_failure("any character")
|
532
|
-
r1 = nil
|
533
|
-
end
|
534
|
-
if r1
|
535
|
-
r0 = nil
|
536
|
-
else
|
537
|
-
self.index = i0
|
538
|
-
r0 = SyntaxNode.new(input, index...index)
|
539
|
-
end
|
540
|
-
|
541
|
-
node_cache[:eof][start_index] = r0
|
542
|
-
|
543
|
-
return r0
|
544
|
-
end
|
545
|
-
|
546
|
-
end
|
547
|
-
|
548
|
-
class StoryParser < Treetop::Runtime::CompiledParser
|
549
|
-
include Story
|
550
|
-
end
|
551
|
-
|
552
|
-
|
553
|
-
end
|
554
|
-
end
|