vex-ast 0.1.0__py3-none-any.whl → 0.2.1__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.
@@ -0,0 +1,9 @@
1
+ # vex_ast/utils/type_definitions.py
2
+ """Type definitions for type hints in the VEX AST."""
3
+
4
+ from typing import Any, Dict, List, Optional, TypeVar, Union, Type, Protocol
5
+
6
+ # Type variables for type hints
7
+ NodeType = TypeVar('NodeType')
8
+ VisitorType = TypeVar('VisitorType')
9
+ TransformerType = TypeVar('TransformerType')
@@ -0,0 +1,49 @@
1
+ AST Visitors (vex_ast.visitors)
2
+
3
+ This directory provides implementations of the Visitor design pattern for traversing and operating on the VEX Abstract Syntax Tree (AST).
4
+
5
+ Purpose
6
+
7
+ Visitors allow you to perform operations on the AST without modifying the AST node classes themselves. They provide a clean and extensible way to implement various forms of analysis, transformation, or code generation based on the AST structure.
8
+
9
+ Core Concepts
10
+
11
+ Visitor Pattern: The core idea is double dispatch. You call visitor.visit(node), which in turn calls node.accept(visitor). The node's accept method then calls the specific visit_NodeType(node) method on the visitor corresponding to its own type.
12
+
13
+ Base Visitor (base.py):
14
+
15
+ AstVisitor[T_VisitorResult]: An abstract generic base class for all visitors. It defines the main visit entry point and provides default visit_NodeType methods that typically delegate to a generic_visit method. Subclasses must implement generic_visit and can override specific visit_NodeType methods for custom behavior.
16
+
17
+ Traversal: The generic_visit method in concrete visitors often iterates through the node's children (obtained via node.get_children()) and calls self.visit(child) recursively to traverse the tree.
18
+
19
+ Provided Visitors
20
+
21
+ Printer (printer.py):
22
+
23
+ PrintVisitor: Traverses the AST and generates a formatted, indented string representation of the tree structure, including node types, attributes, and source locations (if available). Useful for debugging and understanding the AST structure.
24
+
25
+ Analyzers (analyzer.py):
26
+
27
+ NodeCounter: Traverses the AST and counts the total number of nodes, optionally keeping track of counts per node type.
28
+
29
+ VariableCollector: Traverses the AST and collects the names of all variables referenced (VariableReference nodes).
30
+
31
+ Usage
32
+
33
+ Instantiate a Visitor: Create an instance of the desired visitor class (e.g., printer = PrintVisitor()).
34
+
35
+ Parse Code: Obtain the root node (Program object) of the AST using vex_ast.parse_string or vex_ast.parse_file.
36
+
37
+ Start Visitation: Call the visitor's visit method with the root node (e.g., result = printer.visit(ast_root)).
38
+
39
+ Process Result: The visit method will return a result whose type depends on the specific visitor (T_VisitorResult). For PrintVisitor, it's a string; for NodeCounter, an integer; for VariableCollector, a set of strings.
40
+
41
+ Extensibility
42
+
43
+ You can create custom visitors to perform specific tasks (e.g., type checking, code optimization, simulation execution) by:
44
+
45
+ Creating a new class that inherits from AstVisitor[YourResultType].
46
+
47
+ Implementing the generic_visit method to define default behavior and traversal logic.
48
+
49
+ Overriding specific visit_NodeType methods for nodes where specialized logic is required.
@@ -0,0 +1,28 @@
1
+ """
2
+ Visitors package for VEX AST.
3
+
4
+ This package provides visitor pattern implementations for traversing and transforming the AST.
5
+ """
6
+
7
+ from .base import (
8
+ AstVisitor,
9
+ TypedVisitorMixin
10
+ )
11
+ from .printer import PrintVisitor
12
+ from .analyzer import (
13
+ NodeCounter,
14
+ VariableCollector
15
+ )
16
+
17
+ __all__ = [
18
+ # Base visitors
19
+ "AstVisitor",
20
+ "TypedVisitorMixin",
21
+
22
+ # Concrete visitors
23
+ "PrintVisitor",
24
+
25
+ # Analysis visitors
26
+ "NodeCounter",
27
+ "VariableCollector"
28
+ ]
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vex_ast
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: A Python package for generating Abstract Syntax Trees for VEX V5 code.
5
- Home-page: https://github.com/teowy/vex_ast
5
+ Home-page: https://github.com/heartx2/vex_ast
6
6
  Author: Chaze
7
- Author-email: chazelexander@example.com
7
+ Author-email: Chaze <chazelexander@gmail.com>
8
+ License: HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0
9
+ Project-URL: Repository, https://github.com/heartx2/vex_ast
8
10
  Classifier: Development Status :: 3 - Alpha
9
11
  Classifier: Intended Audience :: Developers
10
- Classifier: License :: OSI Approved :: MIT License
11
12
  Classifier: Programming Language :: Python :: 3
12
13
  Classifier: Programming Language :: Python :: 3.8
13
14
  Classifier: Programming Language :: Python :: 3.9
@@ -17,14 +18,11 @@ Classifier: Topic :: Software Development :: Compilers
17
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
19
  Requires-Python: >=3.8
19
20
  Description-Content-Type: text/markdown
21
+ License-File: LICENSE
20
22
  Dynamic: author
21
- Dynamic: author-email
22
- Dynamic: classifier
23
- Dynamic: description
24
- Dynamic: description-content-type
25
23
  Dynamic: home-page
24
+ Dynamic: license-file
26
25
  Dynamic: requires-python
27
- Dynamic: summary
28
26
 
29
27
  # VEX AST Generator
30
28
 
@@ -60,7 +58,7 @@ The core library is within the `vex_ast` directory:
60
58
 
61
59
  1. **Clone the repository:**
62
60
  ```bash
63
- git clone https://github.com/yourusername/vex_ast.git # Replace with actual URL
61
+ git clone https://github.com/heartx2/vex_ast # Replace with actual URL
64
62
  cd vex_ast
65
63
  ```
66
64
 
@@ -173,4 +171,4 @@ Contributions are welcome! Please follow the established coding standards and en
173
171
 
174
172
  ## License
175
173
 
176
- This project is licensed under the MIT License - see the LICENSE file for details (You'll need to add a LICENSE file).
174
+ HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0
@@ -0,0 +1,63 @@
1
+ vex_ast/README.md,sha256=tRaq6n2Ab4IahHSo3utW2imVuTrJu_7zaelgF-lGBYo,2007
2
+ vex_ast/READMEAPI.md,sha256=hGn4IMT9NnI_LW0kd36BdKKXdIhYFLbQcgbVj1EWJps,9107
3
+ vex_ast/__init__.py,sha256=ctZTmMc0ispErWMja0pTwdyst6ELgcfBJ-nwejYg-sc,1604
4
+ vex_ast/ast/README.md,sha256=7IQDHEXmKyJ8zfJNwa3pMGTDZKVPMFD0YeHT06ATRyM,3205
5
+ vex_ast/ast/__init__.py,sha256=_KT8R_WG9_DLvPlDhVCNWz-yw0OtdoKxxWZYbtloCzU,2434
6
+ vex_ast/ast/core.py,sha256=q-15q5VfGIVPAmFsSiWeFAZ55MPsXfCRa21rrt2hmlM,2670
7
+ vex_ast/ast/expressions.py,sha256=b0cDs239wvygCIL9s0W8uuyuPeMZz3DwxQ0wmBta_XM,7758
8
+ vex_ast/ast/interfaces.py,sha256=DXKdAzts0EBWjCRgYkz_kVSMcYbNIyPdwYpTr7c6P2A,5928
9
+ vex_ast/ast/literals.py,sha256=PXbOH5Y2fxEngWk_FOiFsx3PC2SEqcx0bcfOGJ3SdbI,2618
10
+ vex_ast/ast/navigator.py,sha256=9DaVXrknBbBr4omAAMHQnZL9Wpj5wjtoCS6_lni8MYM,7529
11
+ vex_ast/ast/operators.py,sha256=I-yWvhsrz-OxmBZs5zIss_GTZF5S-nwcSmIzvAVtddM,3160
12
+ vex_ast/ast/statements.py,sha256=OWRthjYGmTuNozYAHjh_Enp5t-hR1PphtPnFg31FeWw,11841
13
+ vex_ast/ast/validators.py,sha256=lhEm1dt-nzMiaUan_AWEOm0NiwXN7wYNkLCl1c3drqc,4455
14
+ vex_ast/ast/vex_nodes.py,sha256=kVil-ApFIeZ_BoeqYppfVRPSTg1KFUOcvt1vCE6QRgs,10148
15
+ vex_ast/parser/README.md,sha256=P1qq_97skpgluLDpNu9V_pAdkuF9StjkzOEXJJYpEuM,2565
16
+ vex_ast/parser/__init__.py,sha256=LGHnFm3UzR4Nw7royGH3c_2RqeY66y8O6DdXHbm9yL4,504
17
+ vex_ast/parser/factory.py,sha256=gaje0jOPu5lpndgX9c3VuQ_q-FJuFz9yC5y2bD69lL4,8770
18
+ vex_ast/parser/interfaces.py,sha256=Ttc0bD_5X420ZCT9MLUf_wE1aZLWLkaJRQqCwBy9wIs,956
19
+ vex_ast/parser/python_parser.py,sha256=e1owk-c6Rb4Bt5SYcgB-urZzqsX5xC9tzcK1sB8gkr4,29687
20
+ vex_ast/parser/strategies.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ vex_ast/registry/README.md,sha256=J8xEXEscEZhWa6wmn05kjE395AjrV7p2h7nq4SXI5uE,1535
22
+ vex_ast/registry/__init__.py,sha256=dXT8OS7uLyBSdQKZDWrtbANzgSWcg9HUQDA1EaLOvjQ,1188
23
+ vex_ast/registry/api.py,sha256=yyW-TsCIULTzePAoyMvEqD_RNlkFSb4PLpiSkw6ueQk,5460
24
+ vex_ast/registry/categories.py,sha256=y5tnCzHQ9PPg9hOzOMgyE1ZAhcsjgeFSrgqdJrdqHEg,4885
25
+ vex_ast/registry/language_map.py,sha256=eekN3k-K9g90GFi4--If3nfJCyarUJxDWDCDvLm7mdU,2656
26
+ vex_ast/registry/registry.py,sha256=gvsQKyeXWp84T2uDB4O_WQgKCeq8W9udl8TD5MnPZzc,6661
27
+ vex_ast/registry/signature.py,sha256=m8gQKdc5IaORDdfdBX6_qH1OL5LoTzveGoWlIIaOES0,5763
28
+ vex_ast/registry/simulation_behavior.py,sha256=WwkVKae0owtv3WTrfnVH93rpsh9lbqJ_RSAVmpIVA_k,313
29
+ vex_ast/registry/validation.py,sha256=xq5UjSWYAcRxjxsCGg3WU5RtPN-DB-JAqKqDNGvnJGk,1973
30
+ vex_ast/registry/functions/__init__.py,sha256=X9aw0-Y9Q6Gcx01zepP8G_20ybfwC-LDPQfkK2RDOrE,207
31
+ vex_ast/registry/functions/display.py,sha256=icXgTL6Y94ddm-Xjuv1dIOY5k0K2FVnAvmKBvUCHvk0,4854
32
+ vex_ast/registry/functions/drivetrain.py,sha256=F3voRYRfmAKgMiOP77oFTV8VCg-hXCVDUq3D-xGhN7Y,6307
33
+ vex_ast/registry/functions/initialize.py,sha256=r-FoxCMNDtPDayQR1kq0uDDIvObQ0TUK-tyzD2eqvMo,787
34
+ vex_ast/registry/functions/motor.py,sha256=Vby44hV1goNFgFQEFDlv7z_9uGQeuvLMABplOnLqZbo,5218
35
+ vex_ast/registry/functions/sensors.py,sha256=BdhLV5gSWD5HO-o3JRXhbGQF7s1Ybk3b6VLLqVau1i0,6410
36
+ vex_ast/registry/functions/timing.py,sha256=DqwMVPk7VKDeZB4S3NI7wOYgM1R52dcdgaVIb9135Jg,3204
37
+ vex_ast/serialization/__init__.py,sha256=qPTEiMjU8hpVxNH5z4MY7Yj60AxuFurjXZStjhWWf6o,835
38
+ vex_ast/serialization/json_deserializer.py,sha256=m_xiEUEoFXGfFylK3M8BVs7F2EieQJ9wbUa_ZTpkHtQ,10523
39
+ vex_ast/serialization/json_serializer.py,sha256=YvMRUpqXjtbxlIvathEIywUqbH3Ne6GSRODfFB0QCGM,4465
40
+ vex_ast/serialization/schema.py,sha256=zpKujT7u3Qw2kNbwjV09lNzeQAsCxvMx-uAdaRMEstA,14431
41
+ vex_ast/types/README.md,sha256=Wd3jBShiNXNc3iJ69Qps5_0mBq8QVEd_Gz5OachfS34,1029
42
+ vex_ast/types/__init__.py,sha256=naLOT_-qHWxzYj4nwxjCB5dfL6tcIt7TjMEaRaXMWbU,2163
43
+ vex_ast/types/base.py,sha256=hCPCeBNnD5p29Mim-ouRTkG6Lfa8NXrsdYLO8xsbFtM,2258
44
+ vex_ast/types/enums.py,sha256=BNPQrSh0SXXluVzv9wimOEC8B_5qhB6YNEqNWLp7ZYU,2507
45
+ vex_ast/types/objects.py,sha256=3bmfq-tB4uIghFed2XnisRJjUR2woJX46QIUEN_rHdM,2280
46
+ vex_ast/types/primitives.py,sha256=t_4kEVyPSmKRHEIRQcp-X5Yq46JbG1SxzlvHb0vL4IA,1928
47
+ vex_ast/types/type_checker.py,sha256=emzhmc6AlH71w0DrKLlZRMBlJNZAuENihvRXTenqg_Q,1083
48
+ vex_ast/utils/README.md,sha256=Y9RJMQTqQbpjVkvYJmpeRihD1zfW9PhNL_LgoDJ84ak,1945
49
+ vex_ast/utils/__init__.py,sha256=azzhhFoMykqOkVVm6X2V7dFW3jGBkOvEgnEP1JTCS3g,621
50
+ vex_ast/utils/errors.py,sha256=uq_jyu-YasifXjKSpPbVxup-XFf0XSHmp7A0Zd87TUY,3850
51
+ vex_ast/utils/source_location.py,sha256=r857ypqUBqex2y_R0RzZo7pz5di9qtEeWFFQ4HwzYQE,1297
52
+ vex_ast/utils/type_definitions.py,sha256=2rB85B1vZL1GLWItBuJJpyr-vmp3W346EMMX2TPZ99Q,313
53
+ vex_ast/visitors/README.md,sha256=BKDj8LMuBlCrzgSSLmCkbET7WIqgxe-oCkqQbqXekrE,2725
54
+ vex_ast/visitors/__init__.py,sha256=cndW3yp0Mu9w5vzwqqS2N5EqS0Ioh0V5UCDDrwCO0_Q,492
55
+ vex_ast/visitors/analyzer.py,sha256=cBT5PRbtfQ_Dt1qiHN-wdO5KnC2yl-Ul5RasXg9geHY,3668
56
+ vex_ast/visitors/base.py,sha256=Ph0taTIVMHV_QjXfDd0ipZnCXVJErkyRtPpfwfzo-kY,4859
57
+ vex_ast/visitors/printer.py,sha256=CUY_73hxm7MoC-63JeIXaVYnZ8QqtfMqbek2R2HMEmE,5411
58
+ vex_ast/visitors/transformer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ vex_ast-0.2.1.dist-info/licenses/LICENSE,sha256=IOSlfCuxGv4OAg421BRDKVi16RZ7-5kCMJ4B16r4kuc,69
60
+ vex_ast-0.2.1.dist-info/METADATA,sha256=Cm7vpEPf4qNlTPKTYcO4_HejvWBeyH-kcPpIq6dRe5I,5295
61
+ vex_ast-0.2.1.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
62
+ vex_ast-0.2.1.dist-info/top_level.txt,sha256=MoZGrpKgNUDiqL9gWp4q3wMw3q93XPEEjmBNPJQcNAs,8
63
+ vex_ast-0.2.1.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0
@@ -1,41 +0,0 @@
1
- vex_ast/__init__.py,sha256=YPsS_1ab9-G3WYmyxQobDA1U8y5KJkj2qxm_p_s9Oow,1724
2
- vex_ast/ast/__init__.py,sha256=3ZtTiNeBPWOYgNWmxThn0h7UQx8Z0bHbK6hRHCUuILQ,2435
3
- vex_ast/ast/core.py,sha256=q-15q5VfGIVPAmFsSiWeFAZ55MPsXfCRa21rrt2hmlM,2670
4
- vex_ast/ast/expressions.py,sha256=b0cDs239wvygCIL9s0W8uuyuPeMZz3DwxQ0wmBta_XM,7758
5
- vex_ast/ast/interfaces.py,sha256=DXKdAzts0EBWjCRgYkz_kVSMcYbNIyPdwYpTr7c6P2A,5928
6
- vex_ast/ast/literals.py,sha256=PXbOH5Y2fxEngWk_FOiFsx3PC2SEqcx0bcfOGJ3SdbI,2618
7
- vex_ast/ast/navigator.py,sha256=2ELYIWTZNuaJHLMDiY9bbRkz8XAEDRnPNN8uKRafNYg,7253
8
- vex_ast/ast/operators.py,sha256=I-yWvhsrz-OxmBZs5zIss_GTZF5S-nwcSmIzvAVtddM,3160
9
- vex_ast/ast/statements.py,sha256=OWRthjYGmTuNozYAHjh_Enp5t-hR1PphtPnFg31FeWw,11841
10
- vex_ast/ast/validators.py,sha256=lhEm1dt-nzMiaUan_AWEOm0NiwXN7wYNkLCl1c3drqc,4455
11
- vex_ast/ast/vex_nodes.py,sha256=kVil-ApFIeZ_BoeqYppfVRPSTg1KFUOcvt1vCE6QRgs,10148
12
- vex_ast/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- vex_ast/parser/factory.py,sha256=gaje0jOPu5lpndgX9c3VuQ_q-FJuFz9yC5y2bD69lL4,8770
14
- vex_ast/parser/interfaces.py,sha256=Ttc0bD_5X420ZCT9MLUf_wE1aZLWLkaJRQqCwBy9wIs,956
15
- vex_ast/parser/python_parser.py,sha256=e1owk-c6Rb4Bt5SYcgB-urZzqsX5xC9tzcK1sB8gkr4,29687
16
- vex_ast/parser/strategies.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- vex_ast/registry/__init__.py,sha256=dXT8OS7uLyBSdQKZDWrtbANzgSWcg9HUQDA1EaLOvjQ,1188
18
- vex_ast/registry/api.py,sha256=yyW-TsCIULTzePAoyMvEqD_RNlkFSb4PLpiSkw6ueQk,5460
19
- vex_ast/registry/categories.py,sha256=y5tnCzHQ9PPg9hOzOMgyE1ZAhcsjgeFSrgqdJrdqHEg,4885
20
- vex_ast/registry/language_map.py,sha256=eekN3k-K9g90GFi4--If3nfJCyarUJxDWDCDvLm7mdU,2656
21
- vex_ast/registry/registry.py,sha256=gvsQKyeXWp84T2uDB4O_WQgKCeq8W9udl8TD5MnPZzc,6661
22
- vex_ast/registry/signature.py,sha256=m8gQKdc5IaORDdfdBX6_qH1OL5LoTzveGoWlIIaOES0,5763
23
- vex_ast/registry/simulation_behavior.py,sha256=WwkVKae0owtv3WTrfnVH93rpsh9lbqJ_RSAVmpIVA_k,313
24
- vex_ast/registry/validation.py,sha256=xq5UjSWYAcRxjxsCGg3WU5RtPN-DB-JAqKqDNGvnJGk,1973
25
- vex_ast/serialization/__init__.py,sha256=qPTEiMjU8hpVxNH5z4MY7Yj60AxuFurjXZStjhWWf6o,835
26
- vex_ast/serialization/json_deserializer.py,sha256=m_xiEUEoFXGfFylK3M8BVs7F2EieQJ9wbUa_ZTpkHtQ,10523
27
- vex_ast/serialization/json_serializer.py,sha256=YvMRUpqXjtbxlIvathEIywUqbH3Ne6GSRODfFB0QCGM,4465
28
- vex_ast/serialization/schema.py,sha256=zpKujT7u3Qw2kNbwjV09lNzeQAsCxvMx-uAdaRMEstA,14431
29
- vex_ast/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- vex_ast/utils/errors.py,sha256=uq_jyu-YasifXjKSpPbVxup-XFf0XSHmp7A0Zd87TUY,3850
31
- vex_ast/utils/source_location.py,sha256=r857ypqUBqex2y_R0RzZo7pz5di9qtEeWFFQ4HwzYQE,1297
32
- vex_ast/utils/type_definitions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- vex_ast/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- vex_ast/visitors/analyzer.py,sha256=cBT5PRbtfQ_Dt1qiHN-wdO5KnC2yl-Ul5RasXg9geHY,3668
35
- vex_ast/visitors/base.py,sha256=Ph0taTIVMHV_QjXfDd0ipZnCXVJErkyRtPpfwfzo-kY,4859
36
- vex_ast/visitors/printer.py,sha256=CUY_73hxm7MoC-63JeIXaVYnZ8QqtfMqbek2R2HMEmE,5411
37
- vex_ast/visitors/transformer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- vex_ast-0.1.0.dist-info/METADATA,sha256=A7JHuJeTux45tRPBF9772gQNdp36fVqv2v_Zc_WZ-Zs,5327
39
- vex_ast-0.1.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
40
- vex_ast-0.1.0.dist-info/top_level.txt,sha256=MoZGrpKgNUDiqL9gWp4q3wMw3q93XPEEjmBNPJQcNAs,8
41
- vex_ast-0.1.0.dist-info/RECORD,,