Sha256: 1d35e0682423c31de2d6f20f1dd42698daa888460a5ee1d09ee25ac0bcfe273f

Contents?: true

Size: 851 Bytes

Versions: 33

Compression:

Stored size: 851 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.ignore).maybe) |
          (whitespace? << code << whitespace? << comma.ignore)
      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

33 entries across 33 versions & 1 rubygems

Version Path
code-ruby-1.1.3 lib/code/parser/list.rb
code-ruby-1.1.1 lib/code/parser/list.rb
code-ruby-1.1.0 lib/code/parser/list.rb
code-ruby-1.0.0 lib/code/parser/list.rb
code-ruby-0.15.16 lib/code/parser/list.rb
code-ruby-0.15.15 lib/code/parser/list.rb
code-ruby-0.15.14 lib/code/parser/list.rb
code-ruby-0.15.13 lib/code/parser/list.rb
code-ruby-0.15.12 lib/code/parser/list.rb
code-ruby-0.15.11 lib/code/parser/list.rb
code-ruby-0.15.10 lib/code/parser/list.rb
code-ruby-0.15.9 lib/code/parser/list.rb
code-ruby-0.15.8 lib/code/parser/list.rb
code-ruby-0.15.7 lib/code/parser/list.rb
code-ruby-0.15.6 lib/code/parser/list.rb
code-ruby-0.15.5 lib/code/parser/list.rb
code-ruby-0.15.4 lib/code/parser/list.rb
code-ruby-0.15.3 lib/code/parser/list.rb
code-ruby-0.15.2 lib/code/parser/list.rb
code-ruby-0.15.0 lib/code/parser/list.rb