Sha256: 13d1dd7593b48f98a37da437d51d336ba509768ac677beb548cd14b2e99d1eb1

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Fonte
  module Parsers
    grammar Property
      include Word
      include Number
      include Player

      rule properties
        property+ {
          def value
            elements.inject({}) { |properties, property| properties.merge property.value }
          end
        }
      end

      rule property
        key_only_property / key_value_property
      end

      rule key_only_property
        "(" property_key ")" SPACE? {
          def value
            { property_key.value => true }
          end
        }
      end

      rule key_value_property
        "(" property_key SPACE property_value ")" SPACE? {
          def value
            { property_key.value => property_value.value }
          end
        }
      end

      rule property_key
        (!SPACE ![()] character)+ {
          def value
            text_value
          end
        }
      end

      rule property_value
        number_property / player_property / quoted_word
      end

      rule player_property
        QUOTE value:player QUOTE
      end

      rule number_property
        QUOTE number QUOTE {
          def value
            number.value
          end
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fonte-0.2.0 lib/fonte/parsers/property.treetop