Sha256: c9ebb4015128e005c3c2ff72a71e2d3c0248df2b76e89df9cf7e96ab3b386c3a

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

module Fonte
  module Parsers
    grammar Property
      include Word

      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
        quoted_word
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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