Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ A modern, high-performance programming language designed for scientific computin
- **String functions**: `len`, `concat`, `substring`, `contains`, `starts_with`, `ends_with`, `trim`, `to_int`, `to_float`, `to_string`
- **List/Array functions**: `len` (indexing and literals supported)
- **I/O functions**: `print`
- **PML (Pain Markup Language)**: `pml_load_file`, `pml_parse` - Load and parse PML configuration files

## Installation

Expand Down Expand Up @@ -117,6 +118,28 @@ fn main():
print(sum)
```

### PML (Pain Markup Language) Example

PML is a minimalistic declarative data format for configurations and UI structures:

**config.pml:**
```pml
app:
name: "My App"
version: "1.0.0"
debug: false
```

**main.pain:**
```pain
fn main():
let config = pml_load_file("config.pml")
let app_name = config.app.name
print("Starting " + app_name)
```

See [`docs/PML_SPEC.md`](docs/PML_SPEC.md) for complete PML documentation.

## Project Structure

This is a workspace containing multiple crates:
Expand All @@ -132,6 +155,8 @@ This is a workspace containing multiple crates:
- [`docs/quickstart.md`](docs/quickstart.md) – installation, running programs, `painpkg`.
- [`docs/stdlib.md`](docs/stdlib.md) – summary of built-in APIs.
- [`docs/examples.md`](docs/examples.md) – ready-to-run snippets.
- [`docs/PML_SPEC.md`](docs/PML_SPEC.md) – PML (Pain Markup Language) specification.
- [`docs/examples_pml.md`](docs/examples_pml.md) – PML usage examples.
- [`docs/JIT_SETUP.md`](docs/JIT_SETUP.md) – JIT compilation setup guide.
- Generate fresh API docs from source:

Expand Down
36 changes: 35 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,43 @@ cargo test -p pain-compiler --test integration_test
cargo bench
```

## 9. Next Steps
## 9. Working with PML (Pain Markup Language)

PML is a minimalistic declarative data format for configurations and UI structures. Create a PML file:

**config.pml:**
```pml
app:
name: "My App"
version: "1.0.0"
debug: false
```

Load and use it in Pain:

```pain
fn main():
let config = pml_load_file("config.pml")
let app_name = config.app.name
let version = config.app.version
print("Starting " + app_name + " v" + version)
```

Or parse PML from a string:

```pain
fn main():
let pml_source = "title: \"Hello\"\nwidth: 400"
let doc = pml_parse(pml_source)
print("Parsed PML successfully!")
```

See [`PML_SPEC.md`](PML_SPEC.md) for complete PML syntax and [`examples_pml.md`](examples_pml.md) for more examples.

## 10. Next Steps

- Explore API details in [`stdlib.md`](stdlib.md).
- Copy ready-to-run snippets from [`examples.md`](examples.md).
- Learn about PML in [`PML_SPEC.md`](PML_SPEC.md) and [`examples_pml.md`](examples_pml.md).
- Use the LSP server (`pain-lsp`) inside VS Code for hover docs, completion, and diagnostics.

34 changes: 34 additions & 0 deletions docs/stdlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@ See [`examples.md`](examples.md) for complete class examples.
| --- | --- | --- |
| `print` | `fn print(value: dynamic) -> dynamic` | Sends textual representation to stdout |

## PML (Pain Markup Language)

PML is a minimalistic declarative data format for configurations, UI structures, and tree data. PML files use tab-based indentation and support SCALAR, MAP, and LIST node types.

| Function | Signature | Description |
| --- | --- | --- |
| `pml_load_file` | `fn pml_load_file(path: str) -> dynamic` | Loads and parses a PML file, returns parsed tree as dynamic object |
| `pml_parse` | `fn pml_parse(source: str) -> dynamic` | Parses PML string, returns parsed tree as dynamic object |

**Example:**
```pain
fn main():
# Load PML file
let config = pml_load_file("config.pml")
let app_name = config.app.name
let port = config.app.port

# Parse PML string
let pml_source = "title: \"Hello\"\nwidth: 400"
let doc = pml_parse(pml_source)
let title = doc.title
```

**PML File Example (config.pml):**
```pml
app:
name: "My Application"
version: "1.0.0"
debug: false
port: 8080
```

See [`PML_SPEC.md`](PML_SPEC.md) for complete PML syntax specification and [`examples_pml.md`](examples_pml.md) for more usage examples.

## Extending the Stdlib

1. Modify `pain-compiler/src/stdlib.rs`.
Expand Down
Loading