Skip to main content

Module parser

Module parser 

Source
Expand description

Parser module for Forge YAML models

This module provides functionality for parsing Forge YAML files into structured ParsedModel objects that can be calculated and analyzed.

§Submodules

  • arrays: Array/column type parsing (Number, Text, Date, Boolean)
  • schema: JSON Schema validation (v1.0.0 and v5.0.0)
  • multi_doc: Multi-document YAML parsing (v4.4.2)
  • includes: Cross-file include resolution (v4.0)
  • variables: Table and scalar variable parsing
  • model: Core model parsing logic

Functions§

detect_array_type
Detect the type of a YAML value
detect_multi_document
Detect if content is a multi-document YAML file A multi-document file has at least two document separators (—) on their own lines
is_nested_scalar_section
Check if a mapping contains nested scalar sections (e.g., summary.total) Returns false for v4.0 rich table columns (where value is an array)
is_valid_date_format
Check if a string is a valid date format (YYYY-MM or YYYY-MM-DD)
parse_array_value
Parse a YAML array into a typed ColumnValue
parse_includes
Parse _includes section from YAML (v4.0 cross-file references)
parse_metadata
Extract metadata fields from a YAML mapping (v4.0)
parse_model
Parse a Forge model file (v1.0.0 array format) and return a ParsedModel.
parse_multi_document_yaml
Parse a multi-document YAML file (v4.4.2) Each document is parsed and merged into a single model. Document names come from _name field or are auto-generated as “doc1”, “doc2”, etc.
parse_nested_scalars
Parse nested scalar variables (e.g., summary.total, summary.average)
parse_scalar_variable
Parse a scalar variable (v4.0 enhanced with metadata)
parse_scenarios
Parse scenarios section from YAML
parse_single_document_yaml
Parse a single YAML document
parse_table
Parse a table from a YAML mapping (v4.0 enhanced with metadata)
parse_v1_model
Parse v1.0.0 array model
resolve_includes
Resolve all includes in a model, loading and parsing referenced files. Detects circular dependencies.
split_yaml_documents
Split YAML content into separate documents by “—” separator lines
type_name
Get the type name of a YAML value for error messages
validate_against_schema
Validate YAML against the appropriate Forge JSON Schema based on _forge_version
validate_v1_0_0_no_tables
Runtime validation: v1.0.0 models must NOT contain tables (arrays) This provides a clear error message when users try to use v5.0.0 features in a v1.0.0 model