1
0

Improve highlight queries

This commit is contained in:
Jeff 2023-12-11 11:17:37 -05:00
parent 06da345333
commit e1a7c3ff72
11 changed files with 13383 additions and 9984 deletions

View File

@ -1,6 +1,6 @@
const fs = require('node:fs');
const data = fs.readFileSync("examples/assets/jq_data.json");
const items = JSON.parse(data);
const output = items.map((item) => item.commit.committer.name);
const output = items.map((item) => item:commit:committer:name);
console.log(output)

View File

@ -13,7 +13,8 @@ async { (output 'Whaddup') }
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(value
(string)))))))))

View File

@ -29,7 +29,8 @@ for i in [1, 2, 3] {
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(identifier)))))))))
@ -62,6 +63,7 @@ for list in list_of_lists {
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(identifier))))))))))))

View File

@ -85,14 +85,16 @@ fn |message number| {
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(identifier)))))
(statement
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(identifier)))))))))))

View File

@ -19,7 +19,8 @@ while true {
(expression
(function_call
(expression
(identifier))
(identifier
(built_in_function)))
(expression
(value
(string))))))))))

View File

@ -14,7 +14,8 @@ Simple Yield
(value
(integer)))
(expression
(identifier))))))
(identifier
(built_in_function)))))))
================================================================================
Yield Chain

View File

@ -1,7 +1,7 @@
module.exports = grammar({
name: 'dust',
word: $ => $.identifier,
word: $ => $._identifier_pattern,
extras: $ => [/\s/, $._comment],
@ -31,7 +31,6 @@ module.exports = grammar({
$.index_assignment,
$.match,
$.return,
$.use,
$.while,
),
optional(';'),
@ -61,8 +60,12 @@ module.exports = grammar({
),
),
identifier: $ =>
/[_a-zA-Z]+[_a-zA-Z0-9]?/,
identifier: $ => choice(
$._identifier_pattern,
$.built_in_function,
),
_identifier_pattern: $ => /[_a-zA-Z]+[_a-zA-Z0-9]?/,
value: $ =>
choice(
@ -319,8 +322,6 @@ module.exports = grammar({
seq('return', $.expression),
),
use: $ => seq('use', $.string),
type_definition: $ =>
seq('<', $.type, '>'),
@ -384,5 +385,22 @@ module.exports = grammar({
')',
),
),
built_in_function: $ =>
choice(
"assert",
"assert_equal",
"bash",
"download",
"fish",
"length",
"metadata",
"output",
"output_error",
"random",
"random_boolean",
"random_float",
"random_integer",
),
},
});

View File

@ -1,6 +1,5 @@
(expression) @expression
(value) @value
(comment) @comment
(identifier) @identifier
(value) @value
(string) @string
@ -24,6 +23,8 @@
"}"
"<"
">"
"("
")"
] @punctuation.bracket
[
@ -33,38 +34,22 @@
] @operator
[
"if"
"any"
"async"
"else"
"false"
"float"
"fn"
"for"
"if"
"in"
"function"
"int"
"map"
"match"
"num"
"str"
"true"
"while"
] @keyword
[
"assert"
"assert_equal"
"download"
"help"
"length"
"output"
"output_error"
"type"
"workdir"
"append"
"metadata"
"move"
"read"
"remove"
"write"
"bash"
"fish"
"raw"
"sh"
"zsh"
"random"
"random_boolean"
"random_float"
"random_integer"
"columns"
"rows"
] @function.builtin
(built_in_function) @function.builtin

View File

@ -1,6 +1,6 @@
{
"name": "dust",
"word": "identifier",
"word": "_identifier_pattern",
"rules": {
"root": {
"type": "PREC",
@ -90,10 +90,6 @@
"type": "SYMBOL",
"name": "return"
},
{
"type": "SYMBOL",
"name": "use"
},
{
"type": "SYMBOL",
"name": "while"
@ -181,6 +177,19 @@
}
},
"identifier": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_identifier_pattern"
},
{
"type": "SYMBOL",
"name": "built_in_function"
}
]
},
"_identifier_pattern": {
"type": "PATTERN",
"value": "[_a-zA-Z]+[_a-zA-Z0-9]?"
},
@ -1006,19 +1015,6 @@
]
}
},
"use": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "use"
},
{
"type": "SYMBOL",
"name": "string"
}
]
},
"type_definition": {
"type": "SEQ",
"members": [
@ -1266,6 +1262,63 @@
}
]
}
},
"built_in_function": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "assert"
},
{
"type": "STRING",
"value": "assert_equal"
},
{
"type": "STRING",
"value": "bash"
},
{
"type": "STRING",
"value": "download"
},
{
"type": "STRING",
"value": "fish"
},
{
"type": "STRING",
"value": "length"
},
{
"type": "STRING",
"value": "metadata"
},
{
"type": "STRING",
"value": "output"
},
{
"type": "STRING",
"value": "output_error"
},
{
"type": "STRING",
"value": "random"
},
{
"type": "STRING",
"value": "random_boolean"
},
{
"type": "STRING",
"value": "random_float"
},
{
"type": "STRING",
"value": "random_integer"
}
]
}
},
"extras": [

View File

@ -51,6 +51,11 @@
"named": true,
"fields": {}
},
{
"type": "built_in_function",
"named": true,
"fields": {}
},
{
"type": "else",
"named": true,
@ -181,6 +186,21 @@
]
}
},
{
"type": "identifier",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "built_in_function",
"named": true
}
]
}
},
{
"type": "if",
"named": true,
@ -432,10 +452,6 @@
"type": "return",
"named": true
},
{
"type": "use",
"named": true
},
{
"type": "while",
"named": true
@ -473,21 +489,6 @@
]
}
},
{
"type": "use",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "string",
"named": true
}
]
}
},
{
"type": "value",
"named": true,
@ -665,6 +666,14 @@
"type": "any",
"named": false
},
{
"type": "assert",
"named": false
},
{
"type": "assert_equal",
"named": false
},
{
"type": "async",
"named": false
@ -673,10 +682,18 @@
"type": "async for",
"named": false
},
{
"type": "bash",
"named": false
},
{
"type": "bool",
"named": false
},
{
"type": "download",
"named": false
},
{
"type": "else",
"named": false
@ -690,13 +707,17 @@
"named": false
},
{
"type": "float",
"named": true
"type": "fish",
"named": false
},
{
"type": "float",
"named": false
},
{
"type": "float",
"named": true
},
{
"type": "fn",
"named": false
@ -705,10 +726,6 @@
"type": "for",
"named": false
},
{
"type": "identifier",
"named": true
},
{
"type": "if",
"named": false
@ -725,6 +742,10 @@
"type": "integer",
"named": true
},
{
"type": "length",
"named": false
},
{
"type": "map",
"named": false
@ -733,10 +754,38 @@
"type": "match",
"named": false
},
{
"type": "metadata",
"named": false
},
{
"type": "num",
"named": false
},
{
"type": "output",
"named": false
},
{
"type": "output_error",
"named": false
},
{
"type": "random",
"named": false
},
{
"type": "random_boolean",
"named": false
},
{
"type": "random_float",
"named": false
},
{
"type": "random_integer",
"named": false
},
{
"type": "return",
"named": false
@ -753,10 +802,6 @@
"type": "true",
"named": false
},
{
"type": "use",
"named": false
},
{
"type": "while",
"named": false

File diff suppressed because it is too large Load Diff