Document token spacing

オープン
#1,983 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
rust
領域
documentation

調査の方向性

lexer の章と既存の macro.proc.token.conversion.from-proc_macro セクションから始め、次に rustc_parse/src/parser/mod.rs の break_and_eat 周辺を調べます。構文の概要における連結されたトークンの扱いを、参照パターンおよび借用演算子と比較し、リンクされている issue と pull request を確認します。Reference がトークンの空白、分割または結合、および lexer/parser の境界を明確に定義していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

A-grammar A-lexer

I think the behavior around token splitting should be documented in some way, though I'm uncertain exactly how. The general idea is that the lexer chapter defines tokens, such as <-, which are then split in certain situations to smaller tokens. AFAIK, the reference doesn't really define how this works. I also don't know how much of this is part of the lexer versus the parser. I suspect it needs to be addressed in both depending on which approach we take.

A question I have is whether it should be documented as tokens being split, or tokens being glued, since I could imagine either approach is viable.

I think in rustc, currently the primary method that is used to handle this is break_and_eat. However, I may be misremembering if there are other places where this is handled.

IIUC, the places where this splitting happens is somewhat arbitrary, in terms of places where people thought it would be helpful. There's nothing that prevents the parser from avoiding those splitting methods.

There is a brief mention in macro.proc.token.conversion.from-proc_macro how proc-macro output is glued/split. The proc-macro Spacing type briefly touches on it as well.

Note that reference patterns and borrow operators specifically include the && token in their grammar. I don't remember the exact details about why we did it that way (that is, why did we do this just for && and no other token?). Depending on how we approach this, we may need to consider how that might need to change.

Note that I included some of the jointed tokens in the syntax summary. We may want to remove some. For example, I have >>= and >= linking to generics.

Some relevant links:

主要言語
Rust
スター
1.6k
フォーク
618
平均マージ
5時間 48分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/reference のほかの issue

rust-lang/reference の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。