varphi-devkit 3.0.0b3__tar.gz → 3.0.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: varphi-devkit
3
- Version: 3.0.0b3
3
+ Version: 3.0.1
4
4
  Summary: A framework for building compilers, interpreters, and analysis tools for the Varphi language.
5
5
  Author: Varphi
6
6
  Author-email: Varphi <support@varphi-lang.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "varphi-devkit"
3
- version = "3.0.0b3"
3
+ version = "3.0.1"
4
4
  description = "A framework for building compilers, interpreters, and analysis tools for the Varphi language."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "varphi-devkit"
3
- version = "3.0.0b3"
3
+ version = "3.0.1"
4
4
  description = "A framework for building compilers, interpreters, and analysis tools for the Varphi language."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -10,6 +10,8 @@ convenient abstraction layer for implementing custom Varphi backends.
10
10
  - `VarphiTransition`: A validated, canonicalized representation of a single transition line.
11
11
  """
12
12
 
13
+ __version__ = "3.0.1"
14
+
13
15
  from .compiler import (
14
16
  VarphiCompiler,
15
17
  VarphiTransition,
@@ -24,6 +26,9 @@ from .exceptions import (
24
26
  VarphiTransitionInconsistentTapeCountError,
25
27
  VarphiGlobalTapeCountError,
26
28
  VarphiUndefinedVariableError,
29
+ VarphiInvalidUnicodeError,
30
+ VarphiUnknownSymbolError,
31
+ VarphiUnknownDirectionError,
27
32
  )
28
33
 
29
34
  __all__ = [
@@ -38,4 +43,7 @@ __all__ = [
38
43
  "VarphiTransitionInconsistentTapeCountError",
39
44
  "VarphiGlobalTapeCountError",
40
45
  "VarphiUndefinedVariableError",
46
+ "VarphiInvalidUnicodeError",
47
+ "VarphiUnknownSymbolError",
48
+ "VarphiUnknownDirectionError",
41
49
  ]
@@ -178,9 +178,7 @@ class VarphiCompiler(VarphiListener, ABC):
178
178
  if self._tape_count is None:
179
179
  self._tape_count = current_tape_count
180
180
  elif current_tape_count != self._tape_count:
181
- raise VarphiGlobalTapeCountError(
182
- ctx, self._tape_count, current_tape_count
183
- )
181
+ raise VarphiGlobalTapeCountError(ctx, self._tape_count, current_tape_count)
184
182
 
185
183
  transition = VarphiTransition(
186
184
  current_state=current_state,
@@ -1,12 +1,17 @@
1
+ import sys
1
2
  from antlr4.error.ErrorListener import ErrorListener
2
3
  from antlr4 import Token
3
4
 
4
- RESET = "\033[0m"
5
- BOLD = "\033[1m"
6
- RED = "\033[91m"
7
- BLUE = "\033[34m"
8
- CYAN = "\033[96m"
9
- WHITE = "\033[97m"
5
+ # We won't format if it's not a TTY
6
+ RESET = BOLD = RED = BLUE = CYAN = WHITE = ""
7
+
8
+ if sys.stdout.isatty():
9
+ RESET = "\033[0m"
10
+ BOLD = "\033[1m"
11
+ RED = "\033[91m"
12
+ BLUE = "\033[34m"
13
+ CYAN = "\033[96m"
14
+ WHITE = "\033[97m"
10
15
 
11
16
 
12
17
  class VarphiSyntaxError(Exception):
@@ -120,14 +125,6 @@ class VarphiUndefinedVariableError(VarphiSyntaxError):
120
125
  super().__init__(None, ctx.start, ctx.start.line, ctx.start.column, msg)
121
126
 
122
127
 
123
- class VarphiInvalidSymbolLengthError(VarphiSyntaxError):
124
- """Raised when an ID token used as a tape symbol is longer than one character."""
125
-
126
- def __init__(self, ctx, symbol):
127
- msg = f"invalid symbol '{symbol}': tape symbols must be exactly one character."
128
- super().__init__(None, ctx.start, ctx.start.line, ctx.start.column, msg)
129
-
130
-
131
128
  class VarphiInvalidUnicodeError(VarphiSyntaxError):
132
129
  """Raised when an integer token falls outside the valid unicode code point range."""
133
130
 
@@ -52,7 +52,9 @@ class VarphiTransition:
52
52
  write_symbols: tuple[ReadWriteTupleElement, ...]
53
53
  shift_directions: tuple[Direction, ...]
54
54
  line_number: int
55
- specificity: tuple[int, int] = field(init=False) # (unique variables, total variables)
55
+ specificity: tuple[int, int] = field(
56
+ init=False
57
+ ) # (unique variables, total variables)
56
58
 
57
59
  def __post_init__(self):
58
60
  variables = [s for s in self.read_symbols if isinstance(s, Variable)]
File without changes