From 2a9ef25008b8dc71646455a9f036dbbd3ef4200f Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Fri, 25 Mar 2016 19:58:00 +0900 Subject: [PATCH 1/6] start translating compiler plugins --- 1.6/ja/book/compiler-plugins.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index 800be13a..c773aec0 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -1,4 +1,5 @@ -% Compiler Plugins +% コンパイラプラグイン + # Introduction From 1a95c64e25a6b44cbd80d536c658d4a9154ad56e Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Fri, 25 Mar 2016 20:11:51 +0900 Subject: [PATCH 2/6] wip --- 1.6/ja/book/compiler-plugins.md | 60 ++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index c773aec0..f6692a1c 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -1,30 +1,42 @@ % コンパイラプラグイン -# Introduction - -`rustc` can load compiler plugins, which are user-provided libraries that -extend the compiler's behavior with new syntax extensions, lint checks, etc. - -A plugin is a dynamic library crate with a designated *registrar* function that -registers extensions with `rustc`. Other crates can load these extensions using -the crate attribute `#![plugin(...)]`. See the -[`rustc_plugin`](../rustc_plugin/index.html) documentation for more about the -mechanics of defining and loading a plugin. - -If present, arguments passed as `#![plugin(foo(... args ...))]` are not -interpreted by rustc itself. They are provided to the plugin through the -`Registry`'s [`args` method](../rustc_plugin/registry/struct.Registry.html#method.args). - -In the vast majority of cases, a plugin should *only* be used through -`#![plugin]` and not through an `extern crate` item. Linking a plugin would -pull in all of libsyntax and librustc as dependencies of your crate. This is -generally unwanted unless you are building another plugin. The -`plugin_as_library` lint checks these guidelines. - -The usual practice is to put compiler plugins in their own crate, separate from -any `macro_rules!` macros or ordinary Rust code meant to be used by consumers -of a library. + +# イントロダクション + + + +`rustc` はコンパイラプラグイン、ユーザの提供する構文拡張やs構文チェックなどのコンパイラの振舞を拡張するライブラリをロード出来ます。 + + + + + + +プラグインとは `rustc` に拡張を登録するための、指定された *登録用* 関数を持った動的ライブラリのクレートです。 +他のクレートはこれらのプラグインを `#![plugin(...)]` クレートアトリビュートでロード出来ます。 +プラグインの定義、ロードの仕組みについて詳しくは[`rustc_plugin`](../rustc_plugin/index.html)を参照して下さい。 + + + + +もしあるなら、 `#![plugin(foo(... args ...))]` のように渡された引数はrustcによっては解釈されません。 +これらは `Registry` の[`args` メソッド](../rustc_plugin/registry/struct.Registry.html#method.args)を通じてプラグインに渡されます。 + + + + + + +ほとんどの場合で、プラグインは `#![plugin]` を通じて *のみ* 使われるべきで、 `extern crate` を通じて使われるべきではありません。 +プラグインをリンクするとlibsyntaxとlibrustcの全てをクレートの依存に引き込んでしまいます。 +これは別のプラグインを作っているのでもない限り一般的には望まぬ挙動です。 +`plugin_as_library` チェッカによってこのガイドラインは検査されます。 + + + + +普通の慣行ではコンパイラプラグインは自身のクレートに置かれて、 `macro_rules!` マクロやコンシューマが使うライブラリのコードとは分けられます。 # Syntax extensions From b4f290c70321067eaa974b7580d5ad766e5b7edd Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Fri, 25 Mar 2016 20:32:26 +0900 Subject: [PATCH 3/6] up to sytax extensions --- 1.6/ja/book/compiler-plugins.md | 150 ++++++++++++++++++-------------- 1 file changed, 87 insertions(+), 63 deletions(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index f6692a1c..5b00c6e6 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -38,17 +38,22 @@ 普通の慣行ではコンパイラプラグインは自身のクレートに置かれて、 `macro_rules!` マクロやコンシューマが使うライブラリのコードとは分けられます。 -# Syntax extensions + +# 構文拡張 -Plugins can extend Rust's syntax in various ways. One kind of syntax extension -is the procedural macro. These are invoked the same way as [ordinary -macros](macros.html), but the expansion is performed by arbitrary Rust -code that manipulates [syntax trees](../syntax/ast/index.html) at -compile time. + + + + + +PluginはRustの構文を様々な方法で拡張出来ます。構文拡張の一種に手続的マクロがあります。 +これらは[普通のマクロ](macros.html)と同じように実行されますが展開は任意の[syntax trees](../syntax/ast/index.html)をコンパイル時に操作するRustのコードが行います。 + + + + +ローマ数字リテラルを実装する[`roman_numerals.rs`](https://github.com/rust-lang/rust/tree/master/src/test/auxiliary/roman_numerals.rs)を書いてみましょう。 -Let's write a plugin -[`roman_numerals.rs`](https://github.com/rust-lang/rust/tree/master/src/test/auxiliary/roman_numerals.rs) -that implements Roman numeral integer literals. ```ignore #![crate_type="dylib"] @@ -62,7 +67,8 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::ast::TokenTree; use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; -use syntax::ext::build::AstBuilder; // trait for expr_usize +#// use syntax::ext::build::AstBuilder; // trait for expr_usize +use syntax::ext::build::AstBuilder; // expr_usizeのトレイト use rustc_plugin::Registry; fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) @@ -113,7 +119,8 @@ pub fn plugin_registrar(reg: &mut Registry) { } ``` -Then we can use `rn!()` like any other macro: + +`rn!()` マクロを他の任意のマクロと同じように使えます。 ```ignore #![feature(plugin)] @@ -124,29 +131,38 @@ fn main() { } ``` -The advantages over a simple `fn(&str) -> u32` are: - -* The (arbitrarily complex) conversion is done at compile time. -* Input validation is also performed at compile time. -* It can be extended to allow use in patterns, which effectively gives - a way to define new literal syntax for any data type. - -In addition to procedural macros, you can define new -[`derive`](../reference.html#derive)-like attributes and other kinds of -extensions. See -[`Registry::register_syntax_extension`](../rustc_plugin/registry/struct.Registry.html#method.register_syntax_extension) -and the [`SyntaxExtension` -enum](https://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html). For -a more involved macro example, see -[`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs). - - -## Tips and tricks - -Some of the [macro debugging tips](macros.html#debugging-macro-code) are applicable. - -You can use [`syntax::parse`](../syntax/parse/index.html) to turn token trees into -higher-level syntax elements like expressions: + +単純な `fn(&str) -> u32` に対する利点は + + + + + +* (任意に複雑な)変換がコンパイル時に行われる +* 入力バリデーションもコンパイル時に行なわれる +* パターンで使えるように拡張出来るので、実質的に任意のデータ型に対して新たなリテラル構文を与えられる + + + + + + + + + +手続き的マクロに加えて[`derive`](../reference.html#derive)ライクなアトリビュートや他の拡張を書けます。 +[`Registry::register_syntax_extension`](../rustc_plugin/registry/struct.Registry.html#method.register_syntax_extension)や[`SyntaxExtension` 列挙型](https://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html)を参照して下さい。 +もっと複雑なマクロの例は[`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs)を参照して下さい。 + + +## 豆知識と小技 + + +[マクロデバッグの豆知識](macros.html#debugging-macro-code)のいくつかが使えます。 + + + +[`syntax::parse`](../syntax/parse/index.html)を使うことでトークン木を式などの高レベルな構文要素に変換出来ます。 ```ignore fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) @@ -157,35 +173,43 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) let expr: P = parser.parse_expr(); ``` -Looking through [`libsyntax` parser -code](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs) -will give you a feel for how the parsing infrastructure works. - -Keep the [`Span`s](../syntax/codemap/struct.Span.html) of -everything you parse, for better error reporting. You can wrap -[`Spanned`](../syntax/codemap/struct.Spanned.html) around -your custom data structures. - -Calling -[`ExtCtxt::span_fatal`](../syntax/ext/base/struct.ExtCtxt.html#method.span_fatal) -will immediately abort compilation. It's better to instead call -[`ExtCtxt::span_err`](../syntax/ext/base/struct.ExtCtxt.html#method.span_err) -and return -[`DummyResult`](../syntax/ext/base/struct.DummyResult.html), -so that the compiler can continue and find further errors. - -To print syntax fragments for debugging, you can use -[`span_note`](../syntax/ext/base/struct.ExtCtxt.html#method.span_note) together -with -[`syntax::print::pprust::*_to_string`](https://doc.rust-lang.org/syntax/print/pprust/index.html#functions). - -The example above produced an integer literal using -[`AstBuilder::expr_usize`](../syntax/ext/build/trait.AstBuilder.html#tymethod.expr_usize). -As an alternative to the `AstBuilder` trait, `libsyntax` provides a set of -[quasiquote macros](../syntax/ext/quote/index.html). They are undocumented and -very rough around the edges. However, the implementation may be a good -starting point for an improved quasiquote as an ordinary plugin library. - + + + +[`libsyntax` のパーサのコード](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs)を見るとパーサ機構がどのように機能しているかを感られるでしょう。 + + + + + +パースしたものの[`Span`](../syntax/codemap/struct.Span.html)は良いエラー報告のために保持しておきましょう。 +自身のデータ構造を[`Spanned`](../syntax/codemap/struct.Spanned.html)でラップ出来ます。 + + + + + + + + +[`ExtCtxt::span_fatal`](../syntax/ext/base/struct.ExtCtxt.html#method.span_fatal)を呼ぶとコンパイルは即座に中断されます。 +[`ExtCtxt::span_err`](../syntax/ext/base/struct.ExtCtxt.html#method.span_err)を呼んで[`DummyResult`](../syntax/ext/base/struct.DummyResult.html)を返せばコンパイラはさらなるエラーを発見できるのでその方が良いでしょう。 + + + + + +構文の断片を表示するには[`span_note`](../syntax/ext/base/struct.ExtCtxt.html#method.span_note)と[`syntax::print::pprust::*_to_string`](https://doc.rust-lang.org/syntax/print/pprust/index.html#functions)を使えば出来ます。 + + + + + + + +上記の例では[`AstBuilder::expr_usize`](../syntax/ext/build/trait.AstBuilder.html#tymethod.expr_usize)を使って整数リテラルを作りました。 +`AstBuilder` トレイトの代替として `libsyntax` は[準クォート ](../syntax/ext/quote/index.html)マクロを提供しています。 +ドキュメントがない上に荒削りです。しかしながら実装は改善された普通のプラグインライブラリののとっかかりにはほど良いでしょう。 # Lint plugins From a17f335a4423d81f27df7bc5c273c47f47d30d9e Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Fri, 25 Mar 2016 20:49:26 +0900 Subject: [PATCH 4/6] scratch --- 1.6/ja/book/compiler-plugins.md | 79 ++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index 5b00c6e6..908c8bf4 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -211,12 +211,16 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) `AstBuilder` トレイトの代替として `libsyntax` は[準クォート ](../syntax/ext/quote/index.html)マクロを提供しています。 ドキュメントがない上に荒削りです。しかしながら実装は改善された普通のプラグインライブラリののとっかかりにはほど良いでしょう。 -# Lint plugins + +# 構文チェックプラグイン + + + + + +プラグインによって[Rustの構文チェック機構](../reference.html#lint-check-attributes)を拡張してコーディングスタイル、安全性などを検査するようにできます。では[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs)プラグインを書いてみましょう。 +`lintme` という名前のアイテムについて警告を出すものです。 -Plugins can extend [Rust's lint -infrastructure](../reference.html#lint-check-attributes) with additional checks for -code style, safety, etc. Now let's write a plugin [`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs) -that warns about any item named `lintme`. ```ignore #![feature(plugin_registrar)] @@ -258,7 +262,8 @@ pub fn plugin_registrar(reg: &mut Registry) { } ``` -Then code like + +そしたらこのようなコードは ```ignore #![plugin(lint_plugin_test)] @@ -266,7 +271,8 @@ Then code like fn lintme() { } ``` -will produce a compiler warning: + +コンパイラの警告を発生させます。 ```txt foo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default @@ -274,28 +280,37 @@ foo.rs:4 fn lintme() { } ^~~~~~~~~~~~~~~ ``` -The components of a lint plugin are: - -* one or more `declare_lint!` invocations, which define static - [`Lint`](../rustc/lint/struct.Lint.html) structs; - -* a struct holding any state needed by the lint pass (here, none); - -* a [`LintPass`](../rustc/lint/trait.LintPass.html) - implementation defining how to check each syntax element. A single - `LintPass` may call `span_lint` for several different `Lint`s, but should - register them all through the `get_lints` method. - -Lint passes are syntax traversals, but they run at a late stage of compilation -where type information is available. `rustc`'s [built-in -lints](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs) -mostly use the same infrastructure as lint plugins, and provide examples of how -to access type information. - -Lints defined by plugins are controlled by the usual [attributes and compiler -flags](../reference.html#lint-check-attributes), e.g. `#[allow(test_lint)]` or -`-A test-lint`. These identifiers are derived from the first argument to -`declare_lint!`, with appropriate case and punctuation conversion. - -You can run `rustc -W help foo.rs` to see a list of lints known to `rustc`, -including those provided by plugins loaded by `foo.rs`. + +構文チェックプラグインのコンポーネントは + + + +* 1回以上の `declare_lint` の実行。それによって[`Lint`](../rustc/lint/struct.Lint.html)構造体が定義されます。 + + +* 構文チェックパスで必要となる状態を保持する構造体(ここでは何もない) + + + + + +* それぞれの構文要素をどうやってチェックするかを定めた[`LintPass`](../rustc/lint/trait.LintPass.html)の実装。 + 単一の `LintPass` は複数回 `span_lint` をいくつかの異なる `Lint` を呼ぶかもしれませんが、全て `get_lints`を通じて登録すべきです。 + + + + + + +構文チェックパスは構文巡回ですが、型情報が得られる、遅いステージで走ります。 `rustc` の[組み込み構文チェック](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs)は殆どプラグインと同じ機構を使っており、どうやって型情報にアクセスするかの例になっています。 + + + + + +プラグインによって定義されたLintは普通の[アトリビュートとコンパイラフラグ](../reference.html#lint-check-attributes)例えば `#[allow(test_lint)]` や `-A test-lint` によってコントロールされます。 +これらの識別子は `declare_lint` の第一引数に由来しており、適切な名前に変換されます。 + + + +`rustc -W help foo.rs` を走らせることで `rustc` の知っている、及び `foo.rs` 内で定義されたコンパイラ構文チェックをロード出来ます。 From e2f273f3934f148a9e1f9edf15b607245876b228 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Sun, 27 Mar 2016 21:44:20 +0900 Subject: [PATCH 5/6] final tweaks --- 1.6/ja/book/compiler-plugins.md | 35 +++++++++++++++++---------------- TranslationTable.md | 2 ++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index 908c8bf4..bed0cc95 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -6,7 +6,7 @@ -`rustc` はコンパイラプラグイン、ユーザの提供する構文拡張やs構文チェックなどのコンパイラの振舞を拡張するライブラリをロード出来ます。 +`rustc` はコンパイラプラグイン、ユーザの提供する構文拡張や構文チェックなどのコンパイラの振舞を拡張するライブラリをロード出来ます。 @@ -20,8 +20,8 @@ -もしあるなら、 `#![plugin(foo(... args ...))]` のように渡された引数はrustcによっては解釈されません。 -これらは `Registry` の[`args` メソッド](../rustc_plugin/registry/struct.Registry.html#method.args)を通じてプラグインに渡されます。 +`#![plugin(foo(... args ...))]` のように渡された引数があるなら、それらはrustc自身によっては解釈されません。 +`Registry` の[`args` メソッド](../rustc_plugin/registry/struct.Registry.html#method.args)を通じてプラグインに渡されます。 @@ -36,7 +36,7 @@ -普通の慣行ではコンパイラプラグインは自身のクレートに置かれて、 `macro_rules!` マクロやコンシューマが使うライブラリのコードとは分けられます。 +普通の慣行ではコンパイラプラグインはそれ専用のクレートに置かれて、 `macro_rules!` マクロやコンシューマが使うライブラリのコードとは分けられます。 # 構文拡張 @@ -46,8 +46,8 @@ -PluginはRustの構文を様々な方法で拡張出来ます。構文拡張の一種に手続的マクロがあります。 -これらは[普通のマクロ](macros.html)と同じように実行されますが展開は任意の[syntax trees](../syntax/ast/index.html)をコンパイル時に操作するRustのコードが行います。 +プラグインはRustの構文を様々な方法で拡張出来ます。構文拡張の1つに手続的マクロがあります。 +これらは[普通のマクロ](macros.html)と同じように実行されますが展開は任意の[構文木](../syntax/ast/index.html)をコンパイル時に操作するRustのコードが行います。 @@ -67,7 +67,7 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::ast::TokenTree; use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; -#// use syntax::ext::build::AstBuilder; // trait for expr_usize +# // use syntax::ext::build::AstBuilder; // trait for expr_usize use syntax::ext::build::AstBuilder; // expr_usizeのトレイト use rustc_plugin::Registry; @@ -138,7 +138,7 @@ fn main() { -* (任意に複雑な)変換がコンパイル時に行われる +* (任意に複雑な)変換がコンパイル時に行なわれる * 入力バリデーションもコンパイル時に行なわれる * パターンで使えるように拡張出来るので、実質的に任意のデータ型に対して新たなリテラル構文を与えられる @@ -155,10 +155,10 @@ fn main() { もっと複雑なマクロの例は[`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs)を参照して下さい。 -## 豆知識と小技 +## ヒントと小技 -[マクロデバッグの豆知識](macros.html#debugging-macro-code)のいくつかが使えます。 +[マクロデバッグのヒント](macros.html#debugging-macro-code)のいくつかが使えます。 @@ -176,14 +176,14 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -[`libsyntax` のパーサのコード](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs)を見るとパーサ機構がどのように機能しているかを感られるでしょう。 +[`libsyntax` のパーサのコード](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs)を見るとパーサの基盤がどのように機能しているかを感られるでしょう。 パースしたものの[`Span`](../syntax/codemap/struct.Span.html)は良いエラー報告のために保持しておきましょう。 -自身のデータ構造を[`Spanned`](../syntax/codemap/struct.Spanned.html)でラップ出来ます。 +自分で作ったデータ構造に対しても[`Spanned`](../syntax/codemap/struct.Spanned.html)でラップ出来ます。 @@ -209,7 +209,7 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) 上記の例では[`AstBuilder::expr_usize`](../syntax/ext/build/trait.AstBuilder.html#tymethod.expr_usize)を使って整数リテラルを作りました。 `AstBuilder` トレイトの代替として `libsyntax` は[準クォート ](../syntax/ext/quote/index.html)マクロを提供しています。 -ドキュメントがない上に荒削りです。しかしながら実装は改善された普通のプラグインライブラリののとっかかりにはほど良いでしょう。 +ドキュメントがない上に荒削りです。しかしながらその実装は改良版の普通のプラグインライブラリのとっかかりにはほど良いでしょう。 # 構文チェックプラグイン @@ -218,7 +218,7 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -プラグインによって[Rustの構文チェック機構](../reference.html#lint-check-attributes)を拡張してコーディングスタイル、安全性などを検査するようにできます。では[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs)プラグインを書いてみましょう。 +プラグインによって[Rustの構文チェック基盤](../reference.html#lint-check-attributes)を拡張してコーディングスタイル、安全性などを検査するようにできます。では[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs)プラグインを書いてみましょう。 `lintme` という名前のアイテムについて警告を出すものです。 @@ -228,7 +228,8 @@ fn expand_foo(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) extern crate syntax; -// Load rustc as a plugin to get macros +# // Load rustc as a plugin to get macros +// macroを使うためにrustcをプラグインとして読み込む #[macro_use] extern crate rustc; extern crate rustc_plugin; @@ -295,14 +296,14 @@ foo.rs:4 fn lintme() { } * それぞれの構文要素をどうやってチェックするかを定めた[`LintPass`](../rustc/lint/trait.LintPass.html)の実装。 - 単一の `LintPass` は複数回 `span_lint` をいくつかの異なる `Lint` を呼ぶかもしれませんが、全て `get_lints`を通じて登録すべきです。 + 単一の `LintPass` は複数回 `span_lint` をいくつかの異なる `Lint` に対して呼ぶかもしれませんが、全て `get_lints`を通じて登録すべきです。 -構文チェックパスは構文巡回ですが、型情報が得られる、遅いステージで走ります。 `rustc` の[組み込み構文チェック](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs)は殆どプラグインと同じ機構を使っており、どうやって型情報にアクセスするかの例になっています。 +構文チェックパスは構文巡回ですが、型情報が得られる、遅いステージで走ります。 `rustc` の[組み込み構文チェック](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs)は殆どプラグインと同じ基盤を使っており、どうやって型情報にアクセスするかの例になっています。 diff --git a/TranslationTable.md b/TranslationTable.md index a5399cec..8186ca68 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -164,6 +164,7 @@ | sum type | 直和型 | symbol | シンボル | syntactic sugar | 糖衣構文 +| syntax tree | 構文木 | system | システム | tagged union | タグ付き共用体 | term | 項 @@ -172,6 +173,7 @@ | tick | クオート | trait | トレイト | tuple | タプル +| token trees | トークン木 | type alias | 型エイリアス | type family | 型族 | type inference | 型推論 From 2f7ac8e741ee3c3b8fd0bf05bb78736a7774bf1e Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Mon, 28 Mar 2016 14:10:03 +0900 Subject: [PATCH 6/6] fixes respecting review --- 1.6/ja/book/compiler-plugins.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1.6/ja/book/compiler-plugins.md b/1.6/ja/book/compiler-plugins.md index bed0cc95..7ba59848 100644 --- a/1.6/ja/book/compiler-plugins.md +++ b/1.6/ja/book/compiler-plugins.md @@ -286,7 +286,7 @@ foo.rs:4 fn lintme() { } -* 1回以上の `declare_lint` の実行。それによって[`Lint`](../rustc/lint/struct.Lint.html)構造体が定義されます。 +* 1回以上の `declare_lint!` の実行。それによって[`Lint`](../rustc/lint/struct.Lint.html)構造体が定義されます。 * 構文チェックパスで必要となる状態を保持する構造体(ここでは何もない) @@ -303,14 +303,14 @@ foo.rs:4 fn lintme() { } -構文チェックパスは構文巡回ですが、型情報が得られる、遅いステージで走ります。 `rustc` の[組み込み構文チェック](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs)は殆どプラグインと同じ基盤を使っており、どうやって型情報にアクセスするかの例になっています。 +構文チェックパスは構文巡回ですが、型情報が得られる、コンパイルの終盤で走ります。 `rustc` の[組み込み構文チェック](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs)は殆どプラグインと同じ基盤を使っており、どうやって型情報にアクセスするかの例になっています。 プラグインによって定義されたLintは普通の[アトリビュートとコンパイラフラグ](../reference.html#lint-check-attributes)例えば `#[allow(test_lint)]` や `-A test-lint` によってコントロールされます。 -これらの識別子は `declare_lint` の第一引数に由来しており、適切な名前に変換されます。 +これらの識別子は `declare_lint!` の第一引数に由来しており、適切な名前に変換されます。