Debian Codegraph @

src/parser/core.rs

raw symbols SCIP
1 use superrust-analyzer cargo fluent-syntax 0.12.0 parser/::{
2 commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/,
3 errorsrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/::{ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#, 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 pub type Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<T> = 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#<T, ParserErrorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ParserError#>;
9
10 pub struct Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#<S> {
11 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) sourcerust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#source.: S,
12 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.: usize,
13 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) lengthrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#length.: usize,
14 }
15
16 impl<'s, S> Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#<S>
17 where
18 S: Slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#<'s>,
19 {
20 pub fn newrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]new().(source: S) -> Selfrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`] {
21 let length = source.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
22 Selfrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`] {
23 sourcerust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#source.,
24 ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.: 0,
25 lengthrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#length.,
26 }
27 }
28
29 pub fn parserust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]parse().(
30 mut self,
31 ) -> 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#>)> {
32 let mut errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
33
34 let mut body = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
35
36 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
37 let mut last_comment = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
38 let mut last_blank_count = 0;
39
40 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. {
41 let entry_start = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
42 let mut entry = self.get_entryrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_entry().(entry_start);
43
44 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(comment) = last_comment.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
45 match entry {
46 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(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#(ref mut msg)) if last_blank_count 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().2 => {
47 msg.commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Message#comment. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(comment);
48 }
49 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(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#(ref mut term)) if last_blank_count 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().2 => {
50 term.commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Term#comment. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(comment);
51 }
52 _ => {
53 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#::Commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Comment#(comment));
54 }
55 }
56 }
57
58 match entry {
59 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::Commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Comment#(comment)) => {
60 last_comment = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(comment);
61 }
62 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(entry) => {
63 body.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(entry);
64 }
65 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(mut err) => {
66 self.skip_to_next_entry_startrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_to_next_entry_start().();
67 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.);
68 errors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(err);
69 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.);
70 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. });
71 }
72 }
73 last_blank_count = self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
74 }
75
76 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(last_comment) = last_comment.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
77 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#::Commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Comment#(last_comment));
78 }
79 if errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
80 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. })
81 } else {
82 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))
83 }
84 }
85
86 fn get_entryrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_entry().(&mut self, entry_start: usize) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#<S>> {
87 let entry = match get_current_byterust-analyzer cargo fluent-syntax 0.12.0 parser/macros/get_current_byte!!(self) {
88 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'#') => {
89 let (comment, level) = self.get_commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/impl#[`Parser<S>`]get_comment().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
90 match level {
91 commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/::Levelrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#::Regularrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#Regular# => astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::Commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#Comment#(comment),
92 commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/::Levelrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#::Grouprust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#Group# => astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::GroupCommentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#GroupComment#(comment),
93 commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/::Levelrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#::Resourcerust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#Resource# => astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Entryrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#::ResourceCommentrust-analyzer cargo fluent-syntax 0.12.0 ast/Entry#ResourceComment#(comment),
94 commentrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/::Levelrust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#::Nonerust-analyzer cargo fluent-syntax 0.12.0 parser/comment/Level#None# => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
95 }
96 }
97 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'-') => 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().),
98 _ => 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().),
99 };
100 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(entry)
101 }
102
103 pub fn get_messagerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_message().(&mut self, entry_start: usize) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Messagerust-analyzer cargo fluent-syntax 0.12.0 ast/Message#<S>> {
104 let id = self.get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
105 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
106 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b'=')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
107 let pattern = self.get_patternrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_pattern().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
108
109 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
110
111 let attributes = self.get_attributesrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attributes().();
112
113 if pattern.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() && attributes.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
114 let entry_id = id.namerust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#name..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
115 return errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(
116 ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::ExpectedMessageFieldrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedMessageField# { entry_idrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedMessageField#entry_id. },
117 entry_start, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.
118 );
119 }
120
121 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Messagerust-analyzer cargo fluent-syntax 0.12.0 ast/Message# {
122 idrust-analyzer cargo fluent-syntax 0.12.0 ast/Message#id.,
123 valuerust-analyzer cargo fluent-syntax 0.12.0 ast/Message#value.: pattern,
124 attributesrust-analyzer cargo fluent-syntax 0.12.0 ast/Message#attributes.,
125 commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Message#comment.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
126 })
127 }
128
129 pub fn get_termrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_term().(&mut self, entry_start: usize) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Termrust-analyzer cargo fluent-syntax 0.12.0 ast/Term#<S>> {
130 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b'-')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
131 let id = self.get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
132 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
133 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b'=')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
134 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
135
136 let value = self.get_patternrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_pattern().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
137
138 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
139
140 let attributes = self.get_attributesrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attributes().();
141
142 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = value {
143 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Termrust-analyzer cargo fluent-syntax 0.12.0 ast/Term# {
144 idrust-analyzer cargo fluent-syntax 0.12.0 ast/Term#id.,
145 valuerust-analyzer cargo fluent-syntax 0.12.0 ast/Term#value.,
146 attributesrust-analyzer cargo fluent-syntax 0.12.0 ast/Term#attributes.,
147 commentrust-analyzer cargo fluent-syntax 0.12.0 ast/Term#comment.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
148 })
149 } else {
150 errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(
151 ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::ExpectedTermFieldrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedTermField# {
152 entry_idrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedTermField#entry_id.: id.namerust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#name..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()
153 },
154 entry_start, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.
155 )
156 }
157 }
158
159 fn get_attributesrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attributes().(&mut self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Attributerust-analyzer cargo fluent-syntax 0.12.0 ast/Attribute#<S>> {
160 let mut attributes = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
161
162 loop {
163 let line_start = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
164 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
165 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.take_byte_ifrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]take_byte_if().(b'.') {
166 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. = line_start;
167 break;
168 }
169
170 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(attr) = self.get_attributerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attribute().() {
171 attributes.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(attr);
172 } else {
173 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. = line_start;
174 break;
175 }
176 }
177 attributes
178 }
179
180 fn get_attributerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attribute().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Attributerust-analyzer cargo fluent-syntax 0.12.0 ast/Attribute#<S>> {
181 let id = self.get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
182 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
183 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b'=')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
184 let pattern = self.get_patternrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_pattern().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
185
186 match pattern {
187 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pattern) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Attributerust-analyzer cargo fluent-syntax 0.12.0 ast/Attribute# { idrust-analyzer cargo fluent-syntax 0.12.0 ast/Attribute#id., valuerust-analyzer cargo fluent-syntax 0.12.0 ast/Attribute#value.: pattern }),
188 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::MissingValuerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#MissingValue#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.),
189 }
190 }
191
192 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_identifier_uncheckedrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier_unchecked().(&mut self) -> astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Identifierrust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#<S> {
193 let mut ptr = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
194
195 while matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(get_byterust-analyzer cargo fluent-syntax 0.12.0 parser/macros/get_byte!!(self, ptr), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b) if b.is_ascii_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_alphanumeric().() || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b == b'-' || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b == b'_')
196 {
197 ptr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
198 }
199
200 let name = 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().(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 ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#ptr);
201 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. = ptr;
202
203 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Identifierrust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier# { namerust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#name. }
204 }
205
206 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Identifierrust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#<S>> {
207 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_identifier_startrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]is_identifier_start().() {
208 return errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(
209 ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::ExpectedCharRangerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedCharRange# {
210 rangerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#ExpectedCharRange#range.: "a-zA-Z".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
211 },
212 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.
213 );
214 }
215 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 ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
216 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.get_identifier_uncheckedrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier_unchecked().())
217 }
218
219 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_attribute_accessorrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_attribute_accessor().(&mut self) -> 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/::Identifierrust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#<S>>> {
220 if self.take_byte_ifrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]take_byte_if().(b'.') {
221 let ident = self.get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
222 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#(ident))
223 } else {
224 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#)
225 }
226 }
227
228 fn get_variant_keyrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_variant_key().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::VariantKeyrust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#<S>> {
229 self.skip_blankrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank().();
230
231 let key = if self.is_number_startrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]is_number_start().() {
232 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::VariantKeyrust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#::NumberLiteralrust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#NumberLiteral# {
233 valuerust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#NumberLiteral#value.: self.get_number_literalrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]get_number_literal().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
234 }
235 } else {
236 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::VariantKeyrust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#::Identifierrust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#Identifier# {
237 namerust-analyzer cargo fluent-syntax 0.12.0 ast/VariantKey#Identifier#name.: self.get_identifierrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_identifier().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..namerust-analyzer cargo fluent-syntax 0.12.0 ast/Identifier#name.,
238 }
239 };
240
241 self.skip_blankrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank().();
242
243 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b']')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
244
245 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(key)
246 }
247
248 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_variantsrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_variants().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Variantrust-analyzer cargo fluent-syntax 0.12.0 ast/Variant#<S>>> {
249 let mut variants = 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().(2);
250 let mut has_default = false;
251
252 loop {
253 let default = self.take_byte_ifrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]take_byte_if().(b'*');
254 if default {
255 if has_default {
256 return errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::MultipleDefaultVariantsrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#MultipleDefaultVariants#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.);
257 } else {
258 has_default = true;
259 }
260 }
261
262 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.take_byte_ifrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]take_byte_if().(b'[') {
263 break;
264 }
265
266 let key = self.get_variant_keyrust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_variant_key().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
267
268 let value = self.get_patternrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_pattern().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
269
270 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = value {
271 variants.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/::Variantrust-analyzer cargo fluent-syntax 0.12.0 ast/Variant# {
272 keyrust-analyzer cargo fluent-syntax 0.12.0 ast/Variant#key.,
273 valuerust-analyzer cargo fluent-syntax 0.12.0 ast/Variant#value.,
274 defaultrust-analyzer cargo fluent-syntax 0.12.0 ast/Variant#default.,
275 });
276 self.skip_blankrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank().();
277 } else {
278 return errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::MissingValuerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#MissingValue#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.);
279 }
280 }
281
282 if has_default {
283 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(variants)
284 } else {
285 errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::MissingDefaultVariantrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#MissingDefaultVariant#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.)
286 }
287 }
288
289 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_placeablerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_placeable().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Expressionrust-analyzer cargo fluent-syntax 0.12.0 ast/Expression#<S>> {
290 self.skip_blankrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank().();
291 let exp = self.get_expressionrust-analyzer cargo fluent-syntax 0.12.0 parser/expression/impl#[`Parser<S>`]get_expression().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
292 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
293 self.expect_byterust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]expect_byte().(b'}')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
294
295 let invalid_expression_found = match &exp {
296 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Expressionrust-analyzer cargo fluent-syntax 0.12.0 ast/Expression#::Inlinerust-analyzer cargo fluent-syntax 0.12.0 ast/Expression#Inline#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::InlineExpressionrust-analyzer cargo fluent-syntax 0.12.0 ast/InlineExpression#::TermReferencerust-analyzer cargo fluent-syntax 0.12.0 ast/InlineExpression#TermReference# {
297 ref attributerust-analyzer cargo fluent-syntax 0.12.0 ast/InlineExpression#TermReference#attribute., ..
298 }) => attribute.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(),
299 _ => false,
300 };
301 if invalid_expression_found {
302 return errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::TermAttributeAsPlaceablerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#TermAttributeAsPlaceable#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.);
303 }
304
305 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(exp)
306 }
307 }