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.
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/PKG-INFO +1 -1
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/pyproject.toml +1 -1
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/pyproject.toml.orig +1 -1
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/__init__.py +8 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/compiler.py +1 -3
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/exceptions.py +11 -14
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/models.py +3 -1
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/README.md +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/Varphi.interp +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/Varphi.tokens +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/VarphiLexer.interp +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/VarphiLexer.py +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/VarphiLexer.tokens +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/VarphiListener.py +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/VarphiParser.py +0 -0
- {varphi_devkit-3.0.0b3 → varphi_devkit-3.0.1}/src/varphi_devkit/parser/__init__.py +0 -0
|
@@ -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
|
-
|
|
5
|
-
BOLD = "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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(
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|