vex-ast 0.2.1__py3-none-any.whl → 0.2.2__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/__init__.py CHANGED
@@ -30,7 +30,11 @@ from .serialization.schema import generate_ast_schema, export_schema_to_file
30
30
  __version__ = "0.2.0"
31
31
 
32
32
  # Initialize the registry with default functions
33
- initialize()
33
+ try:
34
+ initialize()
35
+ print("VEX function registry initialized successfully")
36
+ except Exception as e:
37
+ print(f"Error initializing VEX function registry: {e}")
34
38
 
35
39
  __all__ = [
36
40
  # Core functionality
@@ -65,4 +69,4 @@ __all__ = [
65
69
  "deserialize_ast_from_json",
66
70
  "generate_ast_schema",
67
71
  "export_schema_to_file"
68
- ]
72
+ ]
vex_ast/ast/validators.py CHANGED
@@ -81,11 +81,17 @@ class VexFunctionValidator(AstVisitor[List[Tuple[VexAPICall, str]]]):
81
81
  # Check if this is a method call on a known object type
82
82
  if '.' in function_name:
83
83
  obj_name, method_name = function_name.split('.', 1)
84
- # For method calls, we need to check if the method exists for any object type
85
- # since we don't know the actual type of the object at validation time
86
- # Just check if the method name exists in the registry API
84
+
85
+ # First check if the method exists in the registry
87
86
  if registry_api.get_function(method_name):
88
87
  is_vex_function = True
88
+ else:
89
+ # Try to check if it's a method on any known object type
90
+ from ..types.objects import MOTOR, TIMER, BRAIN, CONTROLLER
91
+ for obj_type in [MOTOR, TIMER, BRAIN, CONTROLLER]:
92
+ if registry_api.get_method(obj_type, method_name):
93
+ is_vex_function = True
94
+ break
89
95
  # Or check if it's a direct function
90
96
  elif registry_api.get_function(function_name):
91
97
  is_vex_function = True
vex_ast/ast/vex_nodes.py CHANGED
@@ -59,7 +59,20 @@ class VexAPICall(FunctionCall):
59
59
  if '.' in function_name:
60
60
  # For method calls like "motor1.spin", extract the method name
61
61
  obj_name, method_name = function_name.split('.', 1)
62
+
63
+ # First try to get the method signature directly
62
64
  self._signature = registry_api.get_function(method_name)
65
+
66
+ # If that fails, try to get it as a method of a specific object type
67
+ # This is a fallback since we don't know the actual type at parse time
68
+ if not self._signature:
69
+ # Try common object types
70
+ from ..types.objects import MOTOR, TIMER, BRAIN, CONTROLLER
71
+ for obj_type in [MOTOR, TIMER, BRAIN, CONTROLLER]:
72
+ method_sig = registry_api.get_method(obj_type, method_name)
73
+ if method_sig:
74
+ self._signature = method_sig
75
+ break
63
76
  else:
64
77
  # For direct function calls
65
78
  self._signature = registry_api.get_function(function_name)
@@ -205,7 +218,19 @@ def create_vex_api_call(function: IExpression, args: List[IExpression],
205
218
  if '.' in function_name:
206
219
  # For method calls like "motor1.spin", extract the method name
207
220
  obj_name, method_name = function_name.split('.', 1)
221
+
222
+ # First try to get the method signature directly
208
223
  signature = registry_api.get_function(method_name)
224
+
225
+ # If that fails, try to get it as a method of a specific object type
226
+ if not signature:
227
+ # Try common object types
228
+ from ..types.objects import MOTOR, TIMER, BRAIN, CONTROLLER
229
+ for obj_type in [MOTOR, TIMER, BRAIN, CONTROLLER]:
230
+ method_sig = registry_api.get_method(obj_type, method_name)
231
+ if method_sig:
232
+ signature = method_sig
233
+ break
209
234
  else:
210
235
  # For direct function calls
211
236
  signature = registry_api.get_function(function_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vex_ast
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A Python package for generating Abstract Syntax Trees for VEX V5 code.
5
5
  Home-page: https://github.com/heartx2/vex_ast
6
6
  Author: Chaze
@@ -1,6 +1,6 @@
1
1
  vex_ast/README.md,sha256=tRaq6n2Ab4IahHSo3utW2imVuTrJu_7zaelgF-lGBYo,2007
2
2
  vex_ast/READMEAPI.md,sha256=hGn4IMT9NnI_LW0kd36BdKKXdIhYFLbQcgbVj1EWJps,9107
3
- vex_ast/__init__.py,sha256=ctZTmMc0ispErWMja0pTwdyst6ELgcfBJ-nwejYg-sc,1604
3
+ vex_ast/__init__.py,sha256=0xxA3UL3UMPB1Vlf1jL99bNUnvm41yJEoG5sMeylptY,1757
4
4
  vex_ast/ast/README.md,sha256=7IQDHEXmKyJ8zfJNwa3pMGTDZKVPMFD0YeHT06ATRyM,3205
5
5
  vex_ast/ast/__init__.py,sha256=_KT8R_WG9_DLvPlDhVCNWz-yw0OtdoKxxWZYbtloCzU,2434
6
6
  vex_ast/ast/core.py,sha256=q-15q5VfGIVPAmFsSiWeFAZ55MPsXfCRa21rrt2hmlM,2670
@@ -10,8 +10,8 @@ vex_ast/ast/literals.py,sha256=PXbOH5Y2fxEngWk_FOiFsx3PC2SEqcx0bcfOGJ3SdbI,2618
10
10
  vex_ast/ast/navigator.py,sha256=9DaVXrknBbBr4omAAMHQnZL9Wpj5wjtoCS6_lni8MYM,7529
11
11
  vex_ast/ast/operators.py,sha256=I-yWvhsrz-OxmBZs5zIss_GTZF5S-nwcSmIzvAVtddM,3160
12
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
13
+ vex_ast/ast/validators.py,sha256=ySpi5H0XRdGXXMFAfmuVEyc3Q9mMXhubZAkP4N8NL3c,4717
14
+ vex_ast/ast/vex_nodes.py,sha256=HmUPfiogz0rnObyhg1XEsxPIDdM5xbNxl_kW9NND8pQ,11345
15
15
  vex_ast/parser/README.md,sha256=P1qq_97skpgluLDpNu9V_pAdkuF9StjkzOEXJJYpEuM,2565
16
16
  vex_ast/parser/__init__.py,sha256=LGHnFm3UzR4Nw7royGH3c_2RqeY66y8O6DdXHbm9yL4,504
17
17
  vex_ast/parser/factory.py,sha256=gaje0jOPu5lpndgX9c3VuQ_q-FJuFz9yC5y2bD69lL4,8770
@@ -56,8 +56,8 @@ vex_ast/visitors/analyzer.py,sha256=cBT5PRbtfQ_Dt1qiHN-wdO5KnC2yl-Ul5RasXg9geHY,
56
56
  vex_ast/visitors/base.py,sha256=Ph0taTIVMHV_QjXfDd0ipZnCXVJErkyRtPpfwfzo-kY,4859
57
57
  vex_ast/visitors/printer.py,sha256=CUY_73hxm7MoC-63JeIXaVYnZ8QqtfMqbek2R2HMEmE,5411
58
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,,
59
+ vex_ast-0.2.2.dist-info/licenses/LICENSE,sha256=IOSlfCuxGv4OAg421BRDKVi16RZ7-5kCMJ4B16r4kuc,69
60
+ vex_ast-0.2.2.dist-info/METADATA,sha256=Rftzrxm-exQp3zpV5wcNVkErbkQn1ww0pz65tXOQhDw,5295
61
+ vex_ast-0.2.2.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
62
+ vex_ast-0.2.2.dist-info/top_level.txt,sha256=MoZGrpKgNUDiqL9gWp4q3wMw3q93XPEEjmBNPJQcNAs,8
63
+ vex_ast-0.2.2.dist-info/RECORD,,