Skip to content

Processing shebang and byte order mark #613

@mattheww

Description

@mattheww

Shebang

§18.1 (fls_s35hob3i7lr) provides the following syntax definitions:

SourceFile ::=
    ZeroWidthNoBreakSpace?
    Shebang?
    InnerAttributeOrDoc*
    Item*

Shebang ::=
    #! ~[NewLine]*

NewLine ::=
    \n

This grammar is ambiguous: a file starting with the following could be treated as starting with either a Shebang or an InnerAttributeOrDoc:

#![xxx]

This is an unusual case where the ambiguity isn't resolved "eagerly": rustc sees this as InnerAttributeOrDoc. So I think the FLS ought to say more here.

Also, I think putting a nonterminal inside ~[] isn't strictly following the notation described by §1.1.4:14 (fls_blvsfqeevosr). The definition of NewLine isn't used anywhere else.

Byte order mark

§18.1:2 (fls_ann3cha1xpek) reads

A Shebang does not have an effect on the compilation.

I suggest adding a similar statement for the ZeroWidthNoBreakSpace.

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