File size: 2,231 Bytes
65da30d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# rmscript

A kid-friendly robot programming language for Reachy Mini.

## Overview

rmscript is a simple, Python-like domain-specific language (DSL) designed to make robot programming accessible to children and beginners. It compiles to an intermediate representation (IR) that can be executed by different adapters (queue-based execution, WebSocket streaming, etc.).

## Installation

```bash
pip install rmscript
```

With optional dependencies:
```bash
pip install rmscript[reachy]  # For reachy_mini integration
pip install rmscript[scipy]   # For advanced transformations
```

## Quick Start

```python
from rmscript import compile_script

# Compile rmscript source
result = compile_script("""
DESCRIPTION Wave hello
look left
antenna both up
wait 1s
look right
""")

if result.success:
    print(f"Compiled {len(result.ir)} actions")
    for action in result.ir:
        print(f"  - {type(action).__name__}")
else:
    for error in result.errors:
        print(f"Error: {error}")
```

## Language Features

- **Intuitive syntax**: `look left`, `turn right`, `antenna up`
- **Time control**: `wait 2s`, `slow`, `fast`
- **Qualitative strengths**: `little`, `medium`, `lot`, `maximum`
- **Compound movements**: `look left and up`
- **Loops**: `repeat 3` blocks
- **Sound & pictures**: `play sound`, `picture`

See the [Language Reference](docs/language_reference.md) for complete syntax.

## Architecture

rmscript uses a 5-stage compilation pipeline:

```
Source β†’ Lexer β†’ Parser β†’ Semantic Analyzer β†’ Optimizer β†’ IR
```

The compiler outputs **Intermediate Representation (IR)**, not executable code. Execution is handled by **adapters** that consume IR in different contexts.

## For Developers

### Adapters

Adapters execute IR in specific contexts. Example:

```python
from rmscript import compile_file, ExecutionAdapter, ExecutionContext
from dataclasses import dataclass

@dataclass
class MyContext(ExecutionContext):
    robot: Any

class MyAdapter:
    def execute(self, ir, context: MyContext) -> dict:
        for action in ir:
            # Execute each IR action
            if isinstance(action, IRAction):
                context.robot.move(action.head_pose)
        return {"status": "complete"}
```