Skip to content

Instantly share code, notes, and snippets.

@peta

peta/stacktrace Secret

Last active December 15, 2015 22:59
Show Gist options
  • Save peta/aadf06ac91ca09262138 to your computer and use it in GitHub Desktop.
Save peta/aadf06ac91ca09262138 to your computer and use it in GitHub Desktop.
Steps to reproduce the weird behaviour of RDF.rb/SPARQL when parsing a query string: When I run the script with both statements an exception is thrown (see stacktrace). But when I execute any of them alone (having #1 uncommented and #2 commented out or vice versa) they work as expected.
[]base IRI: #<RDF::URI:0x3ff495a1312c()>
[]validate: false
[1]parse(production): token :SPARQL_PREFIX, prod :Query, depth 0
[1] Query(:start): {:type=>:SPARQL_PREFIX, :value=>"PREFIX"}
[1] parse(production): token :SPARQL_PREFIX prod :Query, prod_branch ["ASK", "BASE", "CONSTRUCT", "DESCRIBE", "PREFIX", "SELECT"], sequence nil
[1] parse(terms): todo {:prod=>:Query, :terms=>[]}, depth 1
[1] parse(pop): todo {:prod=>:Query, :terms=>[]}, depth 1
[1] Query(:finish):1: {}
[1]parse(eof): Finished processing before end of file, found :SPARQL_PREFIX at line 1
/Users/peter/.rvm/gems/ruby-1.9.3-p392@dev1/gems/ebnf-0.2.3/lib/ebnf/ll1/parser.rb:348:in `parse': Finished processing before end of file, found :SPARQL_PREFIX at line 1 (EBNF::LL1::Parser::Error)
from /Users/peter/.rvm/gems/ruby-1.9.3-p392@dev1/gems/sparql-1.0.4/lib/sparql/grammar/parser11.rb:979:in `parse'
from /Users/peter/.rvm/gems/ruby-1.9.3-p392@dev1/gems/sparql-1.0.4/lib/sparql.rb:30:in `parse'
from tests/testscript.rb:9:in `<main>'
@prefix spr: <urn:sempress:vocab:views#>.
@prefix test: <urn:sempress:vocab:test#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
test:subj1 a foaf:Organization.
test:subj2 a foaf:Group.
test:subj3 a foaf:Person.
test:subj4 a spr:Foo.
require 'rdf'
require 'rdf/turtle'
require 'sparql'
# Statement #1
graph = RDF::Graph.load('testfile.ttl')
# Statement #2
SPARQL.parse(<<-SPARQL, :progress => true, :debug => true)
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?subject
WHERE { ?subject a foaf:Person }
SPARQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment