vex-ast 0.2.4__tar.gz → 0.2.6__tar.gz

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 (91) hide show
  1. {vex_ast-0.2.4 → vex_ast-0.2.6}/MANIFEST.in +20 -20
  2. {vex_ast-0.2.4/vex_ast.egg-info → vex_ast-0.2.6}/PKG-INFO +206 -174
  3. {vex_ast-0.2.4 → vex_ast-0.2.6}/README.md +179 -147
  4. {vex_ast-0.2.4 → vex_ast-0.2.6}/pyproject.toml +28 -28
  5. {vex_ast-0.2.4 → vex_ast-0.2.6}/pytest.ini +8 -8
  6. {vex_ast-0.2.4 → vex_ast-0.2.6}/requirements.txt +5 -5
  7. {vex_ast-0.2.4 → vex_ast-0.2.6}/setup.cfg +4 -4
  8. {vex_ast-0.2.4 → vex_ast-0.2.6}/setup.py +24 -24
  9. vex_ast-0.2.6/tests/conftest.py +72 -0
  10. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_comprehensive_integration.py +338 -338
  11. vex_ast-0.2.6/tests/test_conditional_expressions.py +130 -0
  12. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_core.py +85 -85
  13. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_integration.py +69 -69
  14. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_literals.py +55 -55
  15. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_navigator.py +121 -121
  16. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_parser.py +67 -67
  17. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_registry.py +84 -75
  18. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_serialization.py +273 -273
  19. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_statements.py +102 -102
  20. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_vex_nodes.py +47 -47
  21. {vex_ast-0.2.4 → vex_ast-0.2.6}/tests/test_visitors.py +54 -54
  22. vex_ast-0.2.6/vex_ast/README.md +101 -0
  23. vex_ast-0.2.6/vex_ast/READMEAPI.md +133 -0
  24. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/__init__.py +81 -72
  25. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/README.md +87 -87
  26. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/__init__.py +74 -74
  27. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/core.py +71 -71
  28. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/expressions.py +276 -276
  29. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/interfaces.py +208 -208
  30. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/literals.py +80 -80
  31. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/navigator.py +225 -225
  32. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/operators.py +135 -135
  33. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/statements.py +351 -351
  34. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/validators.py +121 -120
  35. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/ast/vex_nodes.py +279 -279
  36. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/README.md +47 -47
  37. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/__init__.py +26 -26
  38. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/factory.py +190 -190
  39. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/interfaces.py +34 -34
  40. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/python_parser.py +831 -786
  41. vex_ast-0.2.6/vex_ast/registry/README.md +107 -0
  42. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/__init__.py +51 -51
  43. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/api.py +190 -155
  44. vex_ast-0.2.6/vex_ast/registry/categories.py +179 -0
  45. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/__init__.py +10 -10
  46. vex_ast-0.2.6/vex_ast/registry/functions/constructors.py +71 -0
  47. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/display.py +146 -146
  48. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/drivetrain.py +163 -163
  49. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/initialize.py +31 -28
  50. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/motor.py +140 -140
  51. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/sensors.py +194 -194
  52. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/functions/timing.py +103 -103
  53. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/language_map.py +77 -77
  54. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/registry.py +164 -153
  55. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/signature.py +269 -191
  56. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/simulation_behavior.py +8 -8
  57. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/registry/validation.py +43 -43
  58. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/serialization/__init__.py +37 -37
  59. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/serialization/json_deserializer.py +284 -275
  60. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/serialization/json_serializer.py +148 -148
  61. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/serialization/schema.py +492 -470
  62. vex_ast-0.2.6/vex_ast/types/README.md +78 -0
  63. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/__init__.py +140 -140
  64. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/base.py +83 -83
  65. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/enums.py +122 -97
  66. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/objects.py +64 -64
  67. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/primitives.py +68 -68
  68. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/types/type_checker.py +31 -31
  69. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/utils/README.md +39 -39
  70. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/utils/__init__.py +37 -37
  71. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/utils/errors.py +112 -112
  72. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/utils/source_location.py +38 -38
  73. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/utils/type_definitions.py +8 -8
  74. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/README.md +49 -49
  75. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/__init__.py +27 -27
  76. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/analyzer.py +102 -102
  77. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/base.py +133 -133
  78. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/printer.py +196 -146
  79. {vex_ast-0.2.4 → vex_ast-0.2.6/vex_ast.egg-info}/PKG-INFO +206 -174
  80. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast.egg-info/SOURCES.txt +2 -0
  81. vex_ast-0.2.4/tests/conftest.py +0 -11
  82. vex_ast-0.2.4/vex_ast/README.md +0 -51
  83. vex_ast-0.2.4/vex_ast/READMEAPI.md +0 -318
  84. vex_ast-0.2.4/vex_ast/registry/README.md +0 -29
  85. vex_ast-0.2.4/vex_ast/registry/categories.py +0 -136
  86. vex_ast-0.2.4/vex_ast/types/README.md +0 -26
  87. {vex_ast-0.2.4 → vex_ast-0.2.6}/LICENSE +0 -0
  88. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/parser/strategies.py +0 -0
  89. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast/visitors/transformer.py +0 -0
  90. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast.egg-info/dependency_links.txt +0 -0
  91. {vex_ast-0.2.4 → vex_ast-0.2.6}/vex_ast.egg-info/top_level.txt +0 -0
@@ -1,20 +1,20 @@
1
- include LICENSE
2
- include README.md
3
- include requirements.txt
4
- include pytest.ini
5
- include pyproject.toml
6
-
7
- # Include all documentation files
8
- recursive-include vex_ast *README.md
9
- recursive-include vex_ast *READMEAPI.md
10
-
11
- # Include test files
12
- recursive-include tests *.py
13
-
14
- # Exclude cache files
15
- global-exclude __pycache__
16
- global-exclude *.py[cod]
17
- global-exclude *.so
18
- global-exclude .DS_Store
19
- global-exclude .env
20
- global-exclude .coverage
1
+ include LICENSE
2
+ include README.md
3
+ include requirements.txt
4
+ include pytest.ini
5
+ include pyproject.toml
6
+
7
+ # Include all documentation files
8
+ recursive-include vex_ast *README.md
9
+ recursive-include vex_ast *READMEAPI.md
10
+
11
+ # Include test files
12
+ recursive-include tests *.py
13
+
14
+ # Exclude cache files
15
+ global-exclude __pycache__
16
+ global-exclude *.py[cod]
17
+ global-exclude *.so
18
+ global-exclude .DS_Store
19
+ global-exclude .env
20
+ global-exclude .coverage
@@ -1,174 +1,206 @@
1
- Metadata-Version: 2.4
2
- Name: vex_ast
3
- Version: 0.2.4
4
- Summary: A Python package for generating Abstract Syntax Trees for VEX V5 code.
5
- Home-page: https://github.com/heartx2/vex_ast
6
- Author: Chaze
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
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Topic :: Software Development :: Compilers
18
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
- Requires-Python: >=3.8
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE
22
- Dynamic: author
23
- Dynamic: home-page
24
- Dynamic: license-file
25
- Dynamic: requires-python
26
-
27
- # VEX AST Generator
28
-
29
- A Python package for generating Abstract Syntax Trees (ASTs) for VEX V5 Robot Python code.
30
-
31
- ## Project Goal
32
-
33
- The primary goal of this project is to provide a robust and extensible framework for parsing VEX V5 Python code and representing it as an Abstract Syntax Tree (AST). This AST can then be used for various purposes, such as static analysis, code transformation, simulation, or integration with other development tools specific to the VEX ecosystem.
34
-
35
- ## Features (Implemented)
36
-
37
- * Parsing of standard Python syntax relevant to VEX programming.
38
- * Generation of a well-defined AST structure using custom node types.
39
- * Representation of core Python constructs (variables, functions, loops, conditionals, expressions).
40
- * Specific AST nodes for common VEX API patterns (e.g., `MotorControl`, `SensorReading`).
41
- * Visitor pattern implementation (`vex_ast.visitors`) for easy AST traversal and manipulation.
42
- * Basic analysis visitors (`NodeCounter`, `VariableCollector`).
43
- * AST pretty-printing visitor (`PrintVisitor`).
44
- * Error handling and reporting with source location information (`vex_ast.utils`).
45
- * JSON serialization and deserialization of AST nodes (`vex_ast.serialization`).
46
- * JSON Schema generation for AST structure validation and documentation.
47
-
48
- ## Library Structure
49
-
50
- The core library is within the `vex_ast` directory:
51
-
52
- * `vex_ast/ast/`: Defines the structure and node types of the Abstract Syntax Tree.
53
- * `vex_ast/parser/`: Contains the logic for parsing Python source code into the AST.
54
- * `vex_ast/visitors/`: Provides tools for traversing and analyzing the generated AST.
55
- * `vex_ast/utils/`: Includes helper modules for error handling and source location tracking.
56
-
57
- ## Setup
58
-
59
- 1. **Clone the repository:**
60
- ```bash
61
- git clone https://github.com/heartx2/vex_ast # Replace with actual URL
62
- cd vex_ast
63
- ```
64
-
65
- 2. **Create and activate a virtual environment:**
66
- ```bash
67
- python3 -m venv .venv
68
- source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
69
- ```
70
-
71
- 3. **Install dependencies:**
72
- ```bash
73
- pip install -r requirements.txt
74
- ```
75
-
76
- 4. **(Optional) Install for development:**
77
- If you plan to contribute to the project, install it in editable mode along with development dependencies:
78
- ```bash
79
- pip install -e .[dev]
80
- ```
81
-
82
- ## Usage Example
83
-
84
- ### Basic Parsing and Printing
85
-
86
- ```python
87
- from vex_ast import parse_string
88
- from vex_ast.visitors.printer import PrintVisitor
89
-
90
- # VEX-like Python code
91
- code = """
92
- left_motor = Motor("port1")
93
- right_motor = Motor("port10")
94
-
95
- def drive_forward(speed_percent):
96
- left_motor.spin(FORWARD, speed_percent, PERCENT)
97
- right_motor.spin(FORWARD, speed_percent, PERCENT)
98
- wait(1, SECONDS)
99
- left_motor.stop()
100
- right_motor.stop()
101
-
102
- drive_forward(50)
103
- print("Movement complete!")
104
- """
105
-
106
- try:
107
- # Parse the code string into an AST
108
- ast_tree = parse_string(code)
109
-
110
- # Use the PrintVisitor to get a textual representation of the AST
111
- printer = PrintVisitor()
112
- ast_representation = printer.visit(ast_tree)
113
-
114
- print("--- AST Representation ---")
115
- print(ast_representation)
116
-
117
- except Exception as e:
118
- print(f"An error occurred: {e}")
119
- ```
120
-
121
- ### Serialization and Deserialization
122
-
123
- ```python
124
- from vex_ast import (
125
- parse_string,
126
- serialize_ast_to_json,
127
- deserialize_ast_from_json,
128
- export_schema_to_file
129
- )
130
-
131
- # Parse code into an AST
132
- code = "x = 10 + 20"
133
- ast = parse_string(code)
134
-
135
- # Serialize the AST to JSON
136
- json_str = serialize_ast_to_json(ast, indent=2)
137
- print(json_str)
138
-
139
- # Save the AST to a file
140
- with open("ast.json", "w") as f:
141
- f.write(json_str)
142
-
143
- # Later, load the AST from JSON
144
- with open("ast.json", "r") as f:
145
- loaded_json = f.read()
146
-
147
- # Deserialize back to an AST object
148
- loaded_ast = deserialize_ast_from_json(loaded_json)
149
-
150
- # Generate and export a JSON schema
151
- export_schema_to_file("ast_schema.json")
152
- ```
153
-
154
- ## Development
155
- ```bash
156
- Running Tests
157
- pytest
158
- ```
159
- ```bash
160
- Type Checking
161
- mypy vex_ast
162
- ```
163
- ```bash
164
- Formatting and Linting
165
- black vex_ast tests
166
- flake8 vex_ast tests
167
- ```
168
- ## Contributing
169
-
170
- Contributions are welcome! Please follow the established coding standards and ensure tests pass before submitting a pull request.
171
-
172
- ## License
173
-
174
- HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0
1
+ Metadata-Version: 2.4
2
+ Name: vex_ast
3
+ Version: 0.2.6
4
+ Summary: A Python package for generating Abstract Syntax Trees for VEX V5 code.
5
+ Home-page: https://github.com/heartx2/vex_ast
6
+ Author: Chaze
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
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Topic :: Software Development :: Compilers
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: author
23
+ Dynamic: home-page
24
+ Dynamic: license-file
25
+ Dynamic: requires-python
26
+
27
+ # VEX AST Generator
28
+
29
+ A Python package for generating Abstract Syntax Trees (ASTs) for VEX V5 Robot Python code.
30
+
31
+ ## Project Goal
32
+
33
+ The primary goal of this project is to provide a robust and extensible framework for parsing VEX V5 Python code and representing it as an Abstract Syntax Tree (AST). This AST can then be used for various purposes, such as static analysis, code transformation, simulation, or integration with other development tools specific to the VEX ecosystem.
34
+
35
+ ## Recent Updates (v0.2.6)
36
+
37
+ ### Major Registry Overhaul
38
+ - Introduced a modern category system with `VexCategory` and `BehaviorType` enums
39
+ - Improved function organization and querying capabilities
40
+ - Added missing Brain and Controller constructors
41
+ - Maintained full backward compatibility
42
+
43
+ ### Enhanced API
44
+ - New methods for behavior-based function queries
45
+ - Combined category and behavior search functionality
46
+ - Improved validation mechanisms
47
+
48
+ ## Features (Implemented)
49
+
50
+ * Parsing of standard Python syntax relevant to VEX programming.
51
+ * Generation of a well-defined AST structure using custom node types.
52
+ * Representation of core Python constructs (variables, functions, loops, conditionals, expressions).
53
+ * Specific AST nodes for common VEX API patterns (e.g., `MotorControl`, `SensorReading`).
54
+ * Visitor pattern implementation (`vex_ast.visitors`) for easy AST traversal and manipulation.
55
+ * Basic analysis visitors (`NodeCounter`, `VariableCollector`).
56
+ * AST pretty-printing visitor (`PrintVisitor`).
57
+ * Error handling and reporting with source location information (`vex_ast.utils`).
58
+ * JSON serialization and deserialization of AST nodes (`vex_ast.serialization`).
59
+ * JSON Schema generation for AST structure validation and documentation.
60
+ * Modern registry system with dual-axis categorization.
61
+
62
+ ## Library Structure
63
+
64
+ The core library is within the `vex_ast` directory:
65
+
66
+ * `vex_ast/ast/`: Defines the structure and node types of the Abstract Syntax Tree.
67
+ * `vex_ast/parser/`: Contains the logic for parsing Python source code into the AST.
68
+ * `vex_ast/visitors/`: Provides tools for traversing and analyzing the generated AST.
69
+ * `vex_ast/utils/`: Includes helper modules for error handling and source location tracking.
70
+ * `vex_ast/registry/`: Modern function registry with category/behavior classification.
71
+ * `vex_ast/types/`: Type system for VEX components and values.
72
+
73
+ ## Setup
74
+
75
+ 1. **Clone the repository:**
76
+ ```bash
77
+ git clone https://github.com/heartx2/vex_ast # Replace with actual URL
78
+ cd vex_ast
79
+ ```
80
+
81
+ 2. **Create and activate a virtual environment:**
82
+ ```bash
83
+ python3 -m venv .venv
84
+ source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
85
+ ```
86
+
87
+ 3. **Install dependencies:**
88
+ ```bash
89
+ pip install -r requirements.txt
90
+ ```
91
+
92
+ 4. **(Optional) Install for development:**
93
+ If you plan to contribute to the project, install it in editable mode along with development dependencies:
94
+ ```bash
95
+ pip install -e .[dev]
96
+ ```
97
+
98
+ ## Usage Example
99
+
100
+ ### Basic Parsing and Printing
101
+
102
+ ```python
103
+ from vex_ast import parse_string
104
+ from vex_ast.visitors.printer import PrintVisitor
105
+
106
+ # VEX-like Python code
107
+ code = """
108
+ left_motor = Motor("port1")
109
+ right_motor = Motor("port10")
110
+
111
+ def drive_forward(speed_percent):
112
+ left_motor.spin(FORWARD, speed_percent, PERCENT)
113
+ right_motor.spin(FORWARD, speed_percent, PERCENT)
114
+ wait(1, SECONDS)
115
+ left_motor.stop()
116
+ right_motor.stop()
117
+
118
+ drive_forward(50)
119
+ print("Movement complete!")
120
+ """
121
+
122
+ try:
123
+ # Parse the code string into an AST
124
+ ast_tree = parse_string(code)
125
+
126
+ # Use the PrintVisitor to get a textual representation of the AST
127
+ printer = PrintVisitor()
128
+ ast_representation = printer.visit(ast_tree)
129
+
130
+ print("--- AST Representation ---")
131
+ print(ast_representation)
132
+
133
+ except Exception as e:
134
+ print(f"An error occurred: {e}")
135
+ ```
136
+
137
+ ### Registry Access
138
+
139
+ ```python
140
+ from vex_ast.registry.api import registry_api
141
+ from vex_ast.registry.categories import VexCategory, BehaviorType
142
+
143
+ # Find motor control functions
144
+ motor_control = registry_api.get_functions_by_category_and_behavior(
145
+ VexCategory.MOTOR,
146
+ BehaviorType.CONTROL
147
+ )
148
+
149
+ # Validate function calls
150
+ valid, error = registry_api.validate_call("motor.spin", [FORWARD, 50, "RPM"], {})
151
+ ```
152
+
153
+ ### Serialization and Deserialization
154
+
155
+ ```python
156
+ from vex_ast import (
157
+ parse_string,
158
+ serialize_ast_to_json,
159
+ deserialize_ast_from_json,
160
+ export_schema_to_file
161
+ )
162
+
163
+ # Parse code into an AST
164
+ code = "x = 10 + 20"
165
+ ast = parse_string(code)
166
+
167
+ # Serialize the AST to JSON
168
+ json_str = serialize_ast_to_json(ast, indent=2)
169
+ print(json_str)
170
+
171
+ # Save the AST to a file
172
+ with open("ast.json", "w") as f:
173
+ f.write(json_str)
174
+
175
+ # Later, load the AST from JSON
176
+ with open("ast.json", "r") as f:
177
+ loaded_json = f.read()
178
+
179
+ # Deserialize back to an AST object
180
+ loaded_ast = deserialize_ast_from_json(loaded_json)
181
+
182
+ # Generate and export a JSON schema
183
+ export_schema_to_file("ast_schema.json")
184
+ ```
185
+
186
+ ## Development
187
+
188
+ ```bash
189
+ # Running Tests
190
+ pytest
191
+
192
+ # Type Checking
193
+ mypy vex_ast
194
+
195
+ # Formatting and Linting
196
+ black vex_ast tests
197
+ flake8 vex_ast tests
198
+ ```
199
+
200
+ ## Contributing
201
+
202
+ Contributions are welcome! Please follow the established coding standards and ensure tests pass before submitting a pull request.
203
+
204
+ ## License
205
+
206
+ HX2's Vex AST © 2025 by charkwayteowy is licensed under CC BY-NC 4.0