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,81 @@
|
|
|
1
|
+
"""`ESSVariables` against variables the program declared itself (pass 2, all four loggers).
|
|
2
|
+
|
|
3
|
+
The real compiler walks its ESS table (`data/**/ess_variables.json`, `tools/extract_tables.py`) at
|
|
4
|
+
each `ESSVariables` statement. A name not yet declared is declared there; one already declared is
|
|
5
|
+
checked, every failing entry reported at that line in table order (oracle, 2026-10-01, decompiled
|
|
6
|
+
CR6 `DAT_005fd008` loop):
|
|
7
|
+
|
|
8
|
+
- `ESS variable %s must be declared as String` / `... as Long` when the type differs;
|
|
9
|
+
- `ESS variable of type string must be of size 255` for a string not declared `* 255`;
|
|
10
|
+
- `ESS variable %s must be dimensioned as %d` when the element count differs (a `LONG_ARRAY16`
|
|
11
|
+
entry is declared `count x 16`, so a second `ESSVariables` reports each of them).
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
from functools import cache
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from .. import consteval
|
|
19
|
+
from .. import syntax as S
|
|
20
|
+
from ..diagnostics import Diagnostics
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@cache
|
|
24
|
+
def _table(data_dir: str) -> tuple[dict, ...]:
|
|
25
|
+
path = Path(data_dir) / "ess_variables.json"
|
|
26
|
+
return tuple(json.loads(path.read_text())) if path.exists() else ()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _const_int(expr: S.Expr | None, env: consteval.Env) -> int | None:
|
|
30
|
+
if expr is None or not consteval.is_constant(expr, env):
|
|
31
|
+
return None
|
|
32
|
+
try:
|
|
33
|
+
value = consteval.value_of(expr, env)
|
|
34
|
+
except consteval.NotConstant:
|
|
35
|
+
return None
|
|
36
|
+
if (
|
|
37
|
+
not isinstance(value, (int, float))
|
|
38
|
+
or isinstance(value, bool)
|
|
39
|
+
or value != value
|
|
40
|
+
or value in (float("inf"), float("-inf"))
|
|
41
|
+
):
|
|
42
|
+
return None # (`String * 1e999`: no implementation exception, round 29)
|
|
43
|
+
return int(value)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def check(program: S.Program, profile, diags: Diagnostics, env: consteval.Env) -> None:
|
|
47
|
+
table = _table(str(profile.data_dir))
|
|
48
|
+
if not table:
|
|
49
|
+
return
|
|
50
|
+
declared: dict[str, tuple[str, str, int | None, int | None]] = {}
|
|
51
|
+
for stmt in program.statements:
|
|
52
|
+
if isinstance(stmt, S.Declaration) and stmt.kind in ("PUBLIC", "DIM", "STATIC"):
|
|
53
|
+
for v in stmt.vars:
|
|
54
|
+
total: int | None = 1
|
|
55
|
+
for d in v.dims:
|
|
56
|
+
n = _const_int(d, env)
|
|
57
|
+
total = None if n is None or total is None else total * n
|
|
58
|
+
kind = (v.type or "FLOAT").upper()
|
|
59
|
+
size = _const_int(v.string_size, env) if v.string_size is not None else 24
|
|
60
|
+
declared.setdefault(v.name.upper(), (v.name, kind, total, size))
|
|
61
|
+
continue
|
|
62
|
+
if not (isinstance(stmt, S.Instruction) and stmt.keyword.upper() == "ESSVARIABLES"):
|
|
63
|
+
continue
|
|
64
|
+
for row in table:
|
|
65
|
+
if not row["count"]:
|
|
66
|
+
continue
|
|
67
|
+
required = "STRING" if row["type"] == "STRING" else "LONG"
|
|
68
|
+
have = declared.get(row["name"].upper())
|
|
69
|
+
if have is None:
|
|
70
|
+
total = row["count"] * (16 if row["type"] == "LONG_ARRAY16" else 1)
|
|
71
|
+
declared[row["name"].upper()] = (row["name"], required, total, 255)
|
|
72
|
+
continue
|
|
73
|
+
spelling, kind, total, size = have
|
|
74
|
+
if kind != required:
|
|
75
|
+
diags.error(
|
|
76
|
+
stmt.line, f"ESS variable {spelling} must be declared as {required.capitalize()}", stmt.file
|
|
77
|
+
)
|
|
78
|
+
elif required == "STRING" and size is not None and size != 255:
|
|
79
|
+
diags.error(stmt.line, "ESS variable of type string must be of size 255", stmt.file)
|
|
80
|
+
elif total is not None and total != row["count"]:
|
|
81
|
+
diags.error(stmt.line, f"ESS variable {spelling} must be dimensioned as {row['count']}", stmt.file)
|