Sha256: cc45ce121915cb8f6c7db928ed84e13bb896404abbeec5012bfc7a90b954d829

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

class Code
  class Parser
    class ChainedCall < ::Code::Parser
      def parse
        left = parse_dictionnary
        previous_cursor = cursor
        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!
            left
          end
        else
          @cursor = previous_cursor
          buffer!
          left
        end
      end

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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
template-ruby-parser-0.1.8 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.8 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.7 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.7 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.6 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.6 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.5 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.5 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.4 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.4 lib/code/parser/chained_call.rb
template-ruby-parser-0.1.3 lib/code/parser/chained_call.rb
code-ruby-parser-0.1.3 lib/code/parser/chained_call.rb