22
33> ** <sup >Syntax</sup >** \
44> _ Crate_ :\
5- >   ;  ; SHEBANG<sup >?</sup >\
65>   ;  ; [ _ InnerAttribute_ ] <sup >\* </sup >\
76>   ;  ; [ _ Item_ ] <sup >\* </sup >
87
9- > ** <sup >Lexer</sup >** \
10- > SHEBANG : ` #! ` \~ ` \n ` <sup >\+ </sup >[ †] ( #shebang )
11-
12-
138> Note: Although Rust, like any other language, can be implemented by an
149> interpreter as well as a compiler, the only existing implementation is a
1510> compiler, and the language has always been designed to be compiled. For these
@@ -51,6 +46,8 @@ that apply to the containing module, most of which influence the behavior of
5146the compiler. The anonymous crate module can have additional attributes that
5247apply to the crate as a whole.
5348
49+ > ** Note** : The file's contents may be preceded by a [ shebang] .
50+
5451``` rust
5552// Specify the crate name.
5653#![crate_name = " projx" ]
@@ -63,28 +60,6 @@ apply to the crate as a whole.
6360#![warn(non_camel_case_types)]
6461```
6562
66- ## Shebang
67-
68- A source file can have a [ _ shebang_ ] (SHEBANG production), which indicates
69- to the operating system what program to use to execute this file. It serves
70- essentially to treat the source file as an executable script. The shebang
71- can only occur at the beginning of the file.
72- It is ignored by the compiler. For example:
73-
74- <!-- ignore: tests don't like shebang -->
75- ``` rust,ignore
76- #!/usr/bin/env rustx
77-
78- fn main() {
79- println!("Hello!");
80- }
81- ```
82-
83- A restriction is imposed on the shebang syntax to avoid confusion with an
84- [ attribute] . The ` #! ` characters must not be followed by a ` [ ` token, ignoring
85- intervening [ comments] or [ whitespace] . If this restriction fails, then it is
86- not treated as a shebang, but instead as the start of an attribute.
87-
8863## Preludes and ` no_std `
8964
9065This section has been moved to the [ Preludes chapter] ( names/preludes.md ) .
@@ -153,19 +128,17 @@ or `_` (U+005F) characters.
153128[ _InnerAttribute_ ] : attributes.md
154129[ _Item_ ] : items.md
155130[ _MetaNameValueStr_ ] : attributes.md#meta-item-attribute-syntax
156- [ _shebang_ ] : https://en.wikipedia.org/wiki/Shebang_(Unix)
157131[ `ExitCode` ] : ../std/process/struct.ExitCode.html
158132[ `Infallible` ] : ../std/convert/enum.Infallible.html
159133[ `Termination` ] : ../std/process/trait.Termination.html
160134[ attribute ] : attributes.md
161135[ attributes ] : attributes.md
162- [ comments ] : comments.md
163136[ function ] : items/functions.md
164137[ module ] : items/modules.md
165138[ module path ] : paths.md
139+ [ shebang ] : input-format.md#shebang-removal
166140[ trait or lifetime bounds ] : trait-bounds.md
167141[ where clauses ] : items/generics.md#where-clauses
168- [ whitespace ] : whitespace.md
169142
170143<script >
171144(function () {
0 commit comments