Extending the Declarative Config Parsing API

Writing custom SectionParsers

class yosys_mau.config_parser.ConfigParser

See ConfigParser for the user API.

sections(name=None, unprocessed_only=False)

Returns all sections or all sections with a given name.

Parameters:
  • name (str | None) – The name of the section to return or None to return all sections.

  • unprocessed_only (bool) – If True only unprocessed sections are returned.

Return type:

list[ConfigSection]

mark_as_processed(section)

Marks a given section as processed.

Sections that are marked as unprocessed at the end of parsing generate an error.

Parameters:

section (ConfigSection | Iterable[ConfigSection])

Return type:

None

class yosys_mau.config_parser.SectionParser
config_parser: ConfigParser

The parser for the config file containing the section being parsed.

attr_name: str

The name of the attribute in the config parser class that this section parser was assigned to.

property result: T

See SectionParser for the user API.

class yosys_mau.config_parser.SectionContentsParser

See SectionContentsParser for the user API.

This part of the API is needed to invoke a section content parser on a custom set of sections and to redirect the result (see ArgSection for an example).

arg_sections: list[ConfigSection] | None = None

Set to override the sections considered by SectionParser.matching_sections().

redirect_result: tuple[dict[Any, Any], Any] | None = None

Set to store the parse result in a dictionary instead of within this section parser.

Writing custom OptionParsers

class yosys_mau.config_parser.ConfigOptions

See ConfigOptions for the user API.

options(name=None, unprocessed_only=False)

Returns all options or all options with a given name.

Parameters:
  • name (str | None) – The name of the option to return or None to return all options.

  • unprocessed_only (bool) – If True only unprocessed options are returned.

Return type:

list[ConfigCommand]

mark_as_processed(section)

Marks a given section as processed.

Sections that are marked as unprocessed at the end of parsing generate an error.

Parameters:

section (ConfigCommand | Iterable[ConfigCommand])

Return type:

None

class yosys_mau.config_parser.OptionParser
config_options: ConfigOptions

The parser for the options section containing the option being parsed.

attr_name: str

The name of the attribute in the config options class that this option parser is associated with.

property result: T

See OptionParser for the user API.