johanwk / elot

Emacs Literate Ontology Tool
GNU General Public License v3.0
6 stars 3 forks source link

flycheck validation (SPARQL) #29

Open VladimirAlexiev opened 3 months ago

VladimirAlexiev commented 3 months ago

I use these to associate various extensions to SPARQL mode:

(add-to-list 'auto-mode-alist '("\\.sparql$" . sparql-mode)) ; SPARQL
(add-to-list 'auto-mode-alist '("\\.tarql$"  . sparql-mode)) ; SPARQL in Tabular files
(add-to-list 'auto-mode-alist '("\\.rq$"     . sparql-mode)) ; SPARQL Query standard extension
(add-to-list 'auto-mode-alist '("\\.ru$"     . sparql-mode)) ; SPARQL Update standard extension

SPARQL validation with flycheck using jena qparse from https://github.com/ljos/sparql-mode/issues/29:

(require 'flycheck)

(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)

https://github.com/ljos/sparql-mode/issues/70 asks for similar modes sparql-update-mode and tarql-mode but haven't been implemented yet. The validation sort of works for such files, but not quite.

johanwk commented 3 months ago

This is great stuff. We definitely need to include it!