mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Add SPARQL
Signed-off-by: BonaBeavis <gordian.dziwis@gmail.com>
This commit is contained in:
parent
cafe733e23
commit
e934c5508a
6 changed files with 270 additions and 0 deletions
|
|
@ -166,6 +166,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [ruby](https://github.com/tree-sitter/tree-sitter-ruby) (maintained by @TravonteD)
|
||||
- [x] [rust](https://github.com/tree-sitter/tree-sitter-rust) (maintained by @vigoux)
|
||||
- [ ] [scala](https://github.com/tree-sitter/tree-sitter-scala)
|
||||
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @bonabeavis)
|
||||
- [ ] [swift](https://github.com/tree-sitter/tree-sitter-swift)
|
||||
- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce)
|
||||
- [x] [toml](https://github.com/ikatyang/tree-sitter-toml) (maintained by @tk-shirasaka)
|
||||
|
|
|
|||
|
|
@ -380,6 +380,15 @@ list.query = {
|
|||
maintainers = {"@steelsojka"},
|
||||
}
|
||||
|
||||
list.sparql = {
|
||||
install_info = {
|
||||
url = "https://github.com/BonaBeavis/tree-sitter-sparql",
|
||||
files = { "src/parser.c" },
|
||||
branch = "main",
|
||||
},
|
||||
maintainers = { "@bonabeavis" },
|
||||
}
|
||||
|
||||
local M = {
|
||||
list = list
|
||||
}
|
||||
|
|
|
|||
26
queries/sparql/folds.scm
Normal file
26
queries/sparql/folds.scm
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
(prologue)
|
||||
(select_query)
|
||||
(construct_query)
|
||||
(describe_query)
|
||||
(ask_query)
|
||||
(values_clause)
|
||||
(load)
|
||||
(clear)
|
||||
(drop)
|
||||
(add)
|
||||
(move)
|
||||
(copy)
|
||||
(create)
|
||||
(insert_data)
|
||||
(delete_data)
|
||||
(delete_where)
|
||||
(modify)
|
||||
(group_graph_pattern)
|
||||
(triples_same_subject)
|
||||
(where_clause)
|
||||
(delete_clause)
|
||||
(insert_clause)
|
||||
(data_block)
|
||||
(blank_node_property_list)
|
||||
] @fold
|
||||
211
queries/sparql/highlights.scm
Normal file
211
queries/sparql/highlights.scm
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
[
|
||||
(path_mod)
|
||||
"||"
|
||||
"&&"
|
||||
"="
|
||||
"<"
|
||||
">"
|
||||
"<="
|
||||
">="
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"!"
|
||||
"|"
|
||||
"^"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"_:"
|
||||
(namespace)
|
||||
] @namespace
|
||||
|
||||
[
|
||||
"UNDEF"
|
||||
"a"
|
||||
] @variable.builtin
|
||||
|
||||
|
||||
[
|
||||
"ADD"
|
||||
"ALL"
|
||||
"AS"
|
||||
"ASC"
|
||||
"ASK"
|
||||
"BIND"
|
||||
"BY"
|
||||
"CLEAR"
|
||||
"CONSTRUCT"
|
||||
"COPY"
|
||||
"CREATE"
|
||||
"DEFAULT"
|
||||
"DELETE"
|
||||
"DELETE DATA"
|
||||
"DELETE WHERE"
|
||||
"DESC"
|
||||
"DESCRIBE"
|
||||
"DISTINCT"
|
||||
"DROP"
|
||||
"EXISTS"
|
||||
"FILTER"
|
||||
"FROM"
|
||||
"GRAPH"
|
||||
"GROUP"
|
||||
"HAVING"
|
||||
"INSERT"
|
||||
"INSERT DATA"
|
||||
"INTO"
|
||||
"LIMIT"
|
||||
"LOAD"
|
||||
"MINUS"
|
||||
"MOVE"
|
||||
"NAMED"
|
||||
"NOT"
|
||||
"OFFSET"
|
||||
"OPTIONAL"
|
||||
"ORDER"
|
||||
"PREFIX"
|
||||
"REDUCED"
|
||||
"SELECT"
|
||||
"SERVICE"
|
||||
"SILENT"
|
||||
"UNION"
|
||||
"USING"
|
||||
"VALUES"
|
||||
"WHERE"
|
||||
"WITH"
|
||||
] @keyword
|
||||
|
||||
(string) @string
|
||||
(echar) @string.escape
|
||||
|
||||
(integer) @number
|
||||
[
|
||||
(decimal)
|
||||
(double)
|
||||
] @float
|
||||
(boolean_literal) @boolean
|
||||
|
||||
[
|
||||
"BASE"
|
||||
"PREFIX"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"ABS"
|
||||
"AVG"
|
||||
"BNODE"
|
||||
"BOUND"
|
||||
"CEIL"
|
||||
"CONCAT"
|
||||
"COALESCE"
|
||||
"CONTAINS"
|
||||
"DATATYPE"
|
||||
"DAY"
|
||||
"ENCODE_FOR_URI"
|
||||
"FLOOR"
|
||||
"HOURS"
|
||||
"IF"
|
||||
"IRI"
|
||||
"LANG"
|
||||
"LANGMATCHES"
|
||||
"LCASE"
|
||||
"MD5"
|
||||
"MINUTES"
|
||||
"MONTH"
|
||||
"NOW"
|
||||
"RAND"
|
||||
"REGEX"
|
||||
"ROUND"
|
||||
"SECONDS"
|
||||
"SHA1"
|
||||
"SHA256"
|
||||
"SHA384"
|
||||
"SHA512"
|
||||
"STR"
|
||||
"SUM"
|
||||
"MAX"
|
||||
"MIN"
|
||||
"SAMPLE"
|
||||
"GROUP_CONCAT"
|
||||
"SEPARATOR"
|
||||
"COUNT"
|
||||
"STRAFTER"
|
||||
"STRBEFORE"
|
||||
"STRDT"
|
||||
"STRENDS"
|
||||
"STRLANG"
|
||||
"STRLEN"
|
||||
"STRSTARTS"
|
||||
"STRUUID"
|
||||
"TIMEZONE"
|
||||
"TZ"
|
||||
"UCASE"
|
||||
"URI"
|
||||
"UUID"
|
||||
"YEAR"
|
||||
"isBLANK"
|
||||
"isIRI"
|
||||
"isLITERAL"
|
||||
"isNUMERIC"
|
||||
"isURI"
|
||||
"sameTerm"
|
||||
] @function.builtin
|
||||
|
||||
[
|
||||
"."
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
(nil)
|
||||
(anon)
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"IN"
|
||||
("NOT" "IN")
|
||||
] @keyword.operator
|
||||
|
||||
|
||||
(comment) @comment
|
||||
|
||||
|
||||
; Could this be summarized?
|
||||
(select_clause
|
||||
[
|
||||
bound_variable: (var)
|
||||
"*"
|
||||
] @parameter)
|
||||
(bind bound_variable: (var) @parameter)
|
||||
(data_block bound_variable: (var) @parameter)
|
||||
(group_condition bound_variable: (var) @parameter)
|
||||
|
||||
(iri_reference ["<" ">"] @namespace)
|
||||
|
||||
(lang_tag) @type
|
||||
(rdf_literal
|
||||
"^^" @type
|
||||
datatype: (_ ["<" ">" (namespace)] @type) @type)
|
||||
|
||||
(function_call identifier: (_) @function)
|
||||
|
||||
(function_call identifier: (iri_reference ["<" ">"] @function))
|
||||
(function_call identifier: (prefixed_name (namespace) @function))
|
||||
(base_declaration (iri_reference ["<" ">"] @variable))
|
||||
(prefix_declaration (iri_reference ["<" ">"] @variable))
|
||||
|
||||
[
|
||||
(var)
|
||||
(blank_node_label)
|
||||
(iri_reference)
|
||||
(prefixed_name)
|
||||
] @variable
|
||||
17
queries/sparql/indents.scm
Normal file
17
queries/sparql/indents.scm
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
(group_graph_pattern)
|
||||
(triples_block)
|
||||
(triples_template)
|
||||
(construct_template)
|
||||
(construct_triples)
|
||||
(quads)
|
||||
(data_block)
|
||||
(blank_node_property_list)
|
||||
(collection)
|
||||
] @indent
|
||||
[
|
||||
"}"
|
||||
"]"
|
||||
")"
|
||||
(triples_same_subject)
|
||||
] @branch
|
||||
6
queries/sparql/locals.scm
Normal file
6
queries/sparql/locals.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(group_graph_pattern (triples_block) @scope)
|
||||
|
||||
(sub_select (select_clause (var) @definition.var)(set! "definition.var.scope" "parent"))
|
||||
(select_query (select_clause (var) @definition.var)(set! "definition.var.scope" "parent"))
|
||||
|
||||
(var) @reference
|
||||
Loading…
Add table
Add a link
Reference in a new issue