Sha256: b7279d35c1289a764ded819d11717fd92ebf4b91b5f8d2720e0cbb7878613664

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

class Code
  class Parser
    class Dictionnary < Language
      def code
        ::Code::Parser::Code.new.present
      end

      def statement
        ::Code::Parser::Statement
      end

      def name
        ::Code::Parser::Name
      end

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

      def whitespace?
        whitespace.maybe
      end

      def opening_curly_bracket
        str("{")
      end

      def closing_curly_bracket
        str("}")
      end

      def comma
        str(",")
      end

      def colon
        str(":")
      end

      def equal
        str("=")
      end

      def greater
        str(">")
      end

      def key_value
        (name.aka(:name) << colon << code.aka(:value)) |
          (statement.aka(:statement) << colon << code.aka(:value)) |
          (
            statement.aka(:statement) << whitespace? << equal << greater <<
              code.aka(:value)
          )
      end

      def root
        (
          opening_curly_bracket.ignore << whitespace? <<
            key_value.repeat(0, 1) <<
            (whitespace? << comma << whitespace? << key_value).repeat <<
            (whitespace? << closing_curly_bracket.ignore).maybe
        ).aka(:dictionnary) | ::Code::Parser::List
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

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