• Home
  • Raw
  • Download

Lines Matching +full:shebang +full:- +full:regex

1 …hub]](https://github.com/dtolnay/syn) [![crates-io]](https://crates.io/crates/syn) [![do…
3 //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo…
4 //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=55555…
5 //! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&lo…
15 //! - **Data structures** — Syn provides a complete syntax tree that can
21 //! - **Derives** — Of particular interest to derive macros is
24 //! derive implementations of a user-defined trait.
26 //! - **Parsing** — Parsing in Syn is built around [parser functions] with the
27 //! signature `fn(ParseStream) -> Result<T>`. Every syntax tree node defined
32 //! - **Location information** — Every token parsed by Syn is associated with a
38 //! - **Feature flags** — Functionality is aggressively feature gated so your
69 //! proc-macro = true
82 //! pub fn my_macro(input: TokenStream) -> TokenStream {
86 //! // Build the output, possibly using quasi-quotation
105 //! fn heap_size_of_children(&self) -> usize;
128 //! The token-based procedural macro API provides great control over where the
143 //! procedural macro as shown in the `heapsize` example, token-based macros in
149 //! --> src/main.rs:7:5
159 //! The [`lazy-static`] example directory shows the implementation of a
163 //! [`lazy-static`]: https://github.com/dtolnay/syn/tree/master/examples/lazy-static
174 //! static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
183 //! --> src/main.rs:10:16
209 //! generated code looks like. Use `cargo rustc -- -Zunstable-options
210 //! --pretty=expanded` or the [`cargo expand`] subcommand.
212 //! [`cargo expand`]: https://github.com/dtolnay/cargo-expand
216 //! your own test cases, run `cargo expand --test the_test_case` where the last
219 //! This write-up by Brandon W Maister discusses debugging in more detail:
222 //! [debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/
232 //! - **`derive`** *(enabled by default)* — Data structures for representing the
234 //! - **`full`** — Data structures for representing the syntax tree of all valid
236 //! - **`parsing`** *(enabled by default)* — Ability to parse input tokens into
238 //! - **`printing`** *(enabled by default)* — Ability to print a syntax tree
240 //! - **`visit`** — Trait for traversing a syntax tree.
241 //! - **`visit-mut`** — Trait for traversing and mutating in place a syntax
243 //! - **`fold`** — Trait for transforming an owned syntax tree.
244 //! - **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree
246 //! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree
248 //! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the
273 clippy::let_underscore_untyped, // https://github.com/rust-lang/rust-clippy/issues/10410
279 …clippy::match_wildcard_for_single_variants, // clippy bug: https://github.com/rust-lang/rust-clipp…
303 #[cfg(feature = "proc-macro")]
448 #[cfg(all(feature = "parsing", feature = "proc-macro"))]
505 #[cfg(all(any(feature = "full", feature = "derive"), feature = "extra-traits"))]
540 /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary {
545 /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute;
546 /// # fn fold_expr(&mut self, node: Expr) -> Expr;
547 /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp;
550 /// pub fn fold_expr_binary<V>(v: &mut V, node: ExprBinary) -> ExprBinary
587 /// fn fold_expr(&mut self, expr: Expr) -> Expr {
780 /// // syn = { version = "2.0", features = ["full", "visit-mut"] }
818 #[cfg(feature = "visit-mut")]
819 #[cfg_attr(doc_cfg, doc(cfg(feature = "visit-mut")))]
823 #[cfg(feature = "clone-impls")]
827 #[cfg(feature = "extra-traits")]
831 #[cfg(feature = "extra-traits")]
835 #[cfg(feature = "extra-traits")]
852 #[cfg(feature = "visit-mut")]
853 #[cfg_attr(doc_cfg, doc(cfg(feature = "visit-mut")))]
886 /// pub fn my_macro(input: TokenStream) -> TokenStream {
890 /// // Build the output, possibly using quasi-quotation
899 #[cfg(all(feature = "parsing", feature = "proc-macro"))]
900 #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))]
901 pub fn parse<T: parse::Parse>(tokens: proc_macro::TokenStream) -> Result<T> { in parse()
905 /// Parse a proc-macro2 token stream into the chosen syntax tree node.
919 pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> { in parse2()
935 /// fn run() -> Result<()> {
946 pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> { in parse_str()
956 /// - It discards a leading byte order mark `\u{FEFF}` if the file has one.
957 /// - It preserves the shebang line of the file, such as `#!/usr/bin/env rustx`.
968 /// fn run() -> Result<(), Box<dyn Error>> {
974 /// if let Some(shebang) = ast.shebang {
975 /// println!("{}", shebang);
986 pub fn parse_file(mut content: &str) -> Result<File> { in parse_file()
993 let mut shebang = None; in parse_file() localVariable
998 shebang = Some(content[..idx].to_string()); in parse_file()
1001 shebang = Some(content.to_string()); in parse_file()
1008 file.shebang = shebang; in parse_file()