oaknut-basic 10.0.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.
oaknut/basic/__init__.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""BBC BASIC tokenisation and detokenisation.
|
|
2
|
+
|
|
3
|
+
Tokenised BBC BASIC is a compact on-disc representation in which
|
|
4
|
+
keywords like ``PRINT`` and ``GOTO`` are replaced with single bytes,
|
|
5
|
+
line numbers are packed at the start of each line, and string
|
|
6
|
+
literals and ``REM`` comments are stored in the Acorn character
|
|
7
|
+
encoding. This module converts between source text and that byte
|
|
8
|
+
representation.
|
|
9
|
+
|
|
10
|
+
BBC BASIC is a language, not a text encoding — tokenised programs
|
|
11
|
+
are bytecode, not text. The two functions here therefore work in
|
|
12
|
+
``str`` ↔ ``bytes`` pairs and must never be composed with
|
|
13
|
+
``DFSPath.read_text`` / ``write_text`` (which would silently mangle
|
|
14
|
+
the bytecode). The canonical way to move a BASIC program through a
|
|
15
|
+
disc image is ``DFSPath.read_basic`` / ``write_basic``, which wrap
|
|
16
|
+
these functions with the correct load-address default.
|
|
17
|
+
|
|
18
|
+
This module is deliberately self-contained and has no runtime
|
|
19
|
+
dependencies on any other oaknut package.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
__version__ = "10.0.1"
|
|
25
|
+
|
|
26
|
+
# Canonical load addresses for BBC BASIC programs on each host.
|
|
27
|
+
# Programs saved by *SAVE on a real machine use these by default.
|
|
28
|
+
BBC_BASIC_LOAD_ADDRESS = 0x1900
|
|
29
|
+
ELECTRON_BASIC_LOAD_ADDRESS = 0x0E00
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def tokenise(source: str) -> bytes:
|
|
33
|
+
"""Tokenise BBC BASIC source text into its on-disc byte form.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
source: BBC BASIC source as a Unicode string.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Tokenised BASIC program bytes, ready to be written to a disc
|
|
40
|
+
image via ``DFSPath.write_bytes`` or ``ADFSPath.write_bytes``.
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
NotImplementedError: The tokeniser has not yet been implemented.
|
|
44
|
+
"""
|
|
45
|
+
raise NotImplementedError("BBC BASIC tokenisation is not yet implemented")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def detokenise(data: bytes) -> str:
|
|
49
|
+
"""Detokenise a BBC BASIC program into source text.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
data: Tokenised BASIC program bytes, as read from a disc image.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
BBC BASIC source as a Unicode string.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
NotImplementedError: The detokeniser has not yet been implemented.
|
|
59
|
+
"""
|
|
60
|
+
raise NotImplementedError("BBC BASIC detokenisation is not yet implemented")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oaknut-basic
|
|
3
|
+
Version: 10.0.1
|
|
4
|
+
Summary: BBC BASIC tokeniser and detokeniser for Acorn 8-bit and 32-bit BASIC source files
|
|
5
|
+
Author-email: Robert Smallshire <robert@smallshire.org.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rob-smallshire/oaknut
|
|
8
|
+
Project-URL: Repository, https://github.com/rob-smallshire/oaknut
|
|
9
|
+
Project-URL: Issues, https://github.com/rob-smallshire/oaknut/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# oaknut-basic
|
|
22
|
+
|
|
23
|
+
BBC BASIC tokeniser and detokeniser for Acorn 8-bit BASIC (BBC
|
|
24
|
+
Micro, Acorn Electron) and 32-bit BASIC V/VI (Archimedes, RISC OS)
|
|
25
|
+
source files. Self-contained, no runtime dependencies on other
|
|
26
|
+
`oaknut-*` packages.
|
|
27
|
+
|
|
28
|
+
Part of the [oaknut](https://github.com/rob-smallshire/oaknut)
|
|
29
|
+
monorepo.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
oaknut/basic/__init__.py,sha256=Ol8ngWO7w3u_bIpO3x-9EZv-STbfipUAP6WpRDiUtD8,2118
|
|
2
|
+
oaknut_basic-10.0.1.dist-info/licenses/LICENSE,sha256=L_Uw2MQC3xsCy2nOzWmY_DYRQMHC-Yu2_zTvUTadNAY,1074
|
|
3
|
+
oaknut_basic-10.0.1.dist-info/METADATA,sha256=cxB0hxRIk9tXe1dX9ez9Tq7xIAxxfrZjdFh-OtSI1IA,1135
|
|
4
|
+
oaknut_basic-10.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
oaknut_basic-10.0.1.dist-info/top_level.txt,sha256=QLKweXQ1HlrA4vuJ4fj2AKq-_qs54zd2M4O0DahuKzw,7
|
|
6
|
+
oaknut_basic-10.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Smallshire
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
oaknut
|