File size: 1,059 Bytes
7952f32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Round-trip parser: Python source -> Graph.

Responsibilities (PROPOSAL.md §3.4):

  * Walk an AST per module file.
  * Recover function declarations as :class:`Node` objects.
  * Recover ``from x import y`` lines as cross-module edges (best-effort).
  * Recognize body templates by structural pattern matching against the
    template library, and recover ``body_template`` + ``body_template_args``.
  * Produce a :class:`Graph` identical (per ``structural_hash``) to the one
    that produced the source via :mod:`graphforge.materializer`.

The round-trip parser is unit-tested against every body template + every
constraint pattern. If it fails to round-trip, the materializer emits a
warning and the graph is treated as canonical.

Public surface (TODO):

    parse_program(files: dict[str, str]) -> Graph
    parse_directory(path: Path) -> Graph
"""

from __future__ import annotations


def parse_program(files: dict[str, str]) -> object:  # pragma: no cover — TODO
    raise NotImplementedError("round-trip parser TODO — see PROPOSAL.md §3.4")