Document token spacing

Abierto
#1,983 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
28/100
Tipo de issue
Documentación
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
rust

Línea de trabajo

Comienza con el capítulo del lexer y la sección existente macro.proc.token.conversion.from-proc_macro; después inspecciona en rustc_parse/src/parser/mod.rs la zona alrededor de break_and_eat. Compara el tratamiento de los tokens unidos en el resumen de sintaxis con los patrones de referencia y los operadores de préstamo, y revisa las issues y pull requests enlazadas. Se considera terminado cuando la Reference define claramente el espaciado de los tokens, su división o unión, y los límites entre el lexer y el parser.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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:

Lenguaje dominante
Rust
Estrellas
1.6k
Forks
618
Merge medio
5 h 48 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/reference

Todos los issues de rust-lang/reference

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.