Sha256: cdbf206101da46c9c347e670f061d14c1178eeeb6dce645ffddb8b1449573b90

Contents?: true

Size: 864 Bytes

Versions: 13

Compression:

Stored size: 864 Bytes

Contents

module Cucumber
  module Parser
    grammar Table

      rule table
        table_row+ {
          def build
            Ast::Table.new(raw)
          end

          def raw
            elements.map{|e| e.build}
          end
        }
      end

      rule table_row
        space* '|' cells:(cell '|')+ space* (eol+ / eof) {
          def build
            row = cells.elements.map do |elt| 
              value = elt.cell.text_value.strip
              value.empty? ? nil : value
            end

            class << row
              attr_accessor :line
            end
            row.line = cells.line

            row
          end
        }
      end

      rule cell
        (!('|' / eol) .)*
      end

      rule space
        [ \t]
      end

      rule eol
        "\n" / ("\r" "\n"?)
      end

      rule eof
        !.
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.99.10 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.11 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.12 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.13 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.14 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.15 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.2 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.3 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.5 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.6 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.7 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.8 lib/cucumber/parser/table.tt
aslakhellesoy-cucumber-0.1.99.9 lib/cucumber/parser/table.tt