Sha256: f9b360b83a380bf9d102ab2b8818511f791c3d5b64ad6d2c54f6992cd791572c

Contents?: true

Size: 837 Bytes

Versions: 19

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true

class Code
  class Parser
    class List < Language
      def code
        Code
      end

      def code_present
        Code.new.present
      end

      def whitespace
        Whitespace
      end

      def whitespace?
        whitespace.maybe
      end

      def opening_square_bracket
        str("[")
      end

      def closing_square_bracket
        str("]")
      end

      def comma
        str(",")
      end

      def element
        (whitespace? << code_present << (whitespace? << comma).maybe) |
          (whitespace? << code << whitespace? << comma)
      end

      def root
        (
          opening_square_bracket.ignore << whitespace? << element.repeat <<
            (whitespace? << closing_square_bracket.ignore).maybe
        ).aka(:list) | String
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
code-ruby-0.10.4 lib/code/parser/list.rb
code-ruby-0.10.3 lib/code/parser/list.rb
code-ruby-0.10.2 lib/code/parser/list.rb
code-ruby-0.10.1 lib/code/parser/list.rb
code-ruby-0.10.0 lib/code/parser/list.rb
code-ruby-0.9.3 lib/code/parser/list.rb
code-ruby-0.9.2 lib/code/parser/list.rb
code-ruby-0.9.1 lib/code/parser/list.rb
code-ruby-0.9.0 lib/code/parser/list.rb
code-ruby-0.8.5 lib/code/parser/list.rb
code-ruby-0.8.4 lib/code/parser/list.rb
code-ruby-0.8.3 lib/code/parser/list.rb
code-ruby-0.8.2 lib/code/parser/list.rb
code-ruby-0.8.1 lib/code/parser/list.rb
code-ruby-0.8.0 lib/code/parser/list.rb
code-ruby-0.7.8 lib/code/parser/list.rb
code-ruby-0.7.7 lib/code/parser/list.rb
code-ruby-0.7.6 lib/code/parser/list.rb
code-ruby-0.7.5 lib/code/parser/list.rb