Add 'field_identifier' alias

This will be useful for high-lighting.
This commit is contained in:
Bruno BELANYI 2022-06-03 10:31:30 +02:00
parent abe5b2e366
commit 0827093fe7
6 changed files with 48 additions and 16 deletions

View file

@ -23,6 +23,7 @@ module.exports = grammar({
inline: ($) => [
$._type_identifier,
$._field_identifier,
],
conflicts: ($) => [
@ -88,6 +89,8 @@ module.exports = grammar({
_type_identifier: ($) => alias($.identifier, $.type_identifier),
_field_identifier: ($) => alias($.identifier, $.field_identifier),
escape_sequence: (_) => token.immediate(
seq(
"\\",
@ -113,7 +116,7 @@ module.exports = grammar({
record_value: ($) => seq(
field("record", $._lvalue),
".",
field("field", $.identifier),
field("field", $._field_identifier),
),
array_value: ($) => seq(
@ -177,7 +180,7 @@ module.exports = grammar({
sepBy(
",",
seq(
field("field", $.identifier),
field("field", $._field_identifier),
"=",
field("init", $._expr),
),

View file

@ -142,6 +142,15 @@
"named": true,
"value": "type_identifier"
},
"_field_identifier": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "field_identifier"
},
"escape_sequence": {
"type": "IMMEDIATE_TOKEN",
"content": {
@ -259,7 +268,7 @@
"name": "field",
"content": {
"type": "SYMBOL",
"name": "identifier"
"name": "_field_identifier"
}
}
]
@ -731,7 +740,7 @@
"name": "field",
"content": {
"type": "SYMBOL",
"name": "identifier"
"name": "_field_identifier"
}
},
{
@ -765,7 +774,7 @@
"name": "field",
"content": {
"type": "SYMBOL",
"name": "identifier"
"name": "_field_identifier"
}
},
{
@ -1460,7 +1469,8 @@
}
],
"inline": [
"_type_identifier"
"_type_identifier",
"_field_identifier"
],
"supertypes": []
}

View file

@ -1466,7 +1466,7 @@
"required": false,
"types": [
{
"type": "identifier",
"type": "field_identifier",
"named": true
}
]
@ -1596,7 +1596,7 @@
"required": true,
"types": [
{
"type": "identifier",
"type": "field_identifier",
"named": true
}
]
@ -2303,6 +2303,10 @@
"type": "escape_sequence",
"named": true
},
{
"type": "field_identifier",
"named": true
},
{
"type": "for",
"named": false

View file

@ -9,7 +9,7 @@
#define STATE_COUNT 148
#define LARGE_STATE_COUNT 2
#define SYMBOL_COUNT 87
#define ALIAS_COUNT 1
#define ALIAS_COUNT 2
#define TOKEN_COUNT 49
#define EXTERNAL_TOKEN_COUNT 1
#define FIELD_COUNT 26
@ -103,7 +103,8 @@ enum {
aux_sym__declaration_chunk_repeat1 = 84,
aux_sym__declaration_chunk_repeat2 = 85,
aux_sym_record_type_repeat1 = 86,
alias_sym_type_identifier = 87,
alias_sym_field_identifier = 87,
alias_sym_type_identifier = 88,
};
static const char * const ts_symbol_names[] = {
@ -194,6 +195,7 @@ static const char * const ts_symbol_names[] = {
[aux_sym__declaration_chunk_repeat1] = "_declaration_chunk_repeat1",
[aux_sym__declaration_chunk_repeat2] = "_declaration_chunk_repeat2",
[aux_sym_record_type_repeat1] = "record_type_repeat1",
[alias_sym_field_identifier] = "field_identifier",
[alias_sym_type_identifier] = "type_identifier",
};
@ -285,6 +287,7 @@ static const TSSymbol ts_symbol_map[] = {
[aux_sym__declaration_chunk_repeat1] = aux_sym__declaration_chunk_repeat1,
[aux_sym__declaration_chunk_repeat2] = aux_sym__declaration_chunk_repeat2,
[aux_sym_record_type_repeat1] = aux_sym_record_type_repeat1,
[alias_sym_field_identifier] = alias_sym_field_identifier,
[alias_sym_type_identifier] = alias_sym_type_identifier,
};
@ -637,6 +640,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = false,
.named = false,
},
[alias_sym_field_identifier] = {
.visible = true,
.named = true,
},
[alias_sym_type_identifier] = {
.visible = true,
.named = true,
@ -872,6 +879,9 @@ static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE
[7] = {
[1] = anon_sym_DASH,
},
[8] = {
[2] = alias_sym_field_identifier,
},
[15] = {
[0] = alias_sym_type_identifier,
},
@ -883,12 +893,17 @@ static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE
},
[25] = {
[0] = alias_sym_type_identifier,
[2] = alias_sym_field_identifier,
},
[32] = {
[3] = alias_sym_type_identifier,
},
[33] = {
[0] = alias_sym_type_identifier,
[2] = alias_sym_field_identifier,
},
[36] = {
[1] = alias_sym_field_identifier,
},
};

View file

@ -40,9 +40,9 @@ record_type { a = 12, b = "27" }
(source_file
(record_expression
type: (type_identifier)
field: (identifier)
field: (field_identifier)
init: (integer_literal)
field: (identifier)
field: (field_identifier)
init: (string_literal)))
================================================================================
@ -56,7 +56,7 @@ record_type { a = 12 }
(source_file
(record_expression
type: (type_identifier)
field: (identifier)
field: (field_identifier)
init: (integer_literal)))
================================================================================
@ -82,7 +82,7 @@ record_type { a = 12, }
(source_file
(record_expression
type: (type_identifier)
field: (identifier)
field: (field_identifier)
init: (integer_literal)
(ERROR)))
@ -156,4 +156,4 @@ a := array[12] := record.field
index: (integer_literal))
right: (record_value
record: (identifier)
field: (identifier)))))
field: (field_identifier)))))

View file

@ -33,4 +33,4 @@ a_record.field
(source_file
(record_value
record: (identifier)
field: (identifier)))
field: (field_identifier)))