python-delphi-lsp 3.6.0__cp310-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. delphi_lsp/__init__.py +184 -0
  2. delphi_lsp/_version.py +1 -0
  3. delphi_lsp/agent_cache.py +1574 -0
  4. delphi_lsp/agent_cli.py +902 -0
  5. delphi_lsp/agent_context.py +3907 -0
  6. delphi_lsp/agent_cpg.py +349 -0
  7. delphi_lsp/agent_cpg_builder.py +666 -0
  8. delphi_lsp/agent_layers.py +1410 -0
  9. delphi_lsp/agent_metrics.py +526 -0
  10. delphi_lsp/agent_protocol.py +445 -0
  11. delphi_lsp/agent_relations.py +1881 -0
  12. delphi_lsp/agent_templates.py +614 -0
  13. delphi_lsp/agent_wiki.py +2853 -0
  14. delphi_lsp/agent_workspace.py +860 -0
  15. delphi_lsp/ast_serialize.py +126 -0
  16. delphi_lsp/binary.py +250 -0
  17. delphi_lsp/comment_builder.py +28 -0
  18. delphi_lsp/consts.py +345 -0
  19. delphi_lsp/delphi_lsp_native.pyd +0 -0
  20. delphi_lsp/delphiast_lexer.py +399 -0
  21. delphi_lsp/delphiast_parser.py +2189 -0
  22. delphi_lsp/delphiast_tokens.py +41 -0
  23. delphi_lsp/grammar.py +459 -0
  24. delphi_lsp/incremental.py +1139 -0
  25. delphi_lsp/lark_builder.py +2684 -0
  26. delphi_lsp/lark_tokens.py +236 -0
  27. delphi_lsp/lexical_scanner.py +30 -0
  28. delphi_lsp/lsp_server.py +6698 -0
  29. delphi_lsp/metrics.py +1452 -0
  30. delphi_lsp/native_bridge.py +300 -0
  31. delphi_lsp/navigation_cache.py +189 -0
  32. delphi_lsp/nodes.py +462 -0
  33. delphi_lsp/parallel_outline.py +662 -0
  34. delphi_lsp/parse_artifacts.py +969 -0
  35. delphi_lsp/parser.py +342 -0
  36. delphi_lsp/parser_backend.py +139 -0
  37. delphi_lsp/preprocessor.py +1122 -0
  38. delphi_lsp/progress.py +26 -0
  39. delphi_lsp/project_config.py +285 -0
  40. delphi_lsp/project_discovery.py +932 -0
  41. delphi_lsp/project_indexer.py +470 -0
  42. delphi_lsp/py.typed +1 -0
  43. delphi_lsp/response_cache.py +465 -0
  44. delphi_lsp/semantic.py +394 -0
  45. delphi_lsp/semantic_builder.py +2302 -0
  46. delphi_lsp/source_reader.py +17 -0
  47. delphi_lsp/wiki_external_sort.py +392 -0
  48. delphi_lsp/wiki_memory.py +548 -0
  49. delphi_lsp/workspace.py +83 -0
  50. delphi_lsp/writer.py +73 -0
  51. python_delphi_lsp-3.6.0.dist-info/METADATA +766 -0
  52. python_delphi_lsp-3.6.0.dist-info/RECORD +56 -0
  53. python_delphi_lsp-3.6.0.dist-info/WHEEL +4 -0
  54. python_delphi_lsp-3.6.0.dist-info/entry_points.txt +3 -0
  55. python_delphi_lsp-3.6.0.dist-info/licenses/LICENSE +373 -0
  56. python_delphi_lsp-3.6.0.dist-info/sboms/python-delphi-lsp.cyclonedx.json +770 -0
@@ -0,0 +1,236 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+
5
+ KEYWORDS = [
6
+ 'abort',
7
+ 'absolute',
8
+ 'abstract',
9
+ 'add',
10
+ 'align',
11
+ 'and',
12
+ 'ansistring',
13
+ 'array',
14
+ 'as',
15
+ 'asm',
16
+ 'assembler',
17
+ 'at',
18
+ 'automated',
19
+ 'begin',
20
+ 'boolean',
21
+ 'break',
22
+ 'byte',
23
+ 'bytebool',
24
+ 'cardinal',
25
+ 'case',
26
+ 'cdecl',
27
+ 'char',
28
+ 'class',
29
+ 'comp',
30
+ 'const',
31
+ 'constructor',
32
+ 'contains',
33
+ 'continue',
34
+ 'currency',
35
+ 'default',
36
+ 'delayed',
37
+ 'deprecated',
38
+ 'destructor',
39
+ 'dispid',
40
+ 'dispinterface',
41
+ 'div',
42
+ 'do',
43
+ 'double',
44
+ 'downto',
45
+ 'dword',
46
+ 'dynamic',
47
+ 'else',
48
+ 'end',
49
+ 'except',
50
+ 'exit',
51
+ 'experimental',
52
+ 'export',
53
+ 'exports',
54
+ 'extended',
55
+ 'false',
56
+ 'external',
57
+ 'far',
58
+ 'file',
59
+ 'final',
60
+ 'finalization',
61
+ 'finally',
62
+ 'for',
63
+ 'forward',
64
+ 'function',
65
+ 'goto',
66
+ 'halt',
67
+ 'helper',
68
+ 'if',
69
+ 'implementation',
70
+ 'implements',
71
+ 'in',
72
+ 'index',
73
+ 'inherited',
74
+ 'initialization',
75
+ 'inline',
76
+ 'int64',
77
+ 'integer',
78
+ 'interface',
79
+ 'is',
80
+ 'label',
81
+ 'library',
82
+ 'local',
83
+ 'longbool',
84
+ 'longint',
85
+ 'longword',
86
+ 'message',
87
+ 'mod',
88
+ 'namespace',
89
+ 'near',
90
+ 'nil',
91
+ 'noreturn',
92
+ 'nodefault',
93
+ 'null',
94
+ 'not',
95
+ 'object',
96
+ 'of',
97
+ 'olevariant',
98
+ 'on',
99
+ 'operator',
100
+ 'or',
101
+ 'out',
102
+ 'overload',
103
+ 'override',
104
+ 'package',
105
+ 'packed',
106
+ 'pascal',
107
+ 'pchar',
108
+ 'platform',
109
+ 'private',
110
+ 'procedure',
111
+ 'program',
112
+ 'property',
113
+ 'protected',
114
+ 'public',
115
+ 'published',
116
+ 'raise',
117
+ 'read',
118
+ 'readonly',
119
+ 'real',
120
+ 'real48',
121
+ 'record',
122
+ 'reference',
123
+ 'register',
124
+ 'reintroduce',
125
+ 'remove',
126
+ 'repeat',
127
+ 'requires',
128
+ 'resident',
129
+ 'resourcestring',
130
+ 'runerror',
131
+ 'safecall',
132
+ 'sealed',
133
+ 'self',
134
+ 'set',
135
+ 'shl',
136
+ 'shortint',
137
+ 'shortstring',
138
+ 'shr',
139
+ 'single',
140
+ 'smallint',
141
+ 'static',
142
+ 'stdcall',
143
+ 'stored',
144
+ 'strict',
145
+ 'string',
146
+ 'stringresource',
147
+ 'then',
148
+ 'threadvar',
149
+ 'true',
150
+ 'to',
151
+ 'try',
152
+ 'type',
153
+ 'unit',
154
+ 'unmanaged',
155
+ 'unsafe',
156
+ 'until',
157
+ 'uses',
158
+ 'var',
159
+ 'varargs',
160
+ 'variant',
161
+ 'virtual',
162
+ 'while',
163
+ 'widechar',
164
+ 'widestring',
165
+ 'with',
166
+ 'word',
167
+ 'wordbool',
168
+ 'write',
169
+ 'writeonly',
170
+ 'winapi',
171
+ 'xor',
172
+ ]
173
+
174
+ DIRECTIVE_KEYWORDS = [
175
+ 'define',
176
+ 'endif',
177
+ 'ifend',
178
+ 'elseif',
179
+ 'ifdef',
180
+ 'ifndef',
181
+ 'ifopt',
182
+ 'include',
183
+ 'resource',
184
+ 'scopedenums',
185
+ 'undef',
186
+ ]
187
+
188
+ def _keyword_terminal(keyword: str) -> str:
189
+ token_name = f"{keyword.upper()}.2"
190
+ pattern = re.escape(keyword)
191
+ return f"{token_name}: /(?i:{pattern})(?!\\w)/"
192
+
193
+
194
+ KEYWORD_TERMINALS = "\n".join(_keyword_terminal(k) for k in KEYWORDS)
195
+
196
+
197
+ BASE_TERMINALS = r"""
198
+ PROC_TYPE_DIRECTIVE.3: /;[ \t\r\n]*(?i:(cdecl|stdcall|pascal|register|safecall|winapi|varargs))(?:[ \t\r\n]+(?i:varargs))?(?!\w)/
199
+ EMPTY_USES_BEFORE_IMPLEMENTATION.4: /(?i:uses)(?=[ \t\r\n]+implementation\b)/
200
+ COMPILER_ERROR_TEXT.1: /(?![^\r\n]*[:;=])(?:[A-Za-z]+[ \t]+){2,}[A-Za-z][^\r\n]*/
201
+
202
+ // literals
203
+ STRING_BLOCK5: /(?s:'''''(?=\r?\n).*?''''')/
204
+ STRING_BLOCK3: /(?s:'''(?=\r?\n).*?''')/
205
+ STRING_LITERAL: /(?s:'(?:''|[^'])*')/
206
+ CHAR_CODE: /#\$[0-9A-Fa-f_]+|#[0-9_]+/
207
+ POINTER_CHAR.0: /\^[A-Za-z\\](?![A-Za-z0-9_])/
208
+ HEX_INT: /\$[0-9A-Fa-f_]+/
209
+ BIN_INT: /%[01_]+/
210
+ FLOAT: /(?:[0-9][0-9_]*\.(?!\.)[0-9_]*([eE][+-]?[0-9_]+)?|[0-9][0-9_]*[eE][+-]?[0-9_]+)/
211
+ INT: /[0-9][0-9_]*/
212
+
213
+ // identifiers
214
+ STRICT_NAME.3: /(?i:strict)(?=\s*[:,])/
215
+ SPACED_GENERIC_NAME: /&?(?:[_]|[^\W\d_])[\w]*\s*<[^;\r\n]*>\s*(?=\.)/
216
+ GENERIC_NAME: /&?(?:[_]|[^\W\d_])[\w]*<(?:[^<>\r\n]+|<(?:[^<>\r\n]+|<(?:[^<>\r\n]+|<[^<>\r\n]*>)*>)*>)+>/
217
+ NAME: /&?(?:[_]|[^\W\d_])[\w]*/
218
+
219
+ // comments
220
+ COMMENT_BRACE: /(?s:\{.*?\})/
221
+ COMMENT_PAREN: /(?s:\(\*.*?\*\))/
222
+ COMMENT_SLASH: /\/\/[^\n]*/
223
+
224
+ %ignore COMMENT_BRACE
225
+ %ignore COMMENT_PAREN
226
+ %ignore COMMENT_SLASH
227
+
228
+ %import common.WS_INLINE
229
+ %import common.NEWLINE -> _NL
230
+ %ignore WS_INLINE
231
+ %ignore _NL
232
+ """
233
+
234
+
235
+ def build_grammar_snippet() -> str:
236
+ return '\n'.join([KEYWORD_TERMINALS, BASE_TERMINALS])
@@ -0,0 +1,30 @@
1
+ """Shared low-level scanners for Delphi lexical regions."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ def scan_brace_comment(
7
+ text: str,
8
+ start: int,
9
+ *,
10
+ nested: bool = True,
11
+ ) -> tuple[int, bool]:
12
+ """Scan an FPC brace comment, optionally relaxing nesting in inactive text."""
13
+ if start < 0 or start >= len(text) or text[start] != "{":
14
+ return start, False
15
+ depth = 1
16
+ index = start + 1
17
+ while index < len(text):
18
+ if text[index] == "{" and (
19
+ nested or (index + 1 < len(text) and text[index + 1] == "$")
20
+ ):
21
+ depth += 1
22
+ elif text[index] == "}":
23
+ depth -= 1
24
+ if depth == 0:
25
+ return index + 1, True
26
+ index += 1
27
+ return len(text), False
28
+
29
+
30
+ __all__ = ["scan_brace_comment"]