1 // pest. The Elegant Parser 2 // Copyright (c) 2018 Dragoș Tiselice 3 // 4 // Licensed under the Apache License, Version 2.0 5 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT 6 // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 // option. All files in the project carrying such notice may not be copied, 8 // modified, or distributed except according to those terms. 9 10 // This structure serves to improve performance over Token objects in two ways: 11 // 12 // * it is smaller than a Token, leading to both less memory use when stored in the queue but also 13 // increased speed when pushing to the queue 14 // * it finds its pair in O(1) time instead of O(N), since pair positions are known at parse time 15 // and can easily be stored instead of recomputed 16 #[derive(Debug)] 17 pub enum QueueableToken<'i, R> { 18 Start { 19 end_token_index: usize, 20 input_pos: usize, 21 }, 22 End { 23 start_token_index: usize, 24 rule: R, 25 tag: Option<&'i str>, 26 input_pos: usize, 27 }, 28 } 29