Parser grammar for roam RPC service trait definitions.
This Is Just a Grammar
This crate contains only the unsynn grammar for parsing Rust trait definitions that define roam RPC services. It does not:
- Generate any code
- Perform validation
- Know anything about roam's wire protocol
- Have opinions about how services should be implemented
It simply parses syntax like:
pub trait Calculator {
/// Add two numbers.
async fn add(&self, a: i32, b: i32) -> i32;
}
...and produces an AST ([ServiceTrait]) that downstream crates can inspect.
Why a Separate Crate?
The grammar is extracted into its own crate so that:
-
It can be tested independently — We use datatest-stable + insta for snapshot testing the parsed AST, which isn't possible in a proc-macro crate.
-
It's reusable — Other tools (linters, documentation generators, IDE plugins) can parse service definitions without pulling in proc-macro dependencies.
-
Separation of concerns — The grammar is pure parsing;
roam-macroshandles the proc-macro machinery;roam-codegenhandles actual code generation.
The Bigger Picture
roam-macros-parse roam-macros roam-codegen
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ unsynn │────▶│ #[service] │────────▶│ build.rs │
│ grammar │ │ proc macro │ │ code gen │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
just parsing emit metadata Rust, TS, Go...