Sha256: c2cf7122f8a0e8d4148fd164b631ec0375bae0d56d719489adc8c3b351bb59d3

Contents?: true

Size: 957 Bytes

Versions: 18

Compression:

Stored size: 957 Bytes

Contents

class Code
  class Parser
    class IfModifier < ::Code::Parser
      def parse
        left = parse_subclass(::Code::Parser::OrKeyword)

        previous_cursor = cursor

        comments_before = parse_comments(whitespace: [SPACE])

        if left && (operator = match(IF_KEYWORD)) ||
             (operator = match(UNLESS_KEYWORD))
          comments_after = parse_comments
          right = parse_subclass(::Code::Parser::IfModifier)

          if right
            {
              if_modifier: {
                left: left,
                right: right,
                operator: operator,
                comments_before: comments_before,
                comments_after: comments_after
              }.compact
            }
          else
            @cursor = previous_cursor
            buffer!
            left
          end
        else
          @cursor = previous_cursor
          buffer!
          left
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
template-ruby-parser-0.1.8 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.8 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.7 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.7 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.6 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.6 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.5 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.5 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.4 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.4 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.3 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.3 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.2 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.2 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.1 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.1 lib/code/parser/if_modifier.rb
template-ruby-parser-0.1.0 lib/code/parser/if_modifier.rb
code-ruby-parser-0.1.0 lib/code/parser/if_modifier.rb