flowchart TD
  A[项目资源] --> A1[robots/robot.urdf]
  A --> A2[targets/*.json]
  A --> A3[paths/*.json]
  A --> A4[operations/*.json]
  A --> A5[programs/*.grl]
  A --> A6[io/io_map.json]
  A --> A7[post/*.profile.json]

  A5 --> B[GRL Lexer]
  B --> C[GRL Parser]
  C --> D[GRL AST]
  D --> E[Symbol Table]
  E --> F[Semantic Analyzer]

  A1 --> G[URDF Parser]
  G --> H[NormalizedRobotModel]
  H --> I[KDL createRobotFromModel]
  I --> J[RobotHandle]

  F --> K[Executable IR]
  K --> L{IR 指令类型}

  L -->|MotionInstruction| M[生成 MotionSegmentRequest]
  L -->|run_path| N[展开 Path points/events]
  L -->|run_operation| O[展开 start_action + path + end_action]
  L -->|IO / wait / pulse| P[虚拟控制器 IO Service]
  L -->|if/for/switch/call/return| Q[虚拟控制器流程执行]
  L -->|alarm / raise / try/catch| R[虚拟控制器报警与异常处理]

  N --> M
  O --> N

  M --> S[KdlWorkerClient]
  S --> T[kdl.worker.ts]
  T --> U[KDL WASM API]

  U --> U1[planMoveJ]
  U --> U2[planMoveL]
  U --> U3[planMoveC]
  U --> U4[planPath]
  U --> U5[validatePath]

  U1 --> V[TrajectoryResult]
  U2 --> V
  U3 --> V
  U4 --> W[PathPlanResult]
  U5 --> X[PathValidationResult]

  V --> Y[Motion Queue / 轨迹回放]
  W --> Y
  X --> Z[可达性与诊断报告]

  K --> AA[Post Processor]
  AA --> AA1[ABB RAPID]
  AA --> AA2[FANUC LS/TP 风格文本]
  AA --> AA3[KUKA KRL]
  AA --> AA4[转换报告]
