Skip to content

[documentation] rust.md#number-literals grammar does not match behaviour in scan_number() #6824

Closed
@caitp

Description

@caitp

From: https://github.com/mozilla/rust/blob/cd2eb4701fc16e7acd6934759be043b1f7e5586d/doc/rust.md#number-literals

num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
        | '0' [       [ dec_digit | '_' ] + num_suffix ?
              | 'b'   [ '1' | '0' | '_' ] + int_suffix ?
              | 'x'   [ hex_digit | '_' ] + int_suffix ? ] ;

num_suffix : int_suffix | float_suffix ;

int_suffix : 'u' int_suffix_size ?
           | 'i' int_suffix_size ;
int_suffix_size : [ '8' | '1' '6' | '3' '2' | '6' '4' ] ;

float_suffix : [ exponent | '.' dec_lit exponent ? ] float_suffix_ty ? ;
float_suffix_ty : 'f' [ '3' '2' | '6' '4' ] ;
exponent : ['E' | 'e'] ['-' | '+' ] ? dec_lit ;
dec_lit : [ dec_digit | '_' ] + ;

This description of the grammar has at least two errors:

I've gone over the lexer in libsyntax and I have not yet come across anything else that does not match the docs, but it would be good to get these in order for the benefit of those of us writing syntax highlighters for our editors, and the like. I'll have a patch up soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions