Sha256: c4d599a18304d687e9b73215160ac6f8cf3e2d3e3cdf948d2cf731256d6931cf

Contents?: true

Size: 880 Bytes

Versions: 6

Compression:

Stored size: 880 Bytes

Contents

class Code
  class Parser
    class List < Parslet::Parser
      rule(:string) { ::Code::Parser::String.new }
      rule(:code) { ::Code::Parser::Code.new.present }

      rule(:opening_square_bracket) { str("[") }
      rule(:closing_square_bracket) { str("]") }
      rule(:comma) { str(",") }

      rule(:space) { str(" ") }
      rule(:newline) { str("\n") }
      rule(:whitespace) { (space | newline).repeat(1) }
      rule(:whitespace?) { whitespace.maybe }

      rule(:list) do
        (
          opening_square_bracket.ignore >> whitespace?.ignore >>
            code.as(:code).repeat(0, 1) >>
            (whitespace? >> comma >> whitespace? >> code.as(:code)).repeat >>
            whitespace?.ignore >> comma.maybe.ignore >> whitespace?.ignore >>
            closing_square_bracket.ignore
        ).as(:list) | string
      end

      root(:list)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
template-ruby-0.4.0 lib/code/parser/list.rb
code-ruby-0.4.0 lib/code/parser/list.rb
template-ruby-0.3.1 lib/code/parser/list.rb
code-ruby-0.3.1 lib/code/parser/list.rb
template-ruby-0.3.0 lib/code/parser/list.rb
code-ruby-0.3.0 lib/code/parser/list.rb