Low-Level Config Parsing API

The low-level API is used internally by the declarative API. It consists of functions that work on strings (usually SourceStr) and split them into components corresponding to different parts of a configuration file. It also defines dataclasses that hold several such related components.

yosys_mau.config_parser.split_into_sections(contents, start_index=0)

Split the contents of a config file into individual sections.

Parameters:
  • contents (str)

  • start_index (int)

Return type:

Iterable[ConfigSection]

class yosys_mau.config_parser.ConfigSection(index, name, arguments, contents, header)

A single section within a config file.

Parameters:
index: int

Sequential index of the section within the config file.

name: str

Name of the section.

The name part in a section header of the form [name] or [name arguments].

For the initial content of a config file that precedes the first section, the name is "". For proper sections, the name must be non-empty.

arguments: str

Arguments of the section.

The arguments part in a section [name arguments] or the empty string if not present.

Can contain spaces.

contents: str

Contents of the section.

The contents following the section header up to the start of the next section or the end of the file.

header: str

The section header.

A section header looks like [name] or [name arguments] and includes the [ and ] characters.

ensure_no_arguments()

Raise an error if the section has arguments.

Return type:

Any

ensure_arguments()

Raise an error if the section has no arguments.

Return type:

Any

yosys_mau.config_parser.split_into_commands(contents)

Split the contents of a section into individual commands.

Parameters:

contents (str)

Return type:

Iterable[ConfigCommand]

class yosys_mau.config_parser.ConfigCommand(index, name, arguments)

A single command or option within a config file.

Parameters: