From eea28360bc0250a6e734d794316dd824ef420678 Mon Sep 17 00:00:00 2001 From: jupblb Date: Wed, 18 Mar 2026 13:37:19 +0100 Subject: [PATCH 1/4] reprolang: add explicit 'local' keyword for file-scoped symbols Replace the implicit local symbol convention (names starting with 'local') with an explicit 'local' keyword in the grammar. Symbols are now either: - Global (default): visible across files, no keyword needed. Use 'global' with project name + descriptors for cross-repo references. - Local: file-scoped, requires the 'local' keyword. This fixes a latent bug where any symbol whose name happened to start with 'local' was incorrectly treated as file-scoped. Also fix .gitattributes paths (src/ -> grammar/) to match the actual tree-sitter output directory. --- reprolang/.gitattributes | 12 +- reprolang/README.md | 15 +- reprolang/grammar.js | 3 + reprolang/grammar/grammar.json | 25 + reprolang/grammar/node-types.json | 30 + reprolang/grammar/parser.c | 820 ++++++++++-------- reprolang/repro/ast.go | 14 +- reprolang/repro/namer.go | 2 +- .../input/local-document/local1.repro | 5 +- .../input/local-document/local2.repro | 4 +- .../missing-symbol-information/locals.repro | 4 +- .../snapshots/input/relationships/mixed.repro | 8 +- .../input/relationships/references.repro | 4 +- .../input/relationships/type_defines.repro | 4 +- .../output/local-document/local1.repro | 11 +- .../output/local-document/local2.repro | 11 +- .../missing-symbol-information/locals.repro | 9 +- .../output/relationships/mixed.repro | 36 +- .../output/relationships/references.repro | 16 +- .../output/relationships/type_defines.repro | 16 +- 20 files changed, 618 insertions(+), 431 deletions(-) diff --git a/reprolang/.gitattributes b/reprolang/.gitattributes index 8e0f381b..e62e60b4 100644 --- a/reprolang/.gitattributes +++ b/reprolang/.gitattributes @@ -1,6 +1,6 @@ -src/grammar.json linguist-generated=true -src/node-types.json linguist-generated=true -src/parser.c linguist-generated=true -src/tree_sitter/alloc.h linguist-generated=true -src/tree_sitter/array.h linguist-generated=true -src/tree_sitter/parser.h linguist-generated=true +grammar/grammar.json linguist-generated=true +grammar/node-types.json linguist-generated=true +grammar/parser.c linguist-generated=true +grammar/tree_sitter/alloc.h linguist-generated=true +grammar/tree_sitter/array.h linguist-generated=true +grammar/tree_sitter/parser.h linguist-generated=true diff --git a/reprolang/README.md b/reprolang/README.md index 8a8dc520..aecfe5e4 100644 --- a/reprolang/README.md +++ b/reprolang/README.md @@ -10,13 +10,26 @@ relationships between them. The indexer parses these files with a tree-sitter grammar and emits a complete SCIP index, making it possible to write concise, deterministic test cases for any SCIP capability. +## Symbol scoping + +Reprolang supports two levels of symbol scope: + +- **Global** (default): Visible across all files in the same project. + No keyword needed. Use the `global` keyword with a project name and + descriptors to reference symbols from an external project/dependency. +- **Local**: Scoped to a single file. Use the `local` keyword. + ## Example ``` -# Define a symbol and reference it +# Define a global symbol and reference it definition hello(). reference hello(). +# Local symbol (file-scoped) +definition local myHelper +reference local myHelper + # Forward reference (reference before definition) reference forward_definition abc# definition abc# diff --git a/reprolang/grammar.js b/reprolang/grammar.js index 1d1d3751..1dfb95cf 100644 --- a/reprolang/grammar.js +++ b/reprolang/grammar.js @@ -54,9 +54,12 @@ module.exports = grammar({ docstring: $ => seq('# docstring:', /.*/), identifier: $ => choice( + field('local', $.local_identifier), field('global', $.global_identifier), field('workspace', $.workspace_identifier) ), + local_identifier: $ => + seq('local', field('name', $.workspace_identifier)), global_identifier: $ => seq( 'global', diff --git a/reprolang/grammar/grammar.json b/reprolang/grammar/grammar.json index 17dc20b2..f3b86129 100644 --- a/reprolang/grammar/grammar.json +++ b/reprolang/grammar/grammar.json @@ -281,6 +281,14 @@ "identifier": { "type": "CHOICE", "members": [ + { + "type": "FIELD", + "name": "local", + "content": { + "type": "SYMBOL", + "name": "local_identifier" + } + }, { "type": "FIELD", "name": "global", @@ -299,6 +307,23 @@ } ] }, + "local_identifier": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "local" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "workspace_identifier" + } + } + ] + }, "global_identifier": { "type": "SEQ", "members": [ diff --git a/reprolang/grammar/node-types.json b/reprolang/grammar/node-types.json index c02f0aa5..3295405d 100644 --- a/reprolang/grammar/node-types.json +++ b/reprolang/grammar/node-types.json @@ -113,6 +113,16 @@ } ] }, + "local": { + "multiple": false, + "required": false, + "types": [ + { + "type": "local_identifier", + "named": true + } + ] + }, "workspace": { "multiple": false, "required": false, @@ -141,6 +151,22 @@ } } }, + { + "type": "local_identifier", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "workspace_identifier", + "named": true + } + ] + } + } + }, { "type": "reference_statement", "named": true, @@ -297,6 +323,10 @@ "type": "implements", "named": false }, + { + "type": "local", + "named": false + }, { "type": "reference", "named": false diff --git a/reprolang/grammar/parser.c b/reprolang/grammar/parser.c index 31181288..98c0babf 100644 --- a/reprolang/grammar/parser.c +++ b/reprolang/grammar/parser.c @@ -7,16 +7,16 @@ #endif #define LANGUAGE_VERSION 14 -#define STATE_COUNT 41 +#define STATE_COUNT 44 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 33 +#define SYMBOL_COUNT 35 #define ALIAS_COUNT 0 -#define TOKEN_COUNT 15 +#define TOKEN_COUNT 16 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 8 +#define FIELD_COUNT 9 #define MAX_ALIAS_SEQUENCE_LENGTH 5 #define MAX_RESERVED_WORD_SET_SIZE 0 -#define PRODUCTION_ID_COUNT 9 +#define PRODUCTION_ID_COUNT 10 #define SUPERTYPE_COUNT 0 enum ts_symbol_identifiers { @@ -33,25 +33,27 @@ enum ts_symbol_identifiers { anon_sym_POUND = 11, aux_sym_comment_token1 = 12, anon_sym_POUNDdocstring_COLON = 13, - anon_sym_global = 14, - sym_source_file = 15, - sym__statement = 16, - sym_definition_statement = 17, - sym_reference_statement = 18, - sym__definition_relations = 19, - sym_implementation_relation = 20, - sym_type_definition_relation = 21, - sym_references_relation = 22, - sym_relationships_statement = 23, - sym__all_relations = 24, - sym_defined_by_relation = 25, - sym_comment = 26, - sym_docstring = 27, - sym_identifier = 28, - sym_global_identifier = 29, - aux_sym_source_file_repeat1 = 30, - aux_sym_definition_statement_repeat1 = 31, - aux_sym_relationships_statement_repeat1 = 32, + anon_sym_local = 14, + anon_sym_global = 15, + sym_source_file = 16, + sym__statement = 17, + sym_definition_statement = 18, + sym_reference_statement = 19, + sym__definition_relations = 20, + sym_implementation_relation = 21, + sym_type_definition_relation = 22, + sym_references_relation = 23, + sym_relationships_statement = 24, + sym__all_relations = 25, + sym_defined_by_relation = 26, + sym_comment = 27, + sym_docstring = 28, + sym_identifier = 29, + sym_local_identifier = 30, + sym_global_identifier = 31, + aux_sym_source_file_repeat1 = 32, + aux_sym_definition_statement_repeat1 = 33, + aux_sym_relationships_statement_repeat1 = 34, }; static const char * const ts_symbol_names[] = { @@ -69,6 +71,7 @@ static const char * const ts_symbol_names[] = { [anon_sym_POUND] = "#", [aux_sym_comment_token1] = "comment_token1", [anon_sym_POUNDdocstring_COLON] = "# docstring:", + [anon_sym_local] = "local", [anon_sym_global] = "global", [sym_source_file] = "source_file", [sym__statement] = "_statement", @@ -84,6 +87,7 @@ static const char * const ts_symbol_names[] = { [sym_comment] = "comment", [sym_docstring] = "docstring", [sym_identifier] = "identifier", + [sym_local_identifier] = "local_identifier", [sym_global_identifier] = "global_identifier", [aux_sym_source_file_repeat1] = "source_file_repeat1", [aux_sym_definition_statement_repeat1] = "definition_statement_repeat1", @@ -105,6 +109,7 @@ static const TSSymbol ts_symbol_map[] = { [anon_sym_POUND] = anon_sym_POUND, [aux_sym_comment_token1] = aux_sym_comment_token1, [anon_sym_POUNDdocstring_COLON] = anon_sym_POUNDdocstring_COLON, + [anon_sym_local] = anon_sym_local, [anon_sym_global] = anon_sym_global, [sym_source_file] = sym_source_file, [sym__statement] = sym__statement, @@ -120,6 +125,7 @@ static const TSSymbol ts_symbol_map[] = { [sym_comment] = sym_comment, [sym_docstring] = sym_docstring, [sym_identifier] = sym_identifier, + [sym_local_identifier] = sym_local_identifier, [sym_global_identifier] = sym_global_identifier, [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, [aux_sym_definition_statement_repeat1] = aux_sym_definition_statement_repeat1, @@ -183,6 +189,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, + [anon_sym_local] = { + .visible = true, + .named = false, + }, [anon_sym_global] = { .visible = true, .named = false, @@ -243,6 +253,10 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = true, }, + [sym_local_identifier] = { + .visible = true, + .named = true, + }, [sym_global_identifier] = { .visible = true, .named = true, @@ -266,10 +280,11 @@ enum ts_field_identifiers { field_docstring = 2, field_forward_definition = 3, field_global = 4, - field_name = 5, - field_project_name = 6, - field_roles = 7, - field_workspace = 8, + field_local = 5, + field_name = 6, + field_project_name = 7, + field_roles = 8, + field_workspace = 9, }; static const char * const ts_field_names[] = { @@ -278,6 +293,7 @@ static const char * const ts_field_names[] = { [field_docstring] = "docstring", [field_forward_definition] = "forward_definition", [field_global] = "global", + [field_local] = "local", [field_name] = "name", [field_project_name] = "project_name", [field_roles] = "roles", @@ -288,11 +304,12 @@ static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 1}, [2] = {.index = 1, .length = 1}, [3] = {.index = 2, .length = 1}, - [4] = {.index = 3, .length = 2}, - [5] = {.index = 5, .length = 2}, - [6] = {.index = 7, .length = 2}, - [7] = {.index = 9, .length = 3}, - [8] = {.index = 12, .length = 4}, + [4] = {.index = 3, .length = 1}, + [5] = {.index = 4, .length = 2}, + [6] = {.index = 6, .length = 2}, + [7] = {.index = 8, .length = 2}, + [8] = {.index = 10, .length = 3}, + [9] = {.index = 13, .length = 4}, }; static const TSFieldMapEntry ts_field_map_entries[] = { @@ -301,21 +318,23 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [1] = {field_name, 1}, [2] = - {field_global, 0}, + {field_local, 0}, [3] = + {field_global, 0}, + [4] = {field_name, 1}, {field_roles, 2}, - [5] = + [6] = {field_forward_definition, 1}, {field_name, 2}, - [7] = + [8] = {field_descriptors, 2}, {field_project_name, 1}, - [9] = + [10] = {field_docstring, 0}, {field_docstring, 1}, {field_name, 3}, - [12] = + [13] = {field_docstring, 0}, {field_docstring, 1}, {field_name, 3}, @@ -372,6 +391,9 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [38] = 38, [39] = 39, [40] = 40, + [41] = 41, + [42] = 42, + [43] = 43, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { @@ -793,207 +815,223 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'f') ADVANCE(2); if (lookahead == 'g') ADVANCE(3); if (lookahead == 'i') ADVANCE(4); - if (lookahead == 'r') ADVANCE(5); - if (lookahead == 't') ADVANCE(6); + if (lookahead == 'l') ADVANCE(5); + if (lookahead == 'r') ADVANCE(6); + if (lookahead == 't') ADVANCE(7); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); END_STATE(); case 1: - if (lookahead == 'e') ADVANCE(7); + if (lookahead == 'e') ADVANCE(8); END_STATE(); case 2: - if (lookahead == 'o') ADVANCE(8); + if (lookahead == 'o') ADVANCE(9); END_STATE(); case 3: - if (lookahead == 'l') ADVANCE(9); + if (lookahead == 'l') ADVANCE(10); END_STATE(); case 4: - if (lookahead == 'm') ADVANCE(10); + if (lookahead == 'm') ADVANCE(11); END_STATE(); case 5: - if (lookahead == 'e') ADVANCE(11); + if (lookahead == 'o') ADVANCE(12); END_STATE(); case 6: - if (lookahead == 'y') ADVANCE(12); + if (lookahead == 'e') ADVANCE(13); END_STATE(); case 7: - if (lookahead == 'f') ADVANCE(13); + if (lookahead == 'y') ADVANCE(14); END_STATE(); case 8: - if (lookahead == 'r') ADVANCE(14); + if (lookahead == 'f') ADVANCE(15); END_STATE(); case 9: - if (lookahead == 'o') ADVANCE(15); + if (lookahead == 'r') ADVANCE(16); END_STATE(); case 10: - if (lookahead == 'p') ADVANCE(16); + if (lookahead == 'o') ADVANCE(17); END_STATE(); case 11: - if (lookahead == 'f') ADVANCE(17); + if (lookahead == 'p') ADVANCE(18); END_STATE(); case 12: - if (lookahead == 'p') ADVANCE(18); + if (lookahead == 'c') ADVANCE(19); END_STATE(); case 13: - if (lookahead == 'i') ADVANCE(19); + if (lookahead == 'f') ADVANCE(20); END_STATE(); case 14: - if (lookahead == 'w') ADVANCE(20); + if (lookahead == 'p') ADVANCE(21); END_STATE(); case 15: - if (lookahead == 'b') ADVANCE(21); + if (lookahead == 'i') ADVANCE(22); END_STATE(); case 16: - if (lookahead == 'l') ADVANCE(22); + if (lookahead == 'w') ADVANCE(23); END_STATE(); case 17: - if (lookahead == 'e') ADVANCE(23); + if (lookahead == 'b') ADVANCE(24); END_STATE(); case 18: - if (lookahead == 'e') ADVANCE(24); + if (lookahead == 'l') ADVANCE(25); END_STATE(); case 19: - if (lookahead == 'n') ADVANCE(25); + if (lookahead == 'a') ADVANCE(26); END_STATE(); case 20: - if (lookahead == 'a') ADVANCE(26); + if (lookahead == 'e') ADVANCE(27); END_STATE(); case 21: - if (lookahead == 'a') ADVANCE(27); + if (lookahead == 'e') ADVANCE(28); END_STATE(); case 22: - if (lookahead == 'e') ADVANCE(28); + if (lookahead == 'n') ADVANCE(29); END_STATE(); case 23: - if (lookahead == 'r') ADVANCE(29); + if (lookahead == 'a') ADVANCE(30); END_STATE(); case 24: - if (lookahead == '_') ADVANCE(30); + if (lookahead == 'a') ADVANCE(31); END_STATE(); case 25: - if (lookahead == 'e') ADVANCE(31); + if (lookahead == 'e') ADVANCE(32); END_STATE(); case 26: - if (lookahead == 'r') ADVANCE(32); + if (lookahead == 'l') ADVANCE(33); END_STATE(); case 27: - if (lookahead == 'l') ADVANCE(33); + if (lookahead == 'r') ADVANCE(34); END_STATE(); case 28: - if (lookahead == 'm') ADVANCE(34); + if (lookahead == '_') ADVANCE(35); END_STATE(); case 29: - if (lookahead == 'e') ADVANCE(35); + if (lookahead == 'e') ADVANCE(36); END_STATE(); case 30: - if (lookahead == 'd') ADVANCE(36); + if (lookahead == 'r') ADVANCE(37); END_STATE(); case 31: - if (lookahead == 'd') ADVANCE(37); + if (lookahead == 'l') ADVANCE(38); END_STATE(); case 32: - if (lookahead == 'd') ADVANCE(38); + if (lookahead == 'm') ADVANCE(39); END_STATE(); case 33: - ACCEPT_TOKEN(anon_sym_global); + ACCEPT_TOKEN(anon_sym_local); END_STATE(); case 34: - if (lookahead == 'e') ADVANCE(39); + if (lookahead == 'e') ADVANCE(40); END_STATE(); case 35: - if (lookahead == 'n') ADVANCE(40); + if (lookahead == 'd') ADVANCE(41); END_STATE(); case 36: - if (lookahead == 'e') ADVANCE(41); + if (lookahead == 'd') ADVANCE(42); END_STATE(); case 37: - if (lookahead == '_') ADVANCE(42); + if (lookahead == 'd') ADVANCE(43); END_STATE(); case 38: - if (lookahead == '_') ADVANCE(43); + ACCEPT_TOKEN(anon_sym_global); END_STATE(); case 39: - if (lookahead == 'n') ADVANCE(44); + if (lookahead == 'e') ADVANCE(44); END_STATE(); case 40: - if (lookahead == 'c') ADVANCE(45); + if (lookahead == 'n') ADVANCE(45); END_STATE(); case 41: - if (lookahead == 'f') ADVANCE(46); + if (lookahead == 'e') ADVANCE(46); END_STATE(); case 42: - if (lookahead == 'b') ADVANCE(47); + if (lookahead == '_') ADVANCE(47); END_STATE(); case 43: - if (lookahead == 'd') ADVANCE(48); + if (lookahead == '_') ADVANCE(48); END_STATE(); case 44: - if (lookahead == 't') ADVANCE(49); + if (lookahead == 'n') ADVANCE(49); END_STATE(); case 45: - if (lookahead == 'e') ADVANCE(50); + if (lookahead == 'c') ADVANCE(50); END_STATE(); case 46: - if (lookahead == 'i') ADVANCE(51); + if (lookahead == 'f') ADVANCE(51); END_STATE(); case 47: - if (lookahead == 'y') ADVANCE(52); + if (lookahead == 'b') ADVANCE(52); END_STATE(); case 48: - if (lookahead == 'e') ADVANCE(53); + if (lookahead == 'd') ADVANCE(53); END_STATE(); case 49: - if (lookahead == 's') ADVANCE(54); + if (lookahead == 't') ADVANCE(54); END_STATE(); case 50: - if (lookahead == 's') ADVANCE(55); + if (lookahead == 'e') ADVANCE(55); END_STATE(); case 51: - if (lookahead == 'n') ADVANCE(56); + if (lookahead == 'i') ADVANCE(56); END_STATE(); case 52: - ACCEPT_TOKEN(anon_sym_defined_by); + if (lookahead == 'y') ADVANCE(57); END_STATE(); case 53: - if (lookahead == 'f') ADVANCE(57); + if (lookahead == 'e') ADVANCE(58); END_STATE(); case 54: - ACCEPT_TOKEN(anon_sym_implements); + if (lookahead == 's') ADVANCE(59); END_STATE(); case 55: - ACCEPT_TOKEN(anon_sym_references); + if (lookahead == 's') ADVANCE(60); END_STATE(); case 56: - if (lookahead == 'e') ADVANCE(58); + if (lookahead == 'n') ADVANCE(61); END_STATE(); case 57: - if (lookahead == 'i') ADVANCE(59); + ACCEPT_TOKEN(anon_sym_defined_by); END_STATE(); case 58: - if (lookahead == 's') ADVANCE(60); + if (lookahead == 'f') ADVANCE(62); END_STATE(); case 59: - if (lookahead == 'n') ADVANCE(61); + ACCEPT_TOKEN(anon_sym_implements); END_STATE(); case 60: - ACCEPT_TOKEN(anon_sym_type_defines); + ACCEPT_TOKEN(anon_sym_references); END_STATE(); case 61: - if (lookahead == 'i') ADVANCE(62); + if (lookahead == 'e') ADVANCE(63); END_STATE(); case 62: - if (lookahead == 't') ADVANCE(63); + if (lookahead == 'i') ADVANCE(64); END_STATE(); case 63: - if (lookahead == 'i') ADVANCE(64); + if (lookahead == 's') ADVANCE(65); END_STATE(); case 64: - if (lookahead == 'o') ADVANCE(65); + if (lookahead == 'n') ADVANCE(66); END_STATE(); case 65: - if (lookahead == 'n') ADVANCE(66); + ACCEPT_TOKEN(anon_sym_type_defines); END_STATE(); case 66: + if (lookahead == 'i') ADVANCE(67); + END_STATE(); + case 67: + if (lookahead == 't') ADVANCE(68); + END_STATE(); + case 68: + if (lookahead == 'i') ADVANCE(69); + END_STATE(); + case 69: + if (lookahead == 'o') ADVANCE(70); + END_STATE(); + case 70: + if (lookahead == 'n') ADVANCE(71); + END_STATE(); + case 71: ACCEPT_TOKEN(anon_sym_forward_definition); END_STATE(); default: @@ -1014,35 +1052,38 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [9] = {.lex_state = 1}, [10] = {.lex_state = 1}, [11] = {.lex_state = 1}, - [12] = {.lex_state = 41}, + [12] = {.lex_state = 40}, [13] = {.lex_state = 40}, - [14] = {.lex_state = 1}, - [15] = {.lex_state = 1}, - [16] = {.lex_state = 1}, - [17] = {.lex_state = 1}, - [18] = {.lex_state = 1}, - [19] = {.lex_state = 1}, - [20] = {.lex_state = 1}, + [14] = {.lex_state = 40}, + [15] = {.lex_state = 40}, + [16] = {.lex_state = 41}, + [17] = {.lex_state = 40}, + [18] = {.lex_state = 40}, + [19] = {.lex_state = 40}, + [20] = {.lex_state = 40}, [21] = {.lex_state = 40}, - [22] = {.lex_state = 40}, - [23] = {.lex_state = 40}, - [24] = {.lex_state = 40}, - [25] = {.lex_state = 40}, - [26] = {.lex_state = 40}, - [27] = {.lex_state = 40}, - [28] = {.lex_state = 40}, - [29] = {.lex_state = 2}, - [30] = {.lex_state = 52}, - [31] = {.lex_state = 2}, - [32] = {.lex_state = 52}, - [33] = {.lex_state = 40}, - [34] = {.lex_state = 41}, - [35] = {.lex_state = 2}, - [36] = {.lex_state = 0}, + [22] = {.lex_state = 1}, + [23] = {.lex_state = 1}, + [24] = {.lex_state = 1}, + [25] = {.lex_state = 1}, + [26] = {.lex_state = 1}, + [27] = {.lex_state = 1}, + [28] = {.lex_state = 1}, + [29] = {.lex_state = 1}, + [30] = {.lex_state = 1}, + [31] = {.lex_state = 41}, + [32] = {.lex_state = 40}, + [33] = {.lex_state = 52}, + [34] = {.lex_state = 40}, + [35] = {.lex_state = 40}, + [36] = {.lex_state = 52}, [37] = {.lex_state = 2}, [38] = {.lex_state = 2}, [39] = {.lex_state = 2}, - [40] = {.lex_state = 40}, + [40] = {.lex_state = 0}, + [41] = {.lex_state = 2}, + [42] = {.lex_state = 2}, + [43] = {.lex_state = 2}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { @@ -1059,16 +1100,17 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_defined_by] = ACTIONS(1), [anon_sym_POUND] = ACTIONS(1), [anon_sym_POUNDdocstring_COLON] = ACTIONS(1), + [anon_sym_local] = ACTIONS(1), [anon_sym_global] = ACTIONS(1), }, [STATE(1)] = { - [sym_source_file] = STATE(36), + [sym_source_file] = STATE(40), [sym__statement] = STATE(2), [sym_definition_statement] = STATE(39), [sym_reference_statement] = STATE(39), [sym_relationships_statement] = STATE(39), [sym_comment] = STATE(39), - [sym_docstring] = STATE(37), + [sym_docstring] = STATE(43), [aux_sym_source_file_repeat1] = STATE(2), [ts_builtin_sym_end] = ACTIONS(3), [anon_sym_definition] = ACTIONS(5), @@ -1093,7 +1135,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUNDdocstring_COLON, ACTIONS(15), 1, ts_builtin_sym_end, - STATE(37), 1, + STATE(43), 1, sym_docstring, STATE(3), 2, sym__statement, @@ -1116,7 +1158,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUND, ACTIONS(31), 1, anon_sym_POUNDdocstring_COLON, - STATE(37), 1, + STATE(43), 1, sym_docstring, STATE(3), 2, sym__statement, @@ -1199,30 +1241,30 @@ static const uint16_t ts_small_parse_table[] = { sym_references_relation, aux_sym_definition_statement_repeat1, [159] = 5, - ACTIONS(36), 1, + ACTIONS(62), 1, + anon_sym_LF, + ACTIONS(64), 1, anon_sym_implements, - ACTIONS(38), 1, + ACTIONS(67), 1, anon_sym_type_defines, - ACTIONS(40), 1, + ACTIONS(70), 1, anon_sym_references, - ACTIONS(62), 1, - anon_sym_LF, - STATE(7), 5, + STATE(8), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, sym_references_relation, aux_sym_definition_statement_repeat1, [179] = 5, - ACTIONS(64), 1, - anon_sym_LF, - ACTIONS(66), 1, + ACTIONS(36), 1, anon_sym_implements, - ACTIONS(69), 1, + ACTIONS(38), 1, anon_sym_type_defines, - ACTIONS(72), 1, + ACTIONS(40), 1, anon_sym_references, - STATE(9), 5, + ACTIONS(73), 1, + anon_sym_LF, + STATE(8), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, @@ -1252,196 +1294,251 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_references, ACTIONS(77), 1, anon_sym_LF, - STATE(9), 5, + STATE(8), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, sym_references_relation, aux_sym_definition_statement_repeat1, - [239] = 2, + [239] = 7, + ACTIONS(79), 1, + sym_workspace_identifier, ACTIONS(81), 1, + anon_sym_forward_definition, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + STATE(38), 1, + sym_identifier, + [261] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(4), 1, + sym_identifier, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + [280] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + STATE(37), 1, + sym_identifier, + [299] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(7), 1, + sym_identifier, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + [318] = 2, + ACTIONS(89), 1, anon_sym_POUND, - ACTIONS(79), 5, + ACTIONS(87), 5, ts_builtin_sym_end, anon_sym_definition, anon_sym_reference, anon_sym_relationships, anon_sym_POUNDdocstring_COLON, - [250] = 5, + [329] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + STATE(29), 1, + sym_identifier, + [348] = 6, + ACTIONS(79), 1, sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, ACTIONS(85), 1, - anon_sym_forward_definition, - ACTIONS(87), 1, anon_sym_global, - STATE(14), 1, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, sym_global_identifier, - STATE(31), 1, + STATE(30), 1, sym_identifier, - [266] = 2, - ACTIONS(89), 1, + [367] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(10), 1, + sym_identifier, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + [386] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + STATE(28), 1, + sym_identifier, + [405] = 6, + ACTIONS(79), 1, + sym_workspace_identifier, + ACTIONS(83), 1, + anon_sym_local, + ACTIONS(85), 1, + anon_sym_global, + STATE(25), 1, + sym_local_identifier, + STATE(26), 1, + sym_global_identifier, + STATE(27), 1, + sym_identifier, + [424] = 2, + ACTIONS(91), 1, anon_sym_LF, - ACTIONS(91), 4, + ACTIONS(93), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [276] = 2, - ACTIONS(93), 1, + [434] = 2, + ACTIONS(95), 1, anon_sym_LF, - ACTIONS(95), 4, + ACTIONS(97), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [286] = 2, - ACTIONS(97), 1, + [444] = 2, + ACTIONS(99), 1, anon_sym_LF, - ACTIONS(99), 4, + ACTIONS(101), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [296] = 2, - ACTIONS(101), 1, + [454] = 2, + ACTIONS(103), 1, anon_sym_LF, - ACTIONS(103), 4, + ACTIONS(105), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [306] = 2, - ACTIONS(105), 1, + [464] = 2, + ACTIONS(107), 1, anon_sym_LF, - ACTIONS(107), 4, + ACTIONS(109), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [316] = 2, - ACTIONS(109), 1, + [474] = 2, + ACTIONS(111), 1, anon_sym_LF, - ACTIONS(111), 4, + ACTIONS(113), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [326] = 2, - ACTIONS(113), 1, + [484] = 2, + ACTIONS(115), 1, anon_sym_LF, - ACTIONS(115), 4, + ACTIONS(117), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [336] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, - sym_global_identifier, - STATE(38), 1, - sym_identifier, - [349] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, - sym_global_identifier, - STATE(17), 1, - sym_identifier, - [362] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(4), 1, - sym_identifier, - STATE(14), 1, - sym_global_identifier, - [375] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, - sym_global_identifier, - STATE(18), 1, - sym_identifier, - [388] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, - sym_global_identifier, - STATE(19), 1, - sym_identifier, - [401] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(10), 1, - sym_identifier, - STATE(14), 1, - sym_global_identifier, - [414] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(8), 1, - sym_identifier, - STATE(14), 1, - sym_global_identifier, - [427] = 4, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, - sym_global_identifier, - STATE(16), 1, - sym_identifier, - [440] = 1, - ACTIONS(117), 1, - anon_sym_LF, - [444] = 1, + [494] = 2, ACTIONS(119), 1, - aux_sym_comment_token1, - [448] = 1, - ACTIONS(121), 1, anon_sym_LF, - [452] = 1, + ACTIONS(121), 4, + anon_sym_implements, + anon_sym_type_defines, + anon_sym_references, + anon_sym_defined_by, + [504] = 2, ACTIONS(123), 1, - aux_sym_comment_token1, - [456] = 1, - ACTIONS(125), 1, - sym_workspace_identifier, - [460] = 1, + anon_sym_LF, + ACTIONS(125), 4, + anon_sym_implements, + anon_sym_type_defines, + anon_sym_references, + anon_sym_defined_by, + [514] = 1, ACTIONS(127), 1, anon_sym_definition, - [464] = 1, + [518] = 1, ACTIONS(129), 1, - anon_sym_LF, - [468] = 1, + sym_workspace_identifier, + [522] = 1, ACTIONS(131), 1, - ts_builtin_sym_end, - [472] = 1, + aux_sym_comment_token1, + [526] = 1, ACTIONS(133), 1, - anon_sym_LF, - [476] = 1, + sym_workspace_identifier, + [530] = 1, ACTIONS(135), 1, - anon_sym_LF, - [480] = 1, + sym_workspace_identifier, + [534] = 1, ACTIONS(137), 1, - anon_sym_LF, - [484] = 1, + aux_sym_comment_token1, + [538] = 1, ACTIONS(139), 1, - sym_workspace_identifier, + anon_sym_LF, + [542] = 1, + ACTIONS(141), 1, + anon_sym_LF, + [546] = 1, + ACTIONS(143), 1, + anon_sym_LF, + [550] = 1, + ACTIONS(145), 1, + ts_builtin_sym_end, + [554] = 1, + ACTIONS(147), 1, + anon_sym_LF, + [558] = 1, + ACTIONS(149), 1, + anon_sym_LF, + [562] = 1, + ACTIONS(151), 1, + anon_sym_LF, }; static const uint32_t ts_small_parse_table_map[] = { @@ -1456,102 +1553,111 @@ static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(10)] = 199, [SMALL_STATE(11)] = 219, [SMALL_STATE(12)] = 239, - [SMALL_STATE(13)] = 250, - [SMALL_STATE(14)] = 266, - [SMALL_STATE(15)] = 276, - [SMALL_STATE(16)] = 286, - [SMALL_STATE(17)] = 296, - [SMALL_STATE(18)] = 306, - [SMALL_STATE(19)] = 316, - [SMALL_STATE(20)] = 326, - [SMALL_STATE(21)] = 336, - [SMALL_STATE(22)] = 349, - [SMALL_STATE(23)] = 362, - [SMALL_STATE(24)] = 375, - [SMALL_STATE(25)] = 388, - [SMALL_STATE(26)] = 401, - [SMALL_STATE(27)] = 414, - [SMALL_STATE(28)] = 427, - [SMALL_STATE(29)] = 440, - [SMALL_STATE(30)] = 444, - [SMALL_STATE(31)] = 448, - [SMALL_STATE(32)] = 452, - [SMALL_STATE(33)] = 456, - [SMALL_STATE(34)] = 460, - [SMALL_STATE(35)] = 464, - [SMALL_STATE(36)] = 468, - [SMALL_STATE(37)] = 472, - [SMALL_STATE(38)] = 476, - [SMALL_STATE(39)] = 480, - [SMALL_STATE(40)] = 484, + [SMALL_STATE(13)] = 261, + [SMALL_STATE(14)] = 280, + [SMALL_STATE(15)] = 299, + [SMALL_STATE(16)] = 318, + [SMALL_STATE(17)] = 329, + [SMALL_STATE(18)] = 348, + [SMALL_STATE(19)] = 367, + [SMALL_STATE(20)] = 386, + [SMALL_STATE(21)] = 405, + [SMALL_STATE(22)] = 424, + [SMALL_STATE(23)] = 434, + [SMALL_STATE(24)] = 444, + [SMALL_STATE(25)] = 454, + [SMALL_STATE(26)] = 464, + [SMALL_STATE(27)] = 474, + [SMALL_STATE(28)] = 484, + [SMALL_STATE(29)] = 494, + [SMALL_STATE(30)] = 504, + [SMALL_STATE(31)] = 514, + [SMALL_STATE(32)] = 518, + [SMALL_STATE(33)] = 522, + [SMALL_STATE(34)] = 526, + [SMALL_STATE(35)] = 530, + [SMALL_STATE(36)] = 534, + [SMALL_STATE(37)] = 538, + [SMALL_STATE(38)] = 542, + [SMALL_STATE(39)] = 546, + [SMALL_STATE(40)] = 550, + [SMALL_STATE(41)] = 554, + [SMALL_STATE(42)] = 558, + [SMALL_STATE(43)] = 562, }; 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_source_file, 0, 0, 0), - [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), - [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(30), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(33), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), - [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(27), - [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(13), - [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(23), - [28] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(30), - [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(32), + [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(15), + [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(12), + [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(13), + [28] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(33), + [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(36), [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 2, 0, 2), - [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), - [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(22), - [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(25), - [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(28), - [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 4), + [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), + [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), + [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), + [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), + [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 5), [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), - [48] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(24), - [51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(22), - [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(25), - [57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(28), - [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 4), - [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 2), - [64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), - [66] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(24), - [69] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(22), - [72] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(25), - [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 4, 0, 7), - [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 5, 0, 8), - [79] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__statement, 2, 0, 0), - [81] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__statement, 2, 0, 0), - [83] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), - [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), - [87] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), - [89] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 3), - [91] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 3), - [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 3, 0, 6), - [95] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 3, 0, 6), - [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 2), - [99] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 2), - [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 2), - [103] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 2), - [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 2), - [107] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 2), - [109] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 2), - [111] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 2), - [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 1), - [115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 1), - [117] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_docstring, 2, 0, 0), - [119] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), - [121] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 2), - [123] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), - [125] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), - [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), - [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), - [131] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), - [135] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 5), - [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), - [139] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), + [48] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), + [51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), + [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), + [57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(21), + [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 2), + [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), + [64] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), + [67] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), + [70] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), + [73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 5), + [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 4, 0, 8), + [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 5, 0, 9), + [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), + [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), + [83] = {.entry = {.count = 1, .reusable = false}}, SHIFT(34), + [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(35), + [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__statement, 2, 0, 0), + [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__statement, 2, 0, 0), + [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 3, 0, 7), + [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 3, 0, 7), + [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_local_identifier, 2, 0, 2), + [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_local_identifier, 2, 0, 2), + [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 1), + [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 1), + [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 3), + [105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 3), + [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 4), + [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 4), + [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 2), + [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 2), + [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 2), + [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 2), + [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 2), + [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 2), + [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 2), + [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 2), + [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), + [131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), + [135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), + [139] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 6), + [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 2), + [143] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), + [145] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [147] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), + [149] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_docstring, 2, 0, 0), + [151] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), }; #ifdef __cplusplus diff --git a/reprolang/repro/ast.go b/reprolang/repro/ast.go index 837bbb3d..e1390aae 100644 --- a/reprolang/repro/ast.go +++ b/reprolang/repro/ast.go @@ -2,7 +2,6 @@ package repro import ( "fmt" - "strings" sitter "github.com/tree-sitter/go-tree-sitter" @@ -34,6 +33,7 @@ type referenceStatement struct { type identifier struct { value string symbol string + isLocal bool position *scip.Range } @@ -45,6 +45,15 @@ func newIdentifier(s *reproSourceFile, n *sitter.Node) *identifier { panic("expected identifier, obtained " + n.Kind()) } value := s.nodeText(n) + isLocal := false + localIdentifier := n.ChildByFieldName("local") + if localIdentifier != nil { + isLocal = true + nameNode := localIdentifier.ChildByFieldName("name") + if nameNode != nil { + value = s.nodeText(nameNode) + } + } globalIdentifier := n.ChildByFieldName("global") if globalIdentifier != nil { projectName := globalIdentifier.ChildByFieldName("project_name") @@ -55,6 +64,7 @@ func newIdentifier(s *reproSourceFile, n *sitter.Node) *identifier { } return &identifier{ value: value, + isLocal: isLocal, position: NewRangePositionFromNode(n), } } @@ -91,5 +101,5 @@ func (i *identifier) resolveSymbol(localScope *reproScope, context *reproContext } func (i *identifier) isLocalSymbol() bool { - return strings.HasPrefix(i.value, "local") + return i.isLocal } diff --git a/reprolang/repro/namer.go b/reprolang/repro/namer.go index 648ba126..7955f103 100644 --- a/reprolang/repro/namer.go +++ b/reprolang/repro/namer.go @@ -44,7 +44,7 @@ func (s *reproSourceFile) enterDefinitions(context *reproContext) { } var symbol string if name.isLocalSymbol() { - symbol = fmt.Sprintf("local %s", defName.value[len("local"):]) + symbol = fmt.Sprintf("local %s", defName.value) } else { symbol = newGlobalSymbol(context.pkg, s, defName) } diff --git a/reprolang/testdata/snapshots/input/local-document/local1.repro b/reprolang/testdata/snapshots/input/local-document/local1.repro index bb12f63e..4d42f57a 100644 --- a/reprolang/testdata/snapshots/input/local-document/local1.repro +++ b/reprolang/testdata/snapshots/input/local-document/local1.repro @@ -1,4 +1,3 @@ # docstring: local is a local method -definition localExample -reference localExample - +definition local Example +reference local Example diff --git a/reprolang/testdata/snapshots/input/local-document/local2.repro b/reprolang/testdata/snapshots/input/local-document/local2.repro index 076a5f20..b1a6e810 100644 --- a/reprolang/testdata/snapshots/input/local-document/local2.repro +++ b/reprolang/testdata/snapshots/input/local-document/local2.repro @@ -1,2 +1,2 @@ -definition localExample -reference localExample \ No newline at end of file +definition local Example +reference local Example diff --git a/reprolang/testdata/snapshots/input/missing-symbol-information/locals.repro b/reprolang/testdata/snapshots/input/missing-symbol-information/locals.repro index c3dcec75..dbc8d431 100644 --- a/reprolang/testdata/snapshots/input/missing-symbol-information/locals.repro +++ b/reprolang/testdata/snapshots/input/missing-symbol-information/locals.repro @@ -1,2 +1,2 @@ -definition localNoSymbolInformation -reference localNoSymbolInformation \ No newline at end of file +definition local NoSymbolInformation +reference local NoSymbolInformation diff --git a/reprolang/testdata/snapshots/input/relationships/mixed.repro b/reprolang/testdata/snapshots/input/relationships/mixed.repro index fc619922..003105e1 100644 --- a/reprolang/testdata/snapshots/input/relationships/mixed.repro +++ b/reprolang/testdata/snapshots/input/relationships/mixed.repro @@ -1,4 +1,4 @@ -definition local1 -definition local2 -definition local3 -definition local4 implements local1 references local2 type_defines local3 +definition local sym1 +definition local sym2 +definition local sym3 +definition local sym4 implements local sym1 references local sym2 type_defines local sym3 diff --git a/reprolang/testdata/snapshots/input/relationships/references.repro b/reprolang/testdata/snapshots/input/relationships/references.repro index 2b58bb8a..517b7904 100644 --- a/reprolang/testdata/snapshots/input/relationships/references.repro +++ b/reprolang/testdata/snapshots/input/relationships/references.repro @@ -1,2 +1,2 @@ -definition local1 -definition local2 references local1 +definition local sym1 +definition local sym2 references local sym1 diff --git a/reprolang/testdata/snapshots/input/relationships/type_defines.repro b/reprolang/testdata/snapshots/input/relationships/type_defines.repro index 06546617..4f7ba8ec 100644 --- a/reprolang/testdata/snapshots/input/relationships/type_defines.repro +++ b/reprolang/testdata/snapshots/input/relationships/type_defines.repro @@ -1,2 +1,2 @@ -definition local1 -definition local2 type_defines local1 +definition local sym1 +definition local sym2 type_defines local sym1 diff --git a/reprolang/testdata/snapshots/output/local-document/local1.repro b/reprolang/testdata/snapshots/output/local-document/local1.repro index 685441ac..a33c8b90 100755 --- a/reprolang/testdata/snapshots/output/local-document/local1.repro +++ b/reprolang/testdata/snapshots/output/local-document/local1.repro @@ -1,11 +1,10 @@ # docstring: local is a local method - definition localExample -# ^^^^^^^^^^^^ definition local Example + definition local Example +# ^^^^^^^^^^^^^ definition local Example # documentation -# > signature of localExample +# > signature of Example # documentation # > : local is a local method - reference localExample -# ^^^^^^^^^^^^ reference local Example - + reference local Example +# ^^^^^^^^^^^^^ reference local Example diff --git a/reprolang/testdata/snapshots/output/local-document/local2.repro b/reprolang/testdata/snapshots/output/local-document/local2.repro index b7a32a32..902f7450 100755 --- a/reprolang/testdata/snapshots/output/local-document/local2.repro +++ b/reprolang/testdata/snapshots/output/local-document/local2.repro @@ -1,6 +1,7 @@ - definition localExample -# ^^^^^^^^^^^^ definition local Example + definition local Example +# ^^^^^^^^^^^^^ definition local Example # documentation -# > signature of localExample - reference localExample -# ^^^^^^^^^^^^ reference local Example +# > signature of Example + reference local Example +# ^^^^^^^^^^^^^ reference local Example + diff --git a/reprolang/testdata/snapshots/output/missing-symbol-information/locals.repro b/reprolang/testdata/snapshots/output/missing-symbol-information/locals.repro index fa8869ee..1d5de14b 100755 --- a/reprolang/testdata/snapshots/output/missing-symbol-information/locals.repro +++ b/reprolang/testdata/snapshots/output/missing-symbol-information/locals.repro @@ -1,4 +1,5 @@ - definition localNoSymbolInformation -# ^^^^^^^^^^^^^^^^^^^^^^^^ definition local NoSymbolInformation - reference localNoSymbolInformation -# ^^^^^^^^^^^^^^^^^^^^^^^^ reference local NoSymbolInformation + definition local NoSymbolInformation +# ^^^^^^^^^^^^^^^^^^^^^^^^^ definition local NoSymbolInformation + reference local NoSymbolInformation +# ^^^^^^^^^^^^^^^^^^^^^^^^^ reference local NoSymbolInformation + diff --git a/reprolang/testdata/snapshots/output/relationships/mixed.repro b/reprolang/testdata/snapshots/output/relationships/mixed.repro index 6eb69995..b04cb77e 100755 --- a/reprolang/testdata/snapshots/output/relationships/mixed.repro +++ b/reprolang/testdata/snapshots/output/relationships/mixed.repro @@ -1,23 +1,23 @@ - definition local1 -# ^^^^^^ definition local 1 + definition local sym1 +# ^^^^^^^^^^ definition local sym1 # documentation -# > signature of local1 - definition local2 -# ^^^^^^ definition local 2 +# > signature of sym1 + definition local sym2 +# ^^^^^^^^^^ definition local sym2 # documentation -# > signature of local2 - definition local3 -# ^^^^^^ definition local 3 +# > signature of sym2 + definition local sym3 +# ^^^^^^^^^^ definition local sym3 # documentation -# > signature of local3 - definition local4 implements local1 references local2 type_defines local3 -# ^^^^^^ definition local 4 +# > signature of sym3 + definition local sym4 implements local sym1 references local sym2 type_defines local sym3 +# ^^^^^^^^^^ definition local sym4 # documentation -# > signature of local4 -# relationship local 1 implementation -# relationship local 2 reference -# relationship local 3 type_definition -# ^^^^^^ reference local 1 -# ^^^^^^ reference local 2 -# ^^^^^^ reference local 3 +# > signature of sym4 +# relationship local sym1 implementation +# relationship local sym2 reference +# relationship local sym3 type_definition +# ^^^^^^^^^^ reference local sym1 +# ^^^^^^^^^^ reference local sym2 +# ^^^^^^^^^^ reference local sym3 diff --git a/reprolang/testdata/snapshots/output/relationships/references.repro b/reprolang/testdata/snapshots/output/relationships/references.repro index 44c9eab3..917c3728 100755 --- a/reprolang/testdata/snapshots/output/relationships/references.repro +++ b/reprolang/testdata/snapshots/output/relationships/references.repro @@ -1,11 +1,11 @@ - definition local1 -# ^^^^^^ definition local 1 + definition local sym1 +# ^^^^^^^^^^ definition local sym1 # documentation -# > signature of local1 - definition local2 references local1 -# ^^^^^^ definition local 2 +# > signature of sym1 + definition local sym2 references local sym1 +# ^^^^^^^^^^ definition local sym2 # documentation -# > signature of local2 -# relationship local 1 reference -# ^^^^^^ reference local 1 +# > signature of sym2 +# relationship local sym1 reference +# ^^^^^^^^^^ reference local sym1 diff --git a/reprolang/testdata/snapshots/output/relationships/type_defines.repro b/reprolang/testdata/snapshots/output/relationships/type_defines.repro index 708bba8f..b01c64f2 100755 --- a/reprolang/testdata/snapshots/output/relationships/type_defines.repro +++ b/reprolang/testdata/snapshots/output/relationships/type_defines.repro @@ -1,11 +1,11 @@ - definition local1 -# ^^^^^^ definition local 1 + definition local sym1 +# ^^^^^^^^^^ definition local sym1 # documentation -# > signature of local1 - definition local2 type_defines local1 -# ^^^^^^ definition local 2 +# > signature of sym1 + definition local sym2 type_defines local sym1 +# ^^^^^^^^^^ definition local sym2 # documentation -# > signature of local2 -# relationship local 1 type_definition -# ^^^^^^ reference local 1 +# > signature of sym2 +# relationship local sym1 type_definition +# ^^^^^^^^^^ reference local sym1 From 14345b15ac56eb540f4f92242a4c6bc9bf2e36e6 Mon Sep 17 00:00:00 2001 From: jupblb Date: Wed, 18 Mar 2026 13:43:23 +0100 Subject: [PATCH 2/4] reprolang: rename workspace_identifier to name in grammar Aligns with SCIP spec terminology where ::= . --- reprolang/grammar.js | 12 +- reprolang/grammar/binding_test.go | 2 +- reprolang/grammar/grammar.json | 18 ++- reprolang/grammar/node-types.json | 34 +++--- reprolang/grammar/parser.c | 177 +++++++++++++++--------------- 5 files changed, 117 insertions(+), 126 deletions(-) diff --git a/reprolang/grammar.js b/reprolang/grammar.js index 1dfb95cf..6198fdf9 100644 --- a/reprolang/grammar.js +++ b/reprolang/grammar.js @@ -1,7 +1,7 @@ module.exports = grammar({ name: 'reprolang', extras: $ => [/\s+/], - word: $ => $.workspace_identifier, + word: $ => $.name, rules: { source_file: $ => repeat($._statement), @@ -56,16 +56,16 @@ module.exports = grammar({ choice( field('local', $.local_identifier), field('global', $.global_identifier), - field('workspace', $.workspace_identifier) + $.name ), local_identifier: $ => - seq('local', field('name', $.workspace_identifier)), + seq('local', field('name', $.name)), global_identifier: $ => seq( 'global', - field('project_name', $.workspace_identifier), - field('descriptors', $.workspace_identifier) + field('project_name', $.name), + field('descriptors', $.name) ), - workspace_identifier: $ => /[^\s]+/, + name: $ => /[^\s]+/, }, }) diff --git a/reprolang/grammar/binding_test.go b/reprolang/grammar/binding_test.go index 11edd834..791ad540 100644 --- a/reprolang/grammar/binding_test.go +++ b/reprolang/grammar/binding_test.go @@ -17,7 +17,7 @@ func TestParse(t *testing.T) { tree := parser.Parse([]byte("definition a implements b\n"), nil) defer tree.Close() assert.Equal( - "(source_file (definition_statement name: (identifier workspace: (workspace_identifier)) roles: (implementation_relation name: (identifier workspace: (workspace_identifier)))))", + "(source_file (definition_statement name: (identifier (name)) roles: (implementation_relation name: (identifier (name)))))", tree.RootNode().ToSexp(), ) } diff --git a/reprolang/grammar/grammar.json b/reprolang/grammar/grammar.json index f3b86129..c3f69a3c 100644 --- a/reprolang/grammar/grammar.json +++ b/reprolang/grammar/grammar.json @@ -1,7 +1,7 @@ { "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json", "name": "reprolang", - "word": "workspace_identifier", + "word": "name", "rules": { "source_file": { "type": "REPEAT", @@ -298,12 +298,8 @@ } }, { - "type": "FIELD", - "name": "workspace", - "content": { - "type": "SYMBOL", - "name": "workspace_identifier" - } + "type": "SYMBOL", + "name": "name" } ] }, @@ -319,7 +315,7 @@ "name": "name", "content": { "type": "SYMBOL", - "name": "workspace_identifier" + "name": "name" } } ] @@ -336,7 +332,7 @@ "name": "project_name", "content": { "type": "SYMBOL", - "name": "workspace_identifier" + "name": "name" } }, { @@ -344,12 +340,12 @@ "name": "descriptors", "content": { "type": "SYMBOL", - "name": "workspace_identifier" + "name": "name" } } ] }, - "workspace_identifier": { + "name": { "type": "PATTERN", "value": "[^\\s]+" } diff --git a/reprolang/grammar/node-types.json b/reprolang/grammar/node-types.json index 3295405d..9bebd339 100644 --- a/reprolang/grammar/node-types.json +++ b/reprolang/grammar/node-types.json @@ -82,7 +82,7 @@ "required": true, "types": [ { - "type": "workspace_identifier", + "type": "name", "named": true } ] @@ -92,7 +92,7 @@ "required": true, "types": [ { - "type": "workspace_identifier", + "type": "name", "named": true } ] @@ -122,17 +122,17 @@ "named": true } ] - }, - "workspace": { - "multiple": false, - "required": false, - "types": [ - { - "type": "workspace_identifier", - "named": true - } - ] } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "name", + "named": true + } + ] } }, { @@ -160,7 +160,7 @@ "required": true, "types": [ { - "type": "workspace_identifier", + "type": "name", "named": true } ] @@ -327,6 +327,10 @@ "type": "local", "named": false }, + { + "type": "name", + "named": true + }, { "type": "reference", "named": false @@ -342,9 +346,5 @@ { "type": "type_defines", "named": false - }, - { - "type": "workspace_identifier", - "named": true } ] diff --git a/reprolang/grammar/parser.c b/reprolang/grammar/parser.c index 98c0babf..68eb3cae 100644 --- a/reprolang/grammar/parser.c +++ b/reprolang/grammar/parser.c @@ -13,14 +13,14 @@ #define ALIAS_COUNT 0 #define TOKEN_COUNT 16 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 9 +#define FIELD_COUNT 8 #define MAX_ALIAS_SEQUENCE_LENGTH 5 #define MAX_RESERVED_WORD_SET_SIZE 0 -#define PRODUCTION_ID_COUNT 10 +#define PRODUCTION_ID_COUNT 9 #define SUPERTYPE_COUNT 0 enum ts_symbol_identifiers { - sym_workspace_identifier = 1, + sym_name = 1, anon_sym_LF = 2, anon_sym_definition = 3, anon_sym_reference = 4, @@ -58,7 +58,7 @@ enum ts_symbol_identifiers { static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", - [sym_workspace_identifier] = "workspace_identifier", + [sym_name] = "name", [anon_sym_LF] = "\n", [anon_sym_definition] = "definition", [anon_sym_reference] = "reference", @@ -96,7 +96,7 @@ static const char * const ts_symbol_names[] = { static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, - [sym_workspace_identifier] = sym_workspace_identifier, + [sym_name] = sym_name, [anon_sym_LF] = anon_sym_LF, [anon_sym_definition] = anon_sym_definition, [anon_sym_reference] = anon_sym_reference, @@ -137,7 +137,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = true, }, - [sym_workspace_identifier] = { + [sym_name] = { .visible = true, .named = true, }, @@ -284,7 +284,6 @@ enum ts_field_identifiers { field_name = 6, field_project_name = 7, field_roles = 8, - field_workspace = 9, }; static const char * const ts_field_names[] = { @@ -297,44 +296,40 @@ static const char * const ts_field_names[] = { [field_name] = "name", [field_project_name] = "project_name", [field_roles] = "roles", - [field_workspace] = "workspace", }; static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 1}, [2] = {.index = 1, .length = 1}, [3] = {.index = 2, .length = 1}, - [4] = {.index = 3, .length = 1}, - [5] = {.index = 4, .length = 2}, - [6] = {.index = 6, .length = 2}, - [7] = {.index = 8, .length = 2}, - [8] = {.index = 10, .length = 3}, - [9] = {.index = 13, .length = 4}, + [4] = {.index = 3, .length = 2}, + [5] = {.index = 5, .length = 2}, + [6] = {.index = 7, .length = 2}, + [7] = {.index = 9, .length = 3}, + [8] = {.index = 12, .length = 4}, }; static const TSFieldMapEntry ts_field_map_entries[] = { [0] = - {field_workspace, 0}, - [1] = {field_name, 1}, - [2] = + [1] = {field_local, 0}, - [3] = + [2] = {field_global, 0}, - [4] = + [3] = {field_name, 1}, {field_roles, 2}, - [6] = + [5] = {field_forward_definition, 1}, {field_name, 2}, - [8] = + [7] = {field_descriptors, 2}, {field_project_name, 1}, - [10] = + [9] = {field_docstring, 0}, {field_docstring, 1}, {field_name, 3}, - [13] = + [12] = {field_docstring, 0}, {field_docstring, 1}, {field_name, 3}, @@ -606,63 +601,63 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { ACCEPT_TOKEN(anon_sym_POUNDdocstring_COLON); END_STATE(); case 55: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'a') ADVANCE(80); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 56: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'c') ADVANCE(60); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 57: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(62); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 58: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(63); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 59: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(77); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 60: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(47); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 61: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(70); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 62: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'f') ADVANCE(65); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 63: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'f') ADVANCE(59); if (lookahead == 'l') ADVANCE(55); if (lookahead != 0 && @@ -670,133 +665,133 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { lookahead != ' ') ADVANCE(82); END_STATE(); case 64: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'h') ADVANCE(67); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 65: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(73); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 66: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(74); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 67: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(76); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 68: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(75); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 69: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(81); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 70: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'n') ADVANCE(56); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 71: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'n') ADVANCE(78); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 72: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'n') ADVANCE(45); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 73: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'n') ADVANCE(69); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 74: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'o') ADVANCE(71); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 75: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'o') ADVANCE(72); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 76: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'p') ADVANCE(79); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 77: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 'r') ADVANCE(61); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 78: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 's') ADVANCE(64); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 79: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 's') ADVANCE(49); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 80: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 't') ADVANCE(66); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 81: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead == 't') ADVANCE(68); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); END_STATE(); case 82: - ACCEPT_TOKEN(sym_workspace_identifier); + ACCEPT_TOKEN(sym_name); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && lookahead != ' ') ADVANCE(82); @@ -1089,7 +1084,7 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [STATE(0)] = { [ts_builtin_sym_end] = ACTIONS(1), - [sym_workspace_identifier] = ACTIONS(1), + [sym_name] = ACTIONS(1), [anon_sym_definition] = ACTIONS(1), [anon_sym_reference] = ACTIONS(1), [anon_sym_forward_definition] = ACTIONS(1), @@ -1302,7 +1297,7 @@ static const uint16_t ts_small_parse_table[] = { aux_sym_definition_statement_repeat1, [239] = 7, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(81), 1, anon_sym_forward_definition, ACTIONS(83), 1, @@ -1317,7 +1312,7 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, [261] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1330,7 +1325,7 @@ static const uint16_t ts_small_parse_table[] = { sym_global_identifier, [280] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1343,7 +1338,7 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, [299] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1365,7 +1360,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUNDdocstring_COLON, [329] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1378,7 +1373,7 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, [348] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1391,7 +1386,7 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, [367] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1404,7 +1399,7 @@ static const uint16_t ts_small_parse_table[] = { sym_global_identifier, [386] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1417,7 +1412,7 @@ static const uint16_t ts_small_parse_table[] = { sym_identifier, [405] = 6, ACTIONS(79), 1, - sym_workspace_identifier, + sym_name, ACTIONS(83), 1, anon_sym_local, ACTIONS(85), 1, @@ -1505,16 +1500,16 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_definition, [518] = 1, ACTIONS(129), 1, - sym_workspace_identifier, + sym_name, [522] = 1, ACTIONS(131), 1, aux_sym_comment_token1, [526] = 1, ACTIONS(133), 1, - sym_workspace_identifier, + sym_name, [530] = 1, ACTIONS(135), 1, - sym_workspace_identifier, + sym_name, [534] = 1, ACTIONS(137), 1, aux_sym_comment_token1, @@ -1602,57 +1597,57 @@ static const TSParseActionEntry ts_parse_actions[] = { [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(13), [28] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(33), [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(36), - [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 2, 0, 2), + [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 2, 0, 1), [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), - [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 5), + [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 4), [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), [48] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), [51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), [57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(21), - [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 2), + [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 1), [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), [64] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), [67] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), [70] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), - [73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 5), - [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 4, 0, 8), - [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 5, 0, 9), + [73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 4), + [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 4, 0, 7), + [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 5, 0, 8), [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), [83] = {.entry = {.count = 1, .reusable = false}}, SHIFT(34), [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(35), [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__statement, 2, 0, 0), [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__statement, 2, 0, 0), - [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 3, 0, 7), - [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 3, 0, 7), - [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_local_identifier, 2, 0, 2), - [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_local_identifier, 2, 0, 2), - [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 1), - [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 1), - [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 3), - [105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 3), - [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 4), - [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 4), - [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 2), - [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 2), - [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 2), - [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 2), - [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 2), - [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 2), - [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 2), - [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 2), + [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 3, 0, 6), + [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 3, 0, 6), + [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_local_identifier, 2, 0, 1), + [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_local_identifier, 2, 0, 1), + [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 0), + [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 0), + [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 2), + [105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 2), + [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 3), + [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 3), + [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 1), + [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 1), + [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 1), + [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 1), + [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 1), + [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 1), + [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 1), + [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 1), [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), [129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), [131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), [135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [139] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 6), - [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 2), + [139] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 5), + [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 1), [143] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), [145] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), [147] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), @@ -1698,7 +1693,7 @@ TS_PUBLIC const TSLanguage *tree_sitter_reprolang(void) { .lex_modes = (const void*)ts_lex_modes, .lex_fn = ts_lex, .keyword_lex_fn = ts_lex_keywords, - .keyword_capture_token = sym_workspace_identifier, + .keyword_capture_token = sym_name, .primary_state_ids = ts_primary_state_ids, }; return &language; From def6ef7385df7588af6a1e90bbf4b71c2e1462ed Mon Sep 17 00:00:00 2001 From: jupblb Date: Wed, 18 Mar 2026 13:48:50 +0100 Subject: [PATCH 3/4] reprolang: drop 'global' keyword from cross-repo references Cross-repo references are now written as just ' ' instead of 'global '. The keyword was redundant since all non-local symbols are global by default. --- reprolang/grammar.js | 9 +- reprolang/grammar/grammar.json | 4 - reprolang/grammar/node-types.json | 4 - reprolang/grammar/parser.c | 1052 ++++++++--------- .../input/global-cross-repo/reference.repro | 4 +- .../implementation-cross-repo/bird.repro | 2 +- .../output/global-cross-repo/reference.repro | 8 +- .../implementation-cross-repo/bird.repro | 4 +- 8 files changed, 506 insertions(+), 581 deletions(-) diff --git a/reprolang/grammar.js b/reprolang/grammar.js index 6198fdf9..c013882b 100644 --- a/reprolang/grammar.js +++ b/reprolang/grammar.js @@ -58,14 +58,9 @@ module.exports = grammar({ field('global', $.global_identifier), $.name ), - local_identifier: $ => - seq('local', field('name', $.name)), + local_identifier: $ => seq('local', field('name', $.name)), global_identifier: $ => - seq( - 'global', - field('project_name', $.name), - field('descriptors', $.name) - ), + seq(field('project_name', $.name), field('descriptors', $.name)), name: $ => /[^\s]+/, }, }) diff --git a/reprolang/grammar/grammar.json b/reprolang/grammar/grammar.json index c3f69a3c..11a5f77f 100644 --- a/reprolang/grammar/grammar.json +++ b/reprolang/grammar/grammar.json @@ -323,10 +323,6 @@ "global_identifier": { "type": "SEQ", "members": [ - { - "type": "STRING", - "value": "global" - }, { "type": "FIELD", "name": "project_name", diff --git a/reprolang/grammar/node-types.json b/reprolang/grammar/node-types.json index 9bebd339..b8d1e1b6 100644 --- a/reprolang/grammar/node-types.json +++ b/reprolang/grammar/node-types.json @@ -315,10 +315,6 @@ "type": "forward_definition", "named": false }, - { - "type": "global", - "named": false - }, { "type": "implements", "named": false diff --git a/reprolang/grammar/parser.c b/reprolang/grammar/parser.c index 68eb3cae..9968af21 100644 --- a/reprolang/grammar/parser.c +++ b/reprolang/grammar/parser.c @@ -7,11 +7,11 @@ #endif #define LANGUAGE_VERSION 14 -#define STATE_COUNT 44 +#define STATE_COUNT 42 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 35 +#define SYMBOL_COUNT 34 #define ALIAS_COUNT 0 -#define TOKEN_COUNT 16 +#define TOKEN_COUNT 15 #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 8 #define MAX_ALIAS_SEQUENCE_LENGTH 5 @@ -34,26 +34,25 @@ enum ts_symbol_identifiers { aux_sym_comment_token1 = 12, anon_sym_POUNDdocstring_COLON = 13, anon_sym_local = 14, - anon_sym_global = 15, - sym_source_file = 16, - sym__statement = 17, - sym_definition_statement = 18, - sym_reference_statement = 19, - sym__definition_relations = 20, - sym_implementation_relation = 21, - sym_type_definition_relation = 22, - sym_references_relation = 23, - sym_relationships_statement = 24, - sym__all_relations = 25, - sym_defined_by_relation = 26, - sym_comment = 27, - sym_docstring = 28, - sym_identifier = 29, - sym_local_identifier = 30, - sym_global_identifier = 31, - aux_sym_source_file_repeat1 = 32, - aux_sym_definition_statement_repeat1 = 33, - aux_sym_relationships_statement_repeat1 = 34, + sym_source_file = 15, + sym__statement = 16, + sym_definition_statement = 17, + sym_reference_statement = 18, + sym__definition_relations = 19, + sym_implementation_relation = 20, + sym_type_definition_relation = 21, + sym_references_relation = 22, + sym_relationships_statement = 23, + sym__all_relations = 24, + sym_defined_by_relation = 25, + sym_comment = 26, + sym_docstring = 27, + sym_identifier = 28, + sym_local_identifier = 29, + sym_global_identifier = 30, + aux_sym_source_file_repeat1 = 31, + aux_sym_definition_statement_repeat1 = 32, + aux_sym_relationships_statement_repeat1 = 33, }; static const char * const ts_symbol_names[] = { @@ -72,7 +71,6 @@ static const char * const ts_symbol_names[] = { [aux_sym_comment_token1] = "comment_token1", [anon_sym_POUNDdocstring_COLON] = "# docstring:", [anon_sym_local] = "local", - [anon_sym_global] = "global", [sym_source_file] = "source_file", [sym__statement] = "_statement", [sym_definition_statement] = "definition_statement", @@ -110,7 +108,6 @@ static const TSSymbol ts_symbol_map[] = { [aux_sym_comment_token1] = aux_sym_comment_token1, [anon_sym_POUNDdocstring_COLON] = anon_sym_POUNDdocstring_COLON, [anon_sym_local] = anon_sym_local, - [anon_sym_global] = anon_sym_global, [sym_source_file] = sym_source_file, [sym__statement] = sym__statement, [sym_definition_statement] = sym_definition_statement, @@ -193,10 +190,6 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, - [anon_sym_global] = { - .visible = true, - .named = false, - }, [sym_source_file] = { .visible = true, .named = true, @@ -317,14 +310,14 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [2] = {field_global, 0}, [3] = + {field_descriptors, 1}, + {field_project_name, 0}, + [5] = {field_name, 1}, {field_roles, 2}, - [5] = + [7] = {field_forward_definition, 1}, {field_name, 2}, - [7] = - {field_descriptors, 2}, - {field_project_name, 1}, [9] = {field_docstring, 0}, {field_docstring, 1}, @@ -387,8 +380,6 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [39] = 39, [40] = 40, [41] = 41, - [42] = 42, - [43] = 43, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { @@ -396,405 +387,400 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { eof = lexer->eof(lexer); switch (state) { case 0: - if (eof) ADVANCE(42); - if (lookahead == '#') ADVANCE(51); - if (lookahead == 'd') ADVANCE(57); - if (lookahead == 'r') ADVANCE(58); + if (eof) ADVANCE(41); + if (lookahead == '#') ADVANCE(50); + if (lookahead == 'd') ADVANCE(56); + if (lookahead == 'r') ADVANCE(57); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); - if (lookahead != 0) ADVANCE(82); + if (lookahead != 0) ADVANCE(81); END_STATE(); case 1: - if (lookahead == '\n') ADVANCE(43); + if (lookahead == '\n') ADVANCE(42); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(1); - if (lookahead != 0) ADVANCE(82); + if (lookahead != 0) ADVANCE(81); END_STATE(); case 2: - if (lookahead == '\n') ADVANCE(43); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(2); + if (lookahead == ':') ADVANCE(53); END_STATE(); case 3: - if (lookahead == ':') ADVANCE(54); + if (lookahead == 'a') ADVANCE(37); END_STATE(); case 4: - if (lookahead == 'a') ADVANCE(38); + if (lookahead == 'c') ADVANCE(33); END_STATE(); case 5: - if (lookahead == 'c') ADVANCE(34); + if (lookahead == 'c') ADVANCE(9); END_STATE(); case 6: - if (lookahead == 'c') ADVANCE(10); + if (lookahead == 'd') ADVANCE(27); END_STATE(); case 7: - if (lookahead == 'd') ADVANCE(28); + if (lookahead == 'e') ADVANCE(13); END_STATE(); case 8: - if (lookahead == 'e') ADVANCE(14); + if (lookahead == 'e') ADVANCE(12); END_STATE(); case 9: - if (lookahead == 'e') ADVANCE(13); + if (lookahead == 'e') ADVANCE(45); END_STATE(); case 10: - if (lookahead == 'e') ADVANCE(46); + if (lookahead == 'e') ADVANCE(32); END_STATE(); case 11: - if (lookahead == 'e') ADVANCE(33); + if (lookahead == 'e') ADVANCE(24); END_STATE(); case 12: - if (lookahead == 'e') ADVANCE(25); + if (lookahead == 'f') ADVANCE(10); + if (lookahead == 'l') ADVANCE(3); END_STATE(); case 13: - if (lookahead == 'f') ADVANCE(11); - if (lookahead == 'l') ADVANCE(4); + if (lookahead == 'f') ADVANCE(19); END_STATE(); case 14: - if (lookahead == 'f') ADVANCE(20); + if (lookahead == 'g') ADVANCE(2); END_STATE(); case 15: - if (lookahead == 'g') ADVANCE(3); + if (lookahead == 'h') ADVANCE(17); END_STATE(); case 16: - if (lookahead == 'h') ADVANCE(18); + if (lookahead == 'i') ADVANCE(22); END_STATE(); case 17: - if (lookahead == 'i') ADVANCE(23); + if (lookahead == 'i') ADVANCE(30); END_STATE(); case 18: - if (lookahead == 'i') ADVANCE(31); + if (lookahead == 'i') ADVANCE(28); END_STATE(); case 19: - if (lookahead == 'i') ADVANCE(29); + if (lookahead == 'i') ADVANCE(26); END_STATE(); case 20: - if (lookahead == 'i') ADVANCE(27); + if (lookahead == 'i') ADVANCE(29); END_STATE(); case 21: - if (lookahead == 'i') ADVANCE(30); + if (lookahead == 'i') ADVANCE(38); END_STATE(); case 22: - if (lookahead == 'i') ADVANCE(39); + if (lookahead == 'n') ADVANCE(14); END_STATE(); case 23: - if (lookahead == 'n') ADVANCE(15); + if (lookahead == 'n') ADVANCE(43); END_STATE(); case 24: - if (lookahead == 'n') ADVANCE(44); + if (lookahead == 'n') ADVANCE(5); END_STATE(); case 25: - if (lookahead == 'n') ADVANCE(6); + if (lookahead == 'n') ADVANCE(34); END_STATE(); case 26: - if (lookahead == 'n') ADVANCE(35); + if (lookahead == 'n') ADVANCE(21); END_STATE(); case 27: - if (lookahead == 'n') ADVANCE(22); + if (lookahead == 'o') ADVANCE(4); END_STATE(); case 28: - if (lookahead == 'o') ADVANCE(5); + if (lookahead == 'o') ADVANCE(25); END_STATE(); case 29: - if (lookahead == 'o') ADVANCE(26); + if (lookahead == 'o') ADVANCE(23); END_STATE(); case 30: - if (lookahead == 'o') ADVANCE(24); + if (lookahead == 'p') ADVANCE(35); END_STATE(); case 31: - if (lookahead == 'p') ADVANCE(36); + if (lookahead == 'r') ADVANCE(16); END_STATE(); case 32: - if (lookahead == 'r') ADVANCE(17); + if (lookahead == 'r') ADVANCE(11); END_STATE(); case 33: - if (lookahead == 'r') ADVANCE(12); + if (lookahead == 's') ADVANCE(36); END_STATE(); case 34: - if (lookahead == 's') ADVANCE(37); + if (lookahead == 's') ADVANCE(15); END_STATE(); case 35: - if (lookahead == 's') ADVANCE(16); + if (lookahead == 's') ADVANCE(47); END_STATE(); case 36: - if (lookahead == 's') ADVANCE(48); + if (lookahead == 't') ADVANCE(31); END_STATE(); case 37: - if (lookahead == 't') ADVANCE(32); + if (lookahead == 't') ADVANCE(18); END_STATE(); case 38: - if (lookahead == 't') ADVANCE(19); + if (lookahead == 't') ADVANCE(20); END_STATE(); case 39: - if (lookahead == 't') ADVANCE(21); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(39); + if (lookahead != 0) ADVANCE(81); END_STATE(); case 40: + if (eof) ADVANCE(41); + if (lookahead == '#') ADVANCE(49); + if (lookahead == 'd') ADVANCE(7); + if (lookahead == 'r') ADVANCE(8); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(40); - if (lookahead != 0) ADVANCE(82); END_STATE(); case 41: - if (eof) ADVANCE(42); - if (lookahead == '#') ADVANCE(50); - if (lookahead == 'd') ADVANCE(8); - if (lookahead == 'r') ADVANCE(9); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(41); - END_STATE(); - case 42: ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); - case 43: + case 42: ACCEPT_TOKEN(anon_sym_LF); - if (lookahead == '\n') ADVANCE(43); + if (lookahead == '\n') ADVANCE(42); END_STATE(); - case 44: + case 43: ACCEPT_TOKEN(anon_sym_definition); END_STATE(); - case 45: + case 44: ACCEPT_TOKEN(anon_sym_definition); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); - case 46: + case 45: ACCEPT_TOKEN(anon_sym_reference); END_STATE(); - case 47: + case 46: ACCEPT_TOKEN(anon_sym_reference); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); - case 48: + case 47: ACCEPT_TOKEN(anon_sym_relationships); END_STATE(); - case 49: + case 48: ACCEPT_TOKEN(anon_sym_relationships); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); - case 50: + case 49: ACCEPT_TOKEN(anon_sym_POUND); - if (lookahead == ' ') ADVANCE(7); + if (lookahead == ' ') ADVANCE(6); END_STATE(); - case 51: + case 50: ACCEPT_TOKEN(anon_sym_POUND); - if (lookahead == ' ') ADVANCE(7); + if (lookahead == ' ') ADVANCE(6); if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead)) ADVANCE(82); + (lookahead < '\t' || '\r' < lookahead)) ADVANCE(81); END_STATE(); - case 52: + case 51: ACCEPT_TOKEN(aux_sym_comment_token1); if (lookahead == '\t' || (0x0b <= lookahead && lookahead <= '\r') || - lookahead == ' ') ADVANCE(52); + lookahead == ' ') ADVANCE(51); if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead)) ADVANCE(53); + (lookahead < '\t' || '\r' < lookahead)) ADVANCE(52); END_STATE(); - case 53: + case 52: ACCEPT_TOKEN(aux_sym_comment_token1); if (lookahead != 0 && - lookahead != '\n') ADVANCE(53); + lookahead != '\n') ADVANCE(52); END_STATE(); - case 54: + case 53: ACCEPT_TOKEN(anon_sym_POUNDdocstring_COLON); END_STATE(); + case 54: + ACCEPT_TOKEN(sym_name); + if (lookahead == 'a') ADVANCE(79); + if (lookahead != 0 && + (lookahead < '\t' || '\r' < lookahead) && + lookahead != ' ') ADVANCE(81); + END_STATE(); case 55: ACCEPT_TOKEN(sym_name); - if (lookahead == 'a') ADVANCE(80); + if (lookahead == 'c') ADVANCE(59); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 56: ACCEPT_TOKEN(sym_name); - if (lookahead == 'c') ADVANCE(60); + if (lookahead == 'e') ADVANCE(61); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 57: ACCEPT_TOKEN(sym_name); if (lookahead == 'e') ADVANCE(62); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 58: ACCEPT_TOKEN(sym_name); - if (lookahead == 'e') ADVANCE(63); + if (lookahead == 'e') ADVANCE(76); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 59: ACCEPT_TOKEN(sym_name); - if (lookahead == 'e') ADVANCE(77); + if (lookahead == 'e') ADVANCE(46); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 60: ACCEPT_TOKEN(sym_name); - if (lookahead == 'e') ADVANCE(47); + if (lookahead == 'e') ADVANCE(69); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 61: ACCEPT_TOKEN(sym_name); - if (lookahead == 'e') ADVANCE(70); + if (lookahead == 'f') ADVANCE(64); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 62: ACCEPT_TOKEN(sym_name); - if (lookahead == 'f') ADVANCE(65); + if (lookahead == 'f') ADVANCE(58); + if (lookahead == 'l') ADVANCE(54); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 63: ACCEPT_TOKEN(sym_name); - if (lookahead == 'f') ADVANCE(59); - if (lookahead == 'l') ADVANCE(55); + if (lookahead == 'h') ADVANCE(66); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 64: ACCEPT_TOKEN(sym_name); - if (lookahead == 'h') ADVANCE(67); + if (lookahead == 'i') ADVANCE(72); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 65: ACCEPT_TOKEN(sym_name); if (lookahead == 'i') ADVANCE(73); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 66: ACCEPT_TOKEN(sym_name); - if (lookahead == 'i') ADVANCE(74); + if (lookahead == 'i') ADVANCE(75); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 67: ACCEPT_TOKEN(sym_name); - if (lookahead == 'i') ADVANCE(76); + if (lookahead == 'i') ADVANCE(74); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 68: ACCEPT_TOKEN(sym_name); - if (lookahead == 'i') ADVANCE(75); + if (lookahead == 'i') ADVANCE(80); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 69: ACCEPT_TOKEN(sym_name); - if (lookahead == 'i') ADVANCE(81); + if (lookahead == 'n') ADVANCE(55); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 70: ACCEPT_TOKEN(sym_name); - if (lookahead == 'n') ADVANCE(56); + if (lookahead == 'n') ADVANCE(77); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 71: ACCEPT_TOKEN(sym_name); - if (lookahead == 'n') ADVANCE(78); + if (lookahead == 'n') ADVANCE(44); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 72: ACCEPT_TOKEN(sym_name); - if (lookahead == 'n') ADVANCE(45); + if (lookahead == 'n') ADVANCE(68); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 73: ACCEPT_TOKEN(sym_name); - if (lookahead == 'n') ADVANCE(69); + if (lookahead == 'o') ADVANCE(70); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 74: ACCEPT_TOKEN(sym_name); if (lookahead == 'o') ADVANCE(71); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 75: ACCEPT_TOKEN(sym_name); - if (lookahead == 'o') ADVANCE(72); + if (lookahead == 'p') ADVANCE(78); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 76: ACCEPT_TOKEN(sym_name); - if (lookahead == 'p') ADVANCE(79); + if (lookahead == 'r') ADVANCE(60); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 77: ACCEPT_TOKEN(sym_name); - if (lookahead == 'r') ADVANCE(61); + if (lookahead == 's') ADVANCE(63); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 78: ACCEPT_TOKEN(sym_name); - if (lookahead == 's') ADVANCE(64); + if (lookahead == 's') ADVANCE(48); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 79: ACCEPT_TOKEN(sym_name); - if (lookahead == 's') ADVANCE(49); + if (lookahead == 't') ADVANCE(65); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 80: ACCEPT_TOKEN(sym_name); - if (lookahead == 't') ADVANCE(66); + if (lookahead == 't') ADVANCE(67); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); case 81: - ACCEPT_TOKEN(sym_name); - if (lookahead == 't') ADVANCE(68); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); - END_STATE(); - case 82: ACCEPT_TOKEN(sym_name); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); default: return false; @@ -808,225 +794,206 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { case 0: if (lookahead == 'd') ADVANCE(1); if (lookahead == 'f') ADVANCE(2); - if (lookahead == 'g') ADVANCE(3); - if (lookahead == 'i') ADVANCE(4); - if (lookahead == 'l') ADVANCE(5); - if (lookahead == 'r') ADVANCE(6); - if (lookahead == 't') ADVANCE(7); + if (lookahead == 'i') ADVANCE(3); + if (lookahead == 'l') ADVANCE(4); + if (lookahead == 'r') ADVANCE(5); + if (lookahead == 't') ADVANCE(6); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); END_STATE(); case 1: - if (lookahead == 'e') ADVANCE(8); + if (lookahead == 'e') ADVANCE(7); END_STATE(); case 2: - if (lookahead == 'o') ADVANCE(9); + if (lookahead == 'o') ADVANCE(8); END_STATE(); case 3: - if (lookahead == 'l') ADVANCE(10); + if (lookahead == 'm') ADVANCE(9); END_STATE(); case 4: - if (lookahead == 'm') ADVANCE(11); + if (lookahead == 'o') ADVANCE(10); END_STATE(); case 5: - if (lookahead == 'o') ADVANCE(12); + if (lookahead == 'e') ADVANCE(11); END_STATE(); case 6: - if (lookahead == 'e') ADVANCE(13); + if (lookahead == 'y') ADVANCE(12); END_STATE(); case 7: - if (lookahead == 'y') ADVANCE(14); + if (lookahead == 'f') ADVANCE(13); END_STATE(); case 8: - if (lookahead == 'f') ADVANCE(15); + if (lookahead == 'r') ADVANCE(14); END_STATE(); case 9: - if (lookahead == 'r') ADVANCE(16); + if (lookahead == 'p') ADVANCE(15); END_STATE(); case 10: - if (lookahead == 'o') ADVANCE(17); + if (lookahead == 'c') ADVANCE(16); END_STATE(); case 11: - if (lookahead == 'p') ADVANCE(18); + if (lookahead == 'f') ADVANCE(17); END_STATE(); case 12: - if (lookahead == 'c') ADVANCE(19); + if (lookahead == 'p') ADVANCE(18); END_STATE(); case 13: - if (lookahead == 'f') ADVANCE(20); + if (lookahead == 'i') ADVANCE(19); END_STATE(); case 14: - if (lookahead == 'p') ADVANCE(21); + if (lookahead == 'w') ADVANCE(20); END_STATE(); case 15: - if (lookahead == 'i') ADVANCE(22); + if (lookahead == 'l') ADVANCE(21); END_STATE(); case 16: - if (lookahead == 'w') ADVANCE(23); + if (lookahead == 'a') ADVANCE(22); END_STATE(); case 17: - if (lookahead == 'b') ADVANCE(24); + if (lookahead == 'e') ADVANCE(23); END_STATE(); case 18: - if (lookahead == 'l') ADVANCE(25); + if (lookahead == 'e') ADVANCE(24); END_STATE(); case 19: - if (lookahead == 'a') ADVANCE(26); + if (lookahead == 'n') ADVANCE(25); END_STATE(); case 20: - if (lookahead == 'e') ADVANCE(27); + if (lookahead == 'a') ADVANCE(26); END_STATE(); case 21: - if (lookahead == 'e') ADVANCE(28); + if (lookahead == 'e') ADVANCE(27); END_STATE(); case 22: - if (lookahead == 'n') ADVANCE(29); + if (lookahead == 'l') ADVANCE(28); END_STATE(); case 23: - if (lookahead == 'a') ADVANCE(30); + if (lookahead == 'r') ADVANCE(29); END_STATE(); case 24: - if (lookahead == 'a') ADVANCE(31); + if (lookahead == '_') ADVANCE(30); END_STATE(); case 25: - if (lookahead == 'e') ADVANCE(32); + if (lookahead == 'e') ADVANCE(31); END_STATE(); case 26: - if (lookahead == 'l') ADVANCE(33); + if (lookahead == 'r') ADVANCE(32); END_STATE(); case 27: - if (lookahead == 'r') ADVANCE(34); + if (lookahead == 'm') ADVANCE(33); END_STATE(); case 28: - if (lookahead == '_') ADVANCE(35); + ACCEPT_TOKEN(anon_sym_local); END_STATE(); case 29: - if (lookahead == 'e') ADVANCE(36); + if (lookahead == 'e') ADVANCE(34); END_STATE(); case 30: - if (lookahead == 'r') ADVANCE(37); + if (lookahead == 'd') ADVANCE(35); END_STATE(); case 31: - if (lookahead == 'l') ADVANCE(38); + if (lookahead == 'd') ADVANCE(36); END_STATE(); case 32: - if (lookahead == 'm') ADVANCE(39); + if (lookahead == 'd') ADVANCE(37); END_STATE(); case 33: - ACCEPT_TOKEN(anon_sym_local); + if (lookahead == 'e') ADVANCE(38); END_STATE(); case 34: - if (lookahead == 'e') ADVANCE(40); + if (lookahead == 'n') ADVANCE(39); END_STATE(); case 35: - if (lookahead == 'd') ADVANCE(41); + if (lookahead == 'e') ADVANCE(40); END_STATE(); case 36: - if (lookahead == 'd') ADVANCE(42); + if (lookahead == '_') ADVANCE(41); END_STATE(); case 37: - if (lookahead == 'd') ADVANCE(43); + if (lookahead == '_') ADVANCE(42); END_STATE(); case 38: - ACCEPT_TOKEN(anon_sym_global); + if (lookahead == 'n') ADVANCE(43); END_STATE(); case 39: - if (lookahead == 'e') ADVANCE(44); + if (lookahead == 'c') ADVANCE(44); END_STATE(); case 40: - if (lookahead == 'n') ADVANCE(45); + if (lookahead == 'f') ADVANCE(45); END_STATE(); case 41: - if (lookahead == 'e') ADVANCE(46); + if (lookahead == 'b') ADVANCE(46); END_STATE(); case 42: - if (lookahead == '_') ADVANCE(47); + if (lookahead == 'd') ADVANCE(47); END_STATE(); case 43: - if (lookahead == '_') ADVANCE(48); + if (lookahead == 't') ADVANCE(48); END_STATE(); case 44: - if (lookahead == 'n') ADVANCE(49); + if (lookahead == 'e') ADVANCE(49); END_STATE(); case 45: - if (lookahead == 'c') ADVANCE(50); + if (lookahead == 'i') ADVANCE(50); END_STATE(); case 46: - if (lookahead == 'f') ADVANCE(51); + if (lookahead == 'y') ADVANCE(51); END_STATE(); case 47: - if (lookahead == 'b') ADVANCE(52); + if (lookahead == 'e') ADVANCE(52); END_STATE(); case 48: - if (lookahead == 'd') ADVANCE(53); + if (lookahead == 's') ADVANCE(53); END_STATE(); case 49: - if (lookahead == 't') ADVANCE(54); + if (lookahead == 's') ADVANCE(54); END_STATE(); case 50: - if (lookahead == 'e') ADVANCE(55); + if (lookahead == 'n') ADVANCE(55); END_STATE(); case 51: - if (lookahead == 'i') ADVANCE(56); + ACCEPT_TOKEN(anon_sym_defined_by); END_STATE(); case 52: - if (lookahead == 'y') ADVANCE(57); + if (lookahead == 'f') ADVANCE(56); END_STATE(); case 53: - if (lookahead == 'e') ADVANCE(58); + ACCEPT_TOKEN(anon_sym_implements); END_STATE(); case 54: - if (lookahead == 's') ADVANCE(59); + ACCEPT_TOKEN(anon_sym_references); END_STATE(); case 55: - if (lookahead == 's') ADVANCE(60); + if (lookahead == 'e') ADVANCE(57); END_STATE(); case 56: - if (lookahead == 'n') ADVANCE(61); + if (lookahead == 'i') ADVANCE(58); END_STATE(); case 57: - ACCEPT_TOKEN(anon_sym_defined_by); + if (lookahead == 's') ADVANCE(59); END_STATE(); case 58: - if (lookahead == 'f') ADVANCE(62); + if (lookahead == 'n') ADVANCE(60); END_STATE(); case 59: - ACCEPT_TOKEN(anon_sym_implements); + ACCEPT_TOKEN(anon_sym_type_defines); END_STATE(); case 60: - ACCEPT_TOKEN(anon_sym_references); + if (lookahead == 'i') ADVANCE(61); END_STATE(); case 61: - if (lookahead == 'e') ADVANCE(63); + if (lookahead == 't') ADVANCE(62); END_STATE(); case 62: - if (lookahead == 'i') ADVANCE(64); + if (lookahead == 'i') ADVANCE(63); END_STATE(); case 63: - if (lookahead == 's') ADVANCE(65); + if (lookahead == 'o') ADVANCE(64); END_STATE(); case 64: - if (lookahead == 'n') ADVANCE(66); + if (lookahead == 'n') ADVANCE(65); END_STATE(); case 65: - ACCEPT_TOKEN(anon_sym_type_defines); - END_STATE(); - case 66: - if (lookahead == 'i') ADVANCE(67); - END_STATE(); - case 67: - if (lookahead == 't') ADVANCE(68); - END_STATE(); - case 68: - if (lookahead == 'i') ADVANCE(69); - END_STATE(); - case 69: - if (lookahead == 'o') ADVANCE(70); - END_STATE(); - case 70: - if (lookahead == 'n') ADVANCE(71); - END_STATE(); - case 71: ACCEPT_TOKEN(anon_sym_forward_definition); END_STATE(); default: @@ -1036,9 +1003,9 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { static const TSLexMode ts_lex_modes[STATE_COUNT] = { [0] = {.lex_state = 0}, - [1] = {.lex_state = 41}, - [2] = {.lex_state = 41}, - [3] = {.lex_state = 41}, + [1] = {.lex_state = 40}, + [2] = {.lex_state = 40}, + [3] = {.lex_state = 40}, [4] = {.lex_state = 1}, [5] = {.lex_state = 1}, [6] = {.lex_state = 1}, @@ -1047,38 +1014,36 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [9] = {.lex_state = 1}, [10] = {.lex_state = 1}, [11] = {.lex_state = 1}, - [12] = {.lex_state = 40}, + [12] = {.lex_state = 1}, [13] = {.lex_state = 40}, - [14] = {.lex_state = 40}, - [15] = {.lex_state = 40}, - [16] = {.lex_state = 41}, - [17] = {.lex_state = 40}, - [18] = {.lex_state = 40}, - [19] = {.lex_state = 40}, - [20] = {.lex_state = 40}, - [21] = {.lex_state = 40}, + [14] = {.lex_state = 39}, + [15] = {.lex_state = 1}, + [16] = {.lex_state = 39}, + [17] = {.lex_state = 39}, + [18] = {.lex_state = 1}, + [19] = {.lex_state = 1}, + [20] = {.lex_state = 39}, + [21] = {.lex_state = 39}, [22] = {.lex_state = 1}, - [23] = {.lex_state = 1}, - [24] = {.lex_state = 1}, - [25] = {.lex_state = 1}, - [26] = {.lex_state = 1}, + [23] = {.lex_state = 39}, + [24] = {.lex_state = 39}, + [25] = {.lex_state = 39}, + [26] = {.lex_state = 39}, [27] = {.lex_state = 1}, [28] = {.lex_state = 1}, [29] = {.lex_state = 1}, [30] = {.lex_state = 1}, - [31] = {.lex_state = 41}, - [32] = {.lex_state = 40}, - [33] = {.lex_state = 52}, - [34] = {.lex_state = 40}, - [35] = {.lex_state = 40}, - [36] = {.lex_state = 52}, - [37] = {.lex_state = 2}, - [38] = {.lex_state = 2}, - [39] = {.lex_state = 2}, - [40] = {.lex_state = 0}, - [41] = {.lex_state = 2}, - [42] = {.lex_state = 2}, - [43] = {.lex_state = 2}, + [31] = {.lex_state = 1}, + [32] = {.lex_state = 1}, + [33] = {.lex_state = 1}, + [34] = {.lex_state = 51}, + [35] = {.lex_state = 1}, + [36] = {.lex_state = 40}, + [37] = {.lex_state = 0}, + [38] = {.lex_state = 1}, + [39] = {.lex_state = 51}, + [40] = {.lex_state = 39}, + [41] = {.lex_state = 1}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { @@ -1096,16 +1061,15 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_POUND] = ACTIONS(1), [anon_sym_POUNDdocstring_COLON] = ACTIONS(1), [anon_sym_local] = ACTIONS(1), - [anon_sym_global] = ACTIONS(1), }, [STATE(1)] = { - [sym_source_file] = STATE(40), + [sym_source_file] = STATE(37), [sym__statement] = STATE(2), - [sym_definition_statement] = STATE(39), - [sym_reference_statement] = STATE(39), - [sym_relationships_statement] = STATE(39), - [sym_comment] = STATE(39), - [sym_docstring] = STATE(43), + [sym_definition_statement] = STATE(33), + [sym_reference_statement] = STATE(33), + [sym_relationships_statement] = STATE(33), + [sym_comment] = STATE(33), + [sym_docstring] = STATE(41), [aux_sym_source_file_repeat1] = STATE(2), [ts_builtin_sym_end] = ACTIONS(3), [anon_sym_definition] = ACTIONS(5), @@ -1130,12 +1094,12 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUNDdocstring_COLON, ACTIONS(15), 1, ts_builtin_sym_end, - STATE(43), 1, + STATE(41), 1, sym_docstring, STATE(3), 2, sym__statement, aux_sym_source_file_repeat1, - STATE(39), 4, + STATE(33), 4, sym_definition_statement, sym_reference_statement, sym_relationships_statement, @@ -1153,12 +1117,12 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUND, ACTIONS(31), 1, anon_sym_POUNDdocstring_COLON, - STATE(43), 1, + STATE(41), 1, sym_docstring, STATE(3), 2, sym__statement, aux_sym_source_file_repeat1, - STATE(39), 4, + STATE(33), 4, sym_definition_statement, sym_reference_statement, sym_relationships_statement, @@ -1174,7 +1138,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_references, ACTIONS(42), 1, anon_sym_defined_by, - STATE(5), 7, + STATE(6), 7, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, @@ -1193,7 +1157,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_defined_by, ACTIONS(44), 1, anon_sym_LF, - STATE(6), 7, + STATE(4), 7, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, @@ -1236,30 +1200,30 @@ static const uint16_t ts_small_parse_table[] = { sym_references_relation, aux_sym_definition_statement_repeat1, [159] = 5, - ACTIONS(62), 1, - anon_sym_LF, - ACTIONS(64), 1, + ACTIONS(36), 1, anon_sym_implements, - ACTIONS(67), 1, + ACTIONS(38), 1, anon_sym_type_defines, - ACTIONS(70), 1, + ACTIONS(40), 1, anon_sym_references, - STATE(8), 5, + ACTIONS(62), 1, + anon_sym_LF, + STATE(7), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, sym_references_relation, aux_sym_definition_statement_repeat1, [179] = 5, - ACTIONS(36), 1, + ACTIONS(64), 1, + anon_sym_LF, + ACTIONS(66), 1, anon_sym_implements, - ACTIONS(38), 1, + ACTIONS(69), 1, anon_sym_type_defines, - ACTIONS(40), 1, + ACTIONS(72), 1, anon_sym_references, - ACTIONS(73), 1, - anon_sym_LF, - STATE(8), 5, + STATE(9), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, @@ -1289,157 +1253,75 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_references, ACTIONS(77), 1, anon_sym_LF, - STATE(8), 5, + STATE(9), 5, sym__definition_relations, sym_implementation_relation, sym_type_definition_relation, sym_references_relation, aux_sym_definition_statement_repeat1, - [239] = 7, + [239] = 3, ACTIONS(79), 1, sym_name, ACTIONS(81), 1, - anon_sym_forward_definition, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - STATE(38), 1, - sym_identifier, - [261] = 6, - ACTIONS(79), 1, - sym_name, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(4), 1, - sym_identifier, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - [280] = 6, - ACTIONS(79), 1, - sym_name, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - STATE(37), 1, - sym_identifier, - [299] = 6, - ACTIONS(79), 1, - sym_name, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(7), 1, - sym_identifier, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - [318] = 2, - ACTIONS(89), 1, + anon_sym_LF, + ACTIONS(83), 4, + anon_sym_implements, + anon_sym_type_defines, + anon_sym_references, + anon_sym_defined_by, + [252] = 2, + ACTIONS(87), 1, anon_sym_POUND, - ACTIONS(87), 5, + ACTIONS(85), 5, ts_builtin_sym_end, anon_sym_definition, anon_sym_reference, anon_sym_relationships, anon_sym_POUNDdocstring_COLON, - [329] = 6, - ACTIONS(79), 1, - sym_name, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - STATE(29), 1, - sym_identifier, - [348] = 6, - ACTIONS(79), 1, + [263] = 6, + ACTIONS(89), 1, sym_name, - ACTIONS(83), 1, + ACTIONS(91), 1, + anon_sym_forward_definition, + ACTIONS(93), 1, anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, + STATE(22), 1, sym_global_identifier, STATE(30), 1, + sym_local_identifier, + STATE(35), 1, sym_identifier, - [367] = 6, - ACTIONS(79), 1, + [282] = 2, + ACTIONS(95), 1, + anon_sym_LF, + ACTIONS(97), 4, + anon_sym_implements, + anon_sym_type_defines, + anon_sym_references, + anon_sym_defined_by, + [292] = 5, + ACTIONS(89), 1, sym_name, - ACTIONS(83), 1, + ACTIONS(93), 1, anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(10), 1, - sym_identifier, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, + STATE(22), 1, sym_global_identifier, - [386] = 6, - ACTIONS(79), 1, - sym_name, - ACTIONS(83), 1, - anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, + STATE(30), 1, sym_local_identifier, - STATE(26), 1, - sym_global_identifier, - STATE(28), 1, + STATE(38), 1, sym_identifier, - [405] = 6, - ACTIONS(79), 1, + [308] = 5, + ACTIONS(89), 1, sym_name, - ACTIONS(83), 1, + ACTIONS(93), 1, anon_sym_local, - ACTIONS(85), 1, - anon_sym_global, - STATE(25), 1, - sym_local_identifier, - STATE(26), 1, + STATE(22), 1, sym_global_identifier, STATE(27), 1, sym_identifier, - [424] = 2, - ACTIONS(91), 1, - anon_sym_LF, - ACTIONS(93), 4, - anon_sym_implements, - anon_sym_type_defines, - anon_sym_references, - anon_sym_defined_by, - [434] = 2, - ACTIONS(95), 1, - anon_sym_LF, - ACTIONS(97), 4, - anon_sym_implements, - anon_sym_type_defines, - anon_sym_references, - anon_sym_defined_by, - [444] = 2, + STATE(30), 1, + sym_local_identifier, + [324] = 2, ACTIONS(99), 1, anon_sym_LF, ACTIONS(101), 4, @@ -1447,7 +1329,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [454] = 2, + [334] = 2, ACTIONS(103), 1, anon_sym_LF, ACTIONS(105), 4, @@ -1455,7 +1337,29 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [464] = 2, + [344] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(15), 1, + sym_identifier, + STATE(22), 1, + sym_global_identifier, + STATE(30), 1, + sym_local_identifier, + [360] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(22), 1, + sym_global_identifier, + STATE(29), 1, + sym_identifier, + STATE(30), 1, + sym_local_identifier, + [376] = 2, ACTIONS(107), 1, anon_sym_LF, ACTIONS(109), 4, @@ -1463,7 +1367,51 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [474] = 2, + [386] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(5), 1, + sym_identifier, + STATE(22), 1, + sym_global_identifier, + STATE(30), 1, + sym_local_identifier, + [402] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(22), 1, + sym_global_identifier, + STATE(28), 1, + sym_identifier, + STATE(30), 1, + sym_local_identifier, + [418] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(8), 1, + sym_identifier, + STATE(22), 1, + sym_global_identifier, + STATE(30), 1, + sym_local_identifier, + [434] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(10), 1, + sym_identifier, + STATE(22), 1, + sym_global_identifier, + STATE(30), 1, + sym_local_identifier, + [450] = 2, ACTIONS(111), 1, anon_sym_LF, ACTIONS(113), 4, @@ -1471,7 +1419,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [484] = 2, + [460] = 2, ACTIONS(115), 1, anon_sym_LF, ACTIONS(117), 4, @@ -1479,7 +1427,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [494] = 2, + [470] = 2, ACTIONS(119), 1, anon_sym_LF, ACTIONS(121), 4, @@ -1487,7 +1435,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [504] = 2, + [480] = 2, ACTIONS(123), 1, anon_sym_LF, ACTIONS(125), 4, @@ -1495,45 +1443,39 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [514] = 1, + [490] = 1, ACTIONS(127), 1, - anon_sym_definition, - [518] = 1, + anon_sym_LF, + [494] = 1, ACTIONS(129), 1, - sym_name, - [522] = 1, + anon_sym_LF, + [498] = 1, ACTIONS(131), 1, - aux_sym_comment_token1, - [526] = 1, + anon_sym_LF, + [502] = 1, ACTIONS(133), 1, - sym_name, - [530] = 1, + aux_sym_comment_token1, + [506] = 1, ACTIONS(135), 1, - sym_name, - [534] = 1, + anon_sym_LF, + [510] = 1, ACTIONS(137), 1, - aux_sym_comment_token1, - [538] = 1, + anon_sym_definition, + [514] = 1, ACTIONS(139), 1, - anon_sym_LF, - [542] = 1, + ts_builtin_sym_end, + [518] = 1, ACTIONS(141), 1, anon_sym_LF, - [546] = 1, + [522] = 1, ACTIONS(143), 1, - anon_sym_LF, - [550] = 1, + aux_sym_comment_token1, + [526] = 1, ACTIONS(145), 1, - ts_builtin_sym_end, - [554] = 1, + sym_name, + [530] = 1, ACTIONS(147), 1, anon_sym_LF, - [558] = 1, - ACTIONS(149), 1, - anon_sym_LF, - [562] = 1, - ACTIONS(151), 1, - anon_sym_LF, }; static const uint32_t ts_small_parse_table_map[] = { @@ -1548,111 +1490,107 @@ static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(10)] = 199, [SMALL_STATE(11)] = 219, [SMALL_STATE(12)] = 239, - [SMALL_STATE(13)] = 261, - [SMALL_STATE(14)] = 280, - [SMALL_STATE(15)] = 299, - [SMALL_STATE(16)] = 318, - [SMALL_STATE(17)] = 329, - [SMALL_STATE(18)] = 348, - [SMALL_STATE(19)] = 367, - [SMALL_STATE(20)] = 386, - [SMALL_STATE(21)] = 405, - [SMALL_STATE(22)] = 424, - [SMALL_STATE(23)] = 434, - [SMALL_STATE(24)] = 444, - [SMALL_STATE(25)] = 454, - [SMALL_STATE(26)] = 464, - [SMALL_STATE(27)] = 474, - [SMALL_STATE(28)] = 484, - [SMALL_STATE(29)] = 494, - [SMALL_STATE(30)] = 504, - [SMALL_STATE(31)] = 514, - [SMALL_STATE(32)] = 518, - [SMALL_STATE(33)] = 522, - [SMALL_STATE(34)] = 526, - [SMALL_STATE(35)] = 530, - [SMALL_STATE(36)] = 534, - [SMALL_STATE(37)] = 538, - [SMALL_STATE(38)] = 542, - [SMALL_STATE(39)] = 546, - [SMALL_STATE(40)] = 550, - [SMALL_STATE(41)] = 554, - [SMALL_STATE(42)] = 558, - [SMALL_STATE(43)] = 562, + [SMALL_STATE(13)] = 252, + [SMALL_STATE(14)] = 263, + [SMALL_STATE(15)] = 282, + [SMALL_STATE(16)] = 292, + [SMALL_STATE(17)] = 308, + [SMALL_STATE(18)] = 324, + [SMALL_STATE(19)] = 334, + [SMALL_STATE(20)] = 344, + [SMALL_STATE(21)] = 360, + [SMALL_STATE(22)] = 376, + [SMALL_STATE(23)] = 386, + [SMALL_STATE(24)] = 402, + [SMALL_STATE(25)] = 418, + [SMALL_STATE(26)] = 434, + [SMALL_STATE(27)] = 450, + [SMALL_STATE(28)] = 460, + [SMALL_STATE(29)] = 470, + [SMALL_STATE(30)] = 480, + [SMALL_STATE(31)] = 490, + [SMALL_STATE(32)] = 494, + [SMALL_STATE(33)] = 498, + [SMALL_STATE(34)] = 502, + [SMALL_STATE(35)] = 506, + [SMALL_STATE(36)] = 510, + [SMALL_STATE(37)] = 514, + [SMALL_STATE(38)] = 518, + [SMALL_STATE(39)] = 522, + [SMALL_STATE(40)] = 526, + [SMALL_STATE(41)] = 530, }; 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_source_file, 0, 0, 0), - [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(33), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), + [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), + [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(39), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), - [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(15), - [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(12), - [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(13), - [28] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(33), - [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(36), - [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 2, 0, 1), + [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(25), + [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(14), + [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(23), + [28] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(39), + [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(34), + [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 5), [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), - [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), - [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), - [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), - [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 3, 0, 4), + [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), + [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), + [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), + [44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_relationships_statement, 2, 0, 1), [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), [48] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), - [51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), - [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), - [57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(21), - [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 1), - [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), - [64] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), - [67] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(18), - [70] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), - [73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 4), + [51] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), + [54] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(21), + [57] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_relationships_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(24), + [60] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 3, 0, 5), + [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 2, 0, 1), + [64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), + [66] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(17), + [69] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(20), + [72] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_definition_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(21), [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 4, 0, 7), [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition_statement, 5, 0, 8), - [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), - [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), - [83] = {.entry = {.count = 1, .reusable = false}}, SHIFT(34), - [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(35), - [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__statement, 2, 0, 0), - [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__statement, 2, 0, 0), - [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 3, 0, 6), - [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 3, 0, 6), - [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_local_identifier, 2, 0, 1), - [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_local_identifier, 2, 0, 1), - [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 0), - [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 0), - [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 2), - [105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 2), + [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), + [81] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 0), + [83] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 0), + [85] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__statement, 2, 0, 0), + [87] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__statement, 2, 0, 0), + [89] = {.entry = {.count = 1, .reusable = false}}, SHIFT(12), + [91] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), + [93] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), + [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 1), + [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 1), + [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_global_identifier, 2, 0, 4), + [101] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_global_identifier, 2, 0, 4), + [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_local_identifier, 2, 0, 1), + [105] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_local_identifier, 2, 0, 1), [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 3), [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 3), - [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 1), - [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 1), - [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 1), - [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 1), - [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 1), - [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 1), - [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_definition_relation, 2, 0, 1), - [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_definition_relation, 2, 0, 1), - [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), - [131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), - [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), - [135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), - [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [139] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 5), - [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 1), - [143] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [145] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [147] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), - [149] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_docstring, 2, 0, 0), - [151] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), + [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_implementation_relation, 2, 0, 1), + [113] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_implementation_relation, 2, 0, 1), + [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_defined_by_relation, 2, 0, 1), + [117] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_defined_by_relation, 2, 0, 1), + [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_references_relation, 2, 0, 1), + [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_references_relation, 2, 0, 1), + [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 2), + [125] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_identifier, 1, 0, 2), + [127] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_docstring, 2, 0, 0), + [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2, 0, 0), + [131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), + [135] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 2, 0, 1), + [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), + [139] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reference_statement, 3, 0, 6), + [143] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [145] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [147] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), }; #ifdef __cplusplus diff --git a/reprolang/testdata/snapshots/input/global-cross-repo/reference.repro b/reprolang/testdata/snapshots/input/global-cross-repo/reference.repro index 3c2088f2..f9f8622e 100644 --- a/reprolang/testdata/snapshots/input/global-cross-repo/reference.repro +++ b/reprolang/testdata/snapshots/input/global-cross-repo/reference.repro @@ -1,3 +1,3 @@ # Reference a global symbol from another workspace. -reference global global-workspace hello.repro/hello(). -reference global duplicates duplicate.repro/readFileSync. +reference global-workspace hello.repro/hello(). +reference duplicates duplicate.repro/readFileSync. diff --git a/reprolang/testdata/snapshots/input/implementation-cross-repo/bird.repro b/reprolang/testdata/snapshots/input/implementation-cross-repo/bird.repro index d3c4a0d5..a5b94787 100644 --- a/reprolang/testdata/snapshots/input/implementation-cross-repo/bird.repro +++ b/reprolang/testdata/snapshots/input/implementation-cross-repo/bird.repro @@ -1,2 +1,2 @@ # Test how to implement a symbol from an external workspace. -definition bird# implements global implementation animal.repro/animal# +definition bird# implements implementation animal.repro/animal# diff --git a/reprolang/testdata/snapshots/output/global-cross-repo/reference.repro b/reprolang/testdata/snapshots/output/global-cross-repo/reference.repro index 042bf987..3ebd714e 100755 --- a/reprolang/testdata/snapshots/output/global-cross-repo/reference.repro +++ b/reprolang/testdata/snapshots/output/global-cross-repo/reference.repro @@ -1,6 +1,6 @@ # Reference a global symbol from another workspace. - reference global global-workspace hello.repro/hello(). -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference global-workspace hello.repro/hello(). - reference global duplicates duplicate.repro/readFileSync. -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference duplicates duplicate.repro/readFileSync. + reference global-workspace hello.repro/hello(). +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference global-workspace hello.repro/hello(). + reference duplicates duplicate.repro/readFileSync. +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference duplicates duplicate.repro/readFileSync. diff --git a/reprolang/testdata/snapshots/output/implementation-cross-repo/bird.repro b/reprolang/testdata/snapshots/output/implementation-cross-repo/bird.repro index 0be0be06..aa6c10c7 100755 --- a/reprolang/testdata/snapshots/output/implementation-cross-repo/bird.repro +++ b/reprolang/testdata/snapshots/output/implementation-cross-repo/bird.repro @@ -1,8 +1,8 @@ # Test how to implement a symbol from an external workspace. - definition bird# implements global implementation animal.repro/animal# + definition bird# implements implementation animal.repro/animal# # ^^^^^ definition bird.repro/bird# # documentation # > signature of bird# # relationship implementation animal.repro/animal# implementation -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference implementation animal.repro/animal# +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference implementation animal.repro/animal# From 012ada5dbde3407bab4e4bf135e6ab04bd15f768 Mon Sep 17 00:00:00 2001 From: jupblb Date: Wed, 18 Mar 2026 13:55:43 +0100 Subject: [PATCH 4/4] reprolang: inline isLocalSymbol() into direct field access --- reprolang/repro/ast.go | 6 +----- reprolang/repro/namer.go | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/reprolang/repro/ast.go b/reprolang/repro/ast.go index e1390aae..30c8a7be 100644 --- a/reprolang/repro/ast.go +++ b/reprolang/repro/ast.go @@ -89,7 +89,7 @@ func NewRangePositionFromNode(node *sitter.Node) *scip.Range { func (i *identifier) resolveSymbol(localScope *reproScope, context *reproContext) error { scope := context.globalScope - if i.isLocalSymbol() { + if i.isLocal { scope = localScope } symbol, ok := scope.names[i.value] @@ -99,7 +99,3 @@ func (i *identifier) resolveSymbol(localScope *reproScope, context *reproContext i.symbol = symbol return nil } - -func (i *identifier) isLocalSymbol() bool { - return i.isLocal -} diff --git a/reprolang/repro/namer.go b/reprolang/repro/namer.go index 7955f103..550d81d9 100644 --- a/reprolang/repro/namer.go +++ b/reprolang/repro/namer.go @@ -12,7 +12,7 @@ import ( func (d *reproDependency) enterGlobalDefinitions(context *reproContext) error { var errs error enter := func(file *reproSourceFile, name *identifier) { - if name.isLocalSymbol() { + if name.isLocal { return } symbol := newGlobalSymbol(d.Package, file, name) @@ -39,11 +39,11 @@ func (d *reproDependency) enterGlobalDefinitions(context *reproContext) error { func (s *reproSourceFile) enterDefinitions(context *reproContext) { enter := func(name *identifier, defName *identifier) { scope := context.globalScope - if name.isLocalSymbol() { + if name.isLocal { scope = s.localScope } var symbol string - if name.isLocalSymbol() { + if name.isLocal { symbol = fmt.Sprintf("local %s", defName.value) } else { symbol = newGlobalSymbol(context.pkg, s, defName)