| 1 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.95 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.95 TokenStream#; |
| 2 | use quoterust-analyzer cargo quote 1.0.40 crate/::quoterust-analyzer cargo quote 1.0.40 quote!; |
| 3 | |
| 4 | use craterust-analyzer cargo logos-codegen 0.15.1 crate/::generatorrust-analyzer cargo logos-codegen 0.15.1 generator/::{Contextrust-analyzer cargo logos-codegen 0.15.1 generator/context/Context#, Generatorrust-analyzer cargo logos-codegen 0.15.1 generator/Generator#}; |
| 5 | use craterust-analyzer cargo logos-codegen 0.15.1 crate/::graphrust-analyzer cargo logos-codegen 0.15.1 graph/::Roperust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#; |
| 6 | |
| 7 | impl Generatorrust-analyzer cargo logos-codegen 0.15.1 generator/Generator#<'_> { |
| 8 | pub fn generate_roperust-analyzer cargo logos-codegen 0.15.1 generator/rope/impl#[`Generator<'_>`]generate_rope().(&mut self, rope: &Roperust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#, mut ctx: Contextrust-analyzer cargo logos-codegen 0.15.1 generator/context/Context#) -> TokenStreamrust-analyzer cargo proc-macro2 1.0.95 TokenStream# { |
| 9 | let miss = ctx.missrust-analyzer cargo logos-codegen 0.15.1 generator/context/impl#[Context]miss().(rope.missrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#miss..firstrust-analyzer cargo logos-codegen 0.15.1 graph/rope/impl#[Miss]first().(), self); |
| 10 | let read = ctx.readrust-analyzer cargo logos-codegen 0.15.1 generator/context/impl#[Context]read().(rope.patternrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#pattern..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 11 | let then = self.gotorust-analyzer cargo logos-codegen 0.15.1 generator/impl#[`Generator<'a>`]goto().(rope.thenrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#then., ctx.advancerust-analyzer cargo logos-codegen 0.15.1 generator/context/impl#[Context]advance().(rope.patternrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#pattern..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())); |
| 12 | |
| 13 | let pat = match rope.patternrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#pattern..to_bytesrust-analyzer cargo logos-codegen 0.15.1 graph/rope/impl#[Pattern]to_bytes().() { |
| 14 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bytes) => byte_slice_literalrust-analyzer cargo logos-codegen 0.15.1 generator/rope/byte_slice_literal().(&bytes), |
| 15 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 16 | let ranges = rope.patternrust-analyzer cargo logos-codegen 0.15.1 graph/rope/Rope#pattern..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(); |
| 17 | |
| 18 | quoterust-analyzer cargo quote 1.0.40 quote!!([#(#ranges),*]) |
| 19 | } |
| 20 | }; |
| 21 | |
| 22 | quoterust-analyzer cargo quote 1.0.40 quote!! { |
| 23 | match #read { |
| 24 | Some(#pat) => #then, |
| 25 | _ => #miss, |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | fn byte_slice_literalrust-analyzer cargo logos-codegen 0.15.1 generator/rope/byte_slice_literal().(bytes: &[u8]) -> TokenStreamrust-analyzer cargo proc-macro2 1.0.95 TokenStream# { |
| 32 | if bytes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|&b| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(0x20..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#0x7F).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]contains().(&b)) { |
| 33 | return quoterust-analyzer cargo quote 1.0.40 quote!!(&[#(#bytes),*]); |
| 34 | } |
| 35 | |
| 36 | let slice = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(bytes).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 37 | |
| 38 | synrust-analyzer cargo syn 2.0.101 crate/::parse_strrust-analyzer cargo syn 2.0.101 parse_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("b{:?}", slice)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 39 | } |