Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARQL syntax error checking #29

Open
ljos opened this issue Nov 26, 2014 · 4 comments
Open

SPARQL syntax error checking #29

ljos opened this issue Nov 26, 2014 · 4 comments

Comments

@ljos
Copy link
Owner

ljos commented Nov 26, 2014

To do true syntax error checking we need to parse the syntax and report errors if there are any.

Look into:

@VladimirAlexiev
Copy link
Collaborator

Also look at LSP:

@bjonnh
Copy link

bjonnh commented May 8, 2020

I made a basic implementation for that no idea how to integrate it properly, it works because I have a node_modules in my project (projectile).

https://gist.github.com/bjonnh/dc274cc64aef296d65e37fe71bcf6cbc

@johanwk
Copy link

johanwk commented Feb 3, 2021

Flycheck works well for me, using qparse from Jena. Since I'm on Windows, the command is qparse.bat:

(flycheck-define-checker sparql-syntax
  "A SPARQL syntax checker using ARQ qparse. See URL https://jena.apache.org/documentation/query/cmds.html."
  :command ("qparse.bat" "--query" source)
  :error-patterns
  ((error line-start "Encountered \"" (message) "\" at line " line ", column " column "." line-end)
   (error line-start "Lexical error at line " line ", column " column "." (+ space) "Encountered: " (message) line-end))
  :modes sparql-mode)
(add-to-list 'flycheck-checkers 'sparql-syntax)
(add-hook 'sparql-mode-hook 'flycheck-mode)

@VladimirAlexiev
Copy link
Collaborator

VladimirAlexiev commented Feb 16, 2021

@johanwk @ljos

  1. sparql-mode also works well on SPARQL Update files (*.ru).
    Would it be possible to make the flychecker work for such files as well?
    Jena has another command update that produces errors in the same format as qparse (see below).
    Maybe the cleanest approach is to define a derived sparql-update-mode?
update --update <query>.ru
org.apache.jena.query.QueryParseException: Lexical error at line 7, column 2.  Encountered: "\r" (13), after : "z"
        at org.apache.jena.sparql.lang.ParserSPARQL11Update._parse(ParserSPARQL11Update.java:72)
        at org.apache.jena.sparql.lang.ParserSPARQL11Update.parse$(ParserSPARQL11Update.java:45)
        at org.apache.jena.sparql.lang.UpdateParser.parse(UpdateParser.java:48)
        at org.apache.jena.update.UpdateFactory.make(UpdateFactory.java:283)
        at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:272)
        at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:183)
        at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:167)
        at org.apache.jena.update.UpdateFactory.read(UpdateFactory.java:155)
        at arq.update.execOneFile(update.java:104)
        at arq.update.execUpdate(update.java:81)
        at arq.cmdline.CmdUpdate.exec(CmdUpdate.java:63)
        at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
        at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
        at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
        at arq.update.main(update.java:49)
  1. Would it be possible to adapt the checker to work with http://tarql.github.io/? It's the same as SPARQL, except the last bullet below:
  • A SPARQL 1.1 SELECT query
  • A SPARQL 1.1 ASK query
  • One or more consecutive SPARQL 1.1 CONSTRUCT queries.
    • All prefixes defined at the beginning should apply to all queries
    • IMHO the only way to accommodate this is to split up the file before passing to qparse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants