diff options
author | Edwin Cheng <[email protected]> | 2021-02-07 04:31:33 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2021-02-07 04:31:33 +0000 |
commit | 504a54b222553a096c8eaa0cd9efca33d916c275 (patch) | |
tree | f37761c1d0175c40cd3eb99f738c55206d2424e9 | |
parent | df7f5e9421534121002ab4510eefea3ed7aee295 (diff) |
Update architecture.md for mbe and proc-macro
-rw-r--r-- | docs/dev/architecture.md | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index a6bb024a8..1c892e13a 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md | |||
@@ -254,6 +254,17 @@ A single `rust-analyzer` process can serve many projects, so it is important tha | |||
254 | These crates implement macros as token tree -> token tree transforms. | 254 | These crates implement macros as token tree -> token tree transforms. |
255 | They are independent from the rest of the code. | 255 | They are independent from the rest of the code. |
256 | 256 | ||
257 | `tt` crate defined `TokenTree`, a single token or a delimited sequence of token trees. | ||
258 | `mbe` crate contains tools for transforming between syntax trees and token tree. | ||
259 | And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe). | ||
260 | |||
261 | For proc macros, we pass the token trees by loading the corresponding dynamic library (which built by `cargo`). | ||
262 | That's why the client (`proc_macro_api`) and server (`proc_macro_srv`) model are used to run proc-macro in separate process in background. | ||
263 | |||
264 | **Architecture Invariant:** | ||
265 | Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error. | ||
266 | And they may be non-deterministic which conflict how `salsa` works, so special attention is required. | ||
267 | |||
257 | ### `crates/cfg` | 268 | ### `crates/cfg` |
258 | 269 | ||
259 | This crate is responsible for parsing, evaluation and general definition of `cfg` attributes. | 270 | This crate is responsible for parsing, evaluation and general definition of `cfg` attributes. |