Initial PROTEL 2026 toolchain import

This commit is contained in:
2026-06-08 18:04:03 -05:00
commit 98a0bb329d
125 changed files with 12223 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
"""Preprocessor shebang stripping (Introductory Manual §7.0.5)."""
from pathlib import Path
from src.parser import parse_protel
from src.preprocess import normalize_keywords, strip_shebang
ROOT = Path(__file__).resolve().parent.parent
HELLO = ROOT / "examples" / "Hello.protel"
def test_strip_shebang_removes_first_line():
source = "#!/usr/bin/env -S protel --run --\nSECTION s;\n"
assert strip_shebang(source) == "SECTION s;\n"
def test_strip_shebang_passthrough_without_hash_bang():
source = "% comment\nSECTION s;\n"
assert strip_shebang(source) == source
def test_normalize_keywords_strips_shebang_before_parse():
source = "#!/usr/bin/env protel --run\n% hi\nSECTION s;\n"
norm = normalize_keywords(source)
assert "#!" not in norm
assert "SECTION" in norm
def test_hello_protel_parses_with_shebang():
tree = parse_protel(HELLO.read_text(encoding="utf-8"))
assert tree[0].name == "Hello"
entries = [
decl
for decl in tree[0].declarations
if hasattr(decl, "entry") and decl.entry
]
assert entries and entries[0].name == "Start"