@@ -10,16 +10,11 @@ use thiserror::Error;
1010pub struct Parser {
1111 tokens : TokenStream ,
1212 current : usize ,
13- specs : HashMap < String , TagSpec > ,
1413}
1514
1615impl Parser {
1716 pub fn new ( tokens : TokenStream ) -> Self {
18- Parser {
19- tokens,
20- current : 0 ,
21- specs : TagSpec :: load_builtin_specs ( ) . unwrap_or_default ( ) ,
22- }
17+ Parser { tokens, current : 0 }
2318 }
2419
2520 pub fn parse ( & mut self ) -> Result < Ast , ParserError > {
@@ -165,17 +160,18 @@ impl Parser {
165160 eprintln ! ( "Tag name: {}" , tag_name) ;
166161
167162 eprintln ! ( "Loaded specs: {:?}" , self . specs) ;
163+ let specs = TagSpec :: load_builtin_specs ( ) . unwrap_or_default ( ) ;
168164
169165 // Check if this is a closing tag according to ANY spec
170- for ( _, spec) in self . specs . iter ( ) {
166+ for ( _, spec) in specs. iter ( ) {
171167 if Some ( & tag_name) == spec. closing . as_ref ( ) {
172168 eprintln ! ( "Found closing tag: {}" , tag_name) ;
173169 return Err ( ParserError :: ErrorSignal ( Signal :: SpecialTag ( tag_name) ) ) ;
174170 }
175171 }
176172
177173 // Check if this is an intermediate tag according to ANY spec
178- for ( _, spec) in self . specs . iter ( ) {
174+ for ( _, spec) in specs. iter ( ) {
179175 if let Some ( intermediates) = & spec. intermediates {
180176 if intermediates. contains ( & tag_name) {
181177 eprintln ! ( "Found intermediate tag: {}" , tag_name) ;
@@ -185,8 +181,7 @@ impl Parser {
185181 }
186182
187183 // Get the tag spec for this tag
188- let tag_spec = self . specs . get ( tag_name. as_str ( ) ) . cloned ( ) ;
189- eprintln ! ( "Tag spec: {:?}" , tag_spec) ;
184+ let tag_spec = specs. get ( tag_name. as_str ( ) ) . cloned ( ) ;
190185
191186 let mut children = Vec :: new ( ) ;
192187 let mut branches = Vec :: new ( ) ;
0 commit comments