rcl
RCL - Ruby-like Configuration Language
A Ruby-like configuration language parser written in Crystal.
Features
- Ruby-like syntax - Simple, readable configuration format
- Standalone parser - Independent library, reusable for any project
- Custom block handlers - Register handlers for specific block types
- Type-safe values - Strings, numbers, booleans, arrays, nested blocks
- Comments - Support for # comments
- Stable AST contract -
Document#to_json - Formatter - Convert parsed AST back to canonical RCL text
- Native conversion - Export to YAML/TOML/HCL
- Named blocks -
region "us" doprojects toregions.us
Installation
For local development, add dependency from monorepo path:
dependencies:
rcl:
path: ./implementations/crystal
Usage
require "rcl"
# Parse a file
doc = RCL.parse_file("config.rcl")
# Parse a string
doc = RCL.parse_string("key = \"value\"")
# Access values
doc.get_string("server.address")
doc.get_int("server.port")
doc.get_bool("feature.enabled")
# Convert to Hash
hash = doc.to_h
# AST JSON
json = doc.to_json
# Format
source = RCL.format(doc)
# Convert
yaml = RCL.to_yaml(doc)
toml = RCL.to_toml(doc)
hcl = RCL.to_hcl(doc)
Named block projection example:
config do
region "us" do
name = "My Name"
end
end
{ "config": { "regions": { "us": { "name": "My Name" } } } }
Constraints:
- Comments:
#only - Strings: double quotes only (
"...") - Bare identifier values are invalid (
name = valuefails) - Dotted keys are nested (
a.b = 1->{a: {b: 1}}) - Duplicate/conflicting key paths fail
Example RCL File
# Server configuration
server do
address = "example.com"
port = 8080
enabled = true
end
# List of features
features = ["auth", "logging", "cache"]
Development
# Install dependencies
cd implementations/crystal && crystal deps
# Run tests
cd implementations/crystal && crystal spec
# Build
cd implementations/crystal && crystal build src/rcl.cr
Implementations
Multi-language workspace is available under implementations/.
implementations/crystal- Crystal parser + formatter + convertersimplementations/ruby- Ruby parser + formatterimplementations/typescript- TypeScript parser + formatterimplementations/go- Go parser + formatter + convertersimplementations/kotlin- Kotlin parser + formatter + convertersimplementations/swift- Swift parser + formatter + convertersimplementations/rust- Rust parser + formatter + convertersimplementations/php- PHP parser + formatter + convertersimplementations/elixir- Elixir parser + formatter + convertersimplementations/ocaml- OCaml parser + formatter + convertersimplementations/julia- Julia parser + formatter + convertersimplementations/c- C parser + formatter + convertersimplementations/cpp- C++ parser + formatter + convertersimplementations/zig- Zig parser + formatter + convertersimplementations/java- Java parser + formatter + convertersimplementations/d- D parser + formatter + convertersimplementations/csharp- C# parser + formatter + convertersimplementations/lua- Lua parser + formatter + convertersimplementations/dart- Dart parser + formatter + converters
License
MIT
Repository
rcl
Owner
Statistic
- 1
- 1
- 0
- 0
- 0
- 1 day ago
- March 2, 2026
License
BSD Zero Clause License
Links
Synced at
Tue, 03 Mar 2026 09:18:21 GMT
Languages