Sha256: b5d169ac0ac96e08258d6c7d71ec9c42a97248a1cd5f170399332090a9123fc6

Contents?: true

Size: 1.34 KB

Versions: 21

Compression:

Stored size: 1.34 KB

Contents

class Code
  class Parser
    class If < Language
      def statement
        ::Code::Parser::IfModifier
      end

      def if_class
        ::Code::Parser::If
      end

      def whitespace
        ::Code::Parser::Whitespace
      end

      def code
        ::Code::Parser::Code
      end

      def whitespace?
        whitespace.maybe
      end

      def if_keyword
        str("if")
      end

      def unless_keyword
        str("unless")
      end

      def elsif_keyword
        str("elsif")
      end

      def else_keyword
        str("else")
      end

      def end_keyword
        str("end")
      end

      def root
        (
          (if_keyword | unless_keyword).aka(:first_operator) << whitespace <<
            statement.aka(:first_statement) << code.aka(:first_body) <<
            (
              (
                elsif_keyword.aka(:operator) << whitespace <<
                  statement.aka(:statement) << code.aka(:body)
              ) |
                (
                  else_keyword << whitespace <<
                    (if_keyword | unless_keyword).aka(:operator) <<
                    whitespace << statement.aka(:statement) << code.aka(:body)
                ) | (else_keyword.aka(:operator) << code.aka(:body))
            ).repeat(1).aka(:elses).maybe << end_keyword.maybe
        ).aka(:if) | statement
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
template-ruby-0.5.6 lib/code/parser/if.rb
language-ruby-0.5.6 lib/code/parser/if.rb
code-ruby-0.5.6 lib/code/parser/if.rb
template-ruby-0.5.5 lib/code/parser/if.rb
language-ruby-0.5.5 lib/code/parser/if.rb
code-ruby-0.5.5 lib/code/parser/if.rb
template-ruby-0.5.4 lib/code/parser/if.rb
language-ruby-0.5.4 lib/code/parser/if.rb
code-ruby-0.5.4 lib/code/parser/if.rb
template-ruby-0.5.3 lib/code/parser/if.rb
language-ruby-0.5.3 lib/code/parser/if.rb
code-ruby-0.5.3 lib/code/parser/if.rb
template-ruby-0.5.2 lib/code/parser/if.rb
language-ruby-0.5.2 lib/code/parser/if.rb
code-ruby-0.5.2 lib/code/parser/if.rb
language-ruby-0.5.1 lib/code/parser/if.rb
template-ruby-0.5.1 lib/code/parser/if.rb
code-ruby-0.5.1 lib/code/parser/if.rb
template-ruby-0.5.0 lib/code/parser/if.rb
language-ruby-0.5.0 lib/code/parser/if.rb