Debian Codegraph @

src/parser/runtime.rs

raw symbols SCIP
1 use superrust-analyzer cargo fluent-syntax 0.12.0 parser/::{
2 corerust-analyzer cargo fluent-syntax 0.12.0 parser/core/::{Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#, Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#},
3 errorsrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/::ParserErrorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ParserError#,
4 slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/::Slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#,
5 };
6 use craterust-analyzer cargo fluent-syntax 0.12.0 crate/::astrust-analyzer cargo fluent-syntax 0.12.0 ast/;
7
8 impl<'s, S> Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#<S>
9 where
10 S: Slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#<'s>,
11 {
12 pub fn parse_runtimerust-analyzer cargo fluent-syntax 0.12.0 parser/runtime/impl#[`Parser<S>`]parse_runtime().(
13 mut self,
14 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Resourcerust-analyzer cargo fluent-syntax 0.12.0 ast/Resource#<S>, (astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Resourcerust-analyzer cargo fluent-syntax 0.12.0 ast/Resource#<S>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ParserErrorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ParserError#>)> {
15 let mut errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
16
17 // That default allocation gives the lowest
18 // number of instructions and cycles in ioi.
19 let mut body = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(6);
20
21 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
22
23 while self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.lengthrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#length. {
24 let entry_start = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
25 let entry = self.get_entry_runtimerust-analyzer cargo fluent-syntax 0.12.0 parser/runtime/impl#[`Parser<S>`]get_entry_runtime().(entry_start);
26
27 match entry {
28 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry)) => {
29 body.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(entry);
30 }
31 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => {}
32 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(mut err) => {
33 self.skip_to_next_entry_startrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_to_next_entry_start().();
34 err.slicerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ParserError#slice. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.);
35 errors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(err);
36 let content = self.sourcerust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#source..slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#slice().(entry_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.);
37 body.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::Junkrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Junk# { contentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Junk#content. });
38 }
39 }
40 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
41 }
42
43 if errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
44 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Resourcerust-analyzer cargo fluent-syntax 0.12.0 ast/Resource# { bodyrust-analyzer cargo fluent-syntax 0.12.0 ast/Resource#body. })
45 } else {
46 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#((astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Resourcerust-analyzer cargo fluent-syntax 0.12.0 ast/Resource# { bodyrust-analyzer cargo fluent-syntax 0.12.0 ast/Resource#body. }, errors))
47 }
48 }
49
50 fn get_entry_runtimerust-analyzer cargo fluent-syntax 0.12.0 parser/runtime/impl#[`Parser<S>`]get_entry_runtime().(&mut self, entry_start: usize) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#<S>>> {
51 let entry = match get_current_byterust-analyzer cargo fluent-syntax 0.12.0 parser/macros/get_current_byte!!(self) {
52 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'#') => {
53 self.skip_commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/impl#[`Parser<S>`]skip_comment().();
54 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
55 }
56 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'-') => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::Termrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Term#(self.get_termrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_term().(entry_start)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)),
57 _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::Messagerust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Message#(self.get_messagerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_message().(entry_start)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)),
58 };
59 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(entry)
60 }
61 }