A Human-Friendly Data Serialization Format
This directory contains comprehensive examples demonstrating all features of the UP language.
| Example | Description |
|---|---|
01-basic-scalars.up |
Simple key-value pairs with various type annotations |
02-blocks.up |
Nested block structures for hierarchical data |
03-lists.up |
Multiline and inline list syntax |
04-multiline.up |
Multiline strings with language hints for code blocks |
05-dedent.up |
Dedenting feature to remove leading whitespace |
06-comments.up |
Comment syntax and usage patterns |
07-tables.up |
Table structures with columns and rows |
08-mixed-complex.up |
Realistic complex configuration using all features |
| Example | Description |
|---|---|
templates/base.up |
Base configuration with shared defaults |
templates/development.up |
Development environment overrides |
templates/staging.up |
Staging environment configuration |
templates/production.up |
Production environment settings |
templates/features/*.up |
Feature modules for composition |
templates/composed/*.up |
Composed configurations from multiple files |
templates/multi-doc-example.up |
Multi-document file - All environments in one file |
dynamic-test-data.up |
Dynamic namespaces - Generate test data with faker, random, time, id |
plugin-example.up |
Namespace plugins - Custom namespace via executable plugin |
namespace-aliases-example.up |
Namespace aliases - Multiple versions/implementations with aliases |
# Parse and output as JSON
up parse -i examples/01-basic-scalars.up --pretty
# Validate syntax
up validate -i examples/02-blocks.up
# Format (parse and output as UP)
up format -i examples/03-lists.up
# Process a template file
up template process -i examples/templates/production.up
# Process and output as JSON
up template process -i examples/templates/production.up --json --pretty
# Validate a template
up template validate -i examples/templates/composed/production-ha.up
# Multi-document example - extract and process specific config
sed -n '/# Production configuration/,/^# ---$/p' examples/templates/multi-doc-example.up | up template process
# Dynamic namespaces - generate test data (requires implementation)
up template process -i examples/dynamic-test-data.up --seed 12345
Note: Dynamic namespaces (!use pragma) are currently a design specification. Implementation is planned for future releases.
cd parsers/javascript
node -e "const up = require('./up'); console.log(JSON.stringify(up.parse(require('fs').readFileSync('../../examples/01-basic-scalars.up', 'utf8')), null, 2))"
cd parsers/python
python up.py ../../examples/01-basic-scalars.up
cd parsers/rust
cargo run --bin up-parse ../../examples/01-basic-scalars.up
cd parsers/c
make
# Modify example.c to read from file, then:
./example
See 01-basic-scalars.up for examples of:
!int, !integer - Integer values!bool, !boolean - Boolean values!url, !uri - URL/URI strings!ts, !timestamp - Timestamp values!dur, !duration - Duration values!uuid, !hex, !celsiusSee 02-blocks.up for:
See 03-lists.up for:
[a, b, c])See 04-multiline.up for:
python, json, sql, bash, etc.)See 05-dedent.up for:
!N syntax where N is number of spaces to removeSee 06-comments.up for:
#See 07-tables.up for:
columns and rowsSee 08-mixed-complex.up for:
All examples should parse without errors using the UP parser. To test all examples:
# Using Go implementation
for file in examples/*.up; do
echo "Testing $file..."
up validate -i "$file" || echo "FAILED: $file"
done
# Or use the test script (if created)
./test-examples.sh
When creating UP documents:
!N) when embedding indented contentUP combines the best aspects of:
But with:
To add a new example:
.up file in this directory