# 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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snowddl.com/advanced/architecture-overview/parsers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
