add field name to block to highlight its name
This commit is contained in:
@@ -33,7 +33,7 @@ module.exports = grammar({
|
|||||||
),
|
),
|
||||||
|
|
||||||
block: $ => seq(
|
block: $ => seq(
|
||||||
$.identifier,
|
field('type', $.identifier),
|
||||||
repeat(choice($.string_lit, $.identifier)),
|
repeat(choice($.string_lit, $.identifier)),
|
||||||
'{',
|
'{',
|
||||||
optional($.body),
|
optional($.body),
|
||||||
@@ -55,14 +55,12 @@ module.exports = grammar({
|
|||||||
expr_term: $ => choice(
|
expr_term: $ => choice(
|
||||||
$.literal_value,
|
$.literal_value,
|
||||||
$.collection_value,
|
$.collection_value,
|
||||||
// $.template_expr,
|
|
||||||
$.variable_expr,
|
$.variable_expr,
|
||||||
// $.function_call,
|
// $.function_call,
|
||||||
// $.for_expr,
|
// $.for_expr,
|
||||||
// seq($.expr_term, $.index),
|
// seq($.expr_term, $.index),
|
||||||
// seq($.expr_term, $.get_attr),
|
// seq($.expr_term, $.get_attr),
|
||||||
// seq($.expr_term, $.splat),
|
// seq($.expr_term, $.splat),
|
||||||
// seq($.expr_term, $.splat),
|
|
||||||
seq('(', $.expression, ')'),
|
seq('(', $.expression, ')'),
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ module.exports = grammar({
|
|||||||
|
|
||||||
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
||||||
|
|
||||||
string_lit: $ => seq('"', repeat(/./), '"'),
|
string_lit: $ => seq('"', repeat(choice(/[^\\"\n]/, /\\(.|\n)/)), '"'),
|
||||||
|
|
||||||
bool_lit: $ => choice('true', 'false'),
|
bool_lit: $ => choice('true', 'false'),
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
; highlights.scm
|
; highlights.scm
|
||||||
|
|
||||||
|
(block type: (identifier) @keyword)
|
||||||
(identifier) @string.special
|
(identifier) @string.special
|
||||||
(string_lit) @string
|
(string_lit) @string
|
||||||
(numeric_lit) @number
|
(numeric_lit) @number
|
||||||
|
|||||||
@@ -47,8 +47,12 @@
|
|||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "FIELD",
|
||||||
"name": "identifier"
|
"name": "type",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "identifier"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
@@ -198,8 +202,17 @@
|
|||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "CHOICE",
|
||||||
"value": "."
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[^\\\\\"\\n]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "\\\\(.|\\n)"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,10 +21,21 @@
|
|||||||
{
|
{
|
||||||
"type": "block",
|
"type": "block",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {},
|
"fields": {
|
||||||
|
"type": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "body",
|
"type": "body",
|
||||||
|
|||||||
1101
src/parser.c
1101
src/parser.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user