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.
- vex_ast/README.md +101 -51
- vex_ast/READMEAPI.md +133 -318
- vex_ast/__init__.py +81 -81
- vex_ast/ast/README.md +87 -87
- vex_ast/ast/__init__.py +74 -74
- vex_ast/ast/core.py +71 -71
- vex_ast/ast/expressions.py +276 -276
- vex_ast/ast/interfaces.py +208 -208
- vex_ast/ast/literals.py +80 -80
- vex_ast/ast/navigator.py +241 -225
- vex_ast/ast/operators.py +135 -135
- vex_ast/ast/statements.py +351 -351
- vex_ast/ast/validators.py +121 -121
- vex_ast/ast/vex_nodes.py +279 -279
- vex_ast/parser/README.md +47 -47
- vex_ast/parser/__init__.py +26 -26
- vex_ast/parser/factory.py +190 -190
- vex_ast/parser/interfaces.py +34 -34
- vex_ast/parser/python_parser.py +831 -831
- vex_ast/registry/README.md +107 -29
- vex_ast/registry/__init__.py +51 -51
- vex_ast/registry/api.py +190 -155
- vex_ast/registry/categories.py +179 -136
- vex_ast/registry/functions/__init__.py +10 -10
- vex_ast/registry/functions/constructors.py +71 -35
- vex_ast/registry/functions/display.py +146 -146
- vex_ast/registry/functions/drivetrain.py +163 -163
- vex_ast/registry/functions/initialize.py +31 -31
- vex_ast/registry/functions/motor.py +140 -140
- vex_ast/registry/functions/sensors.py +194 -194
- vex_ast/registry/functions/timing.py +103 -103
- vex_ast/registry/language_map.py +77 -77
- vex_ast/registry/registry.py +164 -153
- vex_ast/registry/signature.py +269 -191
- vex_ast/registry/simulation_behavior.py +8 -8
- vex_ast/registry/validation.py +43 -43
- vex_ast/serialization/__init__.py +37 -37
- vex_ast/serialization/json_deserializer.py +284 -284
- vex_ast/serialization/json_serializer.py +148 -148
- vex_ast/serialization/schema.py +492 -492
- vex_ast/types/README.md +78 -26
- vex_ast/types/__init__.py +140 -140
- vex_ast/types/base.py +83 -83
- vex_ast/types/enums.py +122 -122
- vex_ast/types/objects.py +64 -64
- vex_ast/types/primitives.py +68 -68
- vex_ast/types/type_checker.py +31 -31
- vex_ast/utils/README.md +39 -39
- vex_ast/utils/__init__.py +37 -37
- vex_ast/utils/errors.py +112 -112
- vex_ast/utils/source_location.py +38 -38
- vex_ast/utils/type_definitions.py +8 -8
- vex_ast/visitors/README.md +49 -49
- vex_ast/visitors/__init__.py +27 -27
- vex_ast/visitors/analyzer.py +102 -102
- vex_ast/visitors/base.py +133 -133
- vex_ast/visitors/printer.py +196 -196
- {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/METADATA +206 -174
- vex_ast-0.2.7.dist-info/RECORD +64 -0
- vex_ast-0.2.5.dist-info/RECORD +0 -64
- {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/WHEEL +0 -0
- {vex_ast-0.2.5.dist-info → vex_ast-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {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
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
##
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
) ->
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
+
```
|