aac.in_out.parser¶
AaC Parser and related functions submodule.
- exception aac.in_out.parser.ParserError(source: str, errors: list[str] = NOTHING, yaml_error: YAMLError | None = attr_dict['yaml_error'].default)[source]¶
 An error that represents a file that could not be parsed.
- Parameters:
 source (str)
errors (list[str])
yaml_error (YAMLError | None)
- Return type:
 None
- aac.in_out.parser.get_cache() YamlLFUCache[source]¶
 Return the YAML Parser Cache instance.
- Returns:
 The YAML Parser Cache instance
- Return type:
 YamlLFUCache
- aac.in_out.parser.parse(source: str, source_uri: str = DEFAULT_SOURCE_URI) list[Definition][source]¶
 Parse the Architecture-as-Code (AaC) definition(s) from the provided source.
- Parameters:
 source (str) – Must be either a file path to an AaC yaml file or a string containing AaC definitions.
source_uri (Optional[str]) – Overrides and sets the source_uri
- Returns:
 A list of Definition objects containing the internal representation of the definition and metadata associated with the definition.
- Return type:
 list[Definition]
- aac.in_out.parser.parse_yaml(source: str, content: str) list[dict][source]¶
 Parse content as a YAML string and return the resulting structure.
Be sure to use the YAML Parser Cache instead of this function.
- Parameters:
 source (str) – The source of the YAML content. Used to provide better error messages.
content (str) – The YAML content to be parsed.
- Returns:
 The parsed YAML content.
- Raises:
 If the YAML is invalid, a ParserError is raised. –
If the model is not a dictionary, a ParserError is raised. –
If the model does not have (at least) a "name" field, a ParserError is raised. –
- Return type:
 list[dict]
- aac.in_out.parser.scan_yaml(source: str, content: str) list[Token][source]¶
 Parse the YAML string and produce a list of scanning tokens.
- Parameters:
 source (str) – The source of the YAML content. Used to provide better error messages.
content (str) – The previously parsed YAML content to be scanned.
- Returns:
 The scanned YAML parse content.
- Raises:
 If the YAML is invalid, a ParserError is raised. –
- Return type:
 list[Token]