aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-02-07 04:31:33 +0000
committerEdwin Cheng <[email protected]>2021-02-07 04:31:33 +0000
commit504a54b222553a096c8eaa0cd9efca33d916c275 (patch)
treef37761c1d0175c40cd3eb99f738c55206d2424e9
parentdf7f5e9421534121002ab4510eefea3ed7aee295 (diff)
Update architecture.md for mbe and proc-macro
-rw-r--r--docs/dev/architecture.md11
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
254These crates implement macros as token tree -> token tree transforms. 254These crates implement macros as token tree -> token tree transforms.
255They are independent from the rest of the code. 255They 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.
259And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe).
260
261For proc macros, we pass the token trees by loading the corresponding dynamic library (which built by `cargo`).
262That'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:**
265Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error.
266And they may be non-deterministic which conflict how `salsa` works, so special attention is required.
267
257### `crates/cfg` 268### `crates/cfg`
258 269
259This crate is responsible for parsing, evaluation and general definition of `cfg` attributes. 270This crate is responsible for parsing, evaluation and general definition of `cfg` attributes.