Skip to content

poly_scribe_code_gen.parse_idl

parse_idl

Parse WebIDL files and extract relevant information.

This module provides functionality to parse WebIDL files, validate them, and extract information about typedefs, enums, and structs.

It also handles polymorphism and adds comments to the parsed data.

Functions:

Attributes:

type_transformer module-attribute

type_transformer = {
    "boolean": "bool",
    "byte": "char",
    "ByteString": "string",
}

Mapping of WebIDL types to internal representations.

parse_idl

parse_idl(idl_file: Path) -> ParsedIDL

Parse the given WebIDL file.

This function reads a WebIDL file, validates its content, and extracts typedefs, enums, structs, and inheritance data. It also handles polymorphism and adds comments to the parsed data. It returns a dictionary containing the parsed IDL data.

Parameters:

  • idl_file (Path) –

    Path to the WebIDL file to parse.

Returns:

  • ParsedIDL

    A dictionary containing parsed IDL data, including typedefs, enums, structs, and inheritance data.