> For the complete documentation index, see [llms.txt](https://docs.snowddl.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snowddl.com/advanced/architecture-overview/parsers.md).

# Parsers

<mark style="color:orange;">**Parsers**</mark> are used to process [YAML config files](/basic/yaml-configs.md) into <mark style="color:blue;">**blueprints**</mark>, one parser per object type.

All standard parsers are located in [`/parser/`](https://github.com/littleK0i/SnowDDL/tree/master/snowddl/parser) directory.

### Inheritance

All parsers are derived from `AbstractParser` class.

### JSON schema

SnowDDL uses [jsonschema](https://github.com/Julian/jsonschema) Python library to validate YAML configs. JSON Schema for each object type is stored in the same file as parser for your convenience.

### Methods

* `__init__(config: SnowDDLConfig, base_path: Path)`\
  Initialize <mark style="color:orange;">**parser**</mark> with [<mark style="color:purple;">**config**</mark>](/advanced/architecture-overview/config.md) and Path object containing path to config directory.<br>
* `load_blueprints()`\
  Abstract method, it should be implemented by each parser class. Normally it reads YAML files, builds <mark style="color:blue;">**blueprints**</mark> and adds <mark style="color:blue;">**blueprints**</mark> to <mark style="color:purple;">**config**</mark>.<br>
* `parse_single_file(path: Path, json_schema: dict, callback: Callable = None)`\
  Accepts path to YAML file, JSON schema definition and optional callback function. Parses YAML file, validates it with provided JSON schema, process it using callback function.\
  \
  If any `Exception` is being raised inside callback function, it is treated as config validation error, "muted" and added to `.errors` property of [<mark style="color:purple;">**config**</mark>](/advanced/architecture-overview/config.md).\
  \
  If callback function was not defined, it returns processed YAML file as basic Python dict.<br>
* `parse_schema_object_files(object_type: str, json_schema: dict, callback: Callable)`\
  Accepts name of object type (as string), JSON schema definition, mandatory callback function. Finds and parses all files of specified object type, validate each file with provided JSON schema, process each file with callback function.\
  \
  If any `Exception` is being raised inside callback function, it is treated as config validation error, "muted" and added to `.errors` property of [<mark style="color:purple;">**config**</mark>](/advanced/architecture-overview/config.md).
