vex-ast 0.2.5__py3-none-any.whl → 0.2.7__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 (63) hide show
  1. vex_ast/README.md +101 -51
  2. vex_ast/READMEAPI.md +133 -318
  3. vex_ast/__init__.py +81 -81
  4. vex_ast/ast/README.md +87 -87
  5. vex_ast/ast/__init__.py +74 -74
  6. vex_ast/ast/core.py +71 -71
  7. vex_ast/ast/expressions.py +276 -276
  8. vex_ast/ast/interfaces.py +208 -208
  9. vex_ast/ast/literals.py +80 -80
  10. vex_ast/ast/navigator.py +241 -225
  11. vex_ast/ast/operators.py +135 -135
  12. vex_ast/ast/statements.py +351 -351
  13. vex_ast/ast/validators.py +121 -121
  14. vex_ast/ast/vex_nodes.py +279 -279
  15. vex_ast/parser/README.md +47 -47
  16. vex_ast/parser/__init__.py +26 -26
  17. vex_ast/parser/factory.py +190 -190
  18. vex_ast/parser/interfaces.py +34 -34
  19. vex_ast/parser/python_parser.py +831 -831
  20. vex_ast/registry/README.md +107 -29
  21. vex_ast/registry/__init__.py +51 -51
  22. vex_ast/registry/api.py +190 -155
  23. vex_ast/registry/categories.py +179 -136
  24. vex_ast/registry/functions/__init__.py +10 -10
  25. vex_ast/registry/functions/constructors.py +71 -35
  26. vex_ast/registry/functions/display.py +146 -146
  27. vex_ast/registry/functions/drivetrain.py +163 -163
  28. vex_ast/registry/functions/initialize.py +31 -31
  29. vex_ast/registry/functions/motor.py +140 -140
  30. vex_ast/registry/functions/sensors.py +194 -194
  31. vex_ast/registry/functions/timing.py +103 -103
  32. vex_ast/registry/language_map.py +77 -77
  33. vex_ast/registry/registry.py +164 -153
  34. vex_ast/registry/signature.py +269 -191
  35. vex_ast/registry/simulation_behavior.py +8 -8
  36. vex_ast/registry/validation.py +43 -43
  37. vex_ast/serialization/__init__.py +37 -37
  38. vex_ast/serialization/json_deserializer.py +284 -284
  39. vex_ast/serialization/json_serializer.py +148 -148
  40. vex_ast/serialization/schema.py +492 -492
  41. vex_ast/types/README.md +78 -26
  42. vex_ast/types/__init__.py +140 -140
  43. vex_ast/types/base.py +83 -83
  44. vex_ast/types/enums.py +122 -122
  45. vex_ast/types/objects.py +64 -64
  46. vex_ast/types/primitives.py +68 -68
  47. vex_ast/types/type_checker.py +31 -31
  48. vex_ast/utils/README.md +39 -39
  49. vex_ast/utils/__init__.py +37 -37
  50. vex_ast/utils/errors.py +112 -112
  51. vex_ast/utils/source_location.py +38 -38
  52. vex_ast/utils/type_definitions.py +8 -8
  53. vex_ast/visitors/README.md +49 -49
  54. vex_ast/visitors/__init__.py +27 -27
  55. vex_ast/visitors/analyzer.py +102 -102
  56. vex_ast/visitors/base.py +133 -133
  57. vex_ast/visitors/printer.py +196 -196
  58. {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/METADATA +206 -174
  59. vex_ast-0.2.7.dist-info/RECORD +64 -0
  60. vex_ast-0.2.5.dist-info/RECORD +0 -64
  61. {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/WHEEL +0 -0
  62. {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/licenses/LICENSE +0 -0
  63. {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/top_level.txt +0 -0
vex_ast/README.md CHANGED
@@ -1,51 +1,101 @@
1
- VEX AST Package (vex_ast)
2
-
3
- This directory is the root of the vex_ast Python package. It orchestrates the different components of the VEX AST generation and processing system.
4
-
5
- Purpose
6
-
7
- The vex_ast package provides a unified interface for parsing VEX V5 Python code into an Abstract Syntax Tree (AST) and tools for working with that AST.
8
-
9
- Structure
10
-
11
- The package is organized into several sub-packages:
12
-
13
- ast/: Contains the definitions for all AST node types, representing the structure of the parsed code. See vex_ast/ast/README.md.
14
-
15
- parser/: Includes the parsing logic responsible for converting source code text into an AST instance. See vex_ast/parser/README.md.
16
-
17
- visitors/: Provides implementations of the Visitor pattern for traversing, analyzing, or transforming the AST. See vex_ast/visitors/README.md.
18
-
19
- utils/: Contains utility classes and functions, primarily for error handling and source location tracking. See vex_ast/utils/README.md.
20
-
21
- Core Exports
22
-
23
- The main components are exposed through the vex_ast/__init__.py file, making them easily accessible:
24
-
25
- parse_string(source, ...): Parses Python code from a string.
26
-
27
- parse_file(filepath, ...): Parses Python code from a file.
28
-
29
- Program: The root node type of the generated AST.
30
-
31
- PrintVisitor: A visitor to generate a string representation of the AST.
32
-
33
- NodeCounter: A visitor to count nodes in the AST.
34
-
35
- VariableCollector: A visitor to collect variable names used in the AST.
36
-
37
- ErrorHandler: Class for managing errors during parsing and processing.
38
-
39
- VexSyntaxError, VexAstError: Custom exception types.
40
-
41
- Workflow
42
-
43
- The typical workflow involves:
44
-
45
- Using parse_string or parse_file from this package to generate an AST (Program object) from source code.
46
-
47
- Instantiating one or more visitors from vex_ast.visitors (or custom ones).
48
-
49
- Calling the visit method of the visitor with the root Program node to perform analysis, transformation, or other operations on the AST.
50
-
51
- Using the ErrorHandler to manage and inspect any errors encountered during the process.
1
+ # VEX AST Package
2
+
3
+ The VEX AST (Abstract Syntax Tree) package provides a comprehensive framework for parsing, analyzing, and simulating VEX V5 Robot Python code.
4
+
5
+ ## Key Features
6
+
7
+ ### Advanced Registry System
8
+ - Dual-axis categorization (Category × Behavior)
9
+ - Intelligent function signature validation
10
+ - Language mapping (Python ↔ C++)
11
+ - Full backward compatibility
12
+
13
+ ### Robust AST Generation
14
+ - Python 3.8+ parsing with modern features
15
+ - VEX-specific node types
16
+ - Source location tracking
17
+ - Error recovery and reporting
18
+
19
+ ### Extensible Visitor Pattern
20
+ - Analysis visitors (NodeCounter, VariableCollector)
21
+ - Transformation capabilities
22
+ - Pretty printing and serialization
23
+
24
+ ## What's New in 0.2.6
25
+
26
+ ### Unified Category System
27
+ - Introduced `VexCategory` enum for component types
28
+ - Added `BehaviorType` enum for function behaviors
29
+ - Maintained `SubCategory` for detailed classification
30
+ - Deprecated `SimulationCategory` (still supported)
31
+
32
+ ### Enhanced Registry API
33
+ - New query methods for behavior-based lookups
34
+ - Combined category/behavior queries
35
+ - Improved validation logic
36
+
37
+ ### Missing Components Added
38
+ - Brain and Controller constructors
39
+ - Complete VEX object type coverage
40
+
41
+ ## Usage
42
+
43
+ ### Basic Parsing
44
+ ```python
45
+ from vex_ast import parse_string
46
+
47
+ code = """
48
+ motor1 = Motor(PORT1)
49
+ motor1.spin(FORWARD, 50, RPM)
50
+ """
51
+
52
+ ast = parse_string(code)
53
+ ```
54
+
55
+ ### Registry Access
56
+ ```python
57
+ from vex_ast.registry.api import registry_api
58
+ from vex_ast.registry.categories import VexCategory, BehaviorType
59
+
60
+ # Find control functions
61
+ control_funcs = registry_api.get_functions_by_behavior(BehaviorType.CONTROL)
62
+
63
+ # Find motor functions
64
+ motor_funcs = registry_api.get_functions_by_category(VexCategory.MOTOR)
65
+ ```
66
+
67
+ ## Architecture Overview
68
+
69
+ ```
70
+ vex_ast/
71
+ ├── ast/ # AST node definitions
72
+ ├── parser/ # Parsing logic
73
+ ├── registry/ # Function registry system
74
+ │ ├── api.py # Public API
75
+ │ ├── categories.py # Category system
76
+ │ └── functions/ # Function definitions
77
+ ├── types/ # Type system
78
+ ├── utils/ # Utilities
79
+ └── visitors/ # AST traversal
80
+ ```
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ pip install vex-ast
86
+ ```
87
+
88
+ ## Documentation
89
+
90
+ - [API Reference](./READMEAPI.md)
91
+ - [Registry Guide](./registry/README.md)
92
+ - [Type System](./types/README.md)
93
+ - [Visitor Pattern](./visitors/README.md)
94
+
95
+ ## Contributing
96
+
97
+ We welcome contributions! Please see our contributing guidelines and code of conduct.
98
+
99
+ ## License
100
+
101
+ HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0
vex_ast/READMEAPI.md CHANGED
@@ -1,318 +1,133 @@
1
- # VEX AST (`vex_ast`) - Public API Reference
2
-
3
- This document describes the main functions and classes exposed by the `vex_ast` package, intended for users who want to parse VEX V5 Python code and interact with the resulting Abstract Syntax Tree (AST).
4
-
5
- ## Overview
6
-
7
- The core workflow typically involves:
8
-
9
- 1. Parsing source code (from a string or file) using `parse_string` or `parse_file`. This requires an optional `ErrorHandler` instance.
10
- 2. Receiving a `Program` object, which is the root of the generated AST.
11
- 3. Instantiating one or more `AstVisitor` subclasses (like `PrintVisitor`, `NodeCounter`, `VariableCollector`, or custom ones).
12
- 4. Calling the visitor's `visit()` method with the `Program` node to traverse the AST and perform actions.
13
- 5. Checking the `ErrorHandler` instance for any reported errors during parsing or visiting.
14
-
15
- ---
16
-
17
- ## Parsing Functions
18
-
19
- These functions are the entry points for converting source code into an AST.
20
-
21
- ### `parse_string`
22
-
23
- Parses VEX V5 Python code provided as a string.
24
-
25
- **Signature:**
26
-
27
- ```python
28
- def parse_string(
29
- source: str,
30
- filename: str = "<string>",
31
- error_handler: Optional[ErrorHandler] = None
32
- ) -> Program:
33
-
34
-
35
- Arguments:
36
-
37
- source (str): The string containing the Python code to parse.
38
-
39
- filename (str, optional): The name to associate with the source code, used in error messages and source locations. Defaults to "<string>".
40
-
41
- error_handler (Optional[ErrorHandler], optional): An instance of ErrorHandler to collect parsing errors. If None, a default ErrorHandler is created internally (which will raise VexSyntaxError on the first syntax error). It's recommended to provide your own handler to manage errors more flexibly.
42
-
43
- Returns:
44
-
45
- Program: The root node of the generated Abstract Syntax Tree.
46
-
47
- Raises:
48
-
49
- VexSyntaxError: If a syntax error is encountered during parsing and the error_handler is configured to raise errors immediately (or if no handler is provided).
50
-
51
- VexAstError: For other internal parsing or AST conversion issues if the error_handler is configured to raise errors.
52
-
53
- parse_file
54
-
55
- Parses VEX V5 Python code read from a specified file.
56
-
57
- Signature:
58
-
59
- def parse_file(
60
- filepath: str,
61
- error_handler: Optional[ErrorHandler] = None
62
- ) -> Program:
63
- IGNORE_WHEN_COPYING_START
64
- content_copy
65
- download
66
- Use code with caution.
67
- Python
68
- IGNORE_WHEN_COPYING_END
69
-
70
- Arguments:
71
-
72
- filepath (str): The path to the Python file to be parsed.
73
-
74
- error_handler (Optional[ErrorHandler], optional): An instance of ErrorHandler to collect parsing errors. See parse_string for details.
75
-
76
- Returns:
77
-
78
- Program: The root node of the generated Abstract Syntax Tree.
79
-
80
- Raises:
81
-
82
- FileNotFoundError: If the specified filepath does not exist.
83
-
84
- IOError: If there is an error reading the file.
85
-
86
- VexSyntaxError: If a syntax error is encountered (see parse_string).
87
-
88
- VexAstError: For other internal parsing errors (see parse_string).
89
-
90
- Core AST Node
91
- Program
92
-
93
- Represents the root node of the entire Abstract Syntax Tree.
94
-
95
- Description:
96
-
97
- The Program node is the object returned by parse_string and parse_file. It serves as the entry point for traversing the AST using visitors.
98
-
99
- Key Attribute:
100
-
101
- body (List[IStatement]): A list containing the top-level statements (like function definitions, assignments, expression statements) found in the parsed code.
102
-
103
- Usage:
104
-
105
- You typically don't instantiate Program directly. You receive it from a parsing function and pass it to the visit() method of an AstVisitor.
106
-
107
- ast_root: Program = parse_string("x = 1")
108
- printer = PrintVisitor()
109
- printer.visit(ast_root) # Pass the Program node to the visitor
110
- IGNORE_WHEN_COPYING_START
111
- content_copy
112
- download
113
- Use code with caution.
114
- Python
115
- IGNORE_WHEN_COPYING_END
116
- Standard Visitors
117
-
118
- Visitors provide mechanisms to traverse and process the AST. You instantiate a visitor and then call its visit method on an AST node (usually the Program root).
119
-
120
- PrintVisitor
121
-
122
- Generates a formatted, indented string representation of the AST structure. Useful for debugging and inspection.
123
-
124
- Instantiation:
125
-
126
- printer = PrintVisitor()
127
- IGNORE_WHEN_COPYING_START
128
- content_copy
129
- download
130
- Use code with caution.
131
- Python
132
- IGNORE_WHEN_COPYING_END
133
-
134
- Core Method:
135
-
136
- visit(node: IAstNode) -> str: Traverses the AST starting from node (typically the Program root) and returns a multi-line string representing the tree.
137
-
138
- Example:
139
-
140
- ast_root = parse_string("y = a + 5")
141
- visitor = PrintVisitor()
142
- ast_string_representation = visitor.visit(ast_root)
143
- print(ast_string_representation)
144
- IGNORE_WHEN_COPYING_START
145
- content_copy
146
- download
147
- Use code with caution.
148
- Python
149
- IGNORE_WHEN_COPYING_END
150
- NodeCounter
151
-
152
- Counts the number of nodes in the AST.
153
-
154
- Instantiation:
155
-
156
- counter = NodeCounter()
157
- IGNORE_WHEN_COPYING_START
158
- content_copy
159
- download
160
- Use code with caution.
161
- Python
162
- IGNORE_WHEN_COPYING_END
163
-
164
- Core Method:
165
-
166
- visit(node: IAstNode) -> int: Traverses the AST starting from node and returns the total count of nodes visited.
167
-
168
- Additional Attribute:
169
-
170
- counts_by_type (Dict[str, int]): After calling visit, this dictionary holds the counts for each specific node type encountered (e.g., {'Assignment': 1, 'BinaryOperation': 1, ...}).
171
-
172
- Example:
173
-
174
- ast_root = parse_string("def f():\n return 10")
175
- visitor = NodeCounter()
176
- total_nodes = visitor.visit(ast_root)
177
- print(f"Total nodes: {total_nodes}")
178
- print(f"Nodes by type: {visitor.counts_by_type}")
179
- IGNORE_WHEN_COPYING_START
180
- content_copy
181
- download
182
- Use code with caution.
183
- Python
184
- IGNORE_WHEN_COPYING_END
185
- VariableCollector
186
-
187
- Collects the names of all variables referenced (read from) in the AST. Does not include variables only assigned to or function/class names being defined.
188
-
189
- Instantiation:
190
-
191
- collector = VariableCollector()
192
- IGNORE_WHEN_COPYING_START
193
- content_copy
194
- download
195
- Use code with caution.
196
- Python
197
- IGNORE_WHEN_COPYING_END
198
-
199
- Core Method:
200
-
201
- visit(node: IAstNode) -> Set[str]: Traverses the AST starting from node and returns a set containing the names of all referenced variables (identifiers used in a Load context).
202
-
203
- Example:
204
-
205
- code = """
206
- x = 10
207
- y = x + z
208
- def my_func(p):
209
- q = p
210
- """
211
- ast_root = parse_string(code)
212
- visitor = VariableCollector()
213
- referenced_vars = visitor.visit(ast_root)
214
- print(f"Referenced variables: {referenced_vars}") # Output: {'x', 'z', 'p'}
215
- IGNORE_WHEN_COPYING_START
216
- content_copy
217
- download
218
- Use code with caution.
219
- Python
220
- IGNORE_WHEN_COPYING_END
221
- Error Handling
222
-
223
- Components for managing and reporting errors during parsing and processing.
224
-
225
- ErrorHandler
226
-
227
- Manages the collection and reporting of errors.
228
-
229
- Instantiation:
230
-
231
- # Option 1: Collect errors, don't raise exceptions immediately
232
- handler = ErrorHandler(raise_on_error=False)
233
-
234
- # Option 2: Raise VexSyntaxError/VexAstError on the first error
235
- handler = ErrorHandler(raise_on_error=True) # Default behavior if omitted
236
- IGNORE_WHEN_COPYING_START
237
- content_copy
238
- download
239
- Use code with caution.
240
- Python
241
- IGNORE_WHEN_COPYING_END
242
-
243
- Key Methods:
244
-
245
- get_errors() -> List[Error]: Returns a list of all Error objects collected so far.
246
-
247
- has_errors() -> bool: Returns True if any errors have been collected, False otherwise. Useful after parsing with raise_on_error=False.
248
-
249
- clear_errors() -> None: Removes all collected errors.
250
-
251
- add_observer(observer: ErrorObserver) -> None: (Advanced) Registers a custom object to be notified whenever an error is added.
252
-
253
- remove_observer(observer: ErrorObserver) -> None: (Advanced) Unregisters an observer.
254
-
255
- Usage:
256
-
257
- Typically, you create an ErrorHandler instance and pass it to parse_string or parse_file.
258
-
259
- error_handler = ErrorHandler(raise_on_error=False)
260
- try:
261
- ast = parse_string("x = 1 + ", error_handler=error_handler)
262
- if error_handler.has_errors():
263
- print("Parsing completed with non-fatal errors:")
264
- for err in error_handler.get_errors():
265
- print(f"- {err}")
266
- else:
267
- print("Parsing successful.")
268
- # Proceed with AST processing...
269
- except VexAstError as e:
270
- # This shouldn't happen if raise_on_error=False, but good practice
271
- print(f"Unexpected VexAstError: {e}")
272
- IGNORE_WHEN_COPYING_START
273
- content_copy
274
- download
275
- Use code with caution.
276
- Python
277
- IGNORE_WHEN_COPYING_END
278
- ErrorType
279
-
280
- An Enum used within Error objects to categorize the type of error.
281
-
282
- Values:
283
-
284
- LEXER_ERROR
285
-
286
- PARSER_ERROR
287
-
288
- TYPE_ERROR
289
-
290
- SEMANTIC_ERROR
291
-
292
- INTERNAL_ERROR
293
-
294
- Usage:
295
-
296
- You typically check the error_type attribute of Error objects retrieved from ErrorHandler.get_errors().
297
-
298
- VexSyntaxError
299
-
300
- Exception raised specifically for syntax errors encountered during parsing when the ErrorHandler is configured to raise errors.
301
-
302
- Inheritance: VexSyntaxError -> VexAstError -> Exception
303
-
304
- Attribute:
305
-
306
- location (Optional[SourceLocation]): May contain the location (line, column) where the syntax error occurred.
307
-
308
- VexAstError
309
-
310
- The base exception class for all errors originating from the vex_ast library. VexSyntaxError is a subclass.
311
-
312
- This reference covers the main components needed to use the vex_ast library effectively for parsing and basic AST interaction. For more advanced use cases, you might need to delve into the specific AST node types in vex_ast.ast or create custom visitors inheriting from vex_ast.visitors.AstVisitor.
313
-
314
- IGNORE_WHEN_COPYING_START
315
- content_copy
316
- download
317
- Use code with caution.
318
- IGNORE_WHEN_COPYING_END
1
+ # VEX AST Registry API Reference
2
+
3
+ The Registry API provides a comprehensive interface for accessing and querying VEX function information in the AST system.
4
+
5
+ ## Core API
6
+
7
+ ### Registration and Access
8
+
9
+ #### `registry_api`
10
+ Singleton instance providing access to all registry functionality.
11
+
12
+ ```python
13
+ from vex_ast.registry.api import registry_api
14
+ ```
15
+
16
+ ### Function Queries
17
+
18
+ #### `get_function(name: str, language: str = "python") -> Optional[VexFunctionSignature]`
19
+ Retrieve a function signature by name.
20
+
21
+ ```python
22
+ spin_function = registry_api.get_function("spin")
23
+ ```
24
+
25
+ #### `get_functions_by_category(category: VexCategory) -> List[VexFunctionSignature]`
26
+ Get all functions in a specific category.
27
+
28
+ ```python
29
+ motor_functions = registry_api.get_functions_by_category(VexCategory.MOTOR)
30
+ ```
31
+
32
+ #### `get_functions_by_behavior(behavior: BehaviorType) -> List[VexFunctionSignature]`
33
+ Get all functions with a specific behavior.
34
+
35
+ ```python
36
+ control_functions = registry_api.get_functions_by_behavior(BehaviorType.CONTROL)
37
+ ```
38
+
39
+ #### `get_functions_by_category_and_behavior(category: VexCategory, behavior: BehaviorType) -> List[VexFunctionSignature]`
40
+ Get functions matching both category and behavior.
41
+
42
+ ```python
43
+ motor_control = registry_api.get_functions_by_category_and_behavior(
44
+ VexCategory.MOTOR,
45
+ BehaviorType.CONTROL
46
+ )
47
+ ```
48
+
49
+ ### Method Access
50
+
51
+ #### `get_method(object_type: Union[VexType, str], method_name: str) -> Optional[VexFunctionSignature]`
52
+ Get a method signature for an object type.
53
+
54
+ ```python
55
+ spin_method = registry_api.get_method(MOTOR, "spin")
56
+ ```
57
+
58
+ ### Validation
59
+
60
+ #### `validate_call(function_name: str, args: List[Any], kwargs: Dict[str, Any], language: str = "python") -> Tuple[bool, Optional[str]]`
61
+ Validate a function call against its signature.
62
+
63
+ ```python
64
+ valid, error = registry_api.validate_call("motor.spin", [FORWARD, 50, "RPM"], {})
65
+ ```
66
+
67
+ ### Category Enumerations
68
+
69
+ #### VexCategory
70
+ - `MOTOR`: Motor control functions
71
+ - `DRIVETRAIN`: Drivetrain control functions
72
+ - `SENSOR`: Sensor reading functions
73
+ - `DISPLAY`: Display output functions
74
+ - `TIMING`: Timing control functions
75
+ - `COMPETITION`: Competition control functions
76
+ - `CONTROLLER`: Controller input functions
77
+ - `BRAIN`: Brain functions
78
+ - `UTILITY`: Utility functions
79
+ - `EVENT`: Event handling
80
+
81
+ #### BehaviorType
82
+ - `CONTROL`: Actively controls/changes state
83
+ - `READ`: Reads/retrieves information
84
+ - `CONFIG`: Configuration/setup
85
+ - `OUTPUT`: Produces output (display, signals)
86
+ - `EVENT`: Event handling/callbacks
87
+
88
+ ## Advanced Usage
89
+
90
+ ### Creating Custom Queries
91
+
92
+ ```python
93
+ # Find all motor functions that read data
94
+ motor_readers = [
95
+ func for func in registry_api.get_functions_by_category(VexCategory.MOTOR)
96
+ if func.behavior == BehaviorType.READ
97
+ ]
98
+
99
+ # Find all functions with specific subcategories
100
+ spin_functions = registry_api.get_functions_by_subcategory(SubCategory.MOTOR_SPIN)
101
+ ```
102
+
103
+ ### Registry Extension
104
+
105
+ ```python
106
+ from vex_ast.registry.signature import VexFunctionSignature
107
+ from vex_ast.registry.categories import VexCategory, BehaviorType
108
+
109
+ # Create and register custom function
110
+ custom_signature = VexFunctionSignature(
111
+ name="custom_function",
112
+ category=VexCategory.UTILITY,
113
+ behavior=BehaviorType.CONTROL,
114
+ # ... other parameters
115
+ )
116
+
117
+ registry.register_function(custom_signature)
118
+ ```
119
+
120
+ ## Migration from Legacy Systems
121
+
122
+ If upgrading from older versions:
123
+
124
+ ```python
125
+ # Old code (still works)
126
+ functions = registry_api.get_functions_by_simulation(SimulationCategory.MOTOR_CONTROL)
127
+
128
+ # Modern equivalent
129
+ functions = registry_api.get_functions_by_category_and_behavior(
130
+ VexCategory.MOTOR,
131
+ BehaviorType.CONTROL
132
+ )
133
+ ```