lib/cucumber/treetop_parser/feature_ru.rb in cucumber-0.1.6 vs lib/cucumber/treetop_parser/feature_ru.rb in cucumber-0.1.7

- old
+ new

@@ -1,35 +1,35 @@ -module Cucumber -module TreetopParser +module Cucumber #:nodoc: +module TreetopParser #:nodoc: -module Feature +module Feature #:nodoc: include Treetop::Runtime - def root + def root #:nodoc: @root || :root end - module Root0 - def header + module Root0 #:nodoc: + def header #:nodoc: elements[0] end - def scenario_sequence + def scenario_sequence #:nodoc: elements[1] end end - module Root1 - def compile + module Root1 #:nodoc: + def compile #:nodoc: feature = Tree::Feature.new(header.text_value.strip) scenario_sequence.compile(feature) feature end end - def _nt_root + def _nt_root #:nodoc: start_index = index if node_cache[:root].has_key?(index) cached = node_cache[:root][index] @index = cached.interval.end if cached return cached @@ -63,14 +63,14 @@ node_cache[:root][start_index] = r0 return r0 end - module Header0 + module Header0 #:nodoc: end - def _nt_header + def _nt_header #:nodoc: start_index = index if node_cache[:header].has_key?(index) cached = node_cache[:header][index] @index = cached.interval.end if cached return cached @@ -121,43 +121,43 @@ node_cache[:header][start_index] = r0 return r0 end - module ScenarioSequence0 - def space + module ScenarioSequence0 #:nodoc: + def space #:nodoc: elements[0] end - def scenario_or_table + def scenario_or_table #:nodoc: elements[1] end end - module ScenarioSequence1 - def head + module ScenarioSequence1 #:nodoc: + def head #:nodoc: elements[0] end - def tail + def tail #:nodoc: elements[1] end end - module ScenarioSequence2 - def compile(feature) + module ScenarioSequence2 #:nodoc: + def compile(feature) #:nodoc: ([head] + tail).each do |scenario_or_table| scenario_or_table.compile(feature) if scenario_or_table.respond_to?(:compile) end end - def tail + def tail #:nodoc: super.elements.map { |elt| elt.scenario_or_table } end end - def _nt_scenario_sequence + def _nt_scenario_sequence #:nodoc: start_index = index if node_cache[:scenario_sequence].has_key?(index) cached = node_cache[:scenario_sequence][index] @index = cached.interval.end if cached return cached @@ -209,49 +209,49 @@ node_cache[:scenario_sequence][start_index] = r0 return r0 end - module Scenario0 - def space + module Scenario0 #:nodoc: + def space #:nodoc: elements[0] end - def step_sequence + def step_sequence #:nodoc: elements[1] end end - module Scenario1 - def scenario_keyword + module Scenario1 #:nodoc: + def scenario_keyword #:nodoc: elements[0] end - def space + def space #:nodoc: elements[1] end - def name + def name #:nodoc: elements[2] end - def steps + def steps #:nodoc: elements[3] end end - module Scenario2 - def compile(feature) + module Scenario2 #:nodoc: + def compile(feature) #:nodoc: scenario = feature.add_scenario(name.text_value.strip) steps.step_sequence.compile(scenario) if steps.respond_to?(:step_sequence) # TODO - GET RID OF THIS last_scenario NASTINESS # Use a better datastructure, like a linked list... Feature.last_scenario = scenario end end - def _nt_scenario + def _nt_scenario #:nodoc: start_index = index if node_cache[:scenario].has_key?(index) cached = node_cache[:scenario][index] @index = cached.interval.end if cached return cached @@ -302,11 +302,11 @@ node_cache[:scenario][start_index] = r0 return r0 end - def _nt_scenario_or_table + def _nt_scenario_or_table #:nodoc: start_index = index if node_cache[:scenario_or_table].has_key?(index) cached = node_cache[:scenario_or_table][index] @index = cached.interval.end if cached return cached @@ -329,44 +329,44 @@ node_cache[:scenario_or_table][start_index] = r0 return r0 end - module Table0 - def eol + module Table0 #:nodoc: + def eol #:nodoc: elements[1] end - def table_line + def table_line #:nodoc: elements[3] end end - module Table1 - def head + module Table1 #:nodoc: + def head #:nodoc: elements[0] end - def body + def body #:nodoc: elements[1] end end - module Table2 - def compile(feature) + module Table2 #:nodoc: + def compile(feature) #:nodoc: Feature.last_scenario.table_header = head.cell_values body.each do |table_line| feature.add_row_scenario(Feature.last_scenario, table_line.cell_values, table_line.line) end end - def body + def body #:nodoc: super.elements.map { |elt| elt.table_line } end end - def _nt_table + def _nt_table #:nodoc: start_index = index if node_cache[:table].has_key?(index) cached = node_cache[:table][index] @index = cached.interval.end if cached return cached @@ -435,41 +435,41 @@ node_cache[:table][start_index] = r0 return r0 end - module TableLine0 - def cell_value + module TableLine0 #:nodoc: + def cell_value #:nodoc: elements[1] end - def separator + def separator #:nodoc: elements[3] end end - module TableLine1 - def separator + module TableLine1 #:nodoc: + def separator #:nodoc: elements[0] end - def cells + def cells #:nodoc: elements[1] end end - module TableLine2 - def cell_values + module TableLine2 #:nodoc: + def cell_values #:nodoc: cells.elements.map { |elt| elt.cell_value.text_value.strip } end - def line + def line #:nodoc: input.line_of(interval.first) end end - def _nt_table_line + def _nt_table_line #:nodoc: start_index = index if node_cache[:table_line].has_key?(index) cached = node_cache[:table_line][index] @index = cached.interval.end if cached return cached @@ -547,14 +547,14 @@ node_cache[:table_line][start_index] = r0 return r0 end - module CellValue0 + module CellValue0 #:nodoc: end - def _nt_cell_value + def _nt_cell_value #:nodoc: start_index = index if node_cache[:cell_value].has_key?(index) cached = node_cache[:cell_value][index] @index = cached.interval.end if cached return cached @@ -612,43 +612,43 @@ node_cache[:cell_value][start_index] = r0 return r0 end - module StepSequence0 - def space + module StepSequence0 #:nodoc: + def space #:nodoc: elements[0] end - def step + def step #:nodoc: elements[1] end end - module StepSequence1 - def head + module StepSequence1 #:nodoc: + def head #:nodoc: elements[0] end - def tail + def tail #:nodoc: elements[1] end end - module StepSequence2 - def compile(scenario) + module StepSequence2 #:nodoc: + def compile(scenario) #:nodoc: ([head] + tail).each do |step| step.compile(scenario) end end - def tail + def tail #:nodoc: super.elements.map { |elt| elt.step } end end - def _nt_step_sequence + def _nt_step_sequence #:nodoc: start_index = index if node_cache[:step_sequence].has_key?(index) cached = node_cache[:step_sequence][index] @index = cached.interval.end if cached return cached @@ -695,11 +695,11 @@ node_cache[:step_sequence][start_index] = r0 return r0 end - def _nt_step + def _nt_step #:nodoc: start_index = index if node_cache[:step].has_key?(index) cached = node_cache[:step][index] @index = cached.interval.end if cached return cached @@ -722,32 +722,32 @@ node_cache[:step][start_index] = r0 return r0 end - module GivenScenario0 - def given_scenario_keyword + module GivenScenario0 #:nodoc: + def given_scenario_keyword #:nodoc: elements[0] end - def space + def space #:nodoc: elements[1] end - def name + def name #:nodoc: elements[2] end end - module GivenScenario1 - def compile(scenario) + module GivenScenario1 #:nodoc: + def compile(scenario) #:nodoc: line = input.line_of(interval.first) - scenario.add_given_scenario(name.text_value.strip, line) + scenario.create_given_scenario(name.text_value.strip, line) end end - def _nt_given_scenario + def _nt_given_scenario #:nodoc: start_index = index if node_cache[:given_scenario].has_key?(index) cached = node_cache[:given_scenario][index] @index = cached.interval.end if cached return cached @@ -776,32 +776,32 @@ node_cache[:given_scenario][start_index] = r0 return r0 end - module PlainStep0 - def step_keyword + module PlainStep0 #:nodoc: + def step_keyword #:nodoc: elements[0] end - def space + def space #:nodoc: elements[1] end - def name + def name #:nodoc: elements[2] end end - module PlainStep1 - def compile(scenario) + module PlainStep1 #:nodoc: + def compile(scenario) #:nodoc: line = input.line_of(interval.first) - scenario.add_step(step_keyword.text_value, name.text_value.strip, line) + scenario.create_step(step_keyword.text_value, name.text_value.strip, line) end end - def _nt_plain_step + def _nt_plain_step #:nodoc: start_index = index if node_cache[:plain_step].has_key?(index) cached = node_cache[:plain_step][index] @index = cached.interval.end if cached return cached @@ -830,11 +830,11 @@ node_cache[:plain_step][start_index] = r0 return r0 end - def _nt_separator + def _nt_separator #:nodoc: start_index = index if node_cache[:separator].has_key?(index) cached = node_cache[:separator][index] @index = cached.interval.end if cached return cached @@ -851,11 +851,11 @@ node_cache[:separator][start_index] = r0 return r0 end - def _nt_space + def _nt_space #:nodoc: start_index = index if node_cache[:space].has_key?(index) cached = node_cache[:space][index] @index = cached.interval.end if cached return cached @@ -892,14 +892,14 @@ node_cache[:space][start_index] = r0 return r0 end - module LineToEol0 + module LineToEol0 #:nodoc: end - def _nt_line_to_eol + def _nt_line_to_eol #:nodoc: start_index = index if node_cache[:line_to_eol].has_key?(index) cached = node_cache[:line_to_eol][index] @index = cached.interval.end if cached return cached @@ -945,17 +945,17 @@ node_cache[:line_to_eol][start_index] = r0 return r0 end - module CommentToEol0 - def line_to_eol + module CommentToEol0 #:nodoc: + def line_to_eol #:nodoc: elements[1] end end - def _nt_comment_to_eol + def _nt_comment_to_eol #:nodoc: start_index = index if node_cache[:comment_to_eol].has_key?(index) cached = node_cache[:comment_to_eol][index] @index = cached.interval.end if cached return cached @@ -985,11 +985,11 @@ node_cache[:comment_to_eol][start_index] = r0 return r0 end - def _nt_white + def _nt_white #:nodoc: start_index = index if node_cache[:white].has_key?(index) cached = node_cache[:white][index] @index = cached.interval.end if cached return cached @@ -1012,11 +1012,11 @@ node_cache[:white][start_index] = r0 return r0 end - def _nt_blank + def _nt_blank #:nodoc: start_index = index if node_cache[:blank].has_key?(index) cached = node_cache[:blank][index] @index = cached.interval.end if cached return cached @@ -1032,38 +1032,65 @@ node_cache[:blank][start_index] = r0 return r0 end - def _nt_eol + module Eol0 #:nodoc: + end + + def _nt_eol #:nodoc: start_index = index if node_cache[:eol].has_key?(index) cached = node_cache[:eol][index] @index = cached.interval.end if cached return cached end i0 = index - if input.index("\r\n?", index) == index - r1 = (SyntaxNode).new(input, index...(index + 3)) - @index += 3 + i1, s1 = index, [] + if input.index("\r", index) == index + r2 = (SyntaxNode).new(input, index...(index + 1)) + @index += 1 else - terminal_parse_failure("\r\n?") + terminal_parse_failure("\r") + r2 = nil + end + s1 << r2 + if r2 + if input.index("\n", index) == index + r4 = (SyntaxNode).new(input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure("\n") + r4 = nil + end + if r4 + r3 = r4 + else + r3 = SyntaxNode.new(input, index...index) + end + s1 << r3 + end + if s1.last + r1 = (SyntaxNode).new(input, i1...index, s1) + r1.extend(Eol0) + else + self.index = i1 r1 = nil end if r1 r0 = r1 else if input.index("\n", index) == index - r2 = (SyntaxNode).new(input, index...(index + 1)) + r5 = (SyntaxNode).new(input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") - r2 = nil + r5 = nil end - if r2 - r0 = r2 + if r5 + r0 = r5 else self.index = i0 r0 = nil end end @@ -1071,11 +1098,11 @@ node_cache[:eol][start_index] = r0 return r0 end - def _nt_step_keyword + def _nt_step_keyword #:nodoc: start_index = index if node_cache[:step_keyword].has_key?(index) cached = node_cache[:step_keyword][index] @index = cached.interval.end if cached return cached @@ -1120,23 +1147,34 @@ r4 = nil end if r4 r0 = r4 else - self.index = i0 - r0 = nil + if input.index('Но', index) == index + r5 = (SyntaxNode).new(input, index...(index + 4)) + @index += 4 + else + terminal_parse_failure('Но') + r5 = nil + end + if r5 + r0 = r5 + else + self.index = i0 + r0 = nil + end end end end end node_cache[:step_keyword][start_index] = r0 return r0 end - def _nt_scenario_keyword + def _nt_scenario_keyword #:nodoc: start_index = index if node_cache[:scenario_keyword].has_key?(index) cached = node_cache[:scenario_keyword][index] @index = cached.interval.end if cached return cached @@ -1153,14 +1191,14 @@ node_cache[:scenario_keyword][start_index] = r0 return r0 end - module GivenScenarioKeyword0 + module GivenScenarioKeyword0 #:nodoc: end - def _nt_given_scenario_keyword + def _nt_given_scenario_keyword #:nodoc: start_index = index if node_cache[:given_scenario_keyword].has_key?(index) cached = node_cache[:given_scenario_keyword][index] @index = cached.interval.end if cached return cached @@ -1203,10 +1241,10 @@ return r0 end end -class FeatureParser < Treetop::Runtime::CompiledParser +class FeatureParser < Treetop::Runtime::CompiledParser #:nodoc: include Feature end end \ No newline at end of file