(&mut self)
| 729 | |
| 730 | impl Lexer<'_> { |
| 731 | fn read_raw_script(&mut self) -> Result<String, String> { |
| 732 | let mut script = String::new(); |
| 733 | let mut brace_count = 1; |
| 734 | |
| 735 | while let Some((_, ch)) = self.iter.peek() { |
| 736 | match ch { |
| 737 | '{' => { |
| 738 | brace_count += 1; |
| 739 | script.push('{'); |
| 740 | } |
| 741 | '}' => { |
| 742 | brace_count -= 1; |
| 743 | if brace_count == 0 { |
| 744 | break; |
| 745 | } else { |
| 746 | script.push('}'); |
| 747 | } |
| 748 | } |
| 749 | '\n' => { |
| 750 | script.push('\n'); |
| 751 | self.line += 1; |
| 752 | } |
| 753 | ch => { |
| 754 | script.push(*ch); |
| 755 | } |
| 756 | } |
| 757 | self.advance(); |
| 758 | } |
| 759 | |
| 760 | if brace_count > 0 { |
| 761 | return Err("Unclosed script block".to_string()); |
| 762 | } |
| 763 | |
| 764 | Ok(script.trim().to_owned()) |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | impl<'a> Iterator for Lexer<'a> { |
no test coverage detected