Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Provides a parsing expression grammar for SPARQL and allows the user to interface SPARQL with arbitrary datastores.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
coverage
lib
spec
COPYING
COPYING.lesser
ChangeLog
README.markdown
Rakefile
sparql.gemspec

README.markdown

sparql Release 0.0.1 (July 17th 2008)

Git: http://github.com/pius/sparql
Author: Pius Uzamere, The Uyiosa Corporation

Copyright: Pius Uzamere © 2008 License: The Lesser GNU Public License

SYNOPSIS

sparql is a library for Ruby that formally implements the SPARQL grammar as a parsing expression grammar (PEG). The grammar is implemented in a fantastic syntax language called Treetop.

FEATURE LIST

  1. As of right now (00:10 EST, July 17, 2008) can parse basic SPARQL statements, check the test cases for precisely what it can support: When finished, this library will be able to parse arbitrary SPARQL queries and can serve as a maintainable reference implementation in Ruby.

  2. Starting point for providing SPARQL endpoints for arbitrary datastores: When completed, this library will provide hooks that allow a Ruby developer to easily define a translation from SPARQL to another query language or API of their choosing. Ideally, this will be done using a simple YAML configuration file.

  3. Fully Composable: Because parsing expression grammars are closed under composition, you can compose this grammar with other Treetop grammars with relative ease.

USAGE

Though this library only parses a small subset of SPARQL and I've not added all of the API methods yet, it is ready to start playing with.

  1. Install the Gem

Make sure you've upgraded to RubyGems 1.2. Then, if you've never installed a gem from GitHub before then do this:

gem sources -a http://gems.github.com (you only have to do this once)

Then:

sudo gem install pius-sparql

  1. Make Sure You've Got the Dependencies installed

sparql depends on Treetop (http://github.com/nathansobo/treetop).

sudo gem install treetop

  1. Require the gem in your code, play with it

As of this minute, the code won't be that useful to you, as it can only parse a small subset of SPARQL and the translation hooks have not been added yet. That being said, stay tuned. I think development on this is going to move fairly quickly because Treetop is such a joy to write the PEG in.

Anyway, you can get started by doing the following in IRB.

irb(main):001:0> require 'rubygems'

=> true

irb(main):002:0> gem 'pius-sparql'

=> true

irb(main):003:0> require 'sparql'

=> true

irb(main):004:0> parser = SparqlParser.new

=> #SparqlParser:0x1270bcc @consume_all_input=true

irb(main):005:0> syntaxtree = parser.parse('SELECT ?foo ?bar WHERE { ?x foaf:knows ?y . ?z foaf:name ?y . }')

  1. Read the documentation

Actually, read the tests -- they will show you the forms that are supported. Take a look at lib/sparql/sparql.treetop and get a sense of the grammar. In addition, check out the formal specification of the SPARQL grammar so you can see how the Treetop grammar relates to it.

  1. Contribute!

Fork my repository (http://github.com/pius/sparql), make some changes, and send along a pull request!

The best way to contribute is to add a test case for a specific SPARQL query that does not parse and then tweak the grammar such that your new test case plus all the others pass.

COPYRIGHT

sparql was created in 2008 by Pius Uzamere (pius -AT- alum -DOT- mit -DOT- edu) and is
licensed under the LGPL.

Something went wrong with that request. Please try again.