Sha256: 0882345f9e3879e90f2e876f14c6a6d36479ac20fefc06b829a033a219e0b87e

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

class Code
  class Parser
    class ChainedCall < ::Code::Parser
      def parse
        previous_cursor = cursor
        left = parse_dictionnary
        comments_before = parse_comments

        if left && match([DOT, COLON + COLON])
          comments_after = parse_comments
          right = parse_dictionnary
          if right
            chained_call = [{ left: left, right: right }]
            while match([DOT, COLON + COLON]) && other_right = parse_dictionnary
              chained_call << { right: other_right }
            end
            {
              chained_call: {
                calls: chained_call,
                comments_before: comments_before,
                comments_after: comments_after
              }.compact
            }
          else
            @cursor = previous_cursor
            buffer!
            parse_dictionnary
          end
        else
          @cursor = previous_cursor
          buffer!
          parse_dictionnary
        end
      end

      def parse_dictionnary
        parse_subclass(::Code::Parser::Dictionnary)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
template-ruby-parser-0.1.2 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.2 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.1 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.1 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.0 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.0 lib/code/parser/chained_call.rb