Skip to main content

YAAL (Yet Another Abstract Language) Parser - A human-readable configuration language with executable code blocks

Project description

YAAL Parser Implementation

This project contains both Python (Lark) and C++ (PEGTL) implementations of parsers for the YAAL (Yet Another Abstract Language) specification.

YAAL Language Features

YAAL is a flexible, statement-based language that supports:

  • Dual nature: Same syntax for data structures and executable programs
  • Statement model: Simple statements (no colons) and compound statements (key:value)
  • First colon rule: Everything before first colon = key, everything after = value
  • Shebang support: Context switching with #!pipeline, #!hibrid-code, etc.
  • Brace blocks: Raw content containers with balanced brace matching
  • Triple-quoted strings: Multiline string support
  • Flexible keys: Keys can contain spaces and special characters
  • Indentation-based nesting: Spaces-only (no tabs)

Parser Implementations

C++ Parser (PEGTL)

Location: src/cpp/

Features:

  • Complete YAAL specification compliance
  • Fast parsing with PEGTL library
  • Detailed AST visitor pattern
  • Comprehensive error handling

Building:

cmake -B build -S src/cpp
cmake --build build

Usage:

./build/yaal <filename.yaal>

Python Parser (Lark)

Location: src/py/yaal/

Features:

  • YAAL grammar in Lark format
  • Python indentation handling
  • Command-line interface
  • Graceful dependency handling

Dependencies:

pip install lark

Usage:

python3 src/py/yaal/yaal.py <filename.yaal>

Example YAAL Files

Basic Example (test_input.yaal)

#!pipeline
name: John
api endpoint: https://api.example.com:8080/v1
production
config:
  debug: false
  timeout: 30
script: { echo hello; exit 0 }

Comprehensive Example (comprehensive_test.yaal)

Demonstrates all YAAL features including:

  • Shebang lines
  • Simple and compound statements
  • Keys with spaces
  • Triple-quoted strings
  • Brace blocks
  • Nested structures
  • Polymorphic lists

Grammar Highlights

Lark Grammar (src/py/yaal/yaal.lark)

start: [shebang_line] file_input

shebang_line: \"#!\" IDENTIFIER _NEWLINE

?stmt: simple_stmt | compound_stmt

simple_stmt: line_content _NEWLINE
compound_stmt: key_part \":\" value_part _NEWLINE?

brace_block: \"{\" brace_content \"}\"
quoted_string: ESCAPED_STRING | TRIPLE_QUOTED_STRING

PEGTL Grammar (src/cpp/yaal.cpp)

struct shebang_line : pegtl::seq<pegtl::string<'#', '!'>, identifier, pegtl::eol> {};
struct simple_stmt : pegtl::seq<line_content, _NEWLINE> {};
struct compound_stmt : pegtl::seq<key_part, pegtl::one<':'>, /* ... */> {};
struct brace_block : pegtl::seq<pegtl::one<'{'>, brace_content, pegtl::one<'}'>> {};

Testing

Both parsers have been tested with:

  • Basic YAAL syntax
  • Complex nested structures
  • All string types (unquoted, quoted, triple-quoted)
  • Brace blocks with nested content
  • Real-world examples from the YAAL specification

Compliance

Complete YAAL specification compliance
All examples from https://github.com/zokrezyl/yaal-lang parse successfully
Proper error handling and reporting
Extensible architecture for semantic analysis

Next Steps

  1. Semantic Analysis: Add interpretation and execution capabilities
  2. Context Handlers: Implement shebang-based context switching
  3. Integration: Connect to YAAL execution engines
  4. Tooling: Add syntax highlighting, LSP support, etc.

Both parsers provide a solid foundation for building YAAL-based tools and applications.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaal-0.1.0.tar.gz (191.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaal-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file yaal-0.1.0.tar.gz.

File metadata

  • Download URL: yaal-0.1.0.tar.gz
  • Upload date:
  • Size: 191.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for yaal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a285225090d3208fbaef451d2b8c6e26281fbd90bb0fb2996bfd240fb7173651
MD5 f3ad83a936e2b630675040e90c756389
BLAKE2b-256 56e7470aefabc07254f6149a063b0229166efbc43b98759e7d13b956dff64f08

See more details on using hashes here.

File details

Details for the file yaal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yaal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for yaal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb56fa457b85e17ea946a90f063aad005a500ba28d66e15a8954575a2ca35032
MD5 f74a693e86183019ca1e66fb24a08f55
BLAKE2b-256 8836d88d712199cec1ffac7a7e791521caeb0ce5a0801465d2e735787a38671c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page