vex-ast 0.2.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,69 @@
1
+ from typing import Optional, Union, List, Set, Dict, Any
2
+ from .base import VexType, type_registry
3
+
4
+ class PrimitiveType(VexType):
5
+ """Base class for primitive types like int, float, string, etc."""
6
+
7
+ def __init__(self, name: str):
8
+ self._name = name
9
+ type_registry.register_type(self)
10
+
11
+ @property
12
+ def name(self) -> str:
13
+ return self._name
14
+
15
+ def __str__(self) -> str:
16
+ return self._name
17
+
18
+ class NumericType(PrimitiveType):
19
+ """Base class for numeric types"""
20
+
21
+ def is_compatible_with(self, other: VexType) -> bool:
22
+ """Numeric types are compatible with other numeric types"""
23
+ return isinstance(other, NumericType)
24
+
25
+ class IntegerType(NumericType):
26
+ """Integer type"""
27
+
28
+ def __init__(self):
29
+ super().__init__("int")
30
+
31
+ def is_compatible_with(self, other: VexType) -> bool:
32
+ """Integers are compatible with numeric types"""
33
+ return isinstance(other, NumericType)
34
+
35
+ class FloatType(NumericType):
36
+ """Float type"""
37
+
38
+ def __init__(self):
39
+ super().__init__("float")
40
+
41
+ def is_compatible_with(self, other: VexType) -> bool:
42
+ """Floats are compatible with numeric types"""
43
+ return isinstance(other, NumericType)
44
+
45
+ class BooleanType(PrimitiveType):
46
+ """Boolean type"""
47
+
48
+ def __init__(self):
49
+ super().__init__("bool")
50
+
51
+ def is_compatible_with(self, other: VexType) -> bool:
52
+ """Booleans are only compatible with booleans"""
53
+ return isinstance(other, BooleanType)
54
+
55
+ class StringType(PrimitiveType):
56
+ """String type"""
57
+
58
+ def __init__(self):
59
+ super().__init__("string")
60
+
61
+ def is_compatible_with(self, other: VexType) -> bool:
62
+ """Strings are only compatible with strings"""
63
+ return isinstance(other, StringType)
64
+
65
+ # Singleton instances
66
+ INT = IntegerType()
67
+ FLOAT = FloatType()
68
+ BOOL = BooleanType()
69
+ STRING = StringType()
@@ -0,0 +1,32 @@
1
+ from typing import Optional, Any, List, Dict, Union, Tuple
2
+ from .base import VexType, ANY
3
+ from .primitives import INT, FLOAT, BOOL, STRING
4
+
5
+ class TypeChecker:
6
+ """Utility for checking type compatibility"""
7
+
8
+ def is_compatible(self, value_type: VexType, expected_type: VexType) -> bool:
9
+ """Check if value_type is compatible with expected_type"""
10
+ # Any type is compatible with anything
11
+ if expected_type == ANY:
12
+ return True
13
+
14
+ return value_type.is_compatible_with(expected_type)
15
+
16
+ def get_python_type(self, value: Any) -> Optional[VexType]:
17
+ """Convert a Python value to a VEX type"""
18
+ if value is None:
19
+ return None
20
+ if isinstance(value, bool):
21
+ return BOOL
22
+ if isinstance(value, int):
23
+ return INT
24
+ if isinstance(value, float):
25
+ return FLOAT
26
+ if isinstance(value, str):
27
+ return STRING
28
+ # Complex objects would need additional mapping logic
29
+ return None
30
+
31
+ # Singleton instance
32
+ type_checker = TypeChecker()
vex_ast/utils/__init__.py CHANGED
@@ -0,0 +1,38 @@
1
+ """
2
+ Utilities package for VEX AST.
3
+
4
+ This package provides utility functions and classes for working with the AST.
5
+ """
6
+
7
+ from .errors import (
8
+ ErrorHandler,
9
+ ErrorType,
10
+ VexSyntaxError,
11
+ VexAstError,
12
+ Error
13
+ )
14
+ from .source_location import (
15
+ SourceLocation,
16
+ )
17
+ from .type_definitions import (
18
+ NodeType,
19
+ VisitorType,
20
+ TransformerType
21
+ )
22
+
23
+ __all__ = [
24
+ # Error handling
25
+ "ErrorHandler",
26
+ "ErrorType",
27
+ "VexSyntaxError",
28
+ "VexAstError",
29
+ "Error",
30
+
31
+ # Source location
32
+ "SourceLocation",
33
+
34
+ # Type definitions
35
+ "NodeType",
36
+ "VisitorType",
37
+ "TransformerType"
38
+ ]
@@ -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,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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vex_ast
3
- Version: 0.2.0
3
+ Version: 0.2.1
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,19 +1,19 @@
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=YPsS_1ab9-G3WYmyxQobDA1U8y5KJkj2qxm_p_s9Oow,1724
3
+ vex_ast/__init__.py,sha256=ctZTmMc0ispErWMja0pTwdyst6ELgcfBJ-nwejYg-sc,1604
4
4
  vex_ast/ast/README.md,sha256=7IQDHEXmKyJ8zfJNwa3pMGTDZKVPMFD0YeHT06ATRyM,3205
5
- vex_ast/ast/__init__.py,sha256=3ZtTiNeBPWOYgNWmxThn0h7UQx8Z0bHbK6hRHCUuILQ,2435
5
+ vex_ast/ast/__init__.py,sha256=_KT8R_WG9_DLvPlDhVCNWz-yw0OtdoKxxWZYbtloCzU,2434
6
6
  vex_ast/ast/core.py,sha256=q-15q5VfGIVPAmFsSiWeFAZ55MPsXfCRa21rrt2hmlM,2670
7
7
  vex_ast/ast/expressions.py,sha256=b0cDs239wvygCIL9s0W8uuyuPeMZz3DwxQ0wmBta_XM,7758
8
8
  vex_ast/ast/interfaces.py,sha256=DXKdAzts0EBWjCRgYkz_kVSMcYbNIyPdwYpTr7c6P2A,5928
9
9
  vex_ast/ast/literals.py,sha256=PXbOH5Y2fxEngWk_FOiFsx3PC2SEqcx0bcfOGJ3SdbI,2618
10
- vex_ast/ast/navigator.py,sha256=2ELYIWTZNuaJHLMDiY9bbRkz8XAEDRnPNN8uKRafNYg,7253
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
13
  vex_ast/ast/validators.py,sha256=lhEm1dt-nzMiaUan_AWEOm0NiwXN7wYNkLCl1c3drqc,4455
14
14
  vex_ast/ast/vex_nodes.py,sha256=kVil-ApFIeZ_BoeqYppfVRPSTg1KFUOcvt1vCE6QRgs,10148
15
15
  vex_ast/parser/README.md,sha256=P1qq_97skpgluLDpNu9V_pAdkuF9StjkzOEXJJYpEuM,2565
16
- vex_ast/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ vex_ast/parser/__init__.py,sha256=LGHnFm3UzR4Nw7royGH3c_2RqeY66y8O6DdXHbm9yL4,504
17
17
  vex_ast/parser/factory.py,sha256=gaje0jOPu5lpndgX9c3VuQ_q-FJuFz9yC5y2bD69lL4,8770
18
18
  vex_ast/parser/interfaces.py,sha256=Ttc0bD_5X420ZCT9MLUf_wE1aZLWLkaJRQqCwBy9wIs,956
19
19
  vex_ast/parser/python_parser.py,sha256=e1owk-c6Rb4Bt5SYcgB-urZzqsX5xC9tzcK1sB8gkr4,29687
@@ -27,24 +27,37 @@ vex_ast/registry/registry.py,sha256=gvsQKyeXWp84T2uDB4O_WQgKCeq8W9udl8TD5MnPZzc,
27
27
  vex_ast/registry/signature.py,sha256=m8gQKdc5IaORDdfdBX6_qH1OL5LoTzveGoWlIIaOES0,5763
28
28
  vex_ast/registry/simulation_behavior.py,sha256=WwkVKae0owtv3WTrfnVH93rpsh9lbqJ_RSAVmpIVA_k,313
29
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
30
37
  vex_ast/serialization/__init__.py,sha256=qPTEiMjU8hpVxNH5z4MY7Yj60AxuFurjXZStjhWWf6o,835
31
38
  vex_ast/serialization/json_deserializer.py,sha256=m_xiEUEoFXGfFylK3M8BVs7F2EieQJ9wbUa_ZTpkHtQ,10523
32
39
  vex_ast/serialization/json_serializer.py,sha256=YvMRUpqXjtbxlIvathEIywUqbH3Ne6GSRODfFB0QCGM,4465
33
40
  vex_ast/serialization/schema.py,sha256=zpKujT7u3Qw2kNbwjV09lNzeQAsCxvMx-uAdaRMEstA,14431
34
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
35
48
  vex_ast/utils/README.md,sha256=Y9RJMQTqQbpjVkvYJmpeRihD1zfW9PhNL_LgoDJ84ak,1945
36
- vex_ast/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ vex_ast/utils/__init__.py,sha256=azzhhFoMykqOkVVm6X2V7dFW3jGBkOvEgnEP1JTCS3g,621
37
50
  vex_ast/utils/errors.py,sha256=uq_jyu-YasifXjKSpPbVxup-XFf0XSHmp7A0Zd87TUY,3850
38
51
  vex_ast/utils/source_location.py,sha256=r857ypqUBqex2y_R0RzZo7pz5di9qtEeWFFQ4HwzYQE,1297
39
- vex_ast/utils/type_definitions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
+ vex_ast/utils/type_definitions.py,sha256=2rB85B1vZL1GLWItBuJJpyr-vmp3W346EMMX2TPZ99Q,313
40
53
  vex_ast/visitors/README.md,sha256=BKDj8LMuBlCrzgSSLmCkbET7WIqgxe-oCkqQbqXekrE,2725
41
- vex_ast/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ vex_ast/visitors/__init__.py,sha256=cndW3yp0Mu9w5vzwqqS2N5EqS0Ioh0V5UCDDrwCO0_Q,492
42
55
  vex_ast/visitors/analyzer.py,sha256=cBT5PRbtfQ_Dt1qiHN-wdO5KnC2yl-Ul5RasXg9geHY,3668
43
56
  vex_ast/visitors/base.py,sha256=Ph0taTIVMHV_QjXfDd0ipZnCXVJErkyRtPpfwfzo-kY,4859
44
57
  vex_ast/visitors/printer.py,sha256=CUY_73hxm7MoC-63JeIXaVYnZ8QqtfMqbek2R2HMEmE,5411
45
58
  vex_ast/visitors/transformer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- vex_ast-0.2.0.dist-info/licenses/LICENSE,sha256=IOSlfCuxGv4OAg421BRDKVi16RZ7-5kCMJ4B16r4kuc,69
47
- vex_ast-0.2.0.dist-info/METADATA,sha256=xGeh73jQORTXs2-uS-qgiH3aW-Pdsk31J1WW-tKQREE,5295
48
- vex_ast-0.2.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
49
- vex_ast-0.2.0.dist-info/top_level.txt,sha256=MoZGrpKgNUDiqL9gWp4q3wMw3q93XPEEjmBNPJQcNAs,8
50
- vex_ast-0.2.0.dist-info/RECORD,,
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,,