Sha256: 0c9670de9ff02da3065a610f436f5876fc41026062378b79296db3d2aa7320ca

Contents?: true

Size: 733 Bytes

Versions: 12

Compression:

Stored size: 733 Bytes

Contents

class Code
  class Parser
    class IfModifier < Parslet::Parser
      rule(:or_keyword) { ::Code::Parser::OrKeyword.new }

      rule(:if_keyword) { str("if") }
      rule(:unless_keyword) { str("unless") }
      rule(:while_keyword) { str("while") }
      rule(:until_keyword) { str("until") }

      rule(:operator) do
        if_keyword | unless_keyword | while_keyword | until_keyword
      end

      rule(:space) { str(" ") }
      rule(:whitespace) { space.repeat(1) }

      rule(:if_modifier) do
        (
          or_keyword.as(:left) >> whitespace >> operator.as(:operator) >>
            whitespace >> if_modifier.as(:right)
        ).as(:if_modifier) | or_keyword
      end

      root(:if_modifier)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
template-ruby-0.4.0 lib/code/parser/if_modifier.rb
code-ruby-0.4.0 lib/code/parser/if_modifier.rb
template-ruby-0.3.1 lib/code/parser/if_modifier.rb
code-ruby-0.3.1 lib/code/parser/if_modifier.rb
template-ruby-0.3.0 lib/code/parser/if_modifier.rb
code-ruby-0.3.0 lib/code/parser/if_modifier.rb
code-ruby-0.2.4 lib/code/parser/if_modifier.rb
template-ruby-0.2.4 lib/code/parser/if_modifier.rb
template-ruby-0.2.3 lib/code/parser/if_modifier.rb
template-ruby-0.2.2 lib/code/parser/if_modifier.rb
template-ruby-0.2.1 lib/code/parser/if_modifier.rb
template-ruby-0.2.0 lib/code/parser/if_modifier.rb