agent-codinglanguage-mapper 1.0.0__py3-none-any.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 (42) hide show
  1. agent_codinglanguage_mapper/__init__.py +20 -0
  2. agent_codinglanguage_mapper/__main__.py +4 -0
  3. agent_codinglanguage_mapper/_version.py +2 -0
  4. agent_codinglanguage_mapper/adapters/__init__.py +4 -0
  5. agent_codinglanguage_mapper/adapters/delphi.py +822 -0
  6. agent_codinglanguage_mapper/adapters/delphi_frontend/__init__.py +6 -0
  7. agent_codinglanguage_mapper/adapters/delphi_frontend/comment_builder.py +29 -0
  8. agent_codinglanguage_mapper/adapters/delphi_frontend/consts.py +345 -0
  9. agent_codinglanguage_mapper/adapters/delphi_frontend/grammar.py +460 -0
  10. agent_codinglanguage_mapper/adapters/delphi_frontend/lark_builder.py +2674 -0
  11. agent_codinglanguage_mapper/adapters/delphi_frontend/lark_tokens.py +237 -0
  12. agent_codinglanguage_mapper/adapters/delphi_frontend/lsp_server.py +1832 -0
  13. agent_codinglanguage_mapper/adapters/delphi_frontend/nodes.py +371 -0
  14. agent_codinglanguage_mapper/adapters/delphi_frontend/parser.py +193 -0
  15. agent_codinglanguage_mapper/adapters/delphi_frontend/preprocessor.py +997 -0
  16. agent_codinglanguage_mapper/adapters/delphi_frontend/project_discovery.py +518 -0
  17. agent_codinglanguage_mapper/adapters/delphi_frontend/project_indexer.py +319 -0
  18. agent_codinglanguage_mapper/adapters/delphi_frontend/semantic.py +375 -0
  19. agent_codinglanguage_mapper/adapters/delphi_frontend/semantic_builder.py +1384 -0
  20. agent_codinglanguage_mapper/adapters/delphi_frontend/source_reader.py +17 -0
  21. agent_codinglanguage_mapper/adapters/delphi_frontend/workspace.py +67 -0
  22. agent_codinglanguage_mapper/adapters/tree_sitter.py +1722 -0
  23. agent_codinglanguage_mapper/cli.py +138 -0
  24. agent_codinglanguage_mapper/discovery.py +1328 -0
  25. agent_codinglanguage_mapper/indexer.py +1102 -0
  26. agent_codinglanguage_mapper/integration.py +186 -0
  27. agent_codinglanguage_mapper/lsp_server.py +413 -0
  28. agent_codinglanguage_mapper/lsp_service.py +447 -0
  29. agent_codinglanguage_mapper/mapper.py +596 -0
  30. agent_codinglanguage_mapper/models.py +101 -0
  31. agent_codinglanguage_mapper/protocol.py +152 -0
  32. agent_codinglanguage_mapper/rendering.py +153 -0
  33. agent_codinglanguage_mapper/templates/opencode/plugins/codebase_map.ts +191 -0
  34. agent_codinglanguage_mapper/templates/skill/SKILL.md +52 -0
  35. agent_codinglanguage_mapper/worker.py +29 -0
  36. agent_codinglanguage_mapper/workspace.py +114 -0
  37. agent_codinglanguage_mapper-1.0.0.dist-info/METADATA +383 -0
  38. agent_codinglanguage_mapper-1.0.0.dist-info/RECORD +42 -0
  39. agent_codinglanguage_mapper-1.0.0.dist-info/WHEEL +5 -0
  40. agent_codinglanguage_mapper-1.0.0.dist-info/entry_points.txt +2 -0
  41. agent_codinglanguage_mapper-1.0.0.dist-info/licenses/LICENSE +373 -0
  42. agent_codinglanguage_mapper-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,460 @@
1
+ from __future__ import annotations
2
+
3
+ from .lark_tokens import build_grammar_snippet
4
+
5
+
6
+ GRAMMAR_RULES = r'''
7
+ ?start: unit_file
8
+ | program_file
9
+ | library_file
10
+ | package_file
11
+ | include_file
12
+
13
+ unit_file: unit_header interface_section implementation_section? initialization_section? finalization_section? END "."
14
+ | unit_header interface_section implementation_section? bare_initialization_section "."
15
+ program_file: program_header program_body "."
16
+ library_file: library_header program_body "."
17
+ package_file: package_header package_body END "."
18
+ include_file: uses_clause? implementation_decl_sections
19
+ | literal
20
+
21
+ unit_header: UNIT qualified_name unit_directive_list? ";" uses_clause?
22
+ program_header: PROGRAM qualified_name program_params? ";" uses_clause?
23
+ library_header: LIBRARY qualified_name ";" uses_clause?
24
+ package_header: PACKAGE qualified_name ";"
25
+
26
+ unit_directive_list: unit_directive+
27
+ unit_directive: DEPRECATED (STRING_LITERAL)?
28
+ | PLATFORM
29
+ | EXPERIMENTAL
30
+ | LIBRARY
31
+
32
+ program_params: "(" name_list ")"
33
+ program_body: block
34
+ package_body: requires_clause? contains_clause?
35
+
36
+ interface_section: INTERFACE interface_preamble? uses_clause? interface_decl_sections
37
+ implementation_section: IMPLEMENTATION uses_clause? implementation_decl_sections
38
+ initialization_section: INITIALIZATION statement_list?
39
+ finalization_section: FINALIZATION statement_list?
40
+ bare_initialization_section: compound_statement
41
+
42
+ interface_preamble: ignored_compiler_error_line+
43
+
44
+ interface_decl_sections: (label_section | const_section | resourcestring_section | type_section | var_section
45
+ | threadvar_section | routine_decl | property_decl | exports_section)*
46
+ implementation_decl_sections: (label_section | const_section | resourcestring_section | type_section | var_section
47
+ | threadvar_section | routine_impl | property_decl | exports_section
48
+ | ignored_proc_type_directive | ignored_compiler_error_line)*
49
+ ignored_proc_type_directive: proc_type_decl_directive ";"?
50
+ ignored_compiler_error_line: COMPILER_ERROR_TEXT
51
+
52
+ uses_clause: EMPTY_USES_BEFORE_IMPLEMENTATION
53
+ | USES uses_item ("," uses_item)* ";"
54
+ uses_item: qualified_name (IN STRING_LITERAL)?
55
+
56
+ label_section: LABEL label_list ";"
57
+ label_list: label ("," label)*
58
+ label: NAME | INT | EXIT
59
+
60
+ const_section: CONST const_decl+
61
+ resourcestring_section: RESOURCESTRING const_decl+
62
+ const_decl: attribute_sections? NAME (":" type_spec)? "=" const_value? decl_directive_list? ";"
63
+
64
+ type_section: TYPE type_decl+
65
+ type_decl: attribute_sections? type_decl_name type_params? "=" forward_type_decl decl_directive_list? ";"
66
+ | attribute_sections? type_decl_name type_params? "=" type_spec proc_type_decl_directive? decl_directive_list? ";"
67
+ | attribute_sections? type_decl_name type_params? "=" -> incomplete_type_decl
68
+ type_decl_name: NAME | GENERIC_NAME
69
+ forward_type_decl: CLASS class_modifiers? type_heritage? -> forward_class_decl
70
+ | INTERFACE type_heritage? -> forward_interface_decl
71
+ | DISPINTERFACE type_heritage? -> forward_dispinterface_decl
72
+
73
+ decl_directive_list: decl_directive+
74
+ decl_directive: DEPRECATED (STRING_LITERAL)?
75
+ | PLATFORM
76
+ | EXPERIMENTAL
77
+ | LIBRARY
78
+
79
+ var_section: VAR var_decl+
80
+ threadvar_section: THREADVAR var_decl+
81
+ var_decl: attribute_sections? name_list ":" type_spec proc_type_decl_directive? absolute_spec? ("=" const_value)? ";"
82
+ absolute_spec: ABSOLUTE expr
83
+
84
+ exports_section: EXPORTS exports_item ("," exports_item)* ";"
85
+ exports_item: qualified_name formal_parameters? exports_specifier*
86
+ exports_specifier: NAME expr | INDEX expr | RESIDENT
87
+
88
+ requires_clause: REQUIRES qualified_name ("," qualified_name)* ";"
89
+ contains_clause: CONTAINS contains_item ("," contains_item)* ";"
90
+ contains_item: qualified_name (IN STRING_LITERAL)?
91
+
92
+ property_decl: attribute_sections? CLASS? PROPERTY NAME property_params? (":" type_spec)? property_specifier* property_directive* property_directive_block* ";"
93
+ property_params: "[" param_list? "]"
94
+ property_specifier: INDEX expr | READONLY | WRITEONLY
95
+ property_directive_block: ";" property_directive+
96
+ property_directive: READ expr
97
+ | WRITE expr
98
+ | ADD expr
99
+ | REMOVE expr
100
+ | DEFAULT expr?
101
+ | STORED expr?
102
+ | NODEFAULT
103
+ | IMPLEMENTS qualified_name
104
+ | DISPID expr
105
+
106
+ routine_decl: resolution_decl
107
+ | routine_heading proc_type_decl_directive ";" directive_list?
108
+ | routine_heading ";" directive_list?
109
+
110
+ resolution_decl: (procedure_decl | function_decl | operator_decl | qualified_name) "=" qualified_name ";"
111
+
112
+ routine_impl: routine_heading proc_type_decl_directive ";" body_directive_list? routine_body ";"?
113
+ | routine_heading ";" body_directive_list? routine_body ";"?
114
+ | routine_heading proc_type_decl_directive ";" body_directive_list EXTERNAL external_spec? (";" directive)* ";"?
115
+ | routine_heading proc_type_decl_directive EXTERNAL external_spec? (";" directive)* ";"?
116
+ | routine_heading ";" body_directive_list EXTERNAL external_spec? (";" directive)* ";"?
117
+ | routine_heading proc_type_decl_directive proc_type_decl_directive ";" EXTERNAL external_spec? (";" directive)* ";"?
118
+ | routine_heading proc_type_decl_directive ";" body_directive_list FORWARD (";" directive)* ";"?
119
+ | routine_heading ";" body_directive_list FORWARD (";" directive)* ";"?
120
+ | routine_heading proc_type_decl_directive ";" FORWARD (";" directive)* ";"?
121
+ | routine_heading ";" FORWARD (";" directive)* ";"?
122
+ | routine_heading proc_type_decl_directive ";" EXTERNAL external_spec? (";" directive)* ";"?
123
+ | routine_heading ";" EXTERNAL external_spec? (";" directive)* ";"?
124
+
125
+ routine_heading: procedure_decl
126
+ | function_decl
127
+ | constructor_decl
128
+ | destructor_decl
129
+ | operator_decl
130
+
131
+ procedure_decl: attribute_sections? CLASS? PROCEDURE qualified_name type_params? formal_parameters? routine_heading_directive_list?
132
+ function_decl: attribute_sections? CLASS? FUNCTION qualified_name type_params? formal_parameters? (":" type_spec)? routine_heading_directive_list?
133
+ constructor_decl: attribute_sections? CLASS? CONSTRUCTOR qualified_name type_params? formal_parameters? routine_heading_directive_list?
134
+ destructor_decl: attribute_sections? CLASS? DESTRUCTOR qualified_name type_params? formal_parameters? routine_heading_directive_list?
135
+ operator_decl: attribute_sections? CLASS? OPERATOR operator_target type_params? formal_parameters? (":" type_spec)? routine_heading_directive_list?
136
+ operator_target: operator_name | qualified_name
137
+ routine_heading_directive_list: routine_heading_directive+
138
+ routine_heading_directive: VARARGS
139
+
140
+ operator_name: "+" | "-" | "*" | "/" | "=" | "<" | ">" | "<=" | ">=" | "<>" | IN | IS | AS
141
+
142
+ routine_body: block
143
+ | asm_block
144
+ asm_block: block_decl_sections? asm_statement
145
+ block: block_decl_sections? compound_statement
146
+ block_decl_sections: (label_section | const_section | resourcestring_section | type_section | var_section
147
+ | threadvar_section | routine_impl | exports_section)*
148
+
149
+ formal_parameters: "(" param_list? ")"
150
+ param_list: param (";" param)*
151
+ param: attribute_sections? param_modifier? attribute_sections? name_list (":" type_spec)? param_default?
152
+ param_modifier: CONST | VAR | OUT
153
+ param_default: "=" expr
154
+
155
+ name_list: (NAME | STRICT_NAME) ("," (NAME | STRICT_NAME))*
156
+
157
+ ?type_spec: simple_type
158
+ | distinct_type
159
+ | pointer_type
160
+ | array_type
161
+ | array_of_const_type
162
+ | set_type
163
+ | structured_type
164
+ | proc_type
165
+ | subrange_type
166
+ | enum_type
167
+ | string_type
168
+ | file_type
169
+ | class_of_type
170
+ | reference_type
171
+ | packed_type
172
+
173
+ packed_type: PACKED type_spec
174
+ distinct_type: TYPE type_spec
175
+ simple_type: type_name
176
+ type_name: qualified_name type_args? codepage_spec?
177
+ codepage_spec: "(" expr ")"
178
+ pointer_type: "^" type_spec
179
+ | POINTER_CHAR
180
+ array_type: ARRAY ("[" array_bounds "]")? OF type_spec
181
+ array_of_const_type: ARRAY OF CONST
182
+ array_bounds: array_bound ("," array_bound)*
183
+ array_bound: range_expr (".." range_expr)?
184
+ set_type: SET OF type_spec
185
+ subrange_type: range_expr ".." range_expr
186
+ enum_type: "(" enum_item ("," enum_item)* ")"
187
+ enum_item.2: NAME ("=" expr)?
188
+ string_type: STRING ("[" expr "]")?
189
+ file_type: FILE (OF type_spec)?
190
+ class_of_type: CLASS OF type_spec
191
+ reference_type: REFERENCE TO proc_type
192
+
193
+ structured_type: class_type | record_type | interface_type | object_type | helper_type
194
+ class_type: CLASS class_modifiers? type_params? type_heritage? class_body? END
195
+ record_type: RECORD record_body? END record_align?
196
+ record_align: ALIGN expr
197
+ object_type: OBJECT type_heritage? class_body? END
198
+ interface_type: (INTERFACE | DISPINTERFACE) type_heritage? interface_guid? interface_body? END
199
+ helper_type: (CLASS | RECORD) HELPER FOR type_spec class_body? END
200
+
201
+ class_modifiers: (SEALED | ABSTRACT) (SEALED | ABSTRACT)?
202
+ interface_guid: "[" STRING_LITERAL "]"
203
+
204
+ class_body: class_member*
205
+ record_body: class_member*
206
+ interface_body: interface_member*
207
+
208
+ class_member: visibility_spec
209
+ | visibility_spec? class_member_item
210
+ class_member_item: field_decl ";"?
211
+ | routine_decl
212
+ | property_decl
213
+ | class_var_section
214
+ | class_threadvar_section
215
+ | class_const_section
216
+ | class_type_section
217
+ | var_section
218
+ | const_section
219
+ | type_section
220
+ | threadvar_section
221
+ | variant_part
222
+
223
+ class_var_section: CLASS VAR var_decl+
224
+ class_threadvar_section: CLASS THREADVAR var_decl+
225
+ class_const_section: CLASS CONST const_decl+
226
+ class_type_section: CLASS TYPE type_decl+
227
+
228
+ interface_member: routine_decl | property_decl
229
+
230
+ visibility_spec: STRICT? PRIVATE
231
+ | STRICT? PROTECTED
232
+ | PUBLIC
233
+ | PUBLISHED
234
+ | AUTOMATED
235
+
236
+ variant_part: CASE variant_selector? OF variant_section (";" variant_section)* ";"?
237
+ variant_selector: NAME ":" type_spec
238
+ | type_spec
239
+ variant_section: case_label_list ":" "(" field_list? ")"
240
+ field_list: record_field (";" record_field)* ";"?
241
+ record_field: field_decl | variant_part
242
+ field_decl: attribute_sections? name_list ":" type_spec proc_type_decl_directive?
243
+
244
+ proc_type: (PROCEDURE | FUNCTION) formal_parameters? (":" type_spec)? of_object?
245
+ proc_type_decl_directive: PROC_TYPE_DIRECTIVE
246
+ of_object: OF OBJECT
247
+
248
+ type_heritage: "(" type_name ("," type_name)* ")"
249
+
250
+ type_params: "<" type_param ((","|";") type_param)* ">"
251
+ type_param: NAME (":" type_constraints)?
252
+ type_constraints: type_constraint ((","|";") type_constraint)*
253
+ type_constraint: type_spec | CLASS | RECORD | CONSTRUCTOR | INTERFACE | UNMANAGED
254
+
255
+ type_args: "<" type_spec ("," type_spec)* ">"
256
+
257
+ attribute_sections: attribute_section+
258
+ attribute_section: "[" attribute ("," attribute)* "]"
259
+ attribute: attribute_name attribute_arguments?
260
+ attribute_name: qualified_name | attribute_keyword
261
+ attribute_keyword: IN | OUT | CONST | VAR | UNSAFE
262
+ attribute_arguments: "(" arg_list? ")"
263
+
264
+ directive_list: directive ((";" directive) | proc_type_decl_directive)* ";"?
265
+ body_directive_list: body_directive ((";" body_directive) | proc_type_decl_directive)* ";"?
266
+ body_directive: OVERLOAD | OVERRIDE | VIRTUAL | DYNAMIC | ABSTRACT | INLINE | REINTRODUCE | STATIC | FINAL | SEALED
267
+ | STDCALL | CDECL | PASCAL | REGISTER | SAFECALL | WINAPI | MESSAGE expr
268
+ | DEPRECATED (STRING_LITERAL)?
269
+ | PLATFORM
270
+ | EXPERIMENTAL
271
+ | NORETURN
272
+ | VARARGS
273
+ | LOCAL
274
+ | LIBRARY
275
+ | DELAYED
276
+ | EXPORT
277
+ | FAR
278
+ | NEAR
279
+ | ASSEMBLER
280
+ | UNSAFE
281
+ | DISPID expr
282
+ directive: OVERLOAD | OVERRIDE | VIRTUAL | DYNAMIC | ABSTRACT | INLINE | REINTRODUCE | STATIC | FINAL | SEALED
283
+ | STDCALL | CDECL | PASCAL | REGISTER | SAFECALL | WINAPI | MESSAGE expr | EXTERNAL external_spec? | FORWARD
284
+ | DEPRECATED (STRING_LITERAL)?
285
+ | PLATFORM
286
+ | EXPERIMENTAL
287
+ | NORETURN
288
+ | VARARGS
289
+ | LOCAL
290
+ | LIBRARY
291
+ | DELAYED
292
+ | EXPORT
293
+ | FAR
294
+ | NEAR
295
+ | ASSEMBLER
296
+ | UNSAFE
297
+ | DISPID expr
298
+ external_spec: external_item+
299
+ external_item: INDEX expr | DELAYED | expr
300
+
301
+ const_value: expr | array_const | record_const
302
+ array_const: "(" const_value_list? ")"
303
+ const_value_list: const_value ("," const_value)*
304
+ record_const: "(" record_const_item ((","|";") record_const_item)* ";"? ")"
305
+ record_const_item: NAME ":" const_value
306
+ set_const: "[" set_element_list? "]"
307
+ set_element_list: set_element ("," set_element)*
308
+ set_element: expr (".." expr)?
309
+
310
+ ?statement_list: ";"* statement (";"+ statement)* ";"*
311
+ | ";"+
312
+
313
+ ?statement: compound_statement
314
+ | if_statement
315
+ | while_statement
316
+ | for_statement
317
+ | repeat_statement
318
+ | try_statement
319
+ | raise_statement
320
+ | case_statement
321
+ | with_statement
322
+ | asm_statement
323
+ | inline_statement
324
+ | inline_var_section
325
+ | inline_const_section
326
+ | goto_statement
327
+ | label_statement
328
+ | address_assignment
329
+ | assignment
330
+ | comparison_statement
331
+ | call_statement
332
+ | break_statement
333
+ | continue_statement
334
+ | exit_statement
335
+
336
+ compound_statement: BEGIN statement_list? END
337
+ if_statement: IF expr THEN statement? (ELSE statement?)?
338
+ while_statement: WHILE expr DO statement?
339
+ for_statement: FOR for_init (TO|DOWNTO) expr DO statement
340
+ | FOR for_in DO statement
341
+ for_init: NAME ASSIGN expr
342
+ | VAR NAME ASSIGN expr
343
+ | VAR NAME ":" type_spec ASSIGN expr
344
+ for_in: NAME IN expr
345
+ | VAR NAME IN expr
346
+ | VAR NAME ":" type_spec IN expr
347
+ repeat_statement: REPEAT statement_list? UNTIL expr
348
+ case_statement: CASE expr OF case_selector_list case_else? END
349
+ case_selector_list: case_selector (";" case_selector)* ";"?
350
+ case_selector: case_label_list ":" statement?
351
+ case_label_list: case_label ("," case_label)*
352
+ case_label: expr (".." expr)?
353
+ case_else: ELSE statement_list?
354
+ with_statement: WITH expr_list DO statement
355
+ try_statement: TRY statement_list (except_block | finally_block) END
356
+ except_block: EXCEPT statement_list
357
+ | EXCEPT exception_handler+ (ELSE statement_list)?
358
+ | EXCEPT
359
+ exception_handler: ON qualified_name (":" qualified_name)? DO statement_list?
360
+ finally_block: FINALLY statement_list?
361
+ raise_statement: RAISE expr? (AT expr)?
362
+ goto_statement: GOTO label
363
+ label_statement: label ":" statement?
364
+ inherited_statement: INHERITED call_statement?
365
+ break_statement: BREAK
366
+ continue_statement: CONTINUE
367
+ exit_statement: EXIT
368
+ | EXIT "(" ")"
369
+ | EXIT expr
370
+ asm_statement: ASM asm_item* END
371
+ asm_item: NAME | INT | HEX_INT | BIN_INT | FLOAT | STRING_LITERAL | CHAR_CODE | "." | "," | ":" | ";" | "+" | "-" | "*" | "/" | "[" | "]" | "(" | ")" | "@" | "^" | "="
372
+ inline_statement: INLINE "(" inline_number ("/" inline_number)* ")"
373
+ inline_number: INT | HEX_INT
374
+ inline_const_section: CONST inline_const_decl
375
+ inline_const_decl: attribute_sections? NAME (":" type_spec)? "=" const_value
376
+ inline_var_section: VAR inline_var_decl
377
+ inline_var_decl: attribute_sections? name_list (":" type_spec)? (ASSIGN expr)?
378
+
379
+ address_assignment: "@" postfix_expr ASSIGN expr
380
+ assignment: postfix_expr ASSIGN expr
381
+ comparison_statement: postfix_expr rel_op expr
382
+ call_statement: postfix_expr
383
+
384
+ ?expr_list: expr ("," expr)*
385
+
386
+ ?expr: if_expr
387
+ | or_expr
388
+ if_expr: IF expr THEN expr ELSE expr
389
+ ?or_expr: xor_expr (OR xor_expr)*
390
+ ?xor_expr: and_expr (XOR and_expr)*
391
+ ?and_expr: rel_expr (AND rel_expr)*
392
+ ?rel_expr: add_expr (rel_op add_expr)*
393
+ rel_op: "=" | "<>" | "<" | "<=" | ">" | ">=" | IN | IS | AS | not_in_op | is_not_op
394
+ not_in_op: NOT IN
395
+ is_not_op: IS NOT
396
+ ?add_expr: mul_expr (("+"|"-") mul_expr)*
397
+ ?mul_expr: unary_expr (("*"|"/"|DIV|MOD|SHL|SHR) unary_expr)*
398
+ ?unary_expr: (NOT|"+"|"-"|"@"|"^") unary_expr
399
+ | postfix_expr
400
+
401
+ ?postfix_expr: primary (call_suffix | index_suffix | field_suffix | deref_suffix)*
402
+ call_suffix: "(" arg_list? ")"
403
+ index_suffix: "[" expr_list "]"
404
+ field_suffix: "." (NAME | GENERIC_NAME | ADD | REMOVE | READ | WRITE | DEFAULT | STORED | INDEX | MESSAGE | DISPID | ABSOLUTE)
405
+ deref_suffix: "^"
406
+ arg_list: argument ("," argument)*
407
+ argument: named_formatted_argument | formatted_argument | NAME ":" expr | NAME ASSIGN expr | expr
408
+ named_formatted_argument: NAME ":" expr ":" expr
409
+ formatted_argument: expr ":" expr (":" expr)?
410
+
411
+ ?primary: literal
412
+ | expr_qualified_name
413
+ | set_const
414
+ | anonymous_method
415
+ | inherited_expr
416
+ | "(" expr ")"
417
+ | NIL
418
+ | TRUE
419
+ | FALSE
420
+ | SELF
421
+
422
+ inherited_expr: INHERITED postfix_expr?
423
+ anonymous_method: (PROCEDURE formal_parameters? | FUNCTION formal_parameters? ":" type_spec) block
424
+
425
+ literal: string_literal_sequence | numeric_literal
426
+ string_literal_sequence: string_literal_part+
427
+ string_literal_part: STRING_BLOCK5 | STRING_BLOCK3 | STRING_LITERAL | CHAR_CODE | POINTER_CHAR
428
+ numeric_literal: FLOAT | HEX_INT | BIN_INT | INT
429
+
430
+ expr_qualified_name: expr_identifier ("." expr_identifier)*
431
+ expr_identifier: NAME | GENERIC_NAME | SPACED_GENERIC_NAME
432
+ | ADD | REMOVE | READ | WRITE | DEFAULT | STORED | INDEX | MESSAGE | DISPID | ABSOLUTE
433
+
434
+ qualified_name: qualified_name_part ("." qualified_name_part)*
435
+ qualified_name_part: NAME | GENERIC_NAME
436
+
437
+ ?range_expr: range_add
438
+ ?range_add: range_mul (range_add_op range_mul)* -> add_expr
439
+ range_add_op: "+" -> op_add
440
+ | "-" -> op_sub
441
+ ?range_mul: range_unary (range_mul_op range_unary)* -> mul_expr
442
+ range_mul_op: "*" -> op_mul
443
+ | "/" -> op_fdiv
444
+ | DIV -> op_div
445
+ | MOD -> op_mod
446
+ | SHL -> op_shl
447
+ | SHR -> op_shr
448
+ ?range_unary: ("+"|"-") range_unary -> unary_expr
449
+ | range_postfix
450
+ range_postfix: range_primary range_call_suffix*
451
+ range_call_suffix: "(" range_arg_list? ")"
452
+ range_arg_list: range_expr ("," range_expr)*
453
+ range_primary: literal | qualified_name | "(" range_expr ")"
454
+
455
+ ASSIGN: ":="
456
+ '''
457
+
458
+
459
+ def build_grammar() -> str:
460
+ return build_grammar_snippet() + '\n' + GRAMMAR_RULES