MCPcopy Create free account
hub / github.com/pytorch/executorch / _parse_fields

Function _parse_fields

backends/mlx/serialization/generate.py:260–280  ·  view source on GitHub ↗

Parse fields from a struct/table body.

(body: str)

Source from the content-addressed store, hash-verified

258
259
260def _parse_fields(body: str) -> List[FBSField]:
261 """Parse fields from a struct/table body."""
262 fields = []
263 for line in body.split(";"):
264 line = line.strip()
265 if not line:
266 continue
267
268 # Parse: name: type (attributes) = default
269 match = re.match(
270 r"(\w+)\s*:\s*(\[?\w+\]?)\s*(?:\(([^)]*)\))?\s*(?:=\s*([^;]+))?", line
271 )
272 if match:
273 name = match.group(1)
274 type_str = match.group(2)
275 attrs = match.group(3) or ""
276 default = match.group(4).strip() if match.group(4) else None
277 required = "required" in attrs
278 fields.append(FBSField(name, type_str, required, default))
279
280 return fields
281
282
283# Config for compound type factory methods.

Callers 1

parse_fbsFunction · 0.85

Calls 4

FBSFieldClass · 0.85
splitMethod · 0.80
matchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected