11import json
22from pathlib import Path
3- from typing import Any
43
5- import strictyaml
64import yaml
75from pydantic import ValidationError
86
97from .pdl_analysis import unused_program
10- from .pdl_ast import LocationType , PDLException , Program , YamlSource
8+ from .pdl_ast import LocationType , PDLException , Program
119from .pdl_location_utils import get_line_map
1210from .pdl_schema_error_analyzer import analyze_errors
1311
@@ -28,7 +26,7 @@ def parse_str(pdl_str: str, file_name: str = "") -> tuple[Program, LocationType]
2826 loc = LocationType (path = [], file = file_name , table = line_table )
2927 try :
3028 prog = Program .model_validate (prog_yaml )
31- set_program_location (prog , pdl_str )
29+ # set_program_location(prog, pdl_str)
3230 unused_program (prog )
3331 except ValidationError as exc :
3432 pdl_schema_file = Path (__file__ ).parent / "pdl-schema.json"
@@ -42,24 +40,24 @@ def parse_str(pdl_str: str, file_name: str = "") -> tuple[Program, LocationType]
4240 return prog , loc
4341
4442
45- def set_program_location (prog : Program , pdl_str : str , file_name : str = "" ):
46- loc = strictyaml .dirty_load (pdl_str , allow_flow_style = True )
47- set_location (prog .root , loc )
48-
49-
50- def set_location (
51- pdl : Any ,
52- loc : YamlSource ,
53- ):
54- if hasattr (pdl , "pdl_yaml_src" ):
55- pdl .pdl_yaml_src = loc
56- if isinstance (loc .data , dict ):
57- for x , v in loc .items ():
58- if hasattr (pdl , x .data ):
59- set_location (getattr (pdl , x .data ), v )
60- elif isinstance (pdl , list ) and isinstance (loc .data , list ):
61- for data_i , loc_i in zip (pdl , loc ):
62- set_location (data_i , loc_i )
43+ # def set_program_location(prog: Program, pdl_str: str, file_name: str = ""):
44+ # loc = strictyaml.dirty_load(pdl_str, allow_flow_style=True)
45+ # set_location(prog.root, loc)
46+
47+
48+ # def set_location(
49+ # pdl: Any,
50+ # loc: YamlSource,
51+ # ):
52+ # if hasattr(pdl, "pdl_yaml_src"):
53+ # pdl.pdl_yaml_src = loc
54+ # if isinstance(loc.data, dict):
55+ # for x, v in loc.items():
56+ # if hasattr(pdl, x.data):
57+ # set_location(getattr(pdl, x.data), v)
58+ # elif isinstance(pdl, list) and isinstance(loc.data, list):
59+ # for data_i, loc_i in zip(pdl, loc):
60+ # set_location(data_i, loc_i)
6361
6462
6563# def set_program_location(prog: Program, pdl_str: str, file_name: str = ""):
0 commit comments