Sha256: 93819f029f7629e7bf2ca5daa56cb66c291cb23651453604ba82d074d12c68fa

Contents?: true

Size: 921 Bytes

Versions: 65

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

class Code
  class Parser
    class SquareBracket < Language
      def statement
        UnaryMinus
      end

      def square_bracket
        SquareBracket
      end

      def whitespace
        Whitespace
      end

      def whitespace?
        whitespace.maybe
      end

      def left_square_bracket
        str("[")
      end

      def right_square_bracket
        str("]")
      end

      def root
        (
          statement.aka(:left) << (
            left_square_bracket << whitespace? << square_bracket <<
              (whitespace? << right_square_bracket).maybe
          ).repeat(1).aka(:statements).maybe
        )
          .aka(:square_bracket)
          .then do |output|
            if output[:square_bracket][:statements]
              output
            else
              output[:square_bracket][:left]
            end
          end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

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