opencrbasic 1.0.0__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.
- opencrbasic/__init__.py +3 -0
- opencrbasic/__main__.py +5 -0
- opencrbasic/analysis.py +184 -0
- opencrbasic/bindings.py +1034 -0
- opencrbasic/catalog.py +173 -0
- opencrbasic/checkconfig.py +144 -0
- opencrbasic/checker/__init__.py +977 -0
- opencrbasic/checker/cr3xx.py +3118 -0
- opencrbasic/checker/ess.py +81 -0
- opencrbasic/checker/expressions.py +3581 -0
- opencrbasic/checker/instr_data.py +1802 -0
- opencrbasic/checker/instr_measure.py +1547 -0
- opencrbasic/checker/instr_rules.py +3540 -0
- opencrbasic/checker/instructions.py +17 -0
- opencrbasic/checker/intervals.py +678 -0
- opencrbasic/checker/longconv.py +133 -0
- opencrbasic/checker/scan_time.py +580 -0
- opencrbasic/checker/storage.py +456 -0
- opencrbasic/checker/structs.py +240 -0
- opencrbasic/checker/structure.py +6213 -0
- opencrbasic/checker/symbols.py +609 -0
- opencrbasic/checker/terminals.py +249 -0
- opencrbasic/checker/unused.py +186 -0
- opencrbasic/checker/var_types.py +564 -0
- opencrbasic/checker/warnings.py +661 -0
- opencrbasic/checks.py +491 -0
- opencrbasic/cli.py +391 -0
- opencrbasic/commands.py +128 -0
- opencrbasic/compiler.py +320 -0
- opencrbasic/consteval.py +327 -0
- opencrbasic/data/background_calibration.json +4 -0
- opencrbasic/data/before_beginprog.json +99 -0
- opencrbasic/data/cr1000x/background_calibration.json +4 -0
- opencrbasic/data/cr1000x/before_beginprog.json +138 -0
- opencrbasic/data/cr1000x/ess_variables.json +1087 -0
- opencrbasic/data/cr1000x/fnotch.json +29 -0
- opencrbasic/data/cr1000x/functions.json +1337 -0
- opencrbasic/data/cr1000x/instructions.json +4836 -0
- opencrbasic/data/cr1000x/measure.json +121 -0
- opencrbasic/data/cr1000x/mode.json +111 -0
- opencrbasic/data/cr1000x/pipeline_tasks.json +88 -0
- opencrbasic/data/cr1000x/settings_fields.json +321 -0
- opencrbasic/data/cr1000x/status_members.json +318 -0
- opencrbasic/data/cr1000x/symbols.json +872 -0
- opencrbasic/data/cr1000x/terminals.json +225 -0
- opencrbasic/data/cr300/before_beginprog.json +42 -0
- opencrbasic/data/cr300/ess_variables.json +1087 -0
- opencrbasic/data/cr300/fnotch.json +22 -0
- opencrbasic/data/cr300/functions.json +1261 -0
- opencrbasic/data/cr300/instructions.json +2837 -0
- opencrbasic/data/cr300/measure.json +33 -0
- opencrbasic/data/cr300/mode.json +121 -0
- opencrbasic/data/cr300/settings_fields.json +259 -0
- opencrbasic/data/cr300/status_members.json +303 -0
- opencrbasic/data/cr300/symbols.json +584 -0
- opencrbasic/data/cr300/terminals.json +193 -0
- opencrbasic/data/cr350/before_beginprog.json +44 -0
- opencrbasic/data/cr350/ess_variables.json +1087 -0
- opencrbasic/data/cr350/fnotch.json +22 -0
- opencrbasic/data/cr350/functions.json +1262 -0
- opencrbasic/data/cr350/instructions.json +2848 -0
- opencrbasic/data/cr350/measure.json +35 -0
- opencrbasic/data/cr350/mode.json +121 -0
- opencrbasic/data/cr350/settings_fields.json +292 -0
- opencrbasic/data/cr350/status_members.json +303 -0
- opencrbasic/data/cr350/symbols.json +572 -0
- opencrbasic/data/cr350/terminals.json +190 -0
- opencrbasic/data/ess_variables.json +1087 -0
- opencrbasic/data/fnotch.json +34 -0
- opencrbasic/data/functions.json +1337 -0
- opencrbasic/data/instructions.json +4965 -0
- opencrbasic/data/measure.json +123 -0
- opencrbasic/data/mode.json +121 -0
- opencrbasic/data/notices_cr6.json +890 -0
- opencrbasic/data/pipeline_tasks.json +84 -0
- opencrbasic/data/settings_fields.json +322 -0
- opencrbasic/data/status_members.json +319 -0
- opencrbasic/data/status_table.json +684 -0
- opencrbasic/data/symbols.json +902 -0
- opencrbasic/data/terminals.json +195 -0
- opencrbasic/data/type_codes.json +249 -0
- opencrbasic/diagnostics.py +196 -0
- opencrbasic/editing.py +827 -0
- opencrbasic/formatting.py +310 -0
- opencrbasic/helpdocs.py +677 -0
- opencrbasic/hover.py +667 -0
- opencrbasic/inlay.py +169 -0
- opencrbasic/lexer.py +183 -0
- opencrbasic/lsp/__init__.py +5 -0
- opencrbasic/lsp/__main__.py +7 -0
- opencrbasic/lsp/config.py +202 -0
- opencrbasic/lsp/features.py +602 -0
- opencrbasic/lsp/server.py +741 -0
- opencrbasic/lsp/session.py +1189 -0
- opencrbasic/lsp/worker.py +128 -0
- opencrbasic/mode.py +143 -0
- opencrbasic/navigation.py +401 -0
- opencrbasic/parser.py +3264 -0
- opencrbasic/positions.py +274 -0
- opencrbasic/preprocess.py +269 -0
- opencrbasic/profiles.py +266 -0
- opencrbasic/provenance.py +17 -0
- opencrbasic/quickfix.py +331 -0
- opencrbasic/rename.py +662 -0
- opencrbasic/signature.py +33 -0
- opencrbasic/source.py +600 -0
- opencrbasic/sources.py +125 -0
- opencrbasic/syntax.py +337 -0
- opencrbasic/tables.py +2173 -0
- opencrbasic/tables_hook.py +14 -0
- opencrbasic/tdf.py +142 -0
- opencrbasic/timing.py +565 -0
- opencrbasic-1.0.0.dist-info/METADATA +223 -0
- opencrbasic-1.0.0.dist-info/RECORD +117 -0
- opencrbasic-1.0.0.dist-info/WHEEL +4 -0
- opencrbasic-1.0.0.dist-info/entry_points.txt +3 -0
- opencrbasic-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Wires `tables.build_tables` into a `CompileResult` (`compiler.CompileResult.tables` /
|
|
2
|
+
`.table_list`), for `checker.py` to call after a successful compile and for `cli.py`'s `-z`/`-l`.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from . import syntax as S
|
|
6
|
+
from .tables import build_tables
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def attach(program: S.Program, profile, result) -> None:
|
|
10
|
+
tables, table_list_text, diags = build_tables(program, profile, dict(program.consts))
|
|
11
|
+
result.tables = tables
|
|
12
|
+
result.table_list = table_list_text
|
|
13
|
+
for d in diags or ():
|
|
14
|
+
result.diagnostics.warning(0, d)
|
opencrbasic/tdf.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""Table definition file (TDF) reading and writing.
|
|
2
|
+
|
|
3
|
+
The `-z` output of CR6Comp.exe is the PakBus table-definition structure (as returned by the
|
|
4
|
+
logger's `.TDF` file): a version byte (1), then per table: name (NUL-terminated), table size
|
|
5
|
+
(u32 BE), time type (u8), time-into (NSec: s32 + s32 BE), interval (NSec), fields, and a 0 byte
|
|
6
|
+
ending the field list. Each field: type byte (0x80 flag = read-only), name, alias list
|
|
7
|
+
(NUL-terminated strings ending in an empty string), processing, units, description, begin index
|
|
8
|
+
(u32), dimension (u32), sub-dimensions (u32 list ending in 0).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import struct
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class TdfField:
|
|
17
|
+
type: int
|
|
18
|
+
read_only: bool
|
|
19
|
+
name: str
|
|
20
|
+
aliases: list[str] = field(default_factory=list)
|
|
21
|
+
processing: str = ""
|
|
22
|
+
units: str = ""
|
|
23
|
+
description: str = ""
|
|
24
|
+
begin_index: int = 1
|
|
25
|
+
dimension: int = 1
|
|
26
|
+
subdims: list[int] = field(default_factory=list)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class TdfTable:
|
|
31
|
+
name: str
|
|
32
|
+
size: int
|
|
33
|
+
time_type: int
|
|
34
|
+
time_into: tuple[int, int]
|
|
35
|
+
interval: tuple[int, int]
|
|
36
|
+
fields: list[TdfField] = field(default_factory=list)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _cstr(data: bytes, pos: int) -> tuple[str, int]:
|
|
40
|
+
end = data.index(b"\0", pos)
|
|
41
|
+
return data[pos:end].decode("latin-1"), end + 1
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def parse(data: bytes) -> tuple[int, list[TdfTable]]:
|
|
45
|
+
version = data[0]
|
|
46
|
+
pos = 1
|
|
47
|
+
tables = []
|
|
48
|
+
while pos < len(data):
|
|
49
|
+
name, pos = _cstr(data, pos)
|
|
50
|
+
size, time_type = struct.unpack_from(">IB", data, pos)
|
|
51
|
+
pos += 5
|
|
52
|
+
into = struct.unpack_from(">ii", data, pos)
|
|
53
|
+
interval = struct.unpack_from(">ii", data, pos + 8)
|
|
54
|
+
pos += 16
|
|
55
|
+
table = TdfTable(name, size, time_type, into, interval)
|
|
56
|
+
while data[pos] != 0:
|
|
57
|
+
ftype = data[pos]
|
|
58
|
+
pos += 1
|
|
59
|
+
fname, pos = _cstr(data, pos)
|
|
60
|
+
aliases = []
|
|
61
|
+
while True:
|
|
62
|
+
alias, pos = _cstr(data, pos)
|
|
63
|
+
if not alias:
|
|
64
|
+
break
|
|
65
|
+
aliases.append(alias)
|
|
66
|
+
processing, pos = _cstr(data, pos)
|
|
67
|
+
units, pos = _cstr(data, pos)
|
|
68
|
+
description, pos = _cstr(data, pos)
|
|
69
|
+
begin, dim = struct.unpack_from(">II", data, pos)
|
|
70
|
+
pos += 8
|
|
71
|
+
subdims = []
|
|
72
|
+
while True:
|
|
73
|
+
(sd,) = struct.unpack_from(">I", data, pos)
|
|
74
|
+
pos += 4
|
|
75
|
+
if sd == 0:
|
|
76
|
+
break
|
|
77
|
+
subdims.append(sd)
|
|
78
|
+
table.fields.append(
|
|
79
|
+
TdfField(
|
|
80
|
+
ftype & 0x7F,
|
|
81
|
+
bool(ftype & 0x80),
|
|
82
|
+
fname,
|
|
83
|
+
aliases,
|
|
84
|
+
processing,
|
|
85
|
+
units,
|
|
86
|
+
description,
|
|
87
|
+
begin,
|
|
88
|
+
dim,
|
|
89
|
+
subdims,
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
pos += 1
|
|
93
|
+
tables.append(table)
|
|
94
|
+
return version, tables
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def serialize(tables: list[TdfTable], version: int = 1) -> bytes:
|
|
98
|
+
out = bytearray([version])
|
|
99
|
+
for t in tables:
|
|
100
|
+
out += t.name.encode("latin-1") + b"\0"
|
|
101
|
+
out += struct.pack(">IB", t.size, t.time_type)
|
|
102
|
+
out += struct.pack(">ii", *t.time_into) + struct.pack(">ii", *t.interval)
|
|
103
|
+
for f in t.fields:
|
|
104
|
+
out.append(f.type | (0x80 if f.read_only else 0))
|
|
105
|
+
out += f.name.encode("latin-1") + b"\0"
|
|
106
|
+
for a in f.aliases:
|
|
107
|
+
out += a.encode("latin-1") + b"\0"
|
|
108
|
+
out += b"\0"
|
|
109
|
+
for s in (f.processing, f.units, f.description):
|
|
110
|
+
out += s.encode("latin-1") + b"\0"
|
|
111
|
+
out += struct.pack(">II", f.begin_index, f.dimension)
|
|
112
|
+
for sd in f.subdims:
|
|
113
|
+
out += struct.pack(">I", sd)
|
|
114
|
+
out += b"\0\0\0\0"
|
|
115
|
+
out.append(0)
|
|
116
|
+
return bytes(out)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def dump(data: bytes) -> str:
|
|
120
|
+
version, tables = parse(data)
|
|
121
|
+
lines = [f"version {version}"]
|
|
122
|
+
for t in tables:
|
|
123
|
+
lines.append(f"table {t.name} size={t.size} timetype={t.time_type} into={t.time_into} interval={t.interval}")
|
|
124
|
+
for f in t.fields:
|
|
125
|
+
ro = " ro" if f.read_only else ""
|
|
126
|
+
extra = []
|
|
127
|
+
if f.aliases:
|
|
128
|
+
extra.append(f"aliases={f.aliases}")
|
|
129
|
+
for key in ("processing", "units", "description"):
|
|
130
|
+
if getattr(f, key):
|
|
131
|
+
extra.append(f"{key}={getattr(f, key)!r}")
|
|
132
|
+
lines.append(
|
|
133
|
+
f" {f.name} type={f.type}{ro} begin={f.begin_index} dim={f.dimension} "
|
|
134
|
+
f"subdims={f.subdims} {' '.join(extra)}".rstrip()
|
|
135
|
+
)
|
|
136
|
+
return "\n".join(lines)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if __name__ == "__main__":
|
|
140
|
+
import sys
|
|
141
|
+
|
|
142
|
+
print(dump(open(sys.argv[1], "rb").read()))
|