Sha256: 61bc0a69834a3203b67396ccb28e44c93c029c6e8eda2586bf5eaab78172abac

Contents?: true

Size: 671 Bytes

Versions: 12

Compression:

Stored size: 671 Bytes

Contents

class Code
  class Parser
    class While < Parslet::Parser
      rule(:if_rule) { ::Code::Parser::If.new }
      rule(:code) { ::Code::Parser::Code.new }

      rule(:while_keyword) { str("while") }
      rule(:until_keyword) { str("until") }
      rule(:end_keyword) { str("end") }

      rule(:space) { str(" ") }
      rule(:newline) { str("\n") }
      rule(:whitespace) { (space | newline).repeat(1) }

      rule(:while_rule) do
        (
          (while_keyword | until_keyword).as(:operator) >> whitespace >>
            if_rule.as(:statement) >> code.as(:body) >> end_keyword
        ).as(:while) | if_rule
      end

      root(:while_rule)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

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