- 新增 lib/lsp:协议常量、stdio framing、JSON-RPC 响应、lifecycle server - viperc --lsp:独立池、互斥校验、stdout 仅输出协议帧 - 新增 Tools/lsp/probe.py 与 ast_check.py - Gate 0 行为验证:--build-self 后 lifecycle 探针通过
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Syntax gate for .vp files: ExpandSoftKeywords + vast.parse."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def _workspace_transpyc() -> Path:
|
|
return Path(__file__).resolve().parents[3] / "TransPyC"
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="AST-check .vp files with TPC vast")
|
|
parser.add_argument("files", nargs="+", help=".vp files to check")
|
|
args = parser.parse_args()
|
|
|
|
sys.path.insert(0, str(_workspace_transpyc()))
|
|
import lib._bootstrap # noqa: F401
|
|
from lib import vast
|
|
from lib.core.SymbolUtils import ExpandSoftKeywords
|
|
|
|
failed = 0
|
|
for name in args.files:
|
|
path = Path(name)
|
|
try:
|
|
source = path.read_text(encoding="utf-8")
|
|
expanded = ExpandSoftKeywords(source)
|
|
vast.parse(expanded, str(path))
|
|
except SyntaxError as exc:
|
|
text = str(exc)
|
|
if "T1 | T2" in text or "unsupported type union" in text:
|
|
print(f"SKIP {path}: {text.splitlines()[0]}")
|
|
continue
|
|
failed += 1
|
|
print(f"FAIL {path}: {text.splitlines()[0]}")
|
|
except Exception as exc:
|
|
failed += 1
|
|
print(f"FAIL {path}: {type(exc).__name__}: {exc}")
|
|
else:
|
|
print(f"OK {path}")
|
|
return 1 if failed else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|