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..c013882b 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), @@ -54,15 +54,13 @@ module.exports = grammar({ docstring: $ => seq('# docstring:', /.*/), identifier: $ => choice( + field('local', $.local_identifier), field('global', $.global_identifier), - field('workspace', $.workspace_identifier) + $.name ), + local_identifier: $ => seq('local', field('name', $.name)), global_identifier: $ => - seq( - 'global', - field('project_name', $.workspace_identifier), - field('descriptors', $.workspace_identifier) - ), - workspace_identifier: $ => /[^\s]+/, + seq(field('project_name', $.name), field('descriptors', $.name)), + 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 17dc20b2..11a5f77f 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", @@ -283,35 +283,52 @@ "members": [ { "type": "FIELD", - "name": "global", + "name": "local", "content": { "type": "SYMBOL", - "name": "global_identifier" + "name": "local_identifier" } }, { "type": "FIELD", - "name": "workspace", + "name": "global", "content": { "type": "SYMBOL", - "name": "workspace_identifier" + "name": "global_identifier" } + }, + { + "type": "SYMBOL", + "name": "name" } ] }, - "global_identifier": { + "local_identifier": { "type": "SEQ", "members": [ { "type": "STRING", - "value": "global" + "value": "local" }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "name" + } + } + ] + }, + "global_identifier": { + "type": "SEQ", + "members": [ { "type": "FIELD", "name": "project_name", "content": { "type": "SYMBOL", - "name": "workspace_identifier" + "name": "name" } }, { @@ -319,12 +336,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 c02f0aa5..b8d1e1b6 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 } ] @@ -113,16 +113,26 @@ } ] }, - "workspace": { + "local": { "multiple": false, "required": false, "types": [ { - "type": "workspace_identifier", + "type": "local_identifier", "named": true } ] } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "name", + "named": true + } + ] } }, { @@ -141,6 +151,22 @@ } } }, + { + "type": "local_identifier", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "name", + "named": true + } + ] + } + } + }, { "type": "reference_statement", "named": true, @@ -290,13 +316,17 @@ "named": false }, { - "type": "global", + "type": "implements", "named": false }, { - "type": "implements", + "type": "local", "named": false }, + { + "type": "name", + "named": true + }, { "type": "reference", "named": false @@ -312,9 +342,5 @@ { "type": "type_defines", "named": false - }, - { - "type": "workspace_identifier", - "named": true } ] diff --git a/reprolang/grammar/parser.c b/reprolang/grammar/parser.c index 31181288..9968af21 100644 --- a/reprolang/grammar/parser.c +++ b/reprolang/grammar/parser.c @@ -7,9 +7,9 @@ #endif #define LANGUAGE_VERSION 14 -#define STATE_COUNT 41 +#define STATE_COUNT 42 #define LARGE_STATE_COUNT 2 -#define SYMBOL_COUNT 33 +#define SYMBOL_COUNT 34 #define ALIAS_COUNT 0 #define TOKEN_COUNT 15 #define EXTERNAL_TOKEN_COUNT 0 @@ -20,7 +20,7 @@ #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, @@ -33,7 +33,7 @@ enum ts_symbol_identifiers { anon_sym_POUND = 11, aux_sym_comment_token1 = 12, anon_sym_POUNDdocstring_COLON = 13, - anon_sym_global = 14, + anon_sym_local = 14, sym_source_file = 15, sym__statement = 16, sym_definition_statement = 17, @@ -48,15 +48,16 @@ enum ts_symbol_identifiers { 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, + 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[] = { [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", @@ -69,7 +70,7 @@ static const char * const ts_symbol_names[] = { [anon_sym_POUND] = "#", [aux_sym_comment_token1] = "comment_token1", [anon_sym_POUNDdocstring_COLON] = "# docstring:", - [anon_sym_global] = "global", + [anon_sym_local] = "local", [sym_source_file] = "source_file", [sym__statement] = "_statement", [sym_definition_statement] = "definition_statement", @@ -84,6 +85,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", @@ -92,7 +94,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, @@ -105,7 +107,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_global] = anon_sym_global, + [anon_sym_local] = anon_sym_local, [sym_source_file] = sym_source_file, [sym__statement] = sym__statement, [sym_definition_statement] = sym_definition_statement, @@ -120,6 +122,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, @@ -131,7 +134,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = false, .named = true, }, - [sym_workspace_identifier] = { + [sym_name] = { .visible = true, .named = true, }, @@ -183,7 +186,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { .visible = true, .named = false, }, - [anon_sym_global] = { + [anon_sym_local] = { .visible = true, .named = false, }, @@ -243,6 +246,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 +273,10 @@ 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, }; static const char * const ts_field_names[] = { @@ -278,10 +285,10 @@ 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", - [field_workspace] = "workspace", }; static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { @@ -297,20 +304,20 @@ static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { static const TSFieldMapEntry ts_field_map_entries[] = { [0] = - {field_workspace, 0}, - [1] = {field_name, 1}, + [1] = + {field_local, 0}, [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}, @@ -372,6 +379,7 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [38] = 38, [39] = 39, [40] = 40, + [41] = 41, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { @@ -379,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_workspace_identifier); - if (lookahead == 'a') ADVANCE(80); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'c') ADVANCE(60); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); + 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_workspace_identifier); - if (lookahead == 'e') ADVANCE(63); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'e') ADVANCE(77); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'e') ADVANCE(47); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'e') ADVANCE(70); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'f') ADVANCE(65); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'f') ADVANCE(59); - if (lookahead == 'l') ADVANCE(55); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'h') ADVANCE(67); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); + 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_workspace_identifier); - if (lookahead == 'i') ADVANCE(74); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'i') ADVANCE(76); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'i') ADVANCE(75); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'i') ADVANCE(81); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'n') ADVANCE(56); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'n') ADVANCE(78); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'n') ADVANCE(45); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'n') ADVANCE(69); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); + 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_workspace_identifier); - if (lookahead == 'o') ADVANCE(72); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'p') ADVANCE(79); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 'r') ADVANCE(61); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 's') ADVANCE(64); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 's') ADVANCE(49); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 't') ADVANCE(66); + ACCEPT_TOKEN(sym_name); + 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_workspace_identifier); - if (lookahead == 't') ADVANCE(68); + ACCEPT_TOKEN(sym_name); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); - END_STATE(); - case 82: - ACCEPT_TOKEN(sym_workspace_identifier); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - lookahead != ' ') ADVANCE(82); + lookahead != ' ') ADVANCE(81); END_STATE(); default: return false; @@ -791,8 +794,8 @@ 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 == 'i') ADVANCE(3); + if (lookahead == 'l') ADVANCE(4); if (lookahead == 'r') ADVANCE(5); if (lookahead == 't') ADVANCE(6); if (('\t' <= lookahead && lookahead <= '\r') || @@ -805,10 +808,10 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'o') ADVANCE(8); END_STATE(); case 3: - if (lookahead == 'l') ADVANCE(9); + if (lookahead == 'm') ADVANCE(9); END_STATE(); case 4: - if (lookahead == 'm') ADVANCE(10); + if (lookahead == 'o') ADVANCE(10); END_STATE(); case 5: if (lookahead == 'e') ADVANCE(11); @@ -823,10 +826,10 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'r') ADVANCE(14); END_STATE(); case 9: - if (lookahead == 'o') ADVANCE(15); + if (lookahead == 'p') ADVANCE(15); END_STATE(); case 10: - if (lookahead == 'p') ADVANCE(16); + if (lookahead == 'c') ADVANCE(16); END_STATE(); case 11: if (lookahead == 'f') ADVANCE(17); @@ -841,10 +844,10 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'w') ADVANCE(20); END_STATE(); case 15: - if (lookahead == 'b') ADVANCE(21); + if (lookahead == 'l') ADVANCE(21); END_STATE(); case 16: - if (lookahead == 'l') ADVANCE(22); + if (lookahead == 'a') ADVANCE(22); END_STATE(); case 17: if (lookahead == 'e') ADVANCE(23); @@ -859,10 +862,10 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'a') ADVANCE(26); END_STATE(); case 21: - if (lookahead == 'a') ADVANCE(27); + if (lookahead == 'e') ADVANCE(27); END_STATE(); case 22: - if (lookahead == 'e') ADVANCE(28); + if (lookahead == 'l') ADVANCE(28); END_STATE(); case 23: if (lookahead == 'r') ADVANCE(29); @@ -877,123 +880,120 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { if (lookahead == 'r') ADVANCE(32); END_STATE(); case 27: - if (lookahead == 'l') ADVANCE(33); + if (lookahead == 'm') ADVANCE(33); END_STATE(); case 28: - if (lookahead == 'm') ADVANCE(34); + ACCEPT_TOKEN(anon_sym_local); END_STATE(); case 29: - if (lookahead == 'e') ADVANCE(35); + if (lookahead == 'e') ADVANCE(34); END_STATE(); case 30: - if (lookahead == 'd') ADVANCE(36); + if (lookahead == 'd') ADVANCE(35); END_STATE(); case 31: - if (lookahead == 'd') ADVANCE(37); + if (lookahead == 'd') ADVANCE(36); END_STATE(); case 32: - if (lookahead == 'd') ADVANCE(38); + if (lookahead == 'd') ADVANCE(37); END_STATE(); case 33: - ACCEPT_TOKEN(anon_sym_global); + if (lookahead == 'e') ADVANCE(38); END_STATE(); case 34: - if (lookahead == 'e') ADVANCE(39); + if (lookahead == 'n') ADVANCE(39); END_STATE(); case 35: - if (lookahead == 'n') ADVANCE(40); + if (lookahead == 'e') ADVANCE(40); END_STATE(); case 36: - if (lookahead == 'e') ADVANCE(41); + if (lookahead == '_') ADVANCE(41); END_STATE(); case 37: if (lookahead == '_') ADVANCE(42); END_STATE(); case 38: - if (lookahead == '_') ADVANCE(43); + if (lookahead == 'n') ADVANCE(43); END_STATE(); case 39: - if (lookahead == 'n') ADVANCE(44); + if (lookahead == 'c') ADVANCE(44); END_STATE(); case 40: - if (lookahead == 'c') ADVANCE(45); + if (lookahead == 'f') ADVANCE(45); END_STATE(); case 41: - if (lookahead == 'f') ADVANCE(46); + if (lookahead == 'b') ADVANCE(46); END_STATE(); case 42: - if (lookahead == 'b') ADVANCE(47); + if (lookahead == 'd') ADVANCE(47); END_STATE(); case 43: - if (lookahead == 'd') ADVANCE(48); + if (lookahead == 't') ADVANCE(48); END_STATE(); case 44: - if (lookahead == 't') ADVANCE(49); + if (lookahead == 'e') ADVANCE(49); END_STATE(); case 45: - if (lookahead == 'e') ADVANCE(50); + if (lookahead == 'i') ADVANCE(50); END_STATE(); case 46: - if (lookahead == 'i') ADVANCE(51); + if (lookahead == 'y') ADVANCE(51); END_STATE(); case 47: - if (lookahead == 'y') ADVANCE(52); + if (lookahead == 'e') ADVANCE(52); END_STATE(); case 48: - if (lookahead == 'e') ADVANCE(53); + if (lookahead == 's') ADVANCE(53); END_STATE(); case 49: if (lookahead == 's') ADVANCE(54); END_STATE(); case 50: - if (lookahead == 's') ADVANCE(55); + if (lookahead == 'n') ADVANCE(55); END_STATE(); case 51: - if (lookahead == 'n') ADVANCE(56); + ACCEPT_TOKEN(anon_sym_defined_by); END_STATE(); case 52: - ACCEPT_TOKEN(anon_sym_defined_by); + if (lookahead == 'f') ADVANCE(56); END_STATE(); case 53: - if (lookahead == 'f') ADVANCE(57); + ACCEPT_TOKEN(anon_sym_implements); END_STATE(); case 54: - ACCEPT_TOKEN(anon_sym_implements); + ACCEPT_TOKEN(anon_sym_references); END_STATE(); case 55: - ACCEPT_TOKEN(anon_sym_references); + if (lookahead == 'e') ADVANCE(57); END_STATE(); case 56: - if (lookahead == 'e') ADVANCE(58); + if (lookahead == 'i') ADVANCE(58); END_STATE(); case 57: - if (lookahead == 'i') ADVANCE(59); + if (lookahead == 's') ADVANCE(59); END_STATE(); case 58: - if (lookahead == 's') ADVANCE(60); + if (lookahead == 'n') ADVANCE(60); END_STATE(); case 59: - if (lookahead == 'n') ADVANCE(61); + ACCEPT_TOKEN(anon_sym_type_defines); END_STATE(); case 60: - ACCEPT_TOKEN(anon_sym_type_defines); + if (lookahead == 'i') ADVANCE(61); END_STATE(); case 61: - if (lookahead == 'i') ADVANCE(62); + if (lookahead == 't') ADVANCE(62); END_STATE(); case 62: - if (lookahead == 't') ADVANCE(63); + if (lookahead == 'i') ADVANCE(63); END_STATE(); case 63: - if (lookahead == 'i') ADVANCE(64); + if (lookahead == 'o') ADVANCE(64); END_STATE(); case 64: - if (lookahead == 'o') ADVANCE(65); + if (lookahead == 'n') ADVANCE(65); END_STATE(); case 65: - if (lookahead == 'n') ADVANCE(66); - END_STATE(); - case 66: ACCEPT_TOKEN(anon_sym_forward_definition); END_STATE(); default: @@ -1003,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}, @@ -1014,41 +1014,42 @@ 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 = 1}, [13] = {.lex_state = 40}, - [14] = {.lex_state = 1}, + [14] = {.lex_state = 39}, [15] = {.lex_state = 1}, - [16] = {.lex_state = 1}, - [17] = {.lex_state = 1}, + [16] = {.lex_state = 39}, + [17] = {.lex_state = 39}, [18] = {.lex_state = 1}, [19] = {.lex_state = 1}, - [20] = {.lex_state = 1}, - [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}, - [37] = {.lex_state = 2}, - [38] = {.lex_state = 2}, - [39] = {.lex_state = 2}, - [40] = {.lex_state = 40}, + [20] = {.lex_state = 39}, + [21] = {.lex_state = 39}, + [22] = {.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 = 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] = { [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), @@ -1059,16 +1060,16 @@ 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_global] = ACTIONS(1), + [anon_sym_local] = ACTIONS(1), }, [STATE(1)] = { - [sym_source_file] = STATE(36), + [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(37), + [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), @@ -1093,12 +1094,12 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUNDdocstring_COLON, ACTIONS(15), 1, ts_builtin_sym_end, - STATE(37), 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, @@ -1116,12 +1117,12 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_POUND, ACTIONS(31), 1, anon_sym_POUNDdocstring_COLON, - STATE(37), 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, @@ -1137,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, @@ -1156,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, @@ -1258,190 +1259,223 @@ static const uint16_t ts_small_parse_table[] = { sym_type_definition_relation, sym_references_relation, aux_sym_definition_statement_repeat1, - [239] = 2, + [239] = 3, + ACTIONS(79), 1, + sym_name, ACTIONS(81), 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(79), 5, + ACTIONS(85), 5, ts_builtin_sym_end, anon_sym_definition, anon_sym_reference, anon_sym_relationships, anon_sym_POUNDdocstring_COLON, - [250] = 5, - ACTIONS(83), 1, - sym_workspace_identifier, - ACTIONS(85), 1, + [263] = 6, + ACTIONS(89), 1, + sym_name, + ACTIONS(91), 1, anon_sym_forward_definition, - ACTIONS(87), 1, - anon_sym_global, - STATE(14), 1, + ACTIONS(93), 1, + anon_sym_local, + STATE(22), 1, sym_global_identifier, - STATE(31), 1, + STATE(30), 1, + sym_local_identifier, + STATE(35), 1, sym_identifier, - [266] = 2, - ACTIONS(89), 1, + [282] = 2, + ACTIONS(95), 1, anon_sym_LF, - ACTIONS(91), 4, + ACTIONS(97), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [276] = 2, + [292] = 5, + ACTIONS(89), 1, + sym_name, ACTIONS(93), 1, + anon_sym_local, + STATE(22), 1, + sym_global_identifier, + STATE(30), 1, + sym_local_identifier, + STATE(38), 1, + sym_identifier, + [308] = 5, + ACTIONS(89), 1, + sym_name, + ACTIONS(93), 1, + anon_sym_local, + STATE(22), 1, + sym_global_identifier, + STATE(27), 1, + sym_identifier, + STATE(30), 1, + sym_local_identifier, + [324] = 2, + ACTIONS(99), 1, anon_sym_LF, - ACTIONS(95), 4, + ACTIONS(101), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [286] = 2, - ACTIONS(97), 1, + [334] = 2, + ACTIONS(103), 1, anon_sym_LF, - ACTIONS(99), 4, + ACTIONS(105), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [296] = 2, - ACTIONS(101), 1, + [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(103), 4, + ACTIONS(109), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [306] = 2, - ACTIONS(105), 1, + [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(107), 4, + ACTIONS(113), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [316] = 2, - ACTIONS(109), 1, + [460] = 2, + ACTIONS(115), 1, anon_sym_LF, - ACTIONS(111), 4, + ACTIONS(117), 4, anon_sym_implements, anon_sym_type_defines, anon_sym_references, anon_sym_defined_by, - [326] = 2, - ACTIONS(113), 1, + [470] = 2, + ACTIONS(119), 1, anon_sym_LF, - ACTIONS(115), 4, + ACTIONS(121), 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, - ACTIONS(119), 1, - aux_sym_comment_token1, - [448] = 1, - ACTIONS(121), 1, - anon_sym_LF, - [452] = 1, + [480] = 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, + [490] = 1, ACTIONS(127), 1, - anon_sym_definition, - [464] = 1, + anon_sym_LF, + [494] = 1, ACTIONS(129), 1, anon_sym_LF, - [468] = 1, + [498] = 1, ACTIONS(131), 1, - ts_builtin_sym_end, - [472] = 1, - ACTIONS(133), 1, anon_sym_LF, - [476] = 1, + [502] = 1, + ACTIONS(133), 1, + aux_sym_comment_token1, + [506] = 1, ACTIONS(135), 1, anon_sym_LF, - [480] = 1, + [510] = 1, ACTIONS(137), 1, - anon_sym_LF, - [484] = 1, + anon_sym_definition, + [514] = 1, ACTIONS(139), 1, - sym_workspace_identifier, + ts_builtin_sym_end, + [518] = 1, + ACTIONS(141), 1, + anon_sym_LF, + [522] = 1, + ACTIONS(143), 1, + aux_sym_comment_token1, + [526] = 1, + ACTIONS(145), 1, + sym_name, + [530] = 1, + ACTIONS(147), 1, + anon_sym_LF, }; static const uint32_t ts_small_parse_table_map[] = { @@ -1456,102 +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)] = 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)] = 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(27), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [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(30), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [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(27), - [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(13), + [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(30), - [31] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(32), - [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), + [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(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(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), + [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(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(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), + [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 = 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), + [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_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}}, 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), + [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 @@ -1592,7 +1631,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; diff --git a/reprolang/repro/ast.go b/reprolang/repro/ast.go index 837bbb3d..30c8a7be 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), } } @@ -79,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] @@ -89,7 +99,3 @@ func (i *identifier) resolveSymbol(localScope *reproScope, context *reproContext i.symbol = symbol return nil } - -func (i *identifier) isLocalSymbol() bool { - return strings.HasPrefix(i.value, "local") -} diff --git a/reprolang/repro/namer.go b/reprolang/repro/namer.go index 648ba126..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,12 +39,12 @@ 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() { - symbol = fmt.Sprintf("local %s", defName.value[len("local"):]) + if name.isLocal { + symbol = fmt.Sprintf("local %s", defName.value) } else { symbol = newGlobalSymbol(context.pkg, s, defName) } 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/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/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# 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