diff options
-rw-r--r-- | example | 38 | ||||
-rw-r--r-- | grammar.js | 28 | ||||
-rw-r--r-- | queries/gsp/folds.scm | 3 | ||||
-rw-r--r-- | queries/gsp/highlights.scm | 13 | ||||
-rw-r--r-- | queries/gsp/textobjects.scm | 3 | ||||
-rw-r--r-- | src/grammar.json | 127 | ||||
-rw-r--r-- | src/node-types.json | 134 | ||||
-rw-r--r-- | src/parser.c | 1128 | ||||
-rw-r--r-- | test/corpus/document.txt | 156 |
9 files changed, 1047 insertions, 583 deletions
diff --git a/example b/example deleted file mode 100644 index cd38ff8..0000000 --- a/example +++ /dev/null @@ -1,38 +0,0 @@ -html lang="en" { - head { - meta charset="UTF-8" {} - meta - name="viewport" - content="width=device-width, initial-scale=1.0" - {} - link href="/favicon.svg" rel="shortcut icon" type="image/svg" {} - link href="/style.svg" rel="stylesheet" {} - title {-My Website Title} - } - - body { - p #my-id {= This is a paragraph with the id ‘my-id’ } - p .my-cls {= This is a paragraph with the class ‘my-cls’ } - - / div { - p {- This entire div is commented out. } - p {- Isn’t that neat? } - } - - p - #some-id - .class-1 - .class-2 - key-1="value-1" - key-2 = "value-2" - {- - This paragraph has an ID, two classes, and two additional - attributes. GSP allows us to use the ‘#ident’ and ‘.ident’ - syntaxes as shorthands for applying IDs, and classes. This - is a text node, so nothing is being interpreted as GSP nodes, - but we can include them inline if we want. As an example, - here is some @em {-emphatic} text. Your inline nodes can - also have attributes @em #id {-just like a regular node}. - } - } -} @@ -7,10 +7,18 @@ module.exports = grammar({ document: $ => repeat($._toplevel), _toplevel: $ => choice($.comment, $.node), - comment: $ => seq('/', $.node), - node: $ => seq($.node_name, optional($.attrs), $.node_body), + comment: $ => seq( + '/', + optional(field('name', $.ident)), + optional(field('attrs', $.attr_list)), + field('body', $.node_body), + ), + node: $ => seq( + field('name', $.ident), + optional(field('attrs', $.attr_list)), + field('body', $.node_body), + ), - node_name: $ => IDENT, node_body: $ => seq( '{', choice( @@ -20,19 +28,25 @@ module.exports = grammar({ '}', ), - attrs: $ => repeat1(choice( + attr_list: $ => repeat1(choice( $.attr, $.id_attr, $.class_attr, )), - attr: $ => seq(IDENT, '=', /"(\\["\\]|[^"\\])+"/), - id_attr: $ => seq('#', token.immediate(IDENT)), - class_attr: $ => seq('.', token.immediate(IDENT)), + attr: $ => seq( + field('name', $.ident), + '=', + field('value', $.string) + ), + id_attr: $ => seq('#', alias(token.immediate(IDENT), $.ident)), + class_attr: $ => seq('.', alias(token.immediate(IDENT), $.ident)), text: $ => repeat1(choice( /(\\[@}\\]|[^@}\\])+/, seq('@', $._toplevel), )), + ident: $ => IDENT, + string: $ => /"(\\["\\]|[^"\\])+"/, }, }) diff --git a/queries/gsp/folds.scm b/queries/gsp/folds.scm index e15d359..c70d5dc 100644 --- a/queries/gsp/folds.scm +++ b/queries/gsp/folds.scm @@ -1,4 +1,5 @@ [ + (comment) (node) - (attribute_list) + (attr_list) ] @fold diff --git a/queries/gsp/highlights.scm b/queries/gsp/highlights.scm index 92e61f6..bc81edb 100644 --- a/queries/gsp/highlights.scm +++ b/queries/gsp/highlights.scm @@ -1,12 +1,9 @@ -[">" "-" "=" "@"] @operator +["-" "=" "@"] @operator ["{" "}"] @tag.delimiter -(node_name) @tag -[ - (attribute_name) - (class_shorthand) - (id_shorthand) -] @tag.attribute -(attribute_value) @string +(node name: (ident) @tag) +[(id_attr) (class_attr)] @tag.attribute +(attr name: (ident) @tag.attribute) +(string) @string (comment) @comment ([_] @comment (#has-ancestor? @comment comment)) diff --git a/queries/gsp/textobjects.scm b/queries/gsp/textobjects.scm index 53db443..4f735ce 100644 --- a/queries/gsp/textobjects.scm +++ b/queries/gsp/textobjects.scm @@ -1,3 +1,6 @@ (node) @node.outer (node_body) @node.inner (text) @text.outer +(comment) @comment.outer +(comment (_+) @comment.inner) +[(id_attr) (class_attr) (attr)] @attribute.outer diff --git a/src/grammar.json b/src/grammar.json index 060f61c..8fbe7dc 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -29,8 +29,44 @@ "value": "/" }, { - "type": "SYMBOL", - "name": "node" + "type": "CHOICE", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "ident" + } + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "FIELD", + "name": "attrs", + "content": { + "type": "SYMBOL", + "name": "attr_list" + } + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "node_body" + } } ] }, @@ -38,15 +74,23 @@ "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "node_name" + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "ident" + } }, { "type": "CHOICE", "members": [ { - "type": "SYMBOL", - "name": "attrs" + "type": "FIELD", + "name": "attrs", + "content": { + "type": "SYMBOL", + "name": "attr_list" + } }, { "type": "BLANK" @@ -54,16 +98,15 @@ ] }, { - "type": "SYMBOL", - "name": "node_body" + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "node_body" + } } ] }, - "node_name": { - "type": "PATTERN", - "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", - "flags": "u" - }, "node_body": { "type": "SEQ", "members": [ @@ -119,7 +162,7 @@ } ] }, - "attrs": { + "attr_list": { "type": "REPEAT1", "content": { "type": "CHOICE", @@ -143,17 +186,24 @@ "type": "SEQ", "members": [ { - "type": "PATTERN", - "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", - "flags": "u" + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "ident" + } }, { "type": "STRING", "value": "=" }, { - "type": "PATTERN", - "value": "\"(\\\\[\"\\\\]|[^\"\\\\])+\"" + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "string" + } } ] }, @@ -165,12 +215,17 @@ "value": "#" }, { - "type": "IMMEDIATE_TOKEN", + "type": "ALIAS", "content": { - "type": "PATTERN", - "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", - "flags": "u" - } + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PATTERN", + "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", + "flags": "u" + } + }, + "named": true, + "value": "ident" } ] }, @@ -182,12 +237,17 @@ "value": "." }, { - "type": "IMMEDIATE_TOKEN", + "type": "ALIAS", "content": { - "type": "PATTERN", - "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", - "flags": "u" - } + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PATTERN", + "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", + "flags": "u" + } + }, + "named": true, + "value": "ident" } ] }, @@ -215,6 +275,15 @@ } ] } + }, + "ident": { + "type": "PATTERN", + "value": "\\p{XID_Start}[-\\p{XID_Continue}]*", + "flags": "u" + }, + "string": { + "type": "PATTERN", + "value": "\"(\\\\[\"\\\\]|[^\"\\\\])+\"" } }, "extras": [ diff --git a/src/node-types.json b/src/node-types.json index 0c5aa23..806fb1f 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -2,10 +2,31 @@ { "type": "attr", "named": true, - "fields": {} + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "ident", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "string", + "named": true + } + ] + } + } }, { - "type": "attrs", + "type": "attr_list", "named": true, "fields": {}, "children": { @@ -30,24 +51,55 @@ { "type": "class_attr", "named": true, - "fields": {} - }, - { - "type": "comment", - "named": true, "fields": {}, "children": { "multiple": false, "required": true, "types": [ { - "type": "node", + "type": "ident", "named": true } ] } }, { + "type": "comment", + "named": true, + "fields": { + "attrs": { + "multiple": false, + "required": false, + "types": [ + { + "type": "attr_list", + "named": true + } + ] + }, + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "node_body", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": false, + "types": [ + { + "type": "ident", + "named": true + } + ] + } + } + }, + { "type": "document", "named": true, "fields": {}, @@ -69,32 +121,55 @@ { "type": "id_attr", "named": true, - "fields": {} - }, - { - "type": "node", - "named": true, "fields": {}, "children": { - "multiple": true, + "multiple": false, "required": true, "types": [ { - "type": "attrs", - "named": true - }, - { - "type": "node_body", - "named": true - }, - { - "type": "node_name", + "type": "ident", "named": true } ] } }, { + "type": "node", + "named": true, + "fields": { + "attrs": { + "multiple": false, + "required": false, + "types": [ + { + "type": "attr_list", + "named": true + } + ] + }, + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "node_body", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "ident", + "named": true + } + ] + } + } + }, + { "type": "node_body", "named": true, "fields": {}, @@ -118,11 +193,6 @@ } }, { - "type": "node_name", - "named": true, - "fields": {} - }, - { "type": "text", "named": true, "fields": {}, @@ -166,6 +236,14 @@ "named": false }, { + "type": "ident", + "named": true + }, + { + "type": "string", + "named": true + }, + { "type": "{", "named": false }, diff --git a/src/parser.c b/src/parser.c index a7e2b24..36ba66a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -5,102 +5,99 @@ #endif #define LANGUAGE_VERSION 14 -#define STATE_COUNT 45 +#define STATE_COUNT 56 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 27 +#define SYMBOL_COUNT 26 #define ALIAS_COUNT 0 #define TOKEN_COUNT 13 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 0 +#define FIELD_COUNT 4 #define MAX_ALIAS_SEQUENCE_LENGTH 4 -#define PRODUCTION_ID_COUNT 1 +#define PRODUCTION_ID_COUNT 8 enum ts_symbol_identifiers { anon_sym_SLASH = 1, - aux_sym_node_name_token1 = 2, - anon_sym_LBRACE = 3, - anon_sym_DASH = 4, - anon_sym_EQ = 5, - anon_sym_RBRACE = 6, - aux_sym_attr_token1 = 7, - anon_sym_POUND = 8, - aux_sym_id_attr_token1 = 9, - anon_sym_DOT = 10, - aux_sym_text_token1 = 11, - anon_sym_AT = 12, + anon_sym_LBRACE = 2, + anon_sym_DASH = 3, + anon_sym_EQ = 4, + anon_sym_RBRACE = 5, + anon_sym_POUND = 6, + aux_sym_id_attr_token1 = 7, + anon_sym_DOT = 8, + aux_sym_text_token1 = 9, + anon_sym_AT = 10, + sym_ident = 11, + sym_string = 12, sym_document = 13, sym__toplevel = 14, sym_comment = 15, sym_node = 16, - sym_node_name = 17, - sym_node_body = 18, - sym_attrs = 19, - sym_attr = 20, - sym_id_attr = 21, - sym_class_attr = 22, - sym_text = 23, - aux_sym_document_repeat1 = 24, - aux_sym_attrs_repeat1 = 25, - aux_sym_text_repeat1 = 26, + sym_node_body = 17, + sym_attr_list = 18, + sym_attr = 19, + sym_id_attr = 20, + sym_class_attr = 21, + sym_text = 22, + aux_sym_document_repeat1 = 23, + aux_sym_attr_list_repeat1 = 24, + aux_sym_text_repeat1 = 25, }; static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", [anon_sym_SLASH] = "/", - [aux_sym_node_name_token1] = "node_name_token1", [anon_sym_LBRACE] = "{", [anon_sym_DASH] = "-", [anon_sym_EQ] = "=", [anon_sym_RBRACE] = "}", - [aux_sym_attr_token1] = "attr_token1", [anon_sym_POUND] = "#", - [aux_sym_id_attr_token1] = "id_attr_token1", + [aux_sym_id_attr_token1] = "ident", [anon_sym_DOT] = ".", [aux_sym_text_token1] = "text_token1", [anon_sym_AT] = "@", + [sym_ident] = "ident", + [sym_string] = "string", [sym_document] = "document", [sym__toplevel] = "_toplevel", [sym_comment] = "comment", [sym_node] = "node", - [sym_node_name] = "node_name", [sym_node_body] = "node_body", - [sym_attrs] = "attrs", + [sym_attr_list] = "attr_list", [sym_attr] = "attr", [sym_id_attr] = "id_attr", [sym_class_attr] = "class_attr", [sym_text] = "text", [aux_sym_document_repeat1] = "document_repeat1", - [aux_sym_attrs_repeat1] = "attrs_repeat1", + [aux_sym_attr_list_repeat1] = "attr_list_repeat1", [aux_sym_text_repeat1] = "text_repeat1", }; static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, [anon_sym_SLASH] = anon_sym_SLASH, - [aux_sym_node_name_token1] = aux_sym_node_name_token1, [anon_sym_LBRACE] = anon_sym_LBRACE, [anon_sym_DASH] = anon_sym_DASH, [anon_sym_EQ] = anon_sym_EQ, [anon_sym_RBRACE] = anon_sym_RBRACE, - [aux_sym_attr_token1] = aux_sym_attr_token1, [anon_sym_POUND] = anon_sym_POUND, - [aux_sym_id_attr_token1] = aux_sym_id_attr_token1, + [aux_sym_id_attr_token1] = sym_ident, [anon_sym_DOT] = anon_sym_DOT, [aux_sym_text_token1] = aux_sym_text_token1, [anon_sym_AT] = anon_sym_AT, + [sym_ident] = sym_ident, + [sym_string] = sym_string, [sym_document] = sym_document, [sym__toplevel] = sym__toplevel, [sym_comment] = sym_comment, [sym_node] = sym_node, - [sym_node_name] = sym_node_name, [sym_node_body] = sym_node_body, - [sym_attrs] = sym_attrs, + [sym_attr_list] = sym_attr_list, [sym_attr] = sym_attr, [sym_id_attr] = sym_id_attr, [sym_class_attr] = sym_class_attr, [sym_text] = sym_text, [aux_sym_document_repeat1] = aux_sym_document_repeat1, - [aux_sym_attrs_repeat1] = aux_sym_attrs_repeat1, + [aux_sym_attr_list_repeat1] = aux_sym_attr_list_repeat1, [aux_sym_text_repeat1] = aux_sym_text_repeat1, }; @@ -113,10 +110,6 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, - [aux_sym_node_name_token1] = { - .visible = false, - .named = false, - }, [anon_sym_LBRACE] = { .visible = true, .named = false, @@ -133,17 +126,13 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, - [aux_sym_attr_token1] = { - .visible = false, - .named = false, - }, [anon_sym_POUND] = { .visible = true, .named = false, }, [aux_sym_id_attr_token1] = { - .visible = false, - .named = false, + .visible = true, + .named = true, }, [anon_sym_DOT] = { .visible = true, @@ -157,6 +146,14 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, + [sym_ident] = { + .visible = true, + .named = true, + }, + [sym_string] = { + .visible = true, + .named = true, + }, [sym_document] = { .visible = true, .named = true, @@ -173,15 +170,11 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, - [sym_node_name] = { - .visible = true, - .named = true, - }, [sym_node_body] = { .visible = true, .named = true, }, - [sym_attrs] = { + [sym_attr_list] = { .visible = true, .named = true, }, @@ -205,7 +198,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = false, }, - [aux_sym_attrs_repeat1] = { + [aux_sym_attr_list_repeat1] = { .visible = false, .named = false, }, @@ -215,6 +208,56 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { }, }; +enum ts_field_identifiers { + field_attrs = 1, + field_body = 2, + field_name = 3, + field_value = 4, +}; + +static const char * const ts_field_names[] = { + [0] = NULL, + [field_attrs] = "attrs", + [field_body] = "body", + [field_name] = "name", + [field_value] = "value", +}; + +static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { + [1] = {.index = 0, .length = 1}, + [2] = {.index = 1, .length = 2}, + [3] = {.index = 3, .length = 2}, + [4] = {.index = 5, .length = 2}, + [5] = {.index = 7, .length = 3}, + [6] = {.index = 10, .length = 2}, + [7] = {.index = 12, .length = 3}, +}; + +static const TSFieldMapEntry ts_field_map_entries[] = { + [0] = + {field_body, 1}, + [1] = + {field_body, 1}, + {field_name, 0}, + [3] = + {field_body, 2}, + {field_name, 1}, + [5] = + {field_attrs, 1}, + {field_body, 2}, + [7] = + {field_attrs, 1}, + {field_body, 2}, + {field_name, 0}, + [10] = + {field_name, 0}, + {field_value, 2}, + [12] = + {field_attrs, 2}, + {field_body, 3}, + {field_name, 1}, +}; + static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { [0] = {0}, }; @@ -227,14 +270,14 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [0] = 0, [1] = 1, [2] = 2, - [3] = 3, - [4] = 3, - [5] = 2, - [6] = 6, - [7] = 7, + [3] = 2, + [4] = 4, + [5] = 5, + [6] = 4, + [7] = 5, [8] = 8, - [9] = 9, - [10] = 7, + [9] = 8, + [10] = 10, [11] = 11, [12] = 12, [13] = 13, @@ -242,7 +285,7 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [15] = 15, [16] = 16, [17] = 17, - [18] = 18, + [18] = 17, [19] = 19, [20] = 20, [21] = 21, @@ -251,27 +294,38 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [24] = 24, [25] = 25, [26] = 26, - [27] = 15, + [27] = 27, [28] = 28, [29] = 29, - [30] = 26, - [31] = 18, - [32] = 22, - [33] = 25, - [34] = 16, - [35] = 29, + [30] = 30, + [31] = 31, + [32] = 32, + [33] = 27, + [34] = 32, + [35] = 19, [36] = 36, - [37] = 36, - [38] = 38, - [39] = 39, - [40] = 40, - [41] = 41, - [42] = 42, + [37] = 29, + [38] = 22, + [39] = 26, + [40] = 23, + [41] = 25, + [42] = 28, [43] = 43, - [44] = 38, + [44] = 44, + [45] = 45, + [46] = 45, + [47] = 44, + [48] = 43, + [49] = 49, + [50] = 50, + [51] = 51, + [52] = 52, + [53] = 53, + [54] = 54, + [55] = 50, }; -static TSCharacterRange aux_sym_node_name_token1_character_set_1[] = { +static TSCharacterRange aux_sym_id_attr_token1_character_set_1[] = { {'A', 'Z'}, {'a', 'z'}, {0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, {0xd8, 0xf6}, {0xf8, 0x2c1}, {0x2c6, 0x2d1}, {0x2e0, 0x2e4}, {0x2ec, 0x2ec}, {0x2ee, 0x2ee}, {0x370, 0x374}, {0x376, 0x377}, {0x37b, 0x37d}, {0x37f, 0x37f}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3f5}, {0x3f7, 0x481}, {0x48a, 0x52f}, {0x531, 0x556}, @@ -358,7 +412,7 @@ static TSCharacterRange aux_sym_node_name_token1_character_set_1[] = { {0x2f800, 0x2fa1d}, {0x30000, 0x3134a}, {0x31350, 0x323af}, }; -static TSCharacterRange aux_sym_node_name_token1_character_set_2[] = { +static TSCharacterRange aux_sym_id_attr_token1_character_set_2[] = { {'-', '-'}, {'0', '9'}, {'A', 'Z'}, {'_', '_'}, {'a', 'z'}, {0xaa, 0xaa}, {0xb5, 0xb5}, {0xb7, 0xb7}, {0xba, 0xba}, {0xc0, 0xd6}, {0xd8, 0xf6}, {0xf8, 0x2c1}, {0x2c6, 0x2d1}, {0x2e0, 0x2e4}, {0x2ec, 0x2ec}, {0x2ee, 0x2ee}, {0x300, 0x374}, {0x376, 0x377}, {0x37b, 0x37d}, {0x37f, 0x37f}, {0x386, 0x38a}, {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3f5}, @@ -467,14 +521,14 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (eof) ADVANCE(9); ADVANCE_MAP( '"', 3, - '#', 17, - '-', 13, - '.', 19, + '#', 15, + '-', 12, + '.', 17, '/', 10, - '=', 14, - '@', 22, - '{', 12, - '}', 15, + '=', 13, + '@', 20, + '{', 11, + '}', 14, ); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ' || @@ -483,25 +537,25 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == 0x200f || lookahead == 0x2028 || lookahead == 0x2029) SKIP(7); - if (set_contains(aux_sym_node_name_token1_character_set_1, 667, lookahead)) ADVANCE(18); + if (set_contains(aux_sym_id_attr_token1_character_set_1, 667, lookahead)) ADVANCE(16); END_STATE(); case 1: - if (lookahead == '"') ADVANCE(16); + if (lookahead == '"') ADVANCE(22); if (lookahead == '\\') ADVANCE(4); if (lookahead != 0) ADVANCE(1); END_STATE(); case 2: - if (lookahead == '@') ADVANCE(22); + if (lookahead == '@') ADVANCE(20); if (lookahead == '\\') ADVANCE(5); - if (lookahead == '}') ADVANCE(15); + if (lookahead == '}') ADVANCE(14); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ' || lookahead == 0x85 || lookahead == 0x200e || lookahead == 0x200f || lookahead == 0x2028 || - lookahead == 0x2029) ADVANCE(20); - if (lookahead != 0) ADVANCE(21); + lookahead == 0x2029) ADVANCE(18); + if (lookahead != 0) ADVANCE(19); END_STATE(); case 3: if (lookahead == '\\') ADVANCE(4); @@ -515,23 +569,23 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { case 5: if (lookahead == '@' || lookahead == '\\' || - lookahead == '}') ADVANCE(21); + lookahead == '}') ADVANCE(19); END_STATE(); case 6: - if (set_contains(aux_sym_node_name_token1_character_set_1, 667, lookahead)) ADVANCE(18); + if (set_contains(aux_sym_id_attr_token1_character_set_1, 667, lookahead)) ADVANCE(16); END_STATE(); case 7: if (eof) ADVANCE(9); ADVANCE_MAP( '"', 3, - '#', 17, - '-', 13, - '.', 19, + '#', 15, + '-', 12, + '.', 17, '/', 10, - '=', 14, - '@', 22, - '{', 12, - '}', 15, + '=', 13, + '@', 20, + '{', 11, + '}', 14, ); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ' || @@ -540,17 +594,17 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == 0x200f || lookahead == 0x2028 || lookahead == 0x2029) SKIP(7); - if (set_contains(aux_sym_node_name_token1_character_set_1, 667, lookahead)) ADVANCE(11); + if (set_contains(aux_sym_id_attr_token1_character_set_1, 667, lookahead)) ADVANCE(21); END_STATE(); case 8: if (eof) ADVANCE(9); - if (lookahead == '#') ADVANCE(17); - if (lookahead == '-') ADVANCE(13); - if (lookahead == '.') ADVANCE(19); + if (lookahead == '#') ADVANCE(15); + if (lookahead == '-') ADVANCE(12); + if (lookahead == '.') ADVANCE(17); if (lookahead == '/') ADVANCE(10); - if (lookahead == '=') ADVANCE(14); - if (lookahead == '{') ADVANCE(12); - if (lookahead == '}') ADVANCE(15); + if (lookahead == '=') ADVANCE(13); + if (lookahead == '{') ADVANCE(11); + if (lookahead == '}') ADVANCE(14); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ' || lookahead == 0x85 || @@ -558,7 +612,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == 0x200f || lookahead == 0x2028 || lookahead == 0x2029) SKIP(8); - if (set_contains(aux_sym_node_name_token1_character_set_1, 667, lookahead)) ADVANCE(11); + if (set_contains(aux_sym_id_attr_token1_character_set_1, 667, lookahead)) ADVANCE(21); END_STATE(); case 9: ACCEPT_TOKEN(ts_builtin_sym_end); @@ -567,35 +621,28 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { ACCEPT_TOKEN(anon_sym_SLASH); END_STATE(); case 11: - ACCEPT_TOKEN(aux_sym_node_name_token1); - if (set_contains(aux_sym_node_name_token1_character_set_2, 777, lookahead)) ADVANCE(11); - END_STATE(); - case 12: ACCEPT_TOKEN(anon_sym_LBRACE); END_STATE(); - case 13: + case 12: ACCEPT_TOKEN(anon_sym_DASH); END_STATE(); - case 14: + case 13: ACCEPT_TOKEN(anon_sym_EQ); END_STATE(); - case 15: + case 14: ACCEPT_TOKEN(anon_sym_RBRACE); END_STATE(); - case 16: - ACCEPT_TOKEN(aux_sym_attr_token1); - END_STATE(); - case 17: + case 15: ACCEPT_TOKEN(anon_sym_POUND); END_STATE(); - case 18: + case 16: ACCEPT_TOKEN(aux_sym_id_attr_token1); - if (set_contains(aux_sym_node_name_token1_character_set_2, 777, lookahead)) ADVANCE(18); + if (set_contains(aux_sym_id_attr_token1_character_set_2, 777, lookahead)) ADVANCE(16); END_STATE(); - case 19: + case 17: ACCEPT_TOKEN(anon_sym_DOT); END_STATE(); - case 20: + case 18: ACCEPT_TOKEN(aux_sym_text_token1); if (lookahead == '\\') ADVANCE(5); if (('\t' <= lookahead && lookahead <= '\r') || @@ -604,21 +651,28 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead == 0x200e || lookahead == 0x200f || lookahead == 0x2028 || - lookahead == 0x2029) ADVANCE(20); + lookahead == 0x2029) ADVANCE(18); if (lookahead != 0 && lookahead != '@' && - lookahead != '}') ADVANCE(21); + lookahead != '}') ADVANCE(19); END_STATE(); - case 21: + case 19: ACCEPT_TOKEN(aux_sym_text_token1); if (lookahead == '\\') ADVANCE(5); if (lookahead != 0 && lookahead != '@' && - lookahead != '}') ADVANCE(21); + lookahead != '}') ADVANCE(19); END_STATE(); - case 22: + case 20: ACCEPT_TOKEN(anon_sym_AT); END_STATE(); + case 21: + ACCEPT_TOKEN(sym_ident); + if (set_contains(aux_sym_id_attr_token1_character_set_2, 777, lookahead)) ADVANCE(21); + END_STATE(); + case 22: + ACCEPT_TOKEN(sym_string); + END_STATE(); default: return false; } @@ -638,530 +692,657 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [10] = {.lex_state = 8}, [11] = {.lex_state = 8}, [12] = {.lex_state = 8}, - [13] = {.lex_state = 2}, - [14] = {.lex_state = 2}, + [13] = {.lex_state = 8}, + [14] = {.lex_state = 8}, [15] = {.lex_state = 8}, [16] = {.lex_state = 8}, - [17] = {.lex_state = 8}, - [18] = {.lex_state = 8}, - [19] = {.lex_state = 2}, + [17] = {.lex_state = 2}, + [18] = {.lex_state = 2}, + [19] = {.lex_state = 8}, [20] = {.lex_state = 8}, [21] = {.lex_state = 8}, [22] = {.lex_state = 8}, - [23] = {.lex_state = 2}, - [24] = {.lex_state = 8}, + [23] = {.lex_state = 8}, + [24] = {.lex_state = 2}, [25] = {.lex_state = 8}, [26] = {.lex_state = 8}, - [27] = {.lex_state = 2}, - [28] = {.lex_state = 2}, + [27] = {.lex_state = 8}, + [28] = {.lex_state = 8}, [29] = {.lex_state = 8}, [30] = {.lex_state = 2}, - [31] = {.lex_state = 2}, - [32] = {.lex_state = 2}, + [31] = {.lex_state = 8}, + [32] = {.lex_state = 8}, [33] = {.lex_state = 2}, [34] = {.lex_state = 2}, - [35] = {.lex_state = 8}, - [36] = {.lex_state = 0}, - [37] = {.lex_state = 0}, - [38] = {.lex_state = 0}, - [39] = {.lex_state = 0}, - [40] = {.lex_state = 6}, - [41] = {.lex_state = 6}, - [42] = {.lex_state = 0}, + [35] = {.lex_state = 2}, + [36] = {.lex_state = 2}, + [37] = {.lex_state = 2}, + [38] = {.lex_state = 2}, + [39] = {.lex_state = 2}, + [40] = {.lex_state = 2}, + [41] = {.lex_state = 2}, + [42] = {.lex_state = 2}, [43] = {.lex_state = 0}, [44] = {.lex_state = 0}, + [45] = {.lex_state = 0}, + [46] = {.lex_state = 0}, + [47] = {.lex_state = 0}, + [48] = {.lex_state = 0}, + [49] = {.lex_state = 0}, + [50] = {.lex_state = 0}, + [51] = {.lex_state = 0}, + [52] = {.lex_state = 0}, + [53] = {.lex_state = 6}, + [54] = {.lex_state = 6}, + [55] = {.lex_state = 0}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [0] = { [ts_builtin_sym_end] = ACTIONS(1), [anon_sym_SLASH] = ACTIONS(1), - [aux_sym_node_name_token1] = ACTIONS(1), [anon_sym_LBRACE] = ACTIONS(1), [anon_sym_DASH] = ACTIONS(1), [anon_sym_EQ] = ACTIONS(1), [anon_sym_RBRACE] = ACTIONS(1), - [aux_sym_attr_token1] = ACTIONS(1), [anon_sym_POUND] = ACTIONS(1), [aux_sym_id_attr_token1] = ACTIONS(1), [anon_sym_DOT] = ACTIONS(1), [anon_sym_AT] = ACTIONS(1), + [sym_ident] = ACTIONS(1), + [sym_string] = ACTIONS(1), }, [1] = { - [sym_document] = STATE(43), - [sym__toplevel] = STATE(8), - [sym_comment] = STATE(8), - [sym_node] = STATE(8), - [sym_node_name] = STATE(2), - [aux_sym_document_repeat1] = STATE(8), + [sym_document] = STATE(49), + [sym__toplevel] = STATE(15), + [sym_comment] = STATE(15), + [sym_node] = STATE(15), + [aux_sym_document_repeat1] = STATE(15), [ts_builtin_sym_end] = ACTIONS(3), [anon_sym_SLASH] = ACTIONS(5), - [aux_sym_node_name_token1] = ACTIONS(7), + [sym_ident] = ACTIONS(7), }, }; static const uint16_t ts_small_parse_table[] = { - [0] = 7, + [0] = 8, ACTIONS(9), 1, - aux_sym_node_name_token1, + anon_sym_LBRACE, ACTIONS(11), 1, + anon_sym_EQ, + ACTIONS(13), 1, + anon_sym_POUND, + ACTIONS(15), 1, + anon_sym_DOT, + ACTIONS(17), 1, + sym_ident, + STATE(40), 1, + sym_node_body, + STATE(48), 1, + sym_attr_list, + STATE(11), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [28] = 8, + ACTIONS(11), 1, + anon_sym_EQ, + ACTIONS(13), 1, + anon_sym_POUND, + ACTIONS(15), 1, + anon_sym_DOT, + ACTIONS(17), 1, + sym_ident, + ACTIONS(19), 1, + anon_sym_LBRACE, + STATE(23), 1, + sym_node_body, + STATE(43), 1, + sym_attr_list, + STATE(11), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [56] = 7, + ACTIONS(13), 1, + anon_sym_POUND, + ACTIONS(15), 1, + anon_sym_DOT, + ACTIONS(19), 1, + anon_sym_LBRACE, + ACTIONS(21), 1, + sym_ident, + STATE(29), 1, + sym_node_body, + STATE(45), 1, + sym_attr_list, + STATE(11), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [81] = 7, + ACTIONS(13), 1, + anon_sym_POUND, + ACTIONS(15), 1, + anon_sym_DOT, + ACTIONS(17), 1, + sym_ident, + ACTIONS(19), 1, + anon_sym_LBRACE, + STATE(22), 1, + sym_node_body, + STATE(44), 1, + sym_attr_list, + STATE(11), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [106] = 7, + ACTIONS(9), 1, + anon_sym_LBRACE, + ACTIONS(13), 1, + anon_sym_POUND, + ACTIONS(15), 1, + anon_sym_DOT, + ACTIONS(23), 1, + sym_ident, + STATE(37), 1, + sym_node_body, + STATE(46), 1, + sym_attr_list, + STATE(11), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [131] = 7, + ACTIONS(9), 1, anon_sym_LBRACE, ACTIONS(13), 1, anon_sym_POUND, ACTIONS(15), 1, anon_sym_DOT, - STATE(15), 1, + ACTIONS(17), 1, + sym_ident, + STATE(38), 1, sym_node_body, - STATE(36), 1, - sym_attrs, + STATE(47), 1, + sym_attr_list, STATE(11), 4, sym_attr, sym_id_attr, sym_class_attr, - aux_sym_attrs_repeat1, - [25] = 6, + aux_sym_attr_list_repeat1, + [156] = 5, ACTIONS(5), 1, anon_sym_SLASH, ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(19), 1, + sym_ident, + ACTIONS(27), 1, anon_sym_RBRACE, - STATE(2), 1, - sym_node_name, - ACTIONS(17), 2, + ACTIONS(25), 2, anon_sym_DASH, anon_sym_EQ, - STATE(7), 4, + STATE(14), 4, sym__toplevel, sym_comment, sym_node, aux_sym_document_repeat1, - [48] = 6, + [176] = 5, ACTIONS(5), 1, anon_sym_SLASH, ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(23), 1, + sym_ident, + ACTIONS(31), 1, anon_sym_RBRACE, - STATE(2), 1, - sym_node_name, - ACTIONS(21), 2, + ACTIONS(29), 2, anon_sym_DASH, anon_sym_EQ, + STATE(13), 4, + sym__toplevel, + sym_comment, + sym_node, + aux_sym_document_repeat1, + [196] = 4, + ACTIONS(35), 1, + anon_sym_SLASH, + ACTIONS(38), 1, + sym_ident, + ACTIONS(33), 2, + ts_builtin_sym_end, + anon_sym_RBRACE, STATE(10), 4, sym__toplevel, sym_comment, sym_node, aux_sym_document_repeat1, - [71] = 7, - ACTIONS(9), 1, - aux_sym_node_name_token1, + [213] = 5, ACTIONS(13), 1, anon_sym_POUND, ACTIONS(15), 1, anon_sym_DOT, - ACTIONS(25), 1, + ACTIONS(17), 1, + sym_ident, + ACTIONS(41), 1, anon_sym_LBRACE, - STATE(27), 1, - sym_node_body, - STATE(37), 1, - sym_attrs, - STATE(11), 4, + STATE(12), 4, sym_attr, sym_id_attr, sym_class_attr, - aux_sym_attrs_repeat1, - [96] = 5, - ACTIONS(29), 1, - anon_sym_SLASH, - ACTIONS(32), 1, - aux_sym_node_name_token1, - STATE(2), 1, - sym_node_name, - ACTIONS(27), 2, - ts_builtin_sym_end, - anon_sym_RBRACE, - STATE(6), 4, - sym__toplevel, - sym_comment, - sym_node, - aux_sym_document_repeat1, - [116] = 5, + aux_sym_attr_list_repeat1, + [232] = 5, + ACTIONS(43), 1, + anon_sym_LBRACE, + ACTIONS(45), 1, + anon_sym_POUND, + ACTIONS(48), 1, + anon_sym_DOT, + ACTIONS(51), 1, + sym_ident, + STATE(12), 4, + sym_attr, + sym_id_attr, + sym_class_attr, + aux_sym_attr_list_repeat1, + [251] = 4, ACTIONS(5), 1, anon_sym_SLASH, ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(35), 1, + sym_ident, + ACTIONS(54), 1, anon_sym_RBRACE, - STATE(2), 1, - sym_node_name, - STATE(6), 4, + STATE(10), 4, sym__toplevel, sym_comment, sym_node, aux_sym_document_repeat1, - [135] = 5, + [267] = 4, ACTIONS(5), 1, anon_sym_SLASH, ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(37), 1, - ts_builtin_sym_end, - STATE(2), 1, - sym_node_name, - STATE(6), 4, + sym_ident, + ACTIONS(56), 1, + anon_sym_RBRACE, + STATE(10), 4, sym__toplevel, sym_comment, sym_node, aux_sym_document_repeat1, - [154] = 5, - ACTIONS(39), 1, - aux_sym_node_name_token1, - ACTIONS(42), 1, - anon_sym_LBRACE, - ACTIONS(44), 1, - anon_sym_POUND, - ACTIONS(47), 1, - anon_sym_DOT, - STATE(9), 4, - sym_attr, - sym_id_attr, - sym_class_attr, - aux_sym_attrs_repeat1, - [173] = 5, + [283] = 4, ACTIONS(5), 1, anon_sym_SLASH, ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(50), 1, - anon_sym_RBRACE, - STATE(2), 1, - sym_node_name, - STATE(6), 4, + sym_ident, + ACTIONS(58), 1, + ts_builtin_sym_end, + STATE(10), 4, sym__toplevel, sym_comment, sym_node, aux_sym_document_repeat1, - [192] = 5, - ACTIONS(9), 1, - aux_sym_node_name_token1, - ACTIONS(13), 1, - anon_sym_POUND, - ACTIONS(15), 1, - anon_sym_DOT, - ACTIONS(52), 1, - anon_sym_LBRACE, - STATE(9), 4, - sym_attr, - sym_id_attr, - sym_class_attr, - aux_sym_attrs_repeat1, - [211] = 4, - ACTIONS(7), 1, - aux_sym_node_name_token1, - ACTIONS(54), 1, + [299] = 3, + ACTIONS(60), 1, anon_sym_SLASH, - STATE(5), 1, - sym_node_name, - STATE(28), 3, + ACTIONS(62), 1, + sym_ident, + STATE(36), 3, sym__toplevel, sym_comment, sym_node, - [226] = 5, - ACTIONS(56), 1, + [311] = 5, + ACTIONS(64), 1, anon_sym_RBRACE, - ACTIONS(58), 1, + ACTIONS(66), 1, aux_sym_text_token1, - ACTIONS(60), 1, + ACTIONS(68), 1, anon_sym_AT, - STATE(23), 1, + STATE(30), 1, aux_sym_text_repeat1, - STATE(44), 1, + STATE(55), 1, sym_text, - [242] = 5, - ACTIONS(58), 1, + [327] = 5, + ACTIONS(66), 1, aux_sym_text_token1, - ACTIONS(60), 1, + ACTIONS(68), 1, anon_sym_AT, - ACTIONS(62), 1, + ACTIONS(70), 1, anon_sym_RBRACE, - STATE(23), 1, + STATE(30), 1, aux_sym_text_repeat1, - STATE(38), 1, + STATE(50), 1, sym_text, - [258] = 1, - ACTIONS(64), 4, - ts_builtin_sym_end, - anon_sym_SLASH, - aux_sym_node_name_token1, - anon_sym_RBRACE, - [265] = 1, - ACTIONS(66), 4, + [343] = 1, + ACTIONS(72), 4, ts_builtin_sym_end, anon_sym_SLASH, - aux_sym_node_name_token1, anon_sym_RBRACE, - [272] = 1, - ACTIONS(68), 4, - aux_sym_node_name_token1, + sym_ident, + [350] = 1, + ACTIONS(74), 4, anon_sym_LBRACE, anon_sym_POUND, anon_sym_DOT, - [279] = 1, - ACTIONS(70), 4, + sym_ident, + [357] = 1, + ACTIONS(76), 4, + anon_sym_LBRACE, + anon_sym_POUND, + anon_sym_DOT, + sym_ident, + [364] = 1, + ACTIONS(78), 4, ts_builtin_sym_end, anon_sym_SLASH, - aux_sym_node_name_token1, anon_sym_RBRACE, - [286] = 4, - ACTIONS(72), 1, + sym_ident, + [371] = 1, + ACTIONS(80), 4, + ts_builtin_sym_end, + anon_sym_SLASH, anon_sym_RBRACE, - ACTIONS(74), 1, + sym_ident, + [378] = 4, + ACTIONS(82), 1, + anon_sym_RBRACE, + ACTIONS(84), 1, aux_sym_text_token1, - ACTIONS(77), 1, + ACTIONS(87), 1, anon_sym_AT, - STATE(19), 1, + STATE(24), 1, aux_sym_text_repeat1, - [299] = 1, - ACTIONS(80), 4, - aux_sym_node_name_token1, - anon_sym_LBRACE, - anon_sym_POUND, - anon_sym_DOT, - [306] = 1, - ACTIONS(82), 4, - aux_sym_node_name_token1, - anon_sym_LBRACE, - anon_sym_POUND, - anon_sym_DOT, - [313] = 1, - ACTIONS(84), 4, + [391] = 1, + ACTIONS(90), 4, ts_builtin_sym_end, anon_sym_SLASH, - aux_sym_node_name_token1, anon_sym_RBRACE, - [320] = 4, - ACTIONS(60), 1, + sym_ident, + [398] = 1, + ACTIONS(92), 4, + ts_builtin_sym_end, + anon_sym_SLASH, + anon_sym_RBRACE, + sym_ident, + [405] = 1, + ACTIONS(94), 4, + ts_builtin_sym_end, + anon_sym_SLASH, + anon_sym_RBRACE, + sym_ident, + [412] = 1, + ACTIONS(96), 4, + ts_builtin_sym_end, + anon_sym_SLASH, + anon_sym_RBRACE, + sym_ident, + [419] = 1, + ACTIONS(98), 4, + ts_builtin_sym_end, + anon_sym_SLASH, + anon_sym_RBRACE, + sym_ident, + [426] = 4, + ACTIONS(68), 1, anon_sym_AT, - ACTIONS(86), 1, + ACTIONS(100), 1, anon_sym_RBRACE, - ACTIONS(88), 1, + ACTIONS(102), 1, aux_sym_text_token1, - STATE(19), 1, + STATE(24), 1, aux_sym_text_repeat1, - [333] = 1, - ACTIONS(90), 4, - aux_sym_node_name_token1, + [439] = 1, + ACTIONS(104), 4, anon_sym_LBRACE, anon_sym_POUND, anon_sym_DOT, - [340] = 1, - ACTIONS(92), 4, + sym_ident, + [446] = 1, + ACTIONS(106), 4, ts_builtin_sym_end, anon_sym_SLASH, - aux_sym_node_name_token1, anon_sym_RBRACE, - [347] = 1, - ACTIONS(94), 4, - ts_builtin_sym_end, - anon_sym_SLASH, - aux_sym_node_name_token1, + sym_ident, + [453] = 2, + ACTIONS(94), 1, + aux_sym_text_token1, + ACTIONS(108), 2, anon_sym_RBRACE, - [354] = 2, - ACTIONS(64), 1, + anon_sym_AT, + [461] = 2, + ACTIONS(106), 1, aux_sym_text_token1, - ACTIONS(96), 2, + ACTIONS(110), 2, anon_sym_RBRACE, anon_sym_AT, - [362] = 2, - ACTIONS(98), 1, + [469] = 2, + ACTIONS(72), 1, aux_sym_text_token1, - ACTIONS(72), 2, + ACTIONS(112), 2, anon_sym_RBRACE, anon_sym_AT, - [370] = 3, - ACTIONS(7), 1, - aux_sym_node_name_token1, - STATE(2), 1, - sym_node_name, - STATE(26), 1, - sym_node, - [380] = 2, - ACTIONS(94), 1, + [477] = 2, + ACTIONS(114), 1, aux_sym_text_token1, - ACTIONS(100), 2, + ACTIONS(82), 2, anon_sym_RBRACE, anon_sym_AT, - [388] = 2, - ACTIONS(70), 1, + [485] = 2, + ACTIONS(98), 1, aux_sym_text_token1, - ACTIONS(102), 2, + ACTIONS(116), 2, anon_sym_RBRACE, anon_sym_AT, - [396] = 2, - ACTIONS(84), 1, + [493] = 2, + ACTIONS(78), 1, aux_sym_text_token1, - ACTIONS(104), 2, + ACTIONS(118), 2, anon_sym_RBRACE, anon_sym_AT, - [404] = 2, + [501] = 2, ACTIONS(92), 1, aux_sym_text_token1, - ACTIONS(106), 2, + ACTIONS(120), 2, anon_sym_RBRACE, anon_sym_AT, - [412] = 2, - ACTIONS(66), 1, + [509] = 2, + ACTIONS(80), 1, aux_sym_text_token1, - ACTIONS(108), 2, + ACTIONS(122), 2, anon_sym_RBRACE, anon_sym_AT, - [420] = 3, - ACTIONS(7), 1, - aux_sym_node_name_token1, - STATE(5), 1, - sym_node_name, - STATE(30), 1, - sym_node, - [430] = 2, - ACTIONS(11), 1, + [517] = 2, + ACTIONS(90), 1, + aux_sym_text_token1, + ACTIONS(124), 2, + anon_sym_RBRACE, + anon_sym_AT, + [525] = 2, + ACTIONS(96), 1, + aux_sym_text_token1, + ACTIONS(126), 2, + anon_sym_RBRACE, + anon_sym_AT, + [533] = 2, + ACTIONS(19), 1, anon_sym_LBRACE, - STATE(22), 1, + STATE(32), 1, sym_node_body, - [437] = 2, - ACTIONS(25), 1, + [540] = 2, + ACTIONS(19), 1, anon_sym_LBRACE, - STATE(32), 1, + STATE(27), 1, sym_node_body, - [444] = 1, - ACTIONS(110), 1, + [547] = 2, + ACTIONS(19), 1, + anon_sym_LBRACE, + STATE(25), 1, + sym_node_body, + [554] = 2, + ACTIONS(9), 1, + anon_sym_LBRACE, + STATE(41), 1, + sym_node_body, + [561] = 2, + ACTIONS(9), 1, + anon_sym_LBRACE, + STATE(33), 1, + sym_node_body, + [568] = 2, + ACTIONS(9), 1, + anon_sym_LBRACE, + STATE(34), 1, + sym_node_body, + [575] = 1, + ACTIONS(128), 1, + ts_builtin_sym_end, + [579] = 1, + ACTIONS(130), 1, anon_sym_RBRACE, - [448] = 1, - ACTIONS(112), 1, - aux_sym_attr_token1, - [452] = 1, - ACTIONS(114), 1, + [583] = 1, + ACTIONS(132), 1, + sym_string, + [587] = 1, + ACTIONS(11), 1, + anon_sym_EQ, + [591] = 1, + ACTIONS(134), 1, aux_sym_id_attr_token1, - [456] = 1, - ACTIONS(116), 1, + [595] = 1, + ACTIONS(136), 1, aux_sym_id_attr_token1, - [460] = 1, - ACTIONS(118), 1, - anon_sym_EQ, - [464] = 1, - ACTIONS(120), 1, - ts_builtin_sym_end, - [468] = 1, - ACTIONS(122), 1, + [599] = 1, + ACTIONS(138), 1, anon_sym_RBRACE, }; static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(2)] = 0, - [SMALL_STATE(3)] = 25, - [SMALL_STATE(4)] = 48, - [SMALL_STATE(5)] = 71, - [SMALL_STATE(6)] = 96, - [SMALL_STATE(7)] = 116, - [SMALL_STATE(8)] = 135, - [SMALL_STATE(9)] = 154, - [SMALL_STATE(10)] = 173, - [SMALL_STATE(11)] = 192, - [SMALL_STATE(12)] = 211, - [SMALL_STATE(13)] = 226, - [SMALL_STATE(14)] = 242, - [SMALL_STATE(15)] = 258, - [SMALL_STATE(16)] = 265, - [SMALL_STATE(17)] = 272, - [SMALL_STATE(18)] = 279, - [SMALL_STATE(19)] = 286, - [SMALL_STATE(20)] = 299, - [SMALL_STATE(21)] = 306, - [SMALL_STATE(22)] = 313, - [SMALL_STATE(23)] = 320, - [SMALL_STATE(24)] = 333, - [SMALL_STATE(25)] = 340, - [SMALL_STATE(26)] = 347, - [SMALL_STATE(27)] = 354, - [SMALL_STATE(28)] = 362, - [SMALL_STATE(29)] = 370, - [SMALL_STATE(30)] = 380, - [SMALL_STATE(31)] = 388, - [SMALL_STATE(32)] = 396, - [SMALL_STATE(33)] = 404, - [SMALL_STATE(34)] = 412, - [SMALL_STATE(35)] = 420, - [SMALL_STATE(36)] = 430, - [SMALL_STATE(37)] = 437, - [SMALL_STATE(38)] = 444, - [SMALL_STATE(39)] = 448, - [SMALL_STATE(40)] = 452, - [SMALL_STATE(41)] = 456, - [SMALL_STATE(42)] = 460, - [SMALL_STATE(43)] = 464, - [SMALL_STATE(44)] = 468, + [SMALL_STATE(3)] = 28, + [SMALL_STATE(4)] = 56, + [SMALL_STATE(5)] = 81, + [SMALL_STATE(6)] = 106, + [SMALL_STATE(7)] = 131, + [SMALL_STATE(8)] = 156, + [SMALL_STATE(9)] = 176, + [SMALL_STATE(10)] = 196, + [SMALL_STATE(11)] = 213, + [SMALL_STATE(12)] = 232, + [SMALL_STATE(13)] = 251, + [SMALL_STATE(14)] = 267, + [SMALL_STATE(15)] = 283, + [SMALL_STATE(16)] = 299, + [SMALL_STATE(17)] = 311, + [SMALL_STATE(18)] = 327, + [SMALL_STATE(19)] = 343, + [SMALL_STATE(20)] = 350, + [SMALL_STATE(21)] = 357, + [SMALL_STATE(22)] = 364, + [SMALL_STATE(23)] = 371, + [SMALL_STATE(24)] = 378, + [SMALL_STATE(25)] = 391, + [SMALL_STATE(26)] = 398, + [SMALL_STATE(27)] = 405, + [SMALL_STATE(28)] = 412, + [SMALL_STATE(29)] = 419, + [SMALL_STATE(30)] = 426, + [SMALL_STATE(31)] = 439, + [SMALL_STATE(32)] = 446, + [SMALL_STATE(33)] = 453, + [SMALL_STATE(34)] = 461, + [SMALL_STATE(35)] = 469, + [SMALL_STATE(36)] = 477, + [SMALL_STATE(37)] = 485, + [SMALL_STATE(38)] = 493, + [SMALL_STATE(39)] = 501, + [SMALL_STATE(40)] = 509, + [SMALL_STATE(41)] = 517, + [SMALL_STATE(42)] = 525, + [SMALL_STATE(43)] = 533, + [SMALL_STATE(44)] = 540, + [SMALL_STATE(45)] = 547, + [SMALL_STATE(46)] = 554, + [SMALL_STATE(47)] = 561, + [SMALL_STATE(48)] = 568, + [SMALL_STATE(49)] = 575, + [SMALL_STATE(50)] = 579, + [SMALL_STATE(51)] = 583, + [SMALL_STATE(52)] = 587, + [SMALL_STATE(53)] = 591, + [SMALL_STATE(54)] = 595, + [SMALL_STATE(55)] = 599, }; static const TSParseActionEntry ts_parse_actions[] = { [0] = {.entry = {.count = 0, .reusable = false}}, [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 0, 0, 0), - [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), - [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), - [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), - [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), - [23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), - [25] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), - [29] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), SHIFT_REPEAT(29), - [32] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), SHIFT_REPEAT(17), - [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), - [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1, 0, 0), - [39] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attrs_repeat1, 2, 0, 0), SHIFT_REPEAT(42), - [42] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_attrs_repeat1, 2, 0, 0), - [44] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attrs_repeat1, 2, 0, 0), SHIFT_REPEAT(41), - [47] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attrs_repeat1, 2, 0, 0), SHIFT_REPEAT(40), - [50] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), - [52] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attrs, 1, 0, 0), - [54] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), - [56] = {.entry = {.count = 1, .reusable = false}}, SHIFT(33), - [58] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), - [60] = {.entry = {.count = 1, .reusable = false}}, SHIFT(12), - [62] = {.entry = {.count = 1, .reusable = false}}, SHIFT(25), - [64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node, 2, 0, 0), - [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 4, 0, 0), - [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_name, 1, 0, 0), - [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 2, 0, 0), - [72] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), - [74] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), SHIFT_REPEAT(19), - [77] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), SHIFT_REPEAT(12), - [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_id_attr, 2, 0, 0), - [82] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_class_attr, 2, 0, 0), - [84] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node, 3, 0, 0), - [86] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_text, 1, 0, 0), - [88] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attr, 3, 0, 0), - [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 3, 0, 0), - [94] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), - [96] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node, 2, 0, 0), - [98] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), - [100] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 2, 0, 0), - [102] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 2, 0, 0), - [104] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node, 3, 0, 0), - [106] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 3, 0, 0), - [108] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 4, 0, 0), - [110] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [112] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), - [114] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), - [116] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), - [118] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), - [120] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [122] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(51), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), + [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), + [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), + [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [25] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), + [27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), + [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), + [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), + [35] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), SHIFT_REPEAT(4), + [38] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2, 0, 0), SHIFT_REPEAT(5), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attr_list, 1, 0, 0), + [43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_attr_list_repeat1, 2, 0, 0), + [45] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attr_list_repeat1, 2, 0, 0), SHIFT_REPEAT(54), + [48] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attr_list_repeat1, 2, 0, 0), SHIFT_REPEAT(53), + [51] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attr_list_repeat1, 2, 0, 0), SHIFT_REPEAT(52), + [54] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), + [56] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), + [58] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1, 0, 0), + [60] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [62] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [64] = {.entry = {.count = 1, .reusable = false}}, SHIFT(42), + [66] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), + [68] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), + [70] = {.entry = {.count = 1, .reusable = false}}, SHIFT(28), + [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 4, 0, 0), + [74] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_id_attr, 2, 0, 0), + [76] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_class_attr, 2, 0, 0), + [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node, 2, 0, 2), + [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 3, 0, 3), + [82] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), + [84] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), SHIFT_REPEAT(24), + [87] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), SHIFT_REPEAT(16), + [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 3, 0, 4), + [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 2, 0, 0), + [94] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node, 3, 0, 5), + [96] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_node_body, 3, 0, 0), + [98] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 1), + [100] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_text, 1, 0, 0), + [102] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), + [104] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attr, 3, 0, 6), + [106] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 4, 0, 7), + [108] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node, 3, 0, 5), + [110] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 4, 0, 7), + [112] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 4, 0, 0), + [114] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_text_repeat1, 2, 0, 0), + [116] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 2, 0, 1), + [118] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node, 2, 0, 2), + [120] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 2, 0, 0), + [122] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 3, 0, 3), + [124] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 3, 0, 4), + [126] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_node_body, 3, 0, 0), + [128] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [130] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [132] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), + [134] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), + [136] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), + [138] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), }; #ifdef __cplusplus @@ -1192,6 +1373,9 @@ TS_PUBLIC const TSLanguage *tree_sitter_gsp(void) { .small_parse_table_map = ts_small_parse_table_map, .parse_actions = ts_parse_actions, .symbol_names = ts_symbol_names, + .field_names = ts_field_names, + .field_map_slices = ts_field_map_slices, + .field_map_entries = ts_field_map_entries, .symbol_metadata = ts_symbol_metadata, .public_symbol_map = ts_symbol_map, .alias_map = ts_non_terminal_alias_map, diff --git a/test/corpus/document.txt b/test/corpus/document.txt new file mode 100644 index 0000000..5a8f304 --- /dev/null +++ b/test/corpus/document.txt @@ -0,0 +1,156 @@ +========================= +Complete Document Example +========================= + +html lang="en" { + head { + meta charset="UTF-8" {} + meta + name="viewport" + content="width=device-width, initial-scale=1.0" + {} + link href="/favicon.svg" rel="shortcut icon" type="image/svg" {} + link href="/style.svg" rel="stylesheet" {} + title {-My Website Title} + } + + body { + p #my-id {= This is a paragraph with the id ‘my-id’ } + p .my-cls {= This is a paragraph with the class ‘my-cls’ } + + / div { + p {- This entire div is commented out. } + p {- Isn’t that neat? } + } + + p + #some-id + .class-1 + .class-2 + key-1="value-1" + key-2 = "value-2" + {- + This paragraph has an ID, two classes, and two additional + attributes. GSP allows us to use the ‘#ident’ and ‘.ident’ + syntaxes as shorthands for applying IDs, and classes. This + is a text node, so nothing is being interpreted as GSP nodes, + but we can include them inline if we want. As an example, + here is some @em {-emphatic} text. Your inline nodes can + also have attributes @em #id {-just like a regular node}. + } + } +} + +--- + +(document + (node + name: (ident) + attrs: (attr_list + (attr + name: (ident) + value: (string))) + body: (node_body + (node + name: (ident) + body: (node_body + (node + name: (ident) + attrs: (attr_list + (attr + name: (ident) + value: (string))) + body: (node_body)) + (node + name: (ident) + attrs: (attr_list + (attr + name: (ident) + value: (string)) + (attr + name: (ident) + value: (string))) + body: (node_body)) + (node + name: (ident) + attrs: (attr_list + (attr + name: (ident) + value: (string)) + (attr + name: (ident) + value: (string)) + (attr + name: (ident) + value: (string))) + body: (node_body)) + (node + name: (ident) + attrs: (attr_list + (attr + name: (ident) + value: (string)) + (attr + name: (ident) + value: (string))) + body: (node_body)) + (node + name: (ident) + body: (node_body + (text))))) + (node + name: (ident) + body: (node_body + (node + name: (ident) + attrs: (attr_list + (id_attr + (ident))) + body: (node_body + (text))) + (node + name: (ident) + attrs: (attr_list + (class_attr + (ident))) + body: (node_body + (text))) + (comment + name: (ident) + body: (node_body + (node + name: (ident) + body: (node_body + (text))) + (node + name: (ident) + body: (node_body + (text))))) + (node + name: (ident) + attrs: (attr_list + (id_attr + (ident)) + (class_attr + (ident)) + (class_attr + (ident)) + (attr + name: (ident) + value: (string)) + (attr + name: (ident) + value: (string))) + body: (node_body + (text + (node + name: (ident) + body: (node_body + (text))) + (node + name: (ident) + attrs: (attr_list + (id_attr + (ident))) + body: (node_body + (text))))))))))) |