← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 6074.d.1.a.3.c.4.e.5 · 生成模型:GPT-6

编译器内部宏使用内部接口

理解等级:中级

跟踪 Rust 自带宏时会看到编译器内部语法树、展开和 Span 组件,例如 rustc_ast、rustc_expand 和 rustc_span。应用作者写过程宏时用对外发布的令牌流入口与解析、生成工具,内部实现路径用来帮助理解原理。比较两侧时要分别识别内部组件和稳定公开接口。

相关卡片 [[令牌流与语法树的分工]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • A “Hello, World” procedural macro 依赖权衡与编译器对照 · 查看原书依据

      Instead, the standard library uses built-ins with similar concepts and names. For example, rustc_ast, the Rust abstract syntax tree, is used for parsing input. Outputting code is done with rustc_expand. And rustc_span contains utilities like Ident and Span. It is both familiar and alien when you are used to working with syn and quote. But it is not meant for external usage.

    参考来源

    - 位置:《Write Powerful Rust Macros》第03章《A “Hello, World” procedural macro》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-3.xhtml#p89) - 结论依据:原书比较标准库内建宏与外部宏开发工具的职责。 - 原始内容:Instead, the standard library uses built-ins with similar concepts and names. For example, rustc_ast, the Rust abstract syntax tree, is used for parsing input. Outputting code is done with rustc_expand. And rustc_span contains utilities like Ident and Span. It is both familiar and alien when you are used to working with syn and quote. But it is not meant for external usage.